But I was matching against (\d*) \z which cannot fail, although it could match an empty string of digits — which can be useful in and of itself!
Update: Interestingly, what is captured | assigned to $var in a statement like
my ($var) = $s =~ m{ (\d+) \z }xms;
is not the same as what is captured to | not necessarily the same as the value of $1:
This warrants a bit more research!c:\@Work\Perl\monks>perl -wMstrict -le "'zot' =~ m{ (zot) }xms; ;; for my $s ( 'http://172.20.37.115:8080/se/1.0/pro/subs/198968/', 'http://172.20.37.115.8080/se/1.0/pro/123456', ) { my ($var) = $s =~ m{ (\d+) \z }xms; print '$var is ', defined($var) ? '' : 'UN', 'defined'; print qq{'$s' -> '$var' (\$1 is '$1')}; } " $var is UNdefined Use of uninitialized value $var in concatenation (.) or string at -e l +ine 1. 'http://172.20.37.115:8080/se/1.0/pro/subs/198968/' -> '' ($1 is 'zot' +) $var is defined 'http://172.20.37.115.8080/se/1.0/pro/123456' -> '123456' ($1 is '1234 +56')
Give a man a fish: <%-(-(-(-<
In reply to Re^3: how to find particular string and store in to variable
by AnomalousMonk
in thread how to find particular string and store in to variable
by bhushanQA
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |