R
rebound
Hi there,
Please see this code:
use strict;
use warnings;
open(IN, 'myfile.txt') or die "Open failed..$!\n";
while(my @arr = split /:/, <IN>)
{
#print "* $_ *\n";
if (/^#/) { print "Comment found\n"; }
}
close(IN);
I attempted to read the filename (line-by-line), split it using ':' as
seperator and stored the contents in an array. My IF check fails
despite the file having only perl comments.
$cat myfile.txt
#Simple comment
#another comment
##end
I think that $_ is being set to undef by split.
The split documentation does not say that $_ is modified by split.
Can someone please explain why $_ is being modified here.
TIA.
Kasp
Please see this code:
use strict;
use warnings;
open(IN, 'myfile.txt') or die "Open failed..$!\n";
while(my @arr = split /:/, <IN>)
{
#print "* $_ *\n";
if (/^#/) { print "Comment found\n"; }
}
close(IN);
I attempted to read the filename (line-by-line), split it using ':' as
seperator and stored the contents in an array. My IF check fails
despite the file having only perl comments.
$cat myfile.txt
#Simple comment
#another comment
##end
I think that $_ is being set to undef by split.
The split documentation does not say that $_ is modified by split.
Can someone please explain why $_ is being modified here.
TIA.
Kasp