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-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=2275acdc2a5e9bfc8338ccf52a5a82e52653b1b0;p=p5sagit%2Fp5-mst-13.2.git 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