A
asspenm
Hello all,
I've been writing a perl script that requires dealing with a file
containing lines with strings in the form of:
XXX-YYY-ZZZ (3 parameters pattern)
or
XXX-YYY-ZZZ-AAA (4 parameters pattern)
or
XXX-YYY-ZZZ-AAA-BBB.... (N parameters pattern)
While XXX, YYY, etc are strings (locations).
I need to calclulate a total distance between those locations:
$total_distance += $DISTANCE{$2} - $DISTANCE{$1} ;
In other words - i've got from 3 to N parameters per line, seperated
by a dash.
I've tried to think of a smart way to assign them to the back-
refference variables, lets say $1 to $N, but did not succeed.
Currently i'm just breaking up the pattern with split and running over
it with foreach, but this is ugly, i'm sure there's a way to include
them in a regexp that assigns all $1..$N accordingly.
Any ideas?
Thanks
Assaf
I've been writing a perl script that requires dealing with a file
containing lines with strings in the form of:
XXX-YYY-ZZZ (3 parameters pattern)
or
XXX-YYY-ZZZ-AAA (4 parameters pattern)
or
XXX-YYY-ZZZ-AAA-BBB.... (N parameters pattern)
While XXX, YYY, etc are strings (locations).
I need to calclulate a total distance between those locations:
$total_distance += $DISTANCE{$2} - $DISTANCE{$1} ;
In other words - i've got from 3 to N parameters per line, seperated
by a dash.
I've tried to think of a smart way to assign them to the back-
refference variables, lets say $1 to $N, but did not succeed.
Currently i'm just breaking up the pattern with split and running over
it with foreach, but this is ugly, i'm sure there's a way to include
them in a regexp that assigns all $1..$N accordingly.
Any ideas?
Thanks
Assaf