Daniel Falkenberg wrote:
> 
> Basically I have a file like the following...
> 
> test1:x:26:testing1
> test2:x:45:testing2
> test3:x:45:testing3
> test4:x:23:testing4
> test5:x:45:testing5
> 
> Now I need to strip everything in there that is before the first ':' and
> only match anything with the ':45'.  I also need to be able to extract
> everything past the last ':' and then store her in a hash like this...
> 
> %crud = {
>             'test2' => 'testing2',
>             'test3' => 'testing3',   #Because these have 45 within them
>             'test5' => 'testing5'
> }'
> 
> Here is what I have so far...
> 
> $name_of_hash = "Crud";
> 
> open FILE ....
> while (<FILE>) {
>         $keys_of_hash = $1 if /^\s*(.*?)\s*:/;
> }
> close FILE;

Here is one way to do it:

my %crud;
while ( <FILE> ) {
    chomp;
    $crud{ (split /:/)[0] } = (split /:/)[-1] if /:45:/;
    }



John
-- 
use Perl;
program
fulfillment

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to