
fashimpaur
User
/ Moderator
Sep 4, 2002, 5:02 AM
Post #8 of 13
(772 views)
|
|
Re: [cypher_MS] How would I go about..
[In reply to]
|
Can't Post
|
|
Okay, now I will try my hand at the solution. Instead of using your array as input, I added more "ids" using a __DATA__ label. Take a look: #use strict; my @ids = (); while(<DATA>){ chomp; push @ids, split(/ /, $_); } my $n = 1; LOAD_LOOP: while (@ids){ my $arrayname = "page".($n); use vars ( @$arrayname ); for (1..5){ push @$arrayname, shift @ids; } ++$n if @ids > 0; } print "Total Page arrays Created: $n\n\n"; for (1..$n){ my $arrayname = "page".$_; print "\@page$_ = (".join(", ", @$arrayname),")\n"; } print "\n\@page5 = (".join(", ", @page5),")\n"; __DATA__ 01 02 12 13 541 54 1002 18 23 25 27 28 29 30 31 33 35 36 38 39 40 41 42 43 44 45 46 47 48 49 505 1821 1312 112 117 189 220 210 221 317 87 892 2230 As you can see, the output can be obtained using the dynamic variable names (@$arrayname) or , after they are loaded in the LOAD_LOOP, you can use the variable names you were wanting to use such as @page1, @page2, etc. !NOTE! I commented out "use strict;". It will get compile errors if run with strict turned on. Hope that helps, Dennis $a="c323745335d3221214b364d545". "a362532582521254c3640504c3729". "2f493759214b3635554c3040606a0", print unpack"u*",pack "h*",$a,"\n\n";
(This post was edited by fashimpaur on Sep 4, 2002, 6:32 AM)
|