Loading ...
Sorry, an error occurred while loading the content.

Re: [PBML] Struck while capturing "backspace".

Expand Messages
  • Sreeram B S
    Shawn Corey wrote: ... use warnings; ... if( $key eq b ){ if( length( $word )){ print b b ; $word = substr( $word, 0, -1 ); }
    Message 1 of 3 , Sep 1, 2005
    • 0 Attachment
      Shawn Corey <shawn.corey@...> wrote:

      Sreeram B S wrote:
      > #!/usr/bin/perl
      > use strict;

      use warnings;

      > my $key;
      > my $word;
      > system "stty", "-icanon", "eol", "\001";
      > system "stty -echo";
      > print "Password: ";
      > while ( ($key = getc(STDIN)) ne "\n" ) {

      if( $key eq "\b" ){
      if( length( $word )){
      print "\b \b";
      $word = substr( $word, 0, -1 );

      > print "*";
      > $word .= $key;


      > }

      print "\n";

      > print "Word entered is $word\n"; ## This will be crypted later.
      > system "stty","icanon", "eol", "^@"; # ASCII null
      > system "stty echo";


      "\b", like "\n", is a special character. It means a backspace character
      (ASCII \x08). You cannot use this in a regular expression since \b means
      a word boundary in regular expressions. Use \x08 instead.

      Hi friends,

      I am extremely glad to say that this program has worked!! This was one of my aims (goals), ie to write a password program which would print "*" when an user types his password's characters, but I could not achieve this inspite of my efforts. But when I resorted to Perl, this has worked. I think Perl has solutions to everything !!

      This was possible only because of the support extended by the people in this team. I am greatful to this team !!

      Thanks a lot,


      Yahoo! Mail
      Stay connected, organized, and protected. Take the tour

      [Non-text portions of this message have been removed]
    Your message has been successfully submitted and would be delivered to recipients shortly.