in reply to Re: Working with Variables
in thread Working with Variables

Lets say that inside a $var=<<VAR; print "Blah"; VAR print<<BLAH; print "Blah"; eval $var; BLAH will that replace eval $var with "Blah"?

Replies are listed 'Best First'.
Re: Re: Re: Working with Variables
by ChemBoy (Priest) on May 03, 2001 at 00:12 UTC

    No, it will replace $var with the string print "Blah";\n, so when you run it you'll get

    print "Blah"; eval print "Blah"; ;
    as your output, which is probably not what you want.

    See Masem's post and stephen's post below for how to do more interesting interpolation.



    If God had meant us to fly, he would *never* have give us the railroads.
        --Michael Flanders

Re: Re: Re: Working with Variables
by damian1301 (Curate) on Apr 24, 2001 at 00:27 UTC
    No, what you want is

    $var=<<BLAH; print "Blah"; BLAH eval $var;


    Because when it executes it it will print Blah out on the screen because you have print "Blah"; already inside $var;

    UPDATE:WOULD SOMEONE MIND TELLING ME WHAT IS SO WRONG ABOUT THIS POST THAT I GOT A -- ON IT?? THIS IS SO *beeping* REDICULOUS. CONSTANTLY BEING ATTACKED.

    Tiptoeing up to a Perl hacker.
    Dave AKA damian