in reply to quoting/escaping file names
The shell's most likely your problem here, not Perl. Perl won't look at the contents of $filename if you interpolate it into a string, but the resulting string will be seen by a shell which will happily interpret $var if you're not careful.
The following works for me:
#!/usr/bin/perl use strict; use warnings; my $filename = q{$vaa it's not.txt}; $file =~ s/\$/\\\$/; my $exec = `touch "$filename"`;
The double quotes (in the `` string) are passed to the shell there, and ensure that the spaces in $filename won't be an issue. The regular expression adds a backslash in front of the dollar sign; this keeps it from being interpreted by the shell. Finally, the single quote in the filename is not considered special by either Perl or the shell.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: quoting/escaping file names
by Anonymous Monk on Sep 08, 2014 at 21:35 UTC | |
|
Re^2: quoting/escaping file names
by famatte (Novice) on Sep 09, 2014 at 01:06 UTC | |
by AppleFritter (Vicar) on Sep 09, 2014 at 07:50 UTC | |
by Anonymous Monk on Sep 09, 2014 at 06:20 UTC |