in reply to trying to pass variable through system call in windows
But, if that's incorrect, let us know by clarifying your question(s).
If it is correct, consider the difference: your first code will merely echo the value of the variable; not the contents of the file whose name is in your var, where the second code example apparently tries to modify the file's contents.
C:\> perl -E "my $var = 'rstuv'; $var =~ s/r/FOO/; say $var;" FOOstuv # replaced the "r" with "FOO"... and would have done the same if $ +var were a filename; # that is, it would have changed the filename in $var, not the con +tent of the file. # Now that I've said it multiple times, does this make sense to y +ou? C:\> perl -E "my $var = 'rstuv'; $var =~ tr/r/FOO/; say $var;" Fstuv # Grossly oversimplified, the tr///ran out of "r"s to change C:\> perl -E "my $var = 'rstuv'; my $newvar = $var =~ tr/r/FOO/; say +$newvar;" 1 # count of the replacement actions
And if you're still interested is some kind of action with a tr/// please read perldoc -f tr to see how to use it correctly.
|
|---|