Beefy Boxes and Bandwidth Generously Provided by pair Networks
Do you know where your variables are?
 
PerlMonks  

Re: How to handle metacharacters in input file for Perl one-liner code

by marinersk (Priest)
on Jul 16, 2015 at 12:59 UTC ( #1135014=note: print w/replies, xml ) Need Help??


in reply to How to handle metacharacters in input file for Perl one-liner code

Use the interpolative equivalent of quotemeta?

  • Comment on Re: How to handle metacharacters in input file for Perl one-liner code

Replies are listed 'Best First'.
Re^2: How to handle metacharacters in input file for Perl one-liner code
by debug (Initiate) on Jul 16, 2015 at 14:53 UTC

    Thank You!!!

    So I did not use your suggestion of using quotemeta (I haven't used it before, so I'm gonna go look it up), but I got my answer in the sample output you linked :)

    Here's my updated code that's working now. Apparently I just needed to preemptively escape the . in my search string.

    my $file = "foo.c";

    $file =~ s/\./\\\./;

    `perl -p -l -i.bak -e "s/$file/$file,=SUM(B$x:B$y)/" sample.csv`

    Though probably I should look into Dean's suggestion as well. Any thoughts on which approach would have the fastest execution time out of these?

      ... which approach would have the fastest execution time out of these?

      Since you're shelling out to the OS to run another copy of Perl to do your work, fast execution is not something you ever need to worry about.


      Give a man a fish:  <%-(-(-(-<

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://1135014]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others musing on the Monastery: (1)
As of 2021-10-21 02:49 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    My first memorable Perl project was:







    Results (82 votes). Check out past polls.

    Notices?