Beefy Boxes and Bandwidth Generously Provided by pair Networks
P is for Practical
 
PerlMonks  

Re: help declaring variables within perl one-liner

by hippo (Bishop)
on Apr 01, 2021 at 16:39 UTC ( [id://11130677]=note: print w/replies, xml ) Need Help??


in reply to help declaring variables within perl one-liner

Backticks interpolate, so you need to escape the dollars and backslashes:

#!/usr/bin/perl -w use strict; my $num_subs = `perl -w -0777 -pi -e 'my \$c=s/foo/bar/g;print STDOUT +"\$c\\n"' ./foo_test`; printf("num_subs = $num_subs\n");

🦛

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others browsing the Monastery: (1)
As of 2024-04-25 03:52 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found