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

Discussion in 'Perl Misc' started by J Krugman, Nov 25, 2004.

  1. J Krugman

    J Krugman Guest

    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




    --
    To s&e^n]d me m~a}i]l r%e*m?o\v[e bit from my a|d)d:r{e:s]s.
    J Krugman, Nov 25, 2004
    #1
    1. Advertising

  2. J Krugman

    KKramsch Guest

    In <co38ej$2ak$> J Krugman <> writes:

    >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

    --
    Sent from a spam-bucket account; I check it once in a blue moon. If
    you still want to e-mail me, cut out the extension from my address,
    and make the obvious substitutions on what's left.
    KKramsch, Nov 25, 2004
    #2
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Johnathan Doe

    peek at stdin, flush stdin

    Johnathan Doe, May 15, 2004, in forum: C Programming
    Replies:
    5
    Views:
    24,818
    Chatoyer
    May 17, 2013
  2. Larry Bud

    Finding Dupe in a List

    Larry Bud, Jul 30, 2007, in forum: ASP .Net
    Replies:
    4
    Views:
    554
    =?ISO-8859-1?Q?G=F6ran_Andersson?=
    Jul 31, 2007
  3. 2obvious

    dupe records on refresh

    2obvious, Feb 11, 2005, in forum: ASP General
    Replies:
    1
    Views:
    97
    Bob Barrows [MVP]
    Feb 11, 2005
  4. Clint Olsen
    Replies:
    6
    Views:
    340
    Jeff 'japhy' Pinyan
    Nov 13, 2003
  5. Mark

    Replace scalar in another scalar

    Mark, Jan 27, 2005, in forum: Perl Misc
    Replies:
    4
    Views:
    153
    Arndt Jonasson
    Jan 27, 2005
Loading...

Share This Page