thanx a lot for your help rob!!

the idea with the hash.....so simple!

christophe folschette


Rob wrote:

> Christophe
> 
> I think using Tie::File is overkill here. Try this:
> 
> #   Merge the two files into a single hash
> #
>     for $file ( 'file2.dat', 'file1.dat' )
>     {
>         open FILE, "< $file";
> 
>         while ( <FILE> )
>         {
>             chomp;
>             ($key, $val) = split /:\s+/;
>             $data{$key} = $val;
>         }
> 
>         close FILE;
>     }
> 
> #   and splat it out again
> #
>     open FILE, "> file3.dat";
>     printf FILE "%s: %s\n", $_, $data{$_}
>             for (sort keys %data);
>     close FILE;
> 
> I'm not sure about your 'some text'. If you're allowing comment lines
> starting with a hash then
> 
>     next if /^#/;
> 
> at the start of the inner loop will do. Now if you want the comments
> retaining, that's another matter :))
> 
> I never like posting just a solution on the beginners' group, but I don't
> think I'm doing anything obscure here that needs explaining. Tell me if
> I'm wrong.
> 
> HTH.
> 
> Cheers,
> 
> Rob
> 
>



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

Reply via email to