LinuxQuestions.org
Help answer threads with 0 replies.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 05-28-2013, 06:41 AM   #1
fritz001
Member
 
Registered: Aug 2004
Posts: 176

Rep: Reputation: 18
Question perl array to hash


Hello everyone

so, here is my issue

@Y=(S1,S2,S3)
@Z=(A1,A2,A3,A4)

I'd like to create hash like

%W=>{S1="A1,A2,A3,A4",S2=>"A1,A2,A3,A4",S3=>"A1,A2,A3,A4"}

and to print

Key is: S1 and values are A1 A2 A3 A4

Key is: S2 and values are A1 A2 A3 A4

Key is: S3 and values are A1 A2 A3 A4


i'm trying to do a backup script but have to better understand hash to arrays

thanks !!
 
Old 05-28-2013, 07:59 AM   #2
mina86
Member
 
Registered: Aug 2008
Distribution: Debian
Posts: 517

Rep: Reputation: 229Reputation: 229Reputation: 229
Code:
for (@Y) {
    $W{$_} = join ',' @Z;
}
 
Old 05-28-2013, 09:18 AM   #3
sundialsvcs
LQ Guru
 
Registered: Feb 2004
Location: SE Tennessee, USA
Distribution: Gentoo, LFS
Posts: 10,659
Blog Entries: 4

Rep: Reputation: 3941Reputation: 3941Reputation: 3941Reputation: 3941Reputation: 3941Reputation: 3941Reputation: 3941Reputation: 3941Reputation: 3941Reputation: 3941Reputation: 3941
Often, a better and faster site to field such questions is http://www.perlmonks.org. See you there ...
 
Old 05-29-2013, 03:09 AM   #4
fritz001
Member
 
Registered: Aug 2004
Posts: 176

Original Poster
Rep: Reputation: 18
yes, well perlmonks.org better fits searching advanced perl scripting.

thanks !~
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
perl duplicates hash array casperdaghost Programming 4 09-25-2012 03:14 PM
perl array nof hash zahheb Linux - Newbie 5 08-27-2012 03:12 AM
Perl Hashes -- Updating a hash ref via hash value 0.o Programming 5 06-05-2012 12:45 PM
Perl Hash of Hash reference query kdelover Programming 1 02-19-2011 04:47 AM
[SOLVED] Perl - How to store and access an array in a hash of hashes? DevonB Programming 4 07-07-2010 07:57 AM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 08:18 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration