Re: qr + shift



On Aug 14, 3:57 pm, daggerqu...@xxxxxxxxx (Jay Savage) wrote:
On 8/12/07, Mr. Shawn H. Corey <shawnhco...@xxxxxxxx> 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

.



Relevant Pages

  • Re: qr + shift
    ... it's because shift *is* a function. ... As OP's example shows, variables interpolate, functions don't. ... It has to do with shift's behavior WRT string ... print shift. ...
    (perl.beginners)
  • Re: Form filter- numbers rather than text
    ... You may have the shift in a separate table. ... When user selects Day shift or night shift, the 1 or 2 is used to filter the ... Build up the criteria string form the non-blank search ... and build up the criteria string from the ...
    (microsoft.public.access.forms)
  • Re: Minimizing squeaks in VL Et. 1 middle section
    ... on the 4th string with your 1st finger. ... pause a second, then lift the LH fingers off the string, straight up, ... play the 'a', IOW, just behind the 7th fret, fourth string. ... When you play scales do this at every shift ...
    (rec.music.classical.guitar)
  • Re: Minimizing squeaks in VL Et. 1 middle section
    ... on the 4th string with your 1st finger. ... pause a second, then lift the LH fingers off the string, straight up, ... play the 'a', IOW, just behind the 7th fret, fourth string. ... When you play scales do this at every shift ...
    (rec.music.classical.guitar)
  • Re: Minimizing squeaks in VL Et. 1 middle section
    ... on the 4th string with your 1st finger. ... pause a second, then lift the LH fingers off the string, straight up, ... play the 'a', IOW, just behind the 7th fret, fourth string. ... When you play scales do this at every shift ...
    (rec.music.classical.guitar)