Beefy Boxes and Bandwidth Generously Provided by pair Networks
Problems? Is your data what you think it is?
 
PerlMonks  

Re: Here, doccy doccy. nice doccy. heredoc, treat.

by particle (Vicar)
on Jun 22, 2001 at 00:24 UTC ( #90522=note: print w/ replies, xml ) Need Help??


in reply to Here, doccy doccy. nice doccy. heredoc, treat.

just one nit to pick... in your example above,

print <<IMPLIED; $foo IMPLIED;
you have a semi-colon after the string terminator. this won't compile on my ActiveState Perl build 623, with or without strict and warnings. i've only been using Perl since 5.005_03, so i'm not sure if this is a holdover from earlier versions, or a bug. otherwise, your example is accurate, for *NIX. on Win32 of course, the `date` call waits for user input, and outputs something like
The current date is: Thu 06/21/2001 Enter the new date: (mm-dd-yy) date
when enter is pressed. yuck.

~Particle


Comment on Re: Here, doccy doccy. nice doccy. heredoc, treat.
Select or Download Code
Re: Re: Here, doccy doccy. nice doccy. heredoc, treat.
by particle (Vicar) on Jun 22, 2001 at 00:40 UTC
    hey, i just noticed something in my output from running 'date' in a heredoc on Win32. look closely at the output:
    The current date is: Thu 06/21/2001 Enter the new date: (mm-dd-yy) date
    when date is run from the command line, the output is:
    The current date is: Thu 06/21/2001 Enter the new date: (mm-dd-yy)
    so why does date (the contents of $foo) appear when run from a heredoc with backtick interpolation? this seems to be more than just a fancy way of quoting. can someone verify this behaviour on *nix?

    curiouser and curiouser...

    =Particle

      well, if you've copy-pasted my version, you'll note that after printing `date`, it prints "date" -- which would make it appear to be right after the backticked version. move the IMPLIED heredoc to before the BACK heredoc aand you should see that change.

      also, my version of date and yours are different; mine doesn't ask for the new date if called with no arguments. sorry for the inconvenience; i hope i didn't make your machine forget the date.

      .
        aah, you are correct.
        for a moment i thought some how the things were screwy, but it was just the perl interpreter in my head (it's still in beta).

        no inconvenience on the date thing. that's a function that goes back to the first version of DOS i used, and that was made by IBM. when NT 3.0 rolled around, they finally updated the function with a -T option to display only, and not prompt.anyway, this heredoc stuff piqued my interest, since i'd been following a bit of chatterbox today as well.

        ~Particle

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others surveying the Monastery: (8)
As of 2014-12-25 08:55 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

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





    Results (159 votes), past polls