Kristofer Wolff wrote:
>
> hi all,
>
> is it possible to return a hash ?
>
> like:
> ----------------------------------
>
> @list= ("1;b;c", "2;d;g;" "3;test;test");
> %h = gethash("0", @list);
>
> sub gethash
> {
> ($num, @list) = @_;
> foreach(@list)
> {
> @line = split(/;/);
> $h{$line[$num]} = join(";", @line);
> }
> return(%h);
> }
Kind of a lazy question. :)
All you have to do is print out %h and you would know the answer.
Try running this and ye shall know (I localized your %h in the sub
amongst other cosmetic changes):
use strict;
my @list = ("1;b;c", "2;d;g;", "3;test;test");
my %h = &gethash (0, @list);
foreach (keys %h) { print "$_=$h{$_}\n"; }
exit 0;
sub gethash {
my ($num, @list) = @_;
my %h;
foreach (@list) {
my @line = split /;/;
$h{$line[$num]} = join ';', @line;
}
return %h;
}
__END__
--
,-/- __ _ _ $Bill Luebkert ICQ=14439852
(_/ / ) // // DBE Collectibles http://www.todbe.com/
/ ) /--< o // // Mailto:[EMAIL PROTECTED] http://dbecoll.webjump.com/
-/-' /___/_<_</_</_ http://www.freeyellow.com/members/dbecoll/
_______________________________________________
Perl-Win32-Web mailing list
[EMAIL PROTECTED]
http://listserv.ActiveState.com/mailman/listinfo/perl-win32-web