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

I just installed Storable.pm and wrote a short little practice program:
#!/usr/bin/perl -w use strict; use lib '/site_path/path/site_perl/5.005/'; use Storable qw( freeze thaw ); my $hash = { 'black' => 1, 'white' => 2, 'blue' => 3, }; my $stored = freeze ($hash); print "$stored\n";
The code works fine...

BUT...

I get the following output using Putty:
perl storable.pl 12bluwhitblack [username dbi]$ PuTTYPuTTY
Why the heck am I getting that "PuTTYPuTTY" at the command line prompt after the program runs? I figure it's being caused by Storable because when I change the second to last line to: my $stored = "hello";, I don't get "PuTTYPuTTY" on the command line.

Any ideas?

$PM = "Perl Monk's";
$MCF = "Most Clueless Friar Abbot";
$nysus = $PM . $MCF;

Replies are listed 'Best First'.
Re: Strange command line output after using Storable.pm
by bikeNomad (Priest) on Jun 12, 2001 at 07:36 UTC
    You're sending a whole lot of binary control characters to the TTY:
    $ perl stor.pl | od -c 0000000 004 004 004 1 2 3 4 004 004 004 \b 003 003 \0 \0 \ +0 0000020 \b 203 004 \0 \0 \0 b l u e \b 202 005 \0 \0 \ +0 0000040 w h i t e \b 201 005 \0 \0 \0 b l a c +k 0000060 \n
    Some of those could mean something special to SSH, or to Putty, or to Telnet, and could cause strange output. Best bet is not to echo strange binary characters to a console session, especially if you're using a Telnet or SSH client.
Re: Strange command line output after using Storable.pm
by rob_au (Abbot) on Jun 12, 2001 at 12:02 UTC
    I have tested your code and have been unable to duplicate the error in any other terminal environment except PuTTY - With a little digging I found that two ^E (CTRL+E) characters were being sent as part of the Storable structure serialisation metadata and that these, when printed, were causing PuTTY to identify itself.
     
    This is in fact, what is being printed by the line print "$stored\n".
     
    ^D^D^D1234^D^D^D^H^C^C^@^@^@^H\x83^D^@^@^@blue^H\x82^E^@^@^@white^H\x8 +1^E^@^@^@black

     
    In essence, Storable is working, you just can't print the freeze-ed object to the terminal and then copy-paste it into something else for thaw-ing due to non-printing structure serialisation metadata.
     
    HTH,
     
    Ooohhh, Rob no beer function well without!
Re: Strange command line output after using Storable.pm
by japhy (Canon) on Jun 12, 2001 at 06:31 UTC
    I don't have the module, but try doing something like:
    my $stored = freeze($hash); $stored =~ s/\r/\\r/g; $stored =~ s/\n/\\n/g; $stored =~ s/\t/\\t/g; $stored =~ s/\cH/\\b/g; print "<$stored>\n";
    That will show you if there are any bizarre characters in the string.

    japhy -- Perl and Regex Hacker
      I tried your suggestion but I still get "PuTTYPuTTY" on the command line.

      $PM = "Perl Monk's";
      $MCF = "Most Clueless Friar Abbot";
      $nysus = $PM . $MCF;