in reply to modernizing a perl util to upload a file through sftp
Not pertinent to your questions, but
if ( $prompt1 eq ( "y" | "Y" ) ) { ... }
in a few places caught my eye. The bitwise-or of 'y' (ASCII 0x79) and
'Y' (ASCII 0x59) is 'y', so 'Y' will never
match.
A common alternative isWin8 Strawberry 5.8.9.5 (32) Fri 10/16/2020 3:14:29 C:\@Work\Perl\monks >perl -Mstrict -Mwarnings my $Y_bitwise_or_y = 'Y' | 'y'; printf "'%s' %#x \n", $Y_bitwise_or_y, ord $Y_bitwise_or_y; ^Z 'y' 0x79
Update: Well, actually... /y/i matches something like
'funky'. IMHO, a better alternative is
if ($prompt1 =~ m{ \A y }xmsi) { ... }
This case-insensitively matches 'y' 'yy' (I sometimes
double-hit keys) 'yes' 'yup' 'ya' etc.
OTOH, m{ \A y \Z }xmsi exactly matches only 'y' 'Y'
with or without a newline at the end.
Give a man a fish: <%-{-{-{-<
|
|---|