perl is human friendly; infact a comma is missing after the decalration of the lexical filehandle name:
open my $writehandle "+>", $filetowrite
# must be
open my $writehandle , "+>", $filetowrite
PS pay attention: while(<$writehandle>) will never work: the pointer is to the end of file when you try to reaad from that handle:
You can use seek to rewind it but probalby it will be better another strategy: instead of writing to a file accumulate the output into an array.
Then you can foreach my $line (@out_array){ # do whatever you want...
PPS if you provide an example data you are grabbing and the expected output for sure some monk can suggest a better way to handle your data: I suspect you have a filehandle or two more than necessary..
L*
There are no rules, there are no thumbs..
Reinvent the wheel, then learn The Wheel; may be one day you reinvent one of THE WHEELS.
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.