Front page | perl.beginners |
Postings from May 2011
Re: concatenate a hash key
Thread Previous
From:
Jim Gibson
Date:
May 18, 2011 11:34
Subject:
Re: concatenate a hash key
Message ID:
C9F95F43.12100%JimSGibson@gmail.com
On 5/18/11 Wed May 18, 2011 11:29 AM, "Chris Stinemetz"
<cstinemetz@cricketcommunications.com> scribbled:
>
> I have a hash table:
>
> my %formInstance = ( "Cell" => "csno",
> "Servgrp" => "svgrp",
> "Sector" => "antfc" );
>
>
>
> While I am iterating through the rows of the input data how can I concatenate
> a hash key as the first three fields? (i.e. 871-0-1)
while( my $line = <DATA> ) {
my @fields = split(/,/,$line);
my $key = join('-',@fields[0..2]);
# and you are good to go
}
>
> Input data looks like:
>
> 871,0,1,871,2,0,n,0,n
> 871,0,1,871,3,1,n,0,n
> 871,0,1,872,1,0,n,0,n
Thread Previous