http://www.perlmonks.org?node_id=854292

viffer has asked for the wisdom of the Perl Monks concerning the following question:

Thanks for everyones comments on the issue I was having simply replacing a '.' with '\.'. I've now realized that wasn't the issue. The code I had was working, it was looking at in in perl debug mode that was giving me a strange result.
I receive a tarred file that has the directory path within it. What I'm trying to do is untar the file into a different directory using pax. I thought the problem was due to the substitution not recognizing full stops within the directory name. However I have now found that whilst the command
pax -r -f pax.tar -s'/\/home\/kev\/pax\// \/data\/kev\/atlanta\/emtex\/invoices\//p'
works on the command line with the following result
$ tar -tvf pax.tar drwxrwxr-x 252 1 0 Aug 11 14:12:55 2010 /home/kev/pax/ -rw-rw-r-- 252 1 0 Aug 11 14:12:52 2010 /home/kev/pax/t1 -rw-rw-r-- 252 1 0 Aug 11 14:12:54 2010 /home/kev/pax/t2 -rw-rw-r-- 252 1 0 Aug 11 14:12:55 2010 /home/kev/pax/t3 $ pax -r -f pax.tar -s'/\/home\/kev\/pax\// \/data\/kev\/atlanta\/emte +x\/invoices/p' /home/kev/pax/t1 >> /data/kev/atlanta/emtex/invoices/t1 /home/kev/pax/t2 >> /data/kev/atlanta/emtex/invoices/t2 /home/kev/pax/t3 >> /data/kev/atlanta/emtex/invoices/t3
when I try to embed the command into a perl script via
my $homedir="/home/kev"; chdir $homedir; my $cmd = "pax -r -f pax.tar -s'/\/home\/kev\/pax\// \/data\/kev\/atla +nta\/emtex\/invoices\//p'"; system ( $cmd );
I get the error
pax: 0511-660 A replacement string was not added : 0511-661 An invalid trailing option was specified with the -s option
So what I *should* have been asking was, what am I doing wrong when I embed this pax command into my perl script?
Thanks guys and gals
Kev