Reputation: 2951
This code opens a log file (csv) and takes some data from it. For example, here's a line from that file:
m/557,181, f2,20140
Here's the code:
open(LOG, '<',"$data_file") or die "can't open LOG $!\n";
while (my $line = <LOG>) {
print "$line\n";
($re,$sure,$ker,$ste) = split ($line, ',');
}
close LOG;
When I run it, I get:
Reference to nonexistent group in regex; marked by <-- HERE in m/557,181, f\2<-- HERE,20140
Not sure what's going on.
Upvotes: 0
Views: 1102
Reputation: 50637
($re,$sure,$ker,$ste) = split (',', $line);
which is really
($re,$sure,$ker,$ste) = split (/,/, $line);
as split
separator is always regex (' '
is special case)
Upvotes: 4