palinurus has asked for the wisdom of the Perl Monks concerning the following question:
I need to know, how many backslashes are in a variable, but with 'print' it gives me unclear output on the Linux console. I use the following code:
$i1 = '1\2'; $i2 = '1\\2'; $i3 = '1\\\2'; $i4 = '1\\\\2'; print "#$i1#$i2#$i3#$i4#\n";
It gives me the following output:
#1\2#1\2#1\\2#1\\2#
The first 2 and the last 2 variables give the same output. But I must know, how many backslashes in a row are in the variable. Any hints?
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: print backslash in variable
by hippo (Archbishop) on Aug 17, 2015 at 16:06 UTC | |
by soonix (Chancellor) on Aug 18, 2015 at 08:28 UTC | |
|
Re: print backslash in variable
by AnomalousMonk (Archbishop) on Aug 17, 2015 at 17:16 UTC | |
|
Re: print backslash in variable
by johngg (Canon) on Aug 17, 2015 at 21:47 UTC |