Tim Musson wrote:
I have the following data in @return from
my @return = `command \\\\$Server\\$user`;
I would like to put it in a hash.
So the first line would be $hash{User_Name} = userid
How would I go about doing this? I have tried this, but not all the
key names are built the same (some with spaces others without)...
foreach (@return) { chomp;
my @t = split;
print "\n++$t[0] == $_[-1]";
}
I also need to get the group memberships at the bottom all into one
hash key each ( ie Global = "*GroupA *GroupB *GroupC"
This is one way to do it:
my %hash;
my $key;
for ( `command \\\\$Server\\$user` ) {
my ( $k, $v ) = unpack 'A27 A*', $_;
$key = $k if length $k;
$hash{ $key } .= $v;
}
John
--
use Perl;
program
fulfillment
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
<http://learn.perl.org/> <http://learn.perl.org/first-response>