hessef has asked for the wisdom of the Perl Monks concerning the following question:

I'm running Ubuntu 9.10 and wanted to try perl 5.12. I've heard good things about perlbrew and installed perl 5.12 using that.

Running

perl -v
returns
This is perl 5, version 12, subversion 0 (v5.12.0) built for i686-linu +x ...
so I'm assuming that perlbrew did its job. However, running this test program, named brewcheck.pl:
#!/home/explain/localperl/bin/perl print "foo"; die "fark";
yields:
fark at ./brewcheck.pl line 4.
The print statement doesn't print. Running ./brewcheck.pl > outputfile, however runs as expected: I get a file named outputfile that contains the "foo" from the print statement. While that sort of behavior is usable, I'd really, really to be able to read the contents of print statments on the terminal while my perl scripts are running. Help, please?

Replies are listed 'Best First'.
Re: Using perlbrew hides stdout
by NetWallah (Canon) on Apr 23, 2010 at 02:57 UTC
    This is true of perl 5.10 on Ubuntu as well.

    You are missing the "\n" that flushes stdout before stderr takes over - I'm sure others here will explain this better.

    :~$ perl -e 'print q|foo|; die "Fark"' Fark at -e line 1. foo :~$ perl -e 'print qq|foo\n|; die "Fark"' foo Fark at -e line 1. :~$ perl -e '$|=1; print qq|foo|; die "Fark"' fooFark at -e line 1. :~$ perl -v This is perl, v5.10.0 built for i486-linux-gnu-thread-multi

         Syntactic sugar causes cancer of the semicolon.        --Alan Perlis

      Oops, yeah, this is a PEBKAC. Just tried one of my previously written programs with tons of say statements. They work. Sorry to inflict a too-hasty test case on you guys.
Re: Using perlbrew hides stdout
by ikegami (Patriarch) on Apr 23, 2010 at 02:58 UTC

    All perlbrew seems to do is create a symbolic link to Perl. Sounds like a red herring.

    Then you've shown that Perl does output foo. The difference appears to be whether STDOUT is connected to a terminal or not. Odd.

    Are you sure you didn't see it because foo appears after the fark at line? No newline caused STDOUT to be flushed before perl exits.

    $ perl -e'print "foo"; die "fark"' fark at -e line 1. foo