Beefy Boxes and Bandwidth Generously Provided by pair Networks
go ahead... be a heretic
 
PerlMonks  

comment on

( [id://3333]=superdoc: print w/replies, xml ) Need Help??
Hello fellow monks;
I am trying to capture all of the individual SECTION/FIGURE/ITEM by column for each individual line. I can't read the file line by line because the data might run over to the next line. I tried to put the results of the regex into an array but that makes a separate entry in the array for each field. When I do it the way in the example I only get the first occurrence of SECTION/FIGURE/ITEM. What kind of looping structure do I need to get all of the occurrences within my data. Thanks
#!/pw/prod/svr4/bin/perl use strict; use warnings; undef $/; my $data = <DATA>; $data =~ m{(\d+-)(\d+-)(\d+)(\s*/\s*)(\d+)(\s*/\s*)(\d+)}g; print "$1, $2, $3, $4, $5, $6, $7\n"; __DATA__ PART NAME QUANTITY SECTION/FIGURE/ITEM Widget1 1 72-33-00/ 23/ 85 Widget1 1 75-20-00/ 11/ 10 Widget2 1 72-33-00/20/10 Widget2 1 72-33-00/20/70 Widget2 1 72-00-33/2/1 Widget2 1 72-00-33/2/20 Widget2 1 73-12-00/4/1 Widget2 1 73-12-00/4/220 Widget2 1 73-12-00/3/10 Widget2 2 79-20-00/9/1 Widget2 1 79-20-00/5/1
-- Grey Fox
Perl - Hours to learn lifetime to master.

In reply to How to capture all occurances from a slurped file. by Grey Fox

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 chanting in the Monastery: (4)
As of 2024-04-25 07:50 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found