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

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

by morgon (Curate)
on Oct 03, 2010 at 23:04 UTC ( #863210=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

I think you don't really understand what -p does.

I recommend that you read about it in "perldoc perlrun".

In your example you seem to expect that "ConfigFile" is treated as the name of the file that -p workes on and all the other command-line arguments go to @ARGV.

This is wrong.

What happens is that ALL arguments (including "ConfigFile") go to @ARGV but then are treated (via -p's magic) as filenames. This is why you get the error.

So you have to pass your data to perl via some other mechanism if you want to use -p (I would use an environment variable).

  • Comment on Re^3: Command-line arguments to command-line Perl

Replies are listed 'Best First'.
Re^4: Command-line arguments to command-line Perl
by RecursionBane (Beadle) on Oct 04, 2010 at 04:58 UTC
    Yes, you're right. I didn't quite understand what -p did. Thanks for your suggestion regarding perldoc! I have a better understanding of how -p and -i work. Also, -s seems interesting.

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://863210]
[talexb]: Great quote from Re: (OT) Motivating the Unmotivated Programmer: "As Weinberg suggests, when a programmer becomes irreplaceable, it's time to replace him."
[jedikaiti]: SuicideJunkie++ #Apgrade is the highest point it will reach. They're informing you that it will all be downhill from here until the software hits a PEgrade, or impacts the terrain depending on the details of the orbit.

How do I use this? | Other CB clients
Other Users?
Others musing on the Monastery: (12)
As of 2017-07-25 18:50 GMT
Find Nodes?
    Voting Booth?
    I came, I saw, I ...

    Results (377 votes). Check out past polls.