I've got a few files named stuff like this: file (2).jpg
. I'm writing a little Perl script to rename them, but I get errors due to the brackets not being replaced. So. Can someone tell me how to escape all the brackets (and spaces, if they cause a problem) in a string so I can pass it to a command. The script is below:
#Load all jpgs into an array. @pix = `ls *.JPG`; foreach $pix (@pix) { #Let you know it's working print "Processing photo ".$pix; $pix2 = $pix; $pix2 =~ \Q$pix\E; # Problem line #Use the program exiv2 to rename the file with timestamp system("exiv2 -r %Y_%m%d_%H%M%S $pix2"); }
The error is this:
Can't call method "Q" without a package or object reference at script.sh line [problem line].
This is my first time with regex, so I'm looking for the answers that explain what to do as well as giving an answer. Thanks for any help.