They are call backreferences, used in regular expression as buffer where
you can store pieces of the result collected in the regular expression.
eg. if you have this
"123 456" =~ /(\d*) (\d*)/;
$1 will equal to 123 while $2 will equal to 456
If you have the 'proramming perl' book from oreilly,
On Sep 11, lyf said:
>hi, I am a perl beginner, and I am confused by $1.
>what does $1 ($2,and so on) mean?
>and how to use them?
The $DIGIT variables correspond to sets of ()'s in a regex. Here's an
example:
$pn = "1-800-555-1212";
if ($pn =~ /^\d-(\d)\d{2}-(\d{3}-\d{4})$/) {
print "t