Bryan Jones wrote:
> Hello all,

Hello,

> I am somewhat new to perl.  I have tried to read everything that I can.  I
> have a somewhat simple script, so might think.  I have attached the script
> and the file that I am reading to gather the data.  I am trying to parse
> this file to gather information and from here I will import the data into a
> spreadsheet.  I need assistance on this one area with in the script.
> 
> I have a few areas in the data file that has information that looks like the
> following:
> 
> Device Capacity
>     {
>         Cylinders    :    16
>         Tracks        :    240
>         512-byte Blocks    :    15360
>         MegaBytes    :    8
>         KiloBytes        :    7680
>     }
> 
> What I am trying to do is to gather the data in between the { } so it would
> look like such
> SymmSerial =>
>      symmvol =>
>            $symmvol =>
>                 {DeviceCapacity} =>
>                             {512-byteBlocks} => 15360,
>                             {MegaBytes}    => 8,
>                             {KiloBytes} => 7680,
> 
> Above, there is only one for each symmvol.  I have multiple items like this
> I would like to parse from the data file, such as Front Director Paths,
> Device Capacity(from above) and Back End Disk Director Information.

Here is one way to do it:


if ( /^\s+Device Capacity/ ) {
    local $/ = '}';
    $device{ $symmSerial }{ symmvol }{ $symmvol }{ devicecapacity } =
        {  map split( /\s*:\s*/ ), map split( /\s*\n\s*/ ), <> =~
/\s*{\s+(.+)}/s };
    }



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>


Reply via email to