if ($line == $count++)

A

April

looking at the following, if $line has values of 1, 2, 3, ... will the
if test ever tests true when $line equals 1? It seems it won't as
$count starts as 1 and then the test with $count++ (=2), but the
execution suggests otherwise ...

my $count = 1;
while(<IN>)
{
if ($line == $count++)
{
$deleted = $_;
next;
}
print OUT;
}
 
P

Peter Makholm

April said:
looking at the following, if $line has values of 1, 2, 3, ... will the
if test ever tests true when $line equals 1? It seems it won't as
$count starts as 1 and then the test with $count++ (=2), but the
execution suggests otherwise ...

$i++ will return the value of $i before incrementing the value, so yes
$line will become equal $count. Read the 'Auto-increment and
Auto-decrement' section of 'perldoc perlop'.

(But instead of counting lines, you could use the magic variable
$. Read 'perldoc perlvar' for more information about this)

//Makholm
 
A

April

$i++ will return the value of $i before incrementing the value, so yes
$line will become equal $count. Read the 'Auto-increment and
Auto-decrement' section of 'perldoc perlop'.

(But instead of counting lines, you could use the magic variable
$. Read 'perldoc perlvar' for more information about this)

//Makholm

Thanks Peter for your quick answer!
 
T

Tim Greer

April said:
looking at the following, if $line has values of 1, 2, 3, ... will the
if test ever tests true when $line equals 1? It seems it won't as
$count starts as 1 and then the test with $count++ (=2), but the
execution suggests otherwise ...

my $count = 1;
while(<IN>)
{
if ($line == $count++)
{
$deleted = $_;
next;
}
print OUT;
}

See the difference (for example) between $count++ and ++$count.
 
A

April

See the difference (for example) between $count++ and ++$count.
--
Tim Greer, CEO/Founder/CTO, BurlyHost.com, Inc.
Shared Hosting, Reseller Hosting, Dedicated & Semi-Dedicated servers
and Custom Hosting.  24/7 support, 30 day guarantee, secure servers.
Industry's most experienced staff! -- Web Hosting With Muscle!- Hide quoted text -

- Show quoted text -

thanks Tim, haven't tested but guess ++$count would increment first?
 
T

Tim Greer

April said:
thanks Tim, haven't tested but guess ++$count would increment first?

perldoc perlop:

Auto-increment and Auto-decrement

"++" and "--" work as in C. That is, if placed before a
variable, they increment or decrement the variable by one before
returning the value, and if placed after, increment or decrement after
returning the value.

$i = 0; $j = 0;
print $i++; # prints 0
print ++$j; # prints 1

Now, if this will work for you, your purposes and your code, and how you
want, is something I can't say, but that is the general idea. As
another poster stated, using $. for line counting is probably a better
idea, but it really depends on what you're doing.
 
A

April

<please don't quote signatures>

thanks Tim, I'll pay attention to this .. you know if you use Google
Groups, then all the quotes are hidden automaticaly and you get a nice
and clean interface. If you get a chance give it a try and you may
like it. If you want to check the quotes, you can, and also all the
posts for the same topic are in the same spot. I thought people are
using this kind of web tools nowadays and did not pay much attention,
besides I'm not familiar with the good old tradition either.
perldoc perlop:

       Auto-increment and Auto-decrement

       "++" and "--" work as in C.  That is, if placed before a
variable, they increment or decrement the variable by one before
returning the value, and if placed after, increment or decrement after
returning the value.

           $i = 0;  $j = 0;
           print $i++;  # prints 0
           print ++$j;  # prints 1

Now, if this will work for you, your purposes and your code, and how you
want, is something I can't say, but that is the general idea.  As
another poster stated, using $. for line counting is probably a better
idea, but it really depends on what you're doing.

really appreciate this piece of info, thanks again Tim.
 
R

RedGrittyBrick

April said:
thanks Tim, I'll pay attention to this .. you know if you use Google
Groups, then all the quotes are hidden automaticaly and you get a nice
and clean interface. If you get a chance give it a try and you may
like it.

Many of us have tried it and really dislike it. There are a number of
reasons for this.

I find that not only does it have many deficiencies and annoyances, it
has bugs. For example, the article numbers in the tree-view sometimes
don't match those in the main pane. Clicking an article in the tree-view
can take you to a different message in the main view.

Have you tried a proper news reader - like Thunderbird or even Outlook
Express?

If you want to check the quotes, you can, and also all the
posts for the same topic are in the same spot.

They are in a real newsreader but in GG they are spread over several
pages, you have to select "Next Page" a lot. In a real newsreader you
don't have this issue.

I thought people are
using this kind of web tools nowadays and did not pay much attention,
besides I'm not familiar with the good old tradition either.

Here's a few questions I have about Google Groups:

How do you jump easily to the next unread item?

How do you mark an obnoxious poster so their future messages are
automatically ignored?

How do you configure it to delete spam before you read it?

How do you get it to automatically highlight posts from people you respect?

How do you get it to switch quickly between thread-order (tree view) and
date order or author order?

How do you jump quickly to the referred to posting?


Have you tried a real newsreader program?
 
T

Tim Greer

April said:
thanks Tim, I'll pay attention to this .. you know if you use Google
Groups, then all the quotes are hidden automaticaly and you get a nice
and clean interface. If you get a chance give it a try and you may
like it. If you want to check the quotes, you can, and also all the
posts for the same topic are in the same spot. I thought people are
using this kind of web tools nowadays and did not pay much attention,
besides I'm not familiar with the good old tradition either.

There are a lot of issues with services such as google groups. I'm not
interested in it at all (I won't get into the reasons why google groups
is less desirable in every single way, as that's best left to another
topic in another group). Anyway, you might check to see if there's a
configuration option in some 'preferences' area to view signatures or
not have it quote them, or something. It just makes followups appear
confusing as to whom typed what sometimes.
 
A

April

Here's a few questions I have about Google Groups:

How do you jump easily to the next unread item?

How do you mark an obnoxious poster so their future messages are
automatically ignored?

How do you configure it to delete spam before you read it?

How do you get it to automatically highlight posts from people you respect?

How do you get it to switch quickly between thread-order (tree view) and
date order or author order?

How do you jump quickly to the referred to posting?

Have you tried a real newsreader program?

I see your needs as a newsgroup regular, which is quite different from
mine. I only come to a particular newsgroup when I get an issue, and
Google Groups seems meet my needs for that purpose.

Yours seem well-thought-out questions, may consider to send to Google
so they can may enhancement in the future.

I did configure OE for newsgroup at one time, however, later lost it
when HW upgraded. Then I found Google Groups and did not go back or
any real readers.
 
A

April

Anyway, you might check to see if there's a
configuration option in some 'preferences' area to view signatures or
not have it quote them, or something.  

Just looked but could not find one ...
 
T

Tim Greer

April said:
Just looked but could not find one ...

No matter, you seem to have found a way to not quote them in your recent
replies, so that should work fine. I don't think anyone minds what
usenet service you use, and if you are able to reply without google
groups forcing some sig quote on you, then you're good. :)
 
S

sln

looking at the following, if $line has values of 1, 2, 3, ... will the
if test ever tests true when $line equals 1? It seems it won't as
$count starts as 1 and then the test with $count++ (=2), but the
execution suggests otherwise ...

my $count = 1;
while(<IN>)
{
if ($line == $count++)
{
$deleted = $_;
next;
}
print OUT;
}

$line is not part of this code.
Possibly the simplest solution is the right one.
Even if you can copy code, perhaps you shouldn't paste it.

sln
 
D

David Combs

Many of us have tried it and really dislike it. There are a number of
reasons for this.

I find that not only does it have many deficiencies and annoyances, it
has bugs. For example, the article numbers in the tree-view sometimes
don't match those in the main pane. Clicking an article in the tree-view
can take you to a different message in the main view.

Have you tried a proper news reader - like Thunderbird or even Outlook
Express?

How about trn4?



David
 
D

David Combs

There are a lot of issues with services such as google groups. I'm not
interested in it at all (I won't get into the reasons why google groups
is less desirable in every single way, as that's best left to another
topic in another group). Anyway, you might check to see if there's a
configuration option in some 'preferences' area to view signatures or
not have it quote them, or something. It just makes followups appear
confusing as to whom typed what sometimes.
--
Tim Greer, CEO/Founder/CTO, BurlyHost.com, Inc.
Shared Hosting, Reseller Hosting, Dedicated & Semi-Dedicated servers
and Custom Hosting. 24/7 support, 30 day guarantee, secure servers.
Industry's most experienced staff! -- Web Hosting With Muscle!

One good thing about google groups is that it has access
to stuff from months and years ago -- posts long gone
from whatever local or isp-maintained usenet cash you might have
access to.


David
 
J

Jürgen Exner

One good thing about google groups is that it has access
to stuff from months and years ago -- posts long gone
from whatever local or isp-maintained usenet cash you might have
access to.

Well, kind of.
The Usenet archive known as DejaNews used to be better before Google
bought it and renamed it Google Groups.
Now in Google I can't even get a threaded tree view any longer.

jue
 
T

Tim Greer

One good thing about google groups is that it has access
to stuff from months and years ago -- posts long gone
from whatever local or isp-maintained usenet cash you might have
access to.


David

That debate would more accurately be about news readers, rather than
archiving usenet articles. Speaking of, my news reader is configured
(by me) to not display already "read" usenet articles that are over
30-60 days old, so I'm unsure why you've been replying to such old
articles in this group today? It makes it difficult to follow (and I
really dislike google groups, so I'm not going there to check the
history of this thread :)
 
T

Tim Greer

Jürgen Exner said:
Well, kind of.
The Usenet archive known as DejaNews used to be better before Google
bought it and renamed it Google Groups.
Now in Google I can't even get a threaded tree view any longer.

jue

Agreed, Dejanews was far better, and I've not used it much since google
took over (if I ever do need to refer to an old article).
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,580
Members
45,054
Latest member
TrimKetoBoost

Latest Threads

Top