my $answer = ($str =~ /$pattern/); if ($answer) { print "Yes!"; } else { print "No."; }
I think the ternary here would be even more idiomatic. You can replace those 6 lines with just one:
print $str =~ /$pattern/ ? "Yes!" : "No.";
In reply to Re^2: Idiomatic Perl?
by hippo
in thread Idiomatic Perl?
by thenextfart
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |