Beefy Boxes and Bandwidth Generously Provided by pair Networks
XP is just a number
 
PerlMonks  

Re: More Arguments

by Athanasius (Archbishop)
on Sep 05, 2015 at 04:31 UTC ( [id://1141115]=note: print w/replies, xml ) Need Help??


in reply to More Arguments

Hello joaming,

To get the syntax right, you’ll need to study perlop#I/O Operators:

The null filehandle <> is special: it can be used to emulate the behavior of sed and awk, .... Input from <> comes either from standard input, or from each file listed on the command line. Here's how it works: the first time <> is evaluated, the @ARGV array is checked, and if it is empty, $ARGV[0] is set to "-", which when opened gives you standard input....

By trial and error, I found the following (on Windows), which seems to do what you’re looking for:

14:17 >echo Hello| perl -wE "$x = <>; chomp $x; $y = $ARGV[0]; say qq[ +>$x $y<];" - world >Hello world< 14:17 >

The call to <> finds - as the first argument on the command line and so reads from standard input, which is Hello\n. After this, @ARGV is apparently reset. I haven’t found that behaviour documented (yet).

Anyway, hope that helps,

Athanasius <°(((><contra mundum Iustus alius egestas vitae, eros Piratica,

Replies are listed 'Best First'.
Re^2: More Arguments
by joaming (Novice) on Sep 05, 2015 at 05:27 UTC
    Thank you. I still have a long road to walk on Perl, lol

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others imbibing at the Monastery: (8)
As of 2024-04-23 19:11 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found