Dear Perl monks,
i am trying to write the results of some parsing to a fifo to be read by the oracle sqlloader, all in the same perl script but i cant make it work without blocking.. heres the code:
if ($pid = open ($fifo, "|-")) # cookbok 16.11 open for r and w to ava
+oid blocks
{
$fifo->autoflush(1);
no warnings;
foreach my $ky (sort keys %categories)
{
print $fifo "$categories{$ky}#";
}
close $fifo
or die $! ? "Syserr closing fifo writer: $!"
: "Wait status $? from fifo writer";
}
else # child
{
die "Cannot fork: $!" unless defined $pid;
# copy from parent (now stdin) into the file # need to redirect st
+din?
#$fifofile->autoflush(1);
while (<STDIN>)
{
$fifofile = $_;
# print $fifofile;
system "sqlldr control=atpctl.ctl data=atp_fifo.dat userid=someu
+ser/pwd log=loader.log";
}
exit; # Don't forget to make the fifo disappear.
}
I can get the writer to print the line to stdout but sqlloader just hangs.
im not wedded to this approach if it looks like a bad thing to do, but i have to parse 1000 files and read them in, so id rather do it in memory.
thanks
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.