CGI/Perl Guide | Learning Center | Forums | Advertise | Login
Site Search: in

  Main Index MAIN
Search Posts SEARCH
Who's Online WHO'S
Log in LOG

Home: Perl Programming Help: Beginner:
A question on Hashes


New User

Nov 28, 2010, 9:28 PM

Post #1 of 2 (1132 views)
A question on Hashes Can't Post

@array = (Jack Ginger Gel Jam);  
foreach i (0..4) {
$in1[$i]{$in2[$i]{$in3[$i]{$in4[$i]}}}{arr} = @array ;
print "$in1[$i]{$in2[$i]{$in3[$i]{$in4[$i]}}}{arr} = **@array**" ;

When I assign in this manner..

The output of this print statement is

12 = **Jack Ginger Gel Jam**

Could you be able to help in getting the output as

Jack Ginger Gel Jam = Jack Ginger Gel Jam

or is there a easy way to get this.


Nov 30, 2010, 1:01 PM

Post #2 of 2 (1120 views)
Re: [challakcr] A question on Hashes [In reply to] Can't Post

Please do not post multiple copies of your question.

Always use the strict and warnings pragmas. Fix the errors that they report.

Your assignment statement assigns an array to a scalar element of a very complex data structure. You probably do not intend this structure, but without strict, perl creates it for you. When perl assigins an array to a scalar, it assigns the length of the array.

Your first statement requires a dw (refer perldoc -f dw). With strict, perl will report that there is an error in this statement.
Good Luck,


Search for (options) Powered by Gossamer Forum v.1.2.0

Web Applications & Managed Hosting Powered by Gossamer Threads
Visit our Mailing List Archives