*HELP* please: how to dupe STDIN in an IO::Scalar?

J

J Krugman

Please *HELP*!!! (I'm desperate. I can't leave the office and join
my family for the holiday until I get this to work. I'll be up
all night at best...)

I need to redirect STDIN so that it reads from a string. I tried

my $string = IO::Scalar->new(\"some string");
open(STDIN, "<&$string") || die "Duping didn't work\n";

which fails. I get the same bad results if I use IO::String instead
of IO::Scalar.

What am I doing wrong????????

TIA,

jill
 
K

KKramsch

In said:
Please *HELP*!!! (I'm desperate. I can't leave the office and join
my family for the holiday until I get this to work. I'll be up
all night at best...)
I need to redirect STDIN so that it reads from a string. I tried
my $string = IO::Scalar->new(\"some string");
open(STDIN, "<&$string") || die "Duping didn't work\n";
which fails. I get the same bad results if I use IO::String instead
of IO::Scalar.
What am I doing wrong????????

I'll readily admit that I have no clue about what you're doing
wrong; file handles and globs belong to one of those areas where
I see very little difference between Perl and voodoo. The
documentation on this is piss-poor, because, after all, it's all
"*magic*". As the saying goes "always keep 'em guessin'".

Anyway, if you don't care so much about what's wrong with your
code, and just want something that works, try this:

tie *STDIN, 'IO::Scalar', \$string;

Hope you make it to Turkey Dinner.

Karl
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,579
Members
45,053
Latest member
BrodieSola

Latest Threads

Top