Beefy Boxes and Bandwidth Generously Provided by pair Networks
There's more than one way to do things

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]: ... obviously too long
[Eily]: I yes, the natural onion in the flamming eye, I know what you mean
[LanX]: Eily your turn to provide a pic :)
[Eily]: occupe toi de tes oignons
LanX could do a zoom out in animated gif ...
[LanX]: heh
[marto]: get with the times, webm :P
[LanX]: didn't know this expression xD
[Eily]: :)
[Eily]: if you want to learn French expressions you can give a look to @bouletcorp on twitter

How do I use this? | Other CB clients
Other Users?
Others examining the Monastery: (10)
As of 2017-12-14 16:26 GMT
Find Nodes?
    Voting Booth?
    What programming language do you hate the most?

    Results (398 votes). Check out past polls.