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

Hello.

I'm trying to use the instructions in the following reference:

~~~~~~
ref: http://search.cpan.org/src/UNRTST/Authen-Captcha-1.023/README (see code below)
~~~~~~

I haven't been able to get it to work, though. Here are my questions:

1) where is the value for the var, '$number_of_characters' pre-defined? I added a line in my code that assigns a value to this variable and a few error messages went away. ($number_of_characters = 6;)

2) before entering a value for '$number_of_characters', here is the error that I haven't been able to figure out:

~~~~~~~~~~~~~

Name "main::code" used only once: possible typo at imgverfn.pl line 23 +. at imgverfn.pl line 23 Name "main::number_of_characters" used only once: possible typo at img +verfn.pl line 18. at imgverfn.pl line 18 main::(imgverfn.pl:9): my $captcha = Authen::Captcha->new(); resize: not found Unable to get Terminal Size. The TIOCGWINSZ ioctl didn't work. The COL +UMNS and LINES environment variables didn't work. Theresize program d +idn't work. at /usr/local/lib/perl5/site_perl/5.8.8/mach/Term/ReadKey +.pm line 362. Compilation failed in require at /usr/local/lib/perl5/site_perl/5.8.8/ +Term/ReadLine/Perl.pm line 63. at /usr/local/lib/perl5/site_perl/5.8.8/Term/ReadLine/Perl.pm line 63 Term::ReadLine::Perl::new('Term::ReadLine', 'perldb', 'GLOB(0x8128b94) +', 'GLOB(0x80f6358)') called at /usr/local/lib/perl5/5.8.8/perl5db.pl + line 6029 DB::setterm called at /usr/local/lib/perl5/5.8.8/perl5db.pl line 2203 DB::DB called at imgverfn.pl line 9
~~~~~~~~~~~~~

Some of these errors disappeared when I added the '$number_of_characters' value line.

 
The code from the referenced web page is below. NOTE: I removed the lines related to 'Alternatively':
~~~~~~~~~~~~~~~~~~~~

NAME Authen::Captcha - Perl extension for creating captcha's to verify +the human element in transactions. SYNOPSIS use Authen::Captcha; # create a new object my $captcha = Authen::Captcha->new(); # set the data_folder. contains flatfile db to maintain state $captcha->data_folder('/some/folder'); # set directory to hold publicly accessable images $captcha->output_folder('/some/http/folder'); # Alternitively, any of the methods to set variables may also be # used directly in the constructor my $captcha = Authen::Captcha->new( data_folder => '/some/folder', output_folder => '/some/http/folder', ); # create a captcha. Image filename is "$md5sum.png" my $md5sum = $captcha->generate_code($number_of_characters); # check for a valid submitted captcha # $code is the submitted letter combination guess from the use +r # $md5sum is the submitted md5sum from the user (that we gave +them) my $results = $captcha->check_code($code,$md5sum); # $results will be one of: # 1 : Passed # 0 : Code not checked (file error) # -1 : Failed: code expired # -2 : Failed: invalid code (not in database) # -3 : Failed: invalid code (code does not match crypt) ##############
~~~~~~~~~~~~~~~~~~~~

Any thoughts or suggestions? Is using 'GD::SecurityImage' better and easier to install?

(ref: http://cpan.uwinnipeg.ca/htdocs/GD-SecurityImage/GD/SecurityImage.html)

 
Thanks in advance.

Edited by planetscape - linkified links

( keep:0 edit:19 reap:0 )

Replies are listed 'Best First'.
Re: Need help with Authen::Captcha instructions
by shmem (Chancellor) on Jun 29, 2006 at 22:20 UTC
    Hello newbie00,

    you seem to be user here since December 06, 2001, 12:01 GMT, but you seem still unadvised about the basics of posting to this site; and you seem to have missed the PerlMonks FAQ. Please have a look at How do I post a question effectively?. Seeking help here requests that you post all relevant information concerning your problem, of which the most requested information is the program that is causing you headache. From the error messages you've posted, I guess it's a script named imgverfn.pl.

    Posting information that is already provided via a link is not requested and should not be done, whereas the link should be written as

    [http://search.cpan.org/src/UNRTST/Authen-Captcha-1.023/README]

    If you post the program in question, we may be able to help you; without it, there is no way.

    regards,
    --shmem

    _($_=" "x(1<<5)."?\n".q·/)Oo.  G°\        /
                                  /\_¯/(q    /
    ----------------------------  \__(m.====·.(_("always off the crowd"))."·
    ");sub _{s./.($e="'Itrs `mnsgdq Gdbj O`qkdq")=~y/"-y/#-z/;$e.e && print}
Re: Need help with Authen::Captcha instructions
by Joost (Canon) on Jun 29, 2006 at 22:26 UTC
      Thanks for your replies...I haven't been here in a longgg...time...:)

      Here is the code I used from the referenced link except WITH the '$number_of_characters' var pre-defined:

      #!/usr/bin/perl -w -d use Authen::Captcha; # create a new object my $captcha = Authen::Captcha->new(); # set the data_folder. contains flatfile db to maintain state $captcha->data_folder('/usr/home1/user123/public_html/folder01') +; # set directory to hold publicly accessable images $captcha->output_folder('/usr/home1/user123/public_html/folder01 +/images'); # I created this variable's value my $number_of_characters = 6; # create a captcha. Image filename is "$md5sum.png" my $md5sum = $captcha->generate_code($number_of_characters); # check for a valid submitted captcha # $code is the submitted letter combination guess from the use +r # $md5sum is the submitted md5sum from the user (that we gave +them) my $results = $captcha->check_code($code,$md5sum); # $results will be one of: # 1 : Passed # 0 : Code not checked (file error) # -1 : Failed: code expired # -2 : Failed: invalid code (not in database) # -3 : Failed: invalid code (code does not match crypt) ##############

      Let me know if you need additional info.

      Thanks.

        EDIT: changed above: '$number_of_characters = 6;' to 'my $number_of_characters = 6;'

      (haven't edited a Perl script much recently either...)

        Hello newbie00,

        your code is a copy of the SYNOPSIS part of the manual page of Authen::Captcha.

        The SYNOPSIS part of a manual page to a module is meant to give a quick overview of the way a module works. The code written therein is not meant to be copied and run verbatim.

        For instance, the line

        my $results = $captcha->check_code($code,$md5sum);
        must be run after an image has been created, displaying a random set of characters of $number_of_characters length, it's MD5 sum has been created and a user provided $code, i.e they typed the characters displayed on the image.

        Image creation and verification are two sequential processes, but they are conveniently displayed in the SYNOPSIS of the module in one block.

        I advise you to read the manual page of Authen::Captcha thoroughly, formulate your needs, engage in their fulfilment and come back with some code of your own.

        regards,
        --shmem

        _($_=" "x(1<<5)."?\n".q·/)Oo.  G°\        /
                                      /\_¯/(q    /
        ----------------------------  \__(m.====·.(_("always off the crowd"))."·
        ");sub _{s./.($e="'Itrs `mnsgdq Gdbj O`qkdq")=~y/"-y/#-z/;$e.e && print}