Beefy Boxes and Bandwidth Generously Provided by pair Networks
Think about Loose Coupling
 
PerlMonks  

Re^3: assigning arrays as values to keys of hash

by Anonymous Monk
on Sep 18, 2018 at 22:45 UTC ( #1222612=note: print w/replies, xml ) Need Help??


in reply to Re^2: assigning arrays as values to keys of hash
in thread assigning arrays as values to keys of hash

Don't post bad code!
  • Comment on Re^3: assigning arrays as values to keys of hash

Replies are listed 'Best First'.
Re^4: assigning arrays as values to keys of hash
by tybalt89 (Parson) on Sep 18, 2018 at 23:36 UTC

    That sounds like a challenge :)

    #!/usr/bin/perl # https://perlmonks.org/?node_id=1222551 use strict; use warnings; use Data::Dumper; my %hash; $hash{ $& x /\S+/g }{ $& x //g } = 1 while <DATA>; $_ = [ keys %$_ ] for values %hash; print Dumper \%hash; __DATA__ snake fangs snake tail snake fangs bird feathers bird beak snake scales bird beak bird claw bird wings

    (I just wanted to post code that, if the problem is a homework assignment, will force the teacher to make the student go to the front of the class and explain on the blackboard, in detail, to the rest of the students, how the solution works :)

Re^4: assigning arrays as values to keys of hash
by Marshall (Abbot) on Sep 18, 2018 at 23:33 UTC
    What a hoot!

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others cooling their heels in the Monastery: (3)
As of 2019-07-20 05:17 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found

    Notices?