in reply to regular expression.
Be warned that performance is compromised if the $& variable is used any where in the program and that this variable is a read-only variable.
Secondly, since you've not provided an example of the lines that you're reading from to perform this match it is a bit unwieldy to try to replicate
while you only need $2 then why do you wanna worry about $& in the first place?$line=~/.*\sid=\"(.*)\"\slo=\"(.*)\"\sto=\"(.*)\"\srb=.*$/;
Does your code take care of when the lines don't match with the above pattern or it generates an uninitialized variable warning when printing $2?
#maybe try something like print "$2\n\n" if $2;
|
|---|