Yes you are right, thats why I posted my question here.
...cant figure it out or find a good example.
I want to skip some lines ...
<> wrote in message
news: om...
> "Chris Vidal" <> wrote in message
news:<bf1f24$>...
> > Lets say I have a ascii text file named sumfil and its contents are as
> > follows :
> >
> > 1
> > 2
> > 3
> > a
> > b
> > c
> >
> > I dont want to act on any line before the line containing "a". The below
> > doesnt work. I sit at the command line I think in an infinite loop.
> >
> > #! /opt/perl5/bin/perl
> > $tfil = "sumfil";
> > open (IN, "$tfil") or die;
> > while (defined($line = <IN>)) {
> > until ($line =~ "3") {
> > next;
> > } # end until
> > chomp $line;
> > print "$line\n"
> > } #end while
>
> You have misunderstood what until means in Perl.
>
> until (EXPR) {BLOCK}
>
> is a _looping_ construct.
>
> _Each_ time the above is executed it will repeatedly do BLOCK until
> EXPR is true. If BLOCK cannot make EXPR become false and does not
> break out of the loop by some other means then this is an infinite
> loop.
>
> You you evidently believe until is a simple negated condition with
> memory. i.e. it does something once each time it is executed until
> some condition is true and thereafter never does it again.
>
> In Perl that would be written:
>
> unless ( EXPR .. 1 == 0 ) { BLOCK }
>
> Also you want the 'next' to go to the next line, i.e. the next
> iteration of the while loop. But by default it goes to the next
> iteration of the inner-most looping construct (the until). You could
> get around this by labling your loops (see perldoc -f next).
>
> But, of course, you didn't want the inner loop at all.
>
> This newsgroup does not exist (see FAQ). Please do not start threads
> here.
|