Fellow Monks,
here is the situation: i have text from a file stored in a db table. in my program i query that text out of the table and store it in a variable.
is there a way i can use that variable and iterate through it line by line (each line ends in \n) in order to process the text. (in some cases depending on what the line starts with i will need to get the next line as well)
i can get it to work fine if i use a filehandle and open it up for reading but unfortunately i do not have this luxury and the only access i have to the text of the original file is stored in a variable populated by a sql query.
here is what i have so far:
foreach my $record (@files_to_process){
# $$record{data} is the way to reference data since array is a
+n array of hash refs
while(my $line = <$$record{data}>){
next if $line !~ /^06/; #if line isn't needed jump to next rec
+ord
my $line2 = <$$record{data}>; #get next line for in a way that
+ it won't be retrieved next time through from $line
chomp($line);
chomp($line2);
#now do some processing on those 2 lines and then continue loo
+p
}
thanks ahead of time
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.