Hello steve,
what seems to be your immediate problem is that you are trying to do the
following:
$foo[0] = @bar;
$foo[1] = @baz;
and so on...
that does not work in perl; you can only assign scalars to arrays and
hashes, (for the details behind this, i'll refer you to
www.sharemation.com/~perl/tut where some basic tutorials explain a few
things) and you are assigning arrays to @foo.
ok, so what to do? the answer is not so complicated thankfully....
$foo[0] = \@bar; #store a reference to @bar in @foo (for more details,
see the above link again)
now you can access this array again as follow:
@quux = @{$foo[0]} # dereference again by putting an @ in front
of the reference
as for the substring part, you might want to concider using regexes instead,
since they'll be a bit more friendly to possible changes on the site where
you 're getting your info from (if well written), but i'll leave that up to
you =)
hope this helps,
Jos Boumans
> im trying to write a program that takes the daily topten from
> showbizdata.com and formats it in an email. i have everything working
great
> except the format part. i tried the format function but it doesnt seem to
> want to work in arrays and i am really bad at grabbing the stuff in scalar
> (as a matter of fact, out of 20 tries, i have grabbed the topten or even
> anything at all in scalar context for a total of 0 times =( ). so what i
am
> trying to do is this:
>
> for (my $f=0; $f <= $#topten; $f++)
> {
> $rank[$f] = substr($topten[$f], 2, 3);
> $title[$f] = substr($topten[$f], 7, 30);
> $gross[$f] = substr($topten[$f], 50, 4);
> $grosstodate[$f] = substr($topten[$f], 60, 8);
> }
>
> # *************************************************
> for (my $g = 0; $g <= $#topten; $g++)
> {
> $topten[$g] = ("$rank[$g]", "\t", "$title[$g]", "\t", "$gross[$g]",
> "\t", "$grosstodate[$g]", "\n");
> }
> # ***************************************************
> print"@topten\n";
>
>
> the substr grabs all work pretty much ok, but when i try to put them back
in
> topten (the lines between the comment lines) i get useless use of a string
> in void context...i tried grouping the elements with only double-quotes
> around the tab but it didnt work. any suggestions would be appreciated.