Hi,
there is a clause in perl program which assigns two variables with values from a file.
my ($t, undef, $i)=/t: ((\d|\.)+)\s.*?i=((\d|\.)+)/;
What does "undef" mean in the above clause?
Using undef on the left side of the assignment like this allows you to skip an element in the assigned list. Three values are being passed to these variables (four actually), from the capturing parenthesis for the regex in list context. The first goes in $t, the second is discarded (assigned to undef or nothing more literally) and the third goes into $i. (The fourth is also discarded, since there is nowhere else to stick it.)
Which value will be assigned to $t and $i? in the place \d? or some value?
The result of the capture of the first ((\d|\.)+) ends up in $t and the second ((\d|\.)+) ends up in $i. The internally parenthesis in those chunks are intended to cluster, not capture, but as a side-effect they're adding to the resulting list. Undef is basically being used to skip a set of capturing parenthesis. You could change the regex to eliminate the need for it, by using non-capturing clustering:
my ($t, $i)=/t: ((?:\d|\.)+)\s.*?i=((?:\d|\.)+)/;
Hope that clears it up.
James
-- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]