[NEWBIE] Trivial?



I'm solving an exercise studying on a tutorial

The task is to print the (empty or not) lines of a file numbering only the
non empty ones.

How the h### is possible that the following code gives the same result if I
change line 9 with the opposite condition?
if (!$lines[$i]=="")

1 #!/usr/bin/perl
2 #
3 $file = 'C:\Perl\html\Artistic.txt';
4 open(PIP, $file);
5 @lines = <PIP>;
6 close(PIP);
7 for ($i=0;$i <= @lines;++$i)
8 {
9 if ($lines[$i]=="")
10 {print $i." ".$lines[$i]};
11 }


--
ciao
Bando
.



Relevant Pages

  • solution to HTDP exercise-10.1.4
    ... I am providing here help on solving exercises of HTDP ... a-lon) empty] ...
    (comp.lang.scheme)
  • Re: Trivial?
    ... >>> I'm solving an exercise studying on a tutorial ... >> numbering only the> non empty ones. ... lines of a file numbering only the non empty ones." ...
    (comp.lang.perl.misc)
  • Re: Trivial?
    ... >>> I'm solving an exercise studying on a tutorial ... >> numbering only the> non empty ones. ... lines of a file numbering only the non empty ones." ...
    (comp.lang.perl.misc)
  • Average per block
    ... Could anyone help me in solving this problem. ... Every nth ... row in that column is empty. ... empty cell and where the average is based on the n cells above untill ...
    (microsoft.public.excel.worksheet.functions)
  • Re: [NEWBIE] Trivial?
    ... The task is to print the (empty or not) lines of a file numbering only the ... You should enable warnings and perl would have informed you that you are using numerical comparison on strings instead of numbers. ...
    (comp.lang.perl.misc)