Beefy Boxes and Bandwidth Generously Provided by pair Networks
Syntactic Confectionery Delight
 
PerlMonks  

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.

Comment on using < and > with @argv
Download Code
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, http://bob-n.com
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.)

      -sauoq
      "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.
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

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others surveying the Monastery: (11)
As of 2014-12-26 13:19 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    Is guessing a good strategy for surviving in the IT business?





    Results (171 votes), past polls