i have figured out how to read a file a paragraph at a time :D lol. in this example i will be reading a file a paragraph at a time and then getting only certain data back.
this will return everything AFTER the pattern up until a newline char.works very quickly for me but prob could be done faster by a seasoned coder. you can modify it to suit your needs hopefully.
tested with active perl and win7 ultimate x64
$/ = ""; #set to paragraph mode
while(<$file>){
if ($_ =~ /$first_match/ && $_ =~ /$second_match/ && $_ =~ /$third
+_match/){
print "$_\n";
my ($needed_data_0) = (/^data_here(.+)/, $_);
my ($needed_data_1) = (/^more_data(.+)/, $_);
my ($needed_data_2) = (/^other_data(.+)/, $_);
print "data0 is: $needed_data_0\n";
print "data1 is: $needed_data_1\n";
print "data2 is: $needed_data_2";
}
}
any input or pointers are welcome.
:)
Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
Read Where should I post X? if you're not absolutely sure you're posting in the right place.
Please read these before you post! —
Posts may use any of the Perl Monks Approved HTML tags:
- a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
| |
For: |
|
Use: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.