in reply to Storing output of a subroutine into an hash and then printing hash
You probably just used the "C:\Users\li\test" string as a quick example, but be aware that escapes (backslashes) in double-quoted strings are not passive. (I use qq{...} in the following example instead of "..." because Windoze command line doesn't like double-quotes.) The string you posted has three major pitfalls:
Perl treats forward and backward slashes in directory paths equivalently for internal use; it's usually best to use forward slashes in such paths. Also note that the final \ (backslash) in the single-quote example must be escaped.c:\@Work\Perl\monks>perl -wMstrict -le "my $weird = qq{C:\Users\li\test}; print qq{weird double-quotish interpolation '$weird'}; ;; my $cool = qq{C:/Users/li/test}; print qq{forward slashes '$cool'}; ;; my $single = 'C:\Users\li\test\\'; print qq{non-interpolating single quotes '$single'}; " weird double-quotish interpolation 'C:SERSI EST' forward slashes 'C:/Users/li/test' non-interpolating single quotes 'C:\Users\li\test\'
See Quote and Quote-like Operators.
Give a man a fish: <%-{-{-{-<
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: [OT]: Storing output of a subroutine into an hash and then printing hash
by Maire (Scribe) on Oct 21, 2017 at 07:00 UTC |