more useful options | |
PerlMonks |
Re: Short or Long Handby Dietz (Curate) |
on Aug 12, 2004 at 15:25 UTC ( [id://382295]=note: print w/replies, xml ) | Need Help?? |
Why not just use a simple regex: print $day, $/ if $day !~ /^0|6$/; Add: I made a common beginner mistake and I feel really ashamed about it. Although above code will work on a single digit as it was demanded ( $day representing a weekday field from localtime() ) it is not logic as it says: don't match 0 at the beginning or don't match 6 at the end. With nonmatching parens ( !~ /^(?:0|6)$/ ) it will satisfy the logic, still matching nondigits though. So it would've even been better written as !~ /0|6/ since the expected data is a single digit. I'm so sorry!
In Section
Seekers of Perl Wisdom
|
|