Beefy Boxes and Bandwidth Generously Provided by pair Networks
Your skill will accomplish
what the force of many cannot

Re^2: FileHandles in a Hash (<> ambiguity)

by morgon (Deacon)
on May 28, 2014 at 22:10 UTC ( #1087727=note: print w/ replies, xml ) Need Help??

in reply to Re: FileHandles in a Hash (<> ambiguity)
in thread FileHandles in a Hash

For my own understanding I try to reformulate what is happening:

When you do open $teamAccts{$key}.. the expression $teamAccts{$key} refers to a reference to a GLOB.

When you put that into angles it should (from my point of view) be interpreted as a filehandle but for whatever reason it is not - rather it is treated as a glob-pattern that is first stringified (that gives the GLOB(...) value which is then "globbed". Because no file in the current directory matches that pattern, the pattern is returned.

This behaviour of glob is probably to mimik the broken glob-behaviour of shells:

perl -e print glob("hubba"); # prints "hubba" even if you don't have +a file "hubba"
perl -e print glob("hubba*"); # prints nothing, provided no file matc +hes
So this is why <$teamAccts{$key}> returns GLOB(...) For my taste this is not simply a wart but a hunchback with a wart on top of perl...

You have tried to combine in a natural way two of perl's features (hashes and the angle-operator) and and were bitten by a total lack of orthogonality. Really nothing to boast about...

Comment on Re^2: FileHandles in a Hash (<> ambiguity)
Select or Download Code
Re^3: FileHandles in a Hash (<> ambiguity)
by LanX (Canon) on May 29, 2014 at 01:58 UTC
    Well Perl started as a script language, that's why it mimics glob.

    I rarely use <> for globbing, and I wouldn't mind if this feature would be disabled. And I agree that this DWIM logic is somehow surprising.

    But everybody is free to overload <> to do so.

    Your second critic about glob() is somehow cryptic for me, if you say touch hubba you don't want to touch "nothing" because hubba doesn't already exist.

    Perl's success in its early years came from its compatibility with established tools.

    Otherwise we wouldn't be here discussing Perl...

    Cheers Rolf

    ( addicted to the Perl Programming Language)

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://1087727]
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others exploiting the Monastery: (7)
As of 2015-07-04 07:15 GMT
Find Nodes?
    Voting Booth?

    The top three priorities of my open tasks are (in descending order of likelihood to be worked on) ...

    Results (58 votes), past polls