I have a scrit that picks out any word with a "$" in it. I am attempting to add double quotes to this variable in perl
#!/usr/bin/perl use warnings; use strict; my $escaping_file = $ARGV[0]; open( my $filehandle, "<" , "$escaping_file" ) || die "failed : $!"; while (<$filehandle>) { if ($_ =~ /^\$?\w+\$+\w+\$?$/g) { s/\$/\\\$/g ; #$escaped_wquotes = "".$_."" ; #$escaped_wquotes = "\"$_\"" ; $escaped_wquotes = qq("$_") ; print "$escaped_wquotes"; } }
each time I try i get this. the two commented out varaibles give the saem result.
[casper@casperbox$ ./check_escapes /tmp/new_list "bc\$stp ""soc\$ny ""icon\$test ""btec\$stp ""ec\$stp2 ""bos\$nyc ""tec\$live5 ""\$foo\$foo\$ ""\$foo\$baz ""foo\$bad\$
i am trying to get the varaible to spit this out.
"bc\$stp" "soc\$ny" "icon\$test" "btec\$stp" "ec\$stp2" "bos\$nyc" "tec\$live5" "\$foo\$foo\$" "\$foo\$baz" "foo\$bad\$"
In reply to add double quotes to a perl variable by casperdaghost
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |