codetoad.com
  ASP Shopping CartForum & BBS
  - all for $20 from CodeToad Plus!
  
  Home || ASP | ASP.Net | C++/C# | DHTML | HTML | Java | Javascript | Perl | VB | XML || CodeToad Plus! || Forums || RAM 
Search Site:
Search Forums:
  hash within hash  hermanningjaldsson at 12:10 on Monday, September 08, 2008
 

right now i have the following hash of arrays.

%thenames =
(
1 => ['firstname', "sometext1", 20],
2 => ['secondname', "sometext2"],
)



i want to put a hash within the list instead of the number 20.
how do i do that?



  Re: hash within hash  S_Flex at 13:20 on Monday, September 08, 2008
 

This should help.

my %thenames =
(
1 => ['firstname', "sometext1", 20],
2 => ['secondname', "sometext2"],
);
print $thenames{1}[2] . "\n"; # print what it was with a new line
$thenames{1}[2] = "The new data"; # change it
print $thenames{1}[2]; # print what it is

Also take a look at Perl data types as a reminder.

  Re: hash within hash  hermanningjaldsson at 13:46 on Monday, September 08, 2008
 

is there any way i can do this in the line where im filling the array?





  Re: hash within hash  S_Flex at 13:50 on Monday, September 08, 2008
 

now that i have rethought the question this was probably what you wanted.

my %thenames =
(
1 => {Hash1 => 'firstname', Hash2 => "sometext1", Hash3 => '20'},
2 => ['secondname', "sometext2"],
);

print $thenames{1}{Hash3};

  Re: hash within hash  hermanningjaldsson at 13:52 on Monday, September 08, 2008
 

yes, thats what i was looking for.

thanks,










CodeToad Experts

Can't find the answer?
Our Site experts are answering questions for free in the CodeToad forums
//








Recent Forum Threads
•  Re: Parsing, fish up all between <td> and </td> ... without possibility of confusion.
•  Technical problem with Visual Studio C++
•  Put confirm do you really on button instead of link
•  How Can i Create a list[Validation] in embedded Excel Object in JavaScript ?
•  Re: searching for gd::graph guide
•  Re: hash within hash
•  Re: Passing value through function then print... GONE WRONG!!
•  Need help to modify a formula for calculating in Javascript ?
•  form/cgi help


Recent Articles
ASP GetTempName
Decode and Encode UTF-8
ASP GetFile
ASP FolderExists
ASP FileExists
ASP OpenTextFile
ASP FilesystemObject
ASP CreateFolder
ASP CreateTextFile
Javascript Get Selected Text


© Copyright codetoad.com 2001-2008