Beefy Boxes and Bandwidth Generously Provided by pair Networks
Just another Perl shrine
 
PerlMonks  

comment on

( #3333=superdoc: print w/replies, xml ) Need Help??
Or, if you don't want to use a module, you could try this solution:
#!/usr/local/bin/perl use strict; use warnings; use Data::Dumper; chomp(my @data = <DATA>); my $in_section = 0; my @source_go = (); my $record = {}; foreach my $line (@data) { if ($line =~ /^\[([^]]+)\]/ and not $in_section) { $record->{app} = $1; $in_section = 1; } elsif ($line =~ /^\[([^]]+)\]/ and $in_section and not exists $record->{path}) { # We found a section start, but no Script_Path parameter to go # with it. Warn and continue on the current section. warn("No Script_Path for " . $record->{app} . "\n"); $record->{app} = $1; $in_section = 1; } elsif ($line =~ /^Script_Path=(.+)/) { $record->{path} = $1; push @source_go, $record; $record = {}; $in_section = 0; } } print Dumper(\@source_go); __DATA__ [Microsoft MediaPlayer Settings 1.0] Script_Path=apps\microsoft\mediaplayersettings\1.0\go\mediaplayersetti +ngs10.go Information=Go Success Install_Start_Time=05/26/2004 5:55:36 PM Install_End_Time=05/26/2004 5:55:40 PM [Microsoft Windows Journal Viewer v1.5] Script_Path=apps\microsoft\journalviewer\1.5\go\journalviewer.go UTC_Timestamp=06/03/2003 17:04:10 GoScript_Checksum=66665 Install_Start_Time=05/26/2004 5:58:24 PM Install_End_Time=05/26/2004 5:58:34 PM [Company RAC 1.0] Script_Path=apps\company\remoteaccessclient\1.0\go\uninstallvs.go UTC_Timestamp=03/03/2003 18:19:05 GoScript_Checksum=175108 Product version=1.0 PM [Microsoft Resource Kit v1.0] GoScript_Checksum=69503 Product version=1.0 Install_End_Time=05/26/2004 6:00:42 PM [Microsoft Remote Console Setup v2.02] Script_Path=apps\company\msreskitxp\go\rcsetup.go UTC_Timestamp=05/24/2002 01:19:33 GoScript_Checksum=56813 [Microsoft PowerToys for Windows XP 1.00] Script_Path=apps\microsoft\powertoysforwindowsxp\1.00\go\powertoysforw +indowsxp100.go
It's not extensively tested, but seems to work fine.

Arjen


In reply to Re^2: filtering a text file by Aragorn
in thread filtering a text file by Anonymous Monk

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post; it's "PerlMonks-approved HTML":



  • Are you posting in the right place? Check out Where do I post X? to know for sure.
  • Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
    <code> <a> <b> <big> <blockquote> <br /> <dd> <dl> <dt> <em> <font> <h1> <h2> <h3> <h4> <h5> <h6> <hr /> <i> <li> <nbsp> <ol> <p> <small> <strike> <strong> <sub> <sup> <table> <td> <th> <tr> <tt> <u> <ul>
  • Snippets of code should be wrapped in <code> tags not <pre> tags. In fact, <pre> tags should generally be avoided. If they must be used, extreme care should be taken to ensure that their contents do not have long lines (<70 chars), in order to prevent horizontal scrolling (and possible janitor intervention).
  • Want more info? How to link or How to display code and escape characters are good places to start.
Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others examining the Monastery: (6)
As of 2023-01-30 20:58 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found

    Notices?