Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl Monk, Perl Meditation
 
PerlMonks  

Re: Join 2 arrays horizontally

by tybalt89 (Monsignor)
on Mar 03, 2019 at 23:45 UTC ( [id://1230811]=note: print w/replies, xml ) Need Help??


in reply to Join 2 arrays horizontally

#!/usr/bin/perl # https://perlmonks.org/?node_id=1230807 use strict; use warnings; my @array1 = qw(host1 host2 host3); my @array2 = qw(ip1 ip2 ip3); my %ip2host; @ip2host{@array2} = @array1; print "$_ $ip2host{$_}\n" for @array2;

Replies are listed 'Best First'.
Re^2: Join 2 arrays horizontally
by tweetiepooh (Hermit) on Mar 04, 2019 at 12:34 UTC

    And depending on how the original data is sourced you may be better off simply creating the hash in the first place.

    my %ip2host = ( ip1 => host1, ip2 => host2, ip3 => host3 );

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others learning in the Monastery: (1)
As of 2024-04-25 00:29 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found