From:                   Chris Spurgeon <[EMAIL PROTECTED]>

> I have this code snippet...
> print <<END_OF_STUFF;
> 
> I think x is $x and y is $y.
> &foobar
> Did the subroutine fire?
> 
> END_OF_STUFF
> 
> 
> When I run it, the scalar variables $x and $y are interpreted in the print
> statement, but the subroutine doesn't fire.  Is there a way to trigger a
> subroutine from within a print << statement?

While it's possible to use the @{} hack I think it's nicer to 
        use Interpolation;

Especialy if you want to pass some parameters to the function


See http://jenda.krynicky.cz/#Interpolation

For example, you can say 
   use Interpolation money => 'commify',
                     E     => 'eval',
                     placename => 'ucwords',
                     uc => sub{ uc($_[0]) },
;
And then you can write these: 
   print "3 + 4 = $E{3+4}";
   # Prints  ``3 + 4 = 7''
   $SALARY = 57500;
   print "The salary is \$$money{$SALARY}";
   # Prints  ``The salary is $57,500.00''
   $PLACE1 = 'SAN BERNADINO HIGH SCHOOL';
   $PLACE2 = 'n.y. state';
   print "$placename{$PLACE1} is not near $placename{$PLACE2}";
   # Prints  ``San Bernadino High School is not near N.Y. State";

        $fieldname = "LastName";
        print "Field name is: $uc{$fieldname}\n";
        # Prints ``Field name is: LASTNAME"

Jenda

=========== [EMAIL PROTECTED] == http://Jenda.Krynicky.cz ==========
There is a reason for living. There must be. I've seen it somewhere.
It's just that in the mess on my table ... and in my brain.
I can't find it.
                                        --- me

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to