Beefy Boxes and Bandwidth Generously Provided by pair Networks
Think about Loose Coupling
 
PerlMonks  

Re: Nested Heredocs and Shell Escapes (code)

by traveler (Parson)
on Jun 08, 2001 at 20:31 UTC ( [id://86966]=note: print w/replies, xml ) Need Help??


in reply to Nested Heredocs and Shell Escapes (code)

Umm, the problem is the test. echo doesn't read stdin! Try
% foo=bar % cat<<EOF >$foo >EOF bar
If you want to preserve the "$foo" do
% foo=bar % cat<<'EOF' >$foo >EOF $foo
--traveler

Replies are listed 'Best First'.
Re: Re: Nested Heredocs and Shell Escapes (code)
by no_slogan (Deacon) on Jun 09, 2001 at 00:01 UTC
    Good call. Perl's << is a bit different from the shell's, so you can't blindly translate print to echo in the perl code
    print <<FOO bar FOO
    This should probably be mentioned in perltrap, but it's not.

    Aside from the quoting issue, it's never going to work the way deprecated seems to want, because environment variables don't get passed from child back to parent. If you want to set variables in your current shell, you need to do something like this:

    $ eval `perl -e 'print "FOO=bar"'` $ echo $FOO bar

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others rifling through the Monastery: (3)
As of 2024-03-29 01:49 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found