I'm sure I don't understand your code, but one thing
looks funny to me. That is, you select a filehandle
and then close it. I think you need to select
something else somewhere, because a filehandle
remains selected even after it has been closed.
In unix, this can sometimes go unnoticed because the
filehandle for the next file that is opened will be
the next one that is available, which may be the one
that you last closed.
Here is some code that shows the idea:
use strict;
open(IN, "datafile") or die "can't open datafile";
local $/= 1;
select(IN);
$_= <IN>;
close IN or die "can't close IN";
print "datafile:\n", $_ or die "can't print";
This code dies with a
can't print because
IN is still selected. This example is
repaired by adding a
select STDOUT
statement right before the
print.
You may want to add error checking to your code not just
for your open commands, but also on your print and close
statements.
It should work perfectly the first time! - toma
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.