SPUG: Another Eval Question
Asim Jalis
ajalis at beryllium.cobaltgroup.com
Tue Oct 12 12:13:49 CDT 1999
Richard A. Puckett II writes:
> Want to use single quotes here so variables aren't "interpolated".
> Also want to ditch the ampersand on "length". FYI, you can check
> $@ after the eval for possible errors.
Good point.
Another question.
#!/usr/bin/perl
sub hello {
my $y; my $x = q{ $y = shift @_; };
eval $x;
print "y = [$y]\n";
print "@ = [$@]\n";
}
hello(5);
This prints:
y = [5]
@ = []
But replacing "shift @_" with "shift" results in:
y = []
@ = []
Why is this?
Asim
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
POST TO: spug-list at pm.org PROBLEMS: owner-spug-list at pm.org
Seattle Perl Users Group (SPUG) Home Page: http://www.halcyon.com/spug/
SUBSCRIBE/UNSUBSCRIBE: Replace ACTION below by subscribe or unsubscribe
Email to majordomo at pm.org: ACTION spug-list your_address
More information about the spug-list
mailing list