Just met with perl and instantly got a problem nowhere to find a solution for.
I made a text file called perlq.txt with the following four lines in it:
< This is less.
< Again less.
> This is more.
> Also more.
Then I made a script:
#####################################
#!/usr/bin/perl
open (filin, "<perlq.txt") or die $!;
open (filout, ">perlq.out");
while (my $line = <filin>) {
if (substr($line,0,1)=="<"){
print filout "hello\n";
}
if (substr($line,0,1)=='>'){
$newlin=substr($line,2);
print filout $newlin."\n";
}
}
close filin;
close filout;
#############################################
And this is the output of perlq.out:
-----------------------------------------
hello
This is less.
hello
Again less.
hello
This is more.
hello
Also more.
--------------------------------------------
WTH???
It doesn't matter even if I escape the signs like:
if (substr($line,0,1)=="\<")
...the same result.
What do I miss?
I made a text file called perlq.txt with the following four lines in it:
< This is less.
< Again less.
> This is more.
> Also more.
Then I made a script:
#####################################
#!/usr/bin/perl
open (filin, "<perlq.txt") or die $!;
open (filout, ">perlq.out");
while (my $line = <filin>) {
if (substr($line,0,1)=="<"){
print filout "hello\n";
}
if (substr($line,0,1)=='>'){
$newlin=substr($line,2);
print filout $newlin."\n";
}
}
close filin;
close filout;
#############################################
And this is the output of perlq.out:
-----------------------------------------
hello
This is less.
hello
Again less.
hello
This is more.
hello
Also more.
--------------------------------------------
WTH???
It doesn't matter even if I escape the signs like:
if (substr($line,0,1)=="\<")
...the same result.
What do I miss?