Anonymous Monk has asked for the wisdom of the Perl Monks concerning the following question:
But, I also want to keep a copy of the email exactly as it came in, before MIME::Parser does it's thing. However,my $input = \*STDIN; my $entity = $parser->parse($input);
works fine for keeping the copy, but then there is nothing left for MIME::Parser to parse it seems. If I reverse the order, and parse it first, then there is nothing to print in my copy file.I gues STDIN is only good for one read? I tried makeing a copy of the reference, likemy $input = \*STDIN; my @copy = <$input>; open(COPY, ">copy.txt"); print COPY @copy; close COPY; my $entity = $parser->parse($input);
but that just makes another reference to the same data address I guess (which makes a lot of sense), because it is still only good for one read. I triedmy $input = \*STDIN; my $copy = $input;
Which seems to make sense, but now MIME::Parse doesn't parse the $copy. If I print $copy; instead, I see that $copy does indeed contain a copy of the file, but I can't figure out why MIME::Parse will only parse it if it is the original. Anybody have any ideas?my $input = \*STDIN; my @copy = <$input>; open (TMP, ">/tmp/copy.txt"); print TMP @copy; close(TMP); open($copy, "</tmp/copy.txt"); my $entity = $parser->parse($copy);
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Copy of a filehandle reference
by antirice (Priest) on Jun 19, 2003 at 05:59 UTC | |
by Anonymous Monk on Jun 19, 2003 at 12:52 UTC | |
|
Re: Copy of a filehandle reference
by sgifford (Prior) on Jun 19, 2003 at 06:17 UTC | |
|
Re: Copy of a filehandle reference
by fglock (Vicar) on Jun 19, 2003 at 03:55 UTC | |
by Anonymous Monk on Jun 19, 2003 at 04:15 UTC |