Beefy Boxes and Bandwidth Generously Provided by pair Networks
The stupid question is the question not asked

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

by morgon (Curate)
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...

Replies are listed 'Best First'.
Re^3: FileHandles in a Hash (<> ambiguity)
by LanX (Bishop) 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]
[LanX]: Oh I see, userDict should have been declared in n outer scope ...
[LanX]: an
[LanX]: strange python accepts this?
[LanX]: no previous userDict?

How do I use this? | Other CB clients
Other Users?
Others wandering the Monastery: (13)
As of 2018-03-20 18:19 GMT
Find Nodes?
    Voting Booth?
    When I think of a mole I think of:

    Results (257 votes). Check out past polls.