On Thu, 2006-22-06 at 01:47 +0000, Jeff Peng wrote:
> > > This conversion to and fro must be inefficient and time consuming.  Is
> > > there a "better" way to do this?
> >
> >Use an anonymous array:
> >
> >   $array{$client} = [ @field ];
> >
> >   @field = @{ $array{$client} };
> >
> >
> 
> Or use the array's reference as the hash's values:
> 
> $array{$client} = [EMAIL PROTECTED];

This will not save the contents of @field, it only saves a reference to
it:

#!/usr/bin/perl

use strict;
use warnings;

use Data::Dumper;

my @field = qw( a b c );
my $save = [EMAIL PROTECTED];
print Dumper $save;

@field = qw( 1 2 3 );
print Dumper $save;

__END__

An alternate notation is:

  @{ $array{$client} } = @field;


-- 
__END__

Just my 0.00000002 million dollars worth,
   --- Shawn

"For the things we have to learn before we can do them, we learn by doing them."
  Aristotle

* Perl tutorials at http://perlmonks.org/?node=Tutorials
* A searchable perldoc is at http://perldoc.perl.org/



-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
<http://learn.perl.org/> <http://learn.perl.org/first-response>


Reply via email to