in reply to Re^3: showPerlDirConfig
in thread showPerlDirConfig

No. my ($binary) is list context. my $binary would be scalar context. So what happens here is that the first match from the grep is stored in $binary and the rest, if any, are discarded.

Makeshifts last the longest.

Replies are listed 'Best First'.
Re^3: showPerlDirConfig
by Intrepid (Curate) on Aug 07, 2003 at 17:40 UTC

    Aristotle wrote:

    No. my ($binary) is list context.

    ++ for being more idiomatic than I. Good follow-up. I must cantankerously contend that since I don't believe perl should parse this way, though, I will still refuse to code with that usage.

    Tangent:

    You see, it's too obscure, IMHO. In some contexts, people have thought that merely having parenthesis made a list context, when in fact it is comma operators that are doing so (as per a famous rant by mjd that I have no reference to at this moment); so in my book this idiom is truly obfuscated. Yes, it is handy to have a way to say my ($scalar)= to force a list context, but as syntactic sugar it tastes remarkably sour to my buds. It's a dank dark corner of perl that I want to stay away from.

    Still, very ++ for explaining to me. At least I may remember what I am looking at next time I see it, even if I choose not to use it.

        me

    -- 
    use PerlMonk::Tye qw(:wisely);
    
      Sure.
      my $binary = file_name_is_absolute($^X) ? $^X : ( grep -x, map catfile($_,$^X), split /\Q$Config::Config{path_sep}/, $ENV{PATH} )[0];

      Makeshifts last the longest.