Beefy Boxes and Bandwidth Generously Provided by pair Networks BBQ
Don't ask to ask, just ask
 
PerlMonks  

Re^3: Command-line arguments to command-line Perl

by suhailck (Friar)
on Oct 04, 2010 at 01:11 UTC ( #863219=note: print w/ replies, xml ) Need Help??


in reply to Re^2: Command-line arguments to command-line Perl
in thread Command-line arguments to command-line Perl

This seems to be working

cat test 1 2 3 4 5 perl -pe 'BEGIN{$prefix=pop;}s/(\d+)/$prefix.$1/' test A A.1 A.2 A.3 A.4 A.5


Comment on Re^3: Command-line arguments to command-line Perl
Download Code
Re^4: Command-line arguments to command-line Perl
by RecursionBane (Acolyte) on Oct 04, 2010 at 04:57 UTC

    Thank you, suhailck!

    This tactic worked for me; I'd never have thought to use BEGIN() to stall the argument preprocessor until specific args could be gathered before allowing the program to proceed (and thereby still keeping the ability to auto-parse all supplied files "in-line")!

    This is what my one-liner now looks like:

    perl -pi -e 'BEGIN {$design = pop}; s/'def'.*''/\t"def" => "dumper\/$design.def",/g' ConfigFile ADCIF

    The main advantage here is that I can supply "ConfigFile1 ConfigFile2 ... ConfigFileN ADCIF" (or, indeed, "ConfigFile* ADCIF") to have the change applied to all of them. Thanks again for your solution!

    ~RecursionBane

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others making s'mores by the fire in the courtyard of the Monastery: (6)
As of 2014-04-21 10:40 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    April first is:







    Results (492 votes), past polls