Beefy Boxes and Bandwidth Generously Provided by pair Networks
more useful options

Using @ARGV with an > in the command line

by chinamox (Scribe)
on Nov 06, 2006 at 03:02 UTC ( [id://582364]=perlquestion: print w/replies, xml ) Need Help??

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

Hello good monks!

I am working on an assignment for my an online course and I have run into a small issue. I am trying to complete an assignment involving the use of the utterly brilliant Acme::EyeDrops module.

Basically all I really need is a quick clarification on how the <> operator works. My command line input should look like this:

username$:perl orginalprogram > program_after_Ey +eDrops

My question to do with using @ARGV to pass the values for 'orginalprogram' and 'program_after_EyeDrops'. Are they $ARGV[0] and $ARGV2 or does the > do something like automatically open program_after_EyeDrops?

As always, thank you for your time and patience,


Replies are listed 'Best First'.
Re: Using @ARGV with an > in the command line
by GrandFather (Saint) on Nov 06, 2006 at 03:17 UTC

    The '>' in the commandline redirects STDOUT at the OS level (well, shell really) to a file. Your Perl script doesn't know anything about that.

    Your script will get @ARGV populated with just 'originalprogram'. Anything that you print or would otherwise be sent to STDOUT will end up in a file called 'program_after_EyeDrops'.

    DWIM is Perl's answer to Gödel

      Thank you very much for another quick and helpful response!

Re: Using @ARGV with an > in the command line
by imp (Priest) on Nov 06, 2006 at 03:21 UTC
    The '>' symbol instructs the shell to redirect the STDOUT output to the file named 'program_after_EyeDrops'. The shell determines this before launching perl, and this information is not available to perl.

    Here's a tutorial on redirection when using bash.

      Excellent. This makes my task much easier! Thank you very much for the link too.


Re: Using @ARGV with an > in the command line
by smokemachine (Hermit) on Nov 07, 2006 at 23:09 UTC
    if you want you can use the > if use ' or " like:
    username$:perl orginalprogram ">" program_after_ +EyeDrops

    because this will make bash dont interpreter the signal...

Log In?

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: perlquestion [id://582364]
Approved by imp
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others chanting in the Monastery: (6)
As of 2024-04-17 16:18 GMT
Find Nodes?
    Voting Booth?

    No recent polls found