From: Rafael Garcia-Suarez Date: Sat, 28 Jun 2003 16:02:53 +0000 (+0000) Subject: Using $1 without testing success of the regexp, bad. X-Git-Tag: perl-5.9.0~1110 X-Git-Url: https://perl5.git.perl.org/perl5.git/commitdiff_plain/2275acdc2a5e9bfc8338ccf52a5a82e52653b1b0 Using $1 without testing success of the regexp, bad. p4raw-id: //depot/perl@19873 --- diff --git a/pod/perlretut.pod b/pod/perlretut.pod index 57fc772..6e06f19 100644 --- a/pod/perlretut.pod +++ b/pod/perlretut.pod @@ -689,10 +689,11 @@ inside goes into the special variables C<$1>, C<$2>, etc. They can be used just as ordinary variables: # extract hours, minutes, seconds - $time =~ /(\d\d):(\d\d):(\d\d)/; # match hh:mm:ss format - $hours = $1; - $minutes = $2; - $seconds = $3; + if ($time =~ /(\d\d):(\d\d):(\d\d)/) { # match hh:mm:ss format + $hours = $1; + $minutes = $2; + $seconds = $3; + } Now, we know that in scalar context, S > returns a true or false