On Aug 14, 3:57 pm, [EMAIL PROTECTED] (Jay Savage) wrote:
> On 8/12/07, Mr. Shawn H. Corey <[EMAIL PROTECTED]> wrote:
>
> > John W. Krahn wrote:
> > > yitzle wrote:
> > >> Works:
> > >>     my $t = shift;
> > >>     my $id = qr($t);
> > >> Doesn't work:
> > >>     my $id = qr(shift);
>
> > >> Why?
>
> > > perldoc -q "How do I expand function calls in a string"
>
> > It's because qr is not a function, it's a quote-like operator.
>
> No, it's because shift *is* a function.
>
> As OP's example shows, variables interpolate, functions don't. The
> difference between qr($t) and qr(shift) doesn't have anything to do
> with qr().

Of course it does.  That's utter nonsense.  Functions passed as
arguments to functions get called.  Functions included in strings do
not.  qr() is a quoting mechanism.  Its result is a string

> It has to do with shift's behavior WRT string
> interpolation. It doesn't matter whether the interpolated string is
> being passed to an operator, a function, a subroutine, or someplace
> else:

More absurdity.

$ perl -le'
sub foo {
   print @_;
}
@ARGV = (qw/alpha beta gamma/);
foo(shift);
'
alpha

Of COURSE it matters how the function is being used.  If it's being
included in a string (whether it's a "", '', qq, q, qr, qw, or qx)
it's just the name of the function that gets included in the string.
If it's passed as an argument to a function, it gets called and its
return value(s) are passed in its place.

Paul Lalli


-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/


Reply via email to