Beefy Boxes and Bandwidth Generously Provided by pair Networks
There's more than one way to do things

using < and > with @argv

by Gorby (Monk)
on Jul 31, 2003 at 03:50 UTC ( #279474=perlquestion: print w/replies, xml ) Need Help??
Gorby has asked for the wisdom of the Perl Monks concerning the following question:

Dear Monks, I've been trying to make this run on the command line:
perl myprogram.cgi hello>world
My problem is that the output of the program gets saved in a file called "world". What I want is for the entire "hello>world" to be sent to the program. How do I use the > < characters literally?

Thanks in advance.

Replies are listed 'Best First'.
Re: using < and > with @argv
by BrowserUk (Pope) on Jul 31, 2003 at 05:10 UTC

    On windows, you can also escape special chars like <>& | etc. using ^ (rather than \ per *nix).

    P:\test>perl -e"print join $/, @ARGV;" hello^>world ^& ^| ^< hello>world & | <

    Examine what is said, not who speaks.
    "Efficiency is intelligent laziness." -David Dunham
    "When I'm working on a problem, I never think about beauty. I think only how to solve the problem. But when I have finished, if the solution is not beautiful, I know it is wrong." -Richard Buckminster Fuller

Re: using < and > with @argv
by bobn (Chaplain) on Jul 31, 2003 at 04:01 UTC

    Not strictly a perl question, but try (untested):

    perl myprogram.cgi "hello>world"

    If you're on a real OS (e.g. not Windoze) single quotes will work, too.

    --Bob Niederman,
Re: using < and > with @argv
by tedrek (Pilgrim) on Jul 31, 2003 at 04:02 UTC

    Just quote it:

    perl myprogram.cgi "hello>world"
Re: using < and > with @argv
by BUU (Prior) on Jul 31, 2003 at 04:18 UTC
    Or also, cause this is perl and There Is More Then One Way To Do It(tm) you can backwhack it by prefixing it with a backslash, eg perl myprogram.cgi hello\>world
      Or also, cause this is perl and There Is More Then One Way To Do It(tm)

      Well, there is more than one way to do it, but not because "this is perl." This question really has nothing to do with Perl. It has everything to do with how quoting works in the shell (or "command interpreter" in the case of Windows.)

      "My two cents aren't worth a dime.";
        Of course it isn't perl. But this is Perlmonks, home of the perl. Naturally we embrace it's logo in all aspects of life.

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: perlquestion [id://279474]
Approved by rozallin
and all is quiet...

How do I use this? | Other CB clients
Other Users?
Others about the Monastery: (7)
As of 2018-05-22 09:08 GMT
Find Nodes?
    Voting Booth?