E
El Bandolero
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 }
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 }