summaryrefslogtreecommitdiff
path: root/pod/perlretut.pod
diff options
context:
space:
mode:
authorRafael Garcia-Suarez <rgarciasuarez@gmail.com>2003-06-28 16:02:53 +0000
committerRafael Garcia-Suarez <rgarciasuarez@gmail.com>2003-06-28 16:02:53 +0000
commit2275acdc2a5e9bfc8338ccf52a5a82e52653b1b0 (patch)
tree076fee74380c43a830da7da6b876fa5b605896f6 /pod/perlretut.pod
parentca62f0fc957407f48588d44995309a50a80e45ab (diff)
downloadperl-2275acdc2a5e9bfc8338ccf52a5a82e52653b1b0.tar.gz
Using $1 without testing success of the regexp, bad.
p4raw-id: //depot/perl@19873
Diffstat (limited to 'pod/perlretut.pod')
-rw-r--r--pod/perlretut.pod9
1 files changed, 5 insertions, 4 deletions
diff --git a/pod/perlretut.pod b/pod/perlretut.pod
index 57fc772df7..6e06f19291 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<C<$time =~ /(\d\d):(\d\d):(\d\d)/> > returns a true or false