M
mauro papandrea
cat dati
line1
line2
line3
line4
This simple program ( an oversimplified version of my original one for
sake of simplicity ) works:
#!/bin/perl
open (FILE, "dati");
while ( <FILE> ) {
$line = readline(FILE);
print "$. $line";
}
close(FILE);
this is its output:
2 line2
4 line4
However, this oneliner gives a weird error:
Modification of a read-only value attempted at -e line 1.
What am I missing?
Thank you
Regards
Mauro
line1
line2
line3
line4
This simple program ( an oversimplified version of my original one for
sake of simplicity ) works:
#!/bin/perl
open (FILE, "dati");
while ( <FILE> ) {
$line = readline(FILE);
print "$. $line";
}
close(FILE);
this is its output:
2 line2
4 line4
However, this oneliner gives a weird error:
perl -ne '$line = readline; print "$. $line"; ' dati
Modification of a read-only value attempted at -e line 1.
What am I missing?
Thank you
Regards
Mauro