Beefy Boxes and Bandwidth Generously Provided by pair Networks
Welcome to the Monastery
 
PerlMonks  

comment on

( [id://3333]=superdoc: print w/replies, xml ) Need Help??
I have a text file, that I am trying to parse. Each "record" starts with filename.jpg: followed by a blank line or filename.jpg: followed by multiple lines of data. What I want to do is take the info that is associated with a filename and keep it in a variable to work with later.
This is what I have so far:
#!/usr/bin/perl use warnings; use strict; my $fh; open($fh, "</home/me/bulk.txt") or die "Can't open: $!"; while (my $line = <$fh>) # was $line { if ($line=~/(jpg:\Z)/) { print "\n"; print $1; if ($line=~/(\w)/) { print "\n"; print $line; print "\n"; } } }
The part that I am stuck with is after finding the *.jpg filename I want to check to see if the next line is a blank or has data. This is an example of the text file.
rib.jpg: May.jpg: Camera-Specific Properties: Equipment Make: OLYMPUS OPTICAL CO.,LTD Camera Model: C860L,D360L Camera Software: OLYMPUS CAMEDIA Master Maximum Lens Aperture: f/2.8 Image-Specific Properties: Image Orientation: Top, Left-Hand Horizontal Resolution: 72 dpi Vertical Resolution: 72 dpi Image Created: 2001:04:13 23:59:14 Exposure Time: 1/11 sec F-Number: f/2.8 Exposure Program: Normal Program ISO Speed Rating: 500 Exposure Bias: 1/2 EV Metering Mode: Pattern Light Source: Fluorescent Flash: Flash Focal Length: 5.50 mm Color Space Information: sRGB Image Width: 228 Image Height: 380 Compression Setting: SQ Macro Mode: Normal oher.jpg:

In reply to Parsing Multiple Lines. by /dev/trash

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?Last hourOther CB clients
Other Users?
Others drinking their drinks and smoking their pipes about the Monastery: (5)
As of 2024-04-19 02:34 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found