Beefy Boxes and Bandwidth Generously Provided by pair Networks BBQ
No such thing as a small change
 
PerlMonks  

(jeffa) 2Re: 1 line array to hash converter

by jeffa (Bishop)
on Sep 21, 2001 at 14:54 UTC ( [id://113888]=note: print w/replies, xml ) Need Help??

This is an archived low-energy page for bots and other anonmyous visitors. Please sign up if you are a human and want to interact.


in reply to Re: 1 line array to hash converter
in thread 1 line array to hash converter

The @ sign pretty much tells the interpreter to expect a SLICE, and since hash is (hopefully) already defined as a hash, you get a hash slice. :)

japhy has a great little 'tutorial' i found (via google) at http://www.crusoe.net/~jeffp/docs/using_refs

jeffa

  • Comment on (jeffa) 2Re: 1 line array to hash converter

Replies are listed 'Best First'.
Re: (jeffa) 2Re: 1 line array to hash converter
by davorg (Chancellor) on Sep 21, 2001 at 14:58 UTC

    Actually, it's the type of brackets - {} - that tells Perl that's it's a hash slice.

    --
    <http://www.dave.org.uk>

    "The first rule of Perl club is you don't talk about Perl club."

      Just because your statement confused me a little:

      The type of brackets - {} - tells Perl that it's a hash.
      The @ tells Perl to use list context vs. scalar context.

      Note the difference between:

      @hash{@array} = (1) x scalar(@array); print join(" -- ", keys %hash), "\n"; #AND $hash{@array} = (1) x scalar(@array); print join(" -- ", keys %hash), "\n";

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://113888]
help
Sections?
Information?
Find Nodes?
Leftovers?
    Notices?
    hippoepoptai's answer Re: how do I set a cookie and redirect was blessed by hippo!
    erzuuliAnonymous Monks are no longer allowed to use Super Search, due to an excessive use of this resource by robots.