if ( $control eq $code ) { warn("+++ $name: strings DO match\n"); } if ( $control lt $code ) { warn("+++ $name: control lt code\n"); } if ( $control gt $code ) { warn("+++ $name: control gt code\n"); }
You can shortcut this code by putting your messages into an array in the order equal, more, less then subscripting by the comparison using cmp rather than three separate tests.
$ perl -Mstrict -Mwarnings -e ' my $code = q{M}; my @msgs = qw{ equal more less }; warn qq{$_ }, $msgs[ $_ cmp $code ], qq{ $code\n} for qw{ A M Z };' A less M M equal M Z more M $
I hope this is of interest.
Cheers,
JohnGG
In reply to Re: string mis-match?
by johngg
in thread string mis-match?
by zeltus
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |