Beefy Boxes and Bandwidth Generously Provided by pair Networks
P is for Practical
 
PerlMonks  

Re: Need some help with GD::Barcode::UPCE module

by vendion (Scribe)
on Oct 10, 2010 at 17:34 UTC ( [id://864499]=note: print w/replies, xml ) Need Help??


in reply to Need some help with GD::Barcode::UPCE module

Ok so I have switched to Code39 barcodes and made the suggested changes to the code, which changes the error that now gets produced. I now get this:

PTN:000-000000:1010001110111010101000111011101010100011101110101000101 +011101110101000111011101010100011101110101010001110111010101000111011 +101010100011101110101010001110111010 Can't locate object method "Small" via package "GD::Font" (perhaps you + forgot to load "GD::Font"?) at /usr/local/share/perl5/GD/Barcode/Cod +e39.pm line 111, <> line 19.

Here is my new code:

my $oGdBar = GD::Barcode::Code39->new("$customer{id}"); if ( !$oGdBar ) { display_menu_error("ERROR: $GD::Barcode::Code39::errStr \n"); } print "PTN:", $oGdBar->{text}, ":", $oGdBar->barcode(), "\n"; my $output = '/tmp/Code39.png'; open my $OUTFILE, '>', $output; binmode $OUTFILE; print {$OUTFILE} $oGdBar->plot->png; close {$OUTFILE}; undef $oGdBar; undef $OUTFILE; undef $output; system "lpr -r $output";

As for the suggestions of changing $oGdBar->{text} to $oGdBar->{$text} does not seem to work. Does the error mean I should use GD::Font in my code or is it reffering to the module?

Replies are listed 'Best First'.
Re^2: Need some help with GD::Barcode::UPCE module
by kcott (Archbishop) on Oct 11, 2010 at 07:31 UTC

    The documentation for these modules is misleading. GD::Barcode::UPCE has $text $oGdBar->{$text} while GD::Barcode::Code39 has $text $oGdBar->{text}. Checking the source, $oGdBar->{text} would be correct for both modules.

    The message "Can't locate object method "some_method" via package "Some::Module" (perhaps you forgot to load "Some::Module"?) at ..." generally indicates someone wrote:

    $some_object->some_method(); # where $some_object is an instance of So +me::Module

    but should have written:

    use Some::Module; ... $some_object->some_method();

    I can't see a reference to the method Small() in your code but I can see two in the source code for GD::Barcode::Code39 in the plot() method.

    If I were you, I'd raise a bug report at this point. In case you don't know, just go to GD::Barcode::Code39 and follow the Report a bug link in the CPAN RT box (near the top right-hand corner in my browser).

    -- Ken

      Thanks, that is all I needed to know I have already opened a ticket in CPAN RT.

Re^2: Need some help with GD::Barcode::UPCE module
by Khen1950fx (Canon) on Oct 11, 2010 at 17:17 UTC
    I couldn't replicate your error. As for $oGdBar->{text}, that is the correct way to do it. Try this and see if it helps:
    #!/usr/bin/perl use strict; use warnings; use GD::Barcode::Code39; my $oGdBar = GD::Barcode->new( 'Code39', '*123-456789*' ); print "PTN:", $oGdBar->{text}, ':', $oGdBar->barcode(), "\n"; open OUT, '>', '/tmp/Code39.png'; binmode OUT; print OUT $oGdBar->plot->png; close OUT; undef $oGdBar;

      Even after changing my $oGdBar = GD::Barcode::Code39->new() to my $oGdBar = GD::Barcode->new() I still get the same error. I checked to make sure my GD::Barcode module is current and CPAN says I have version 1.15 installed

        You still get the same error because you're still making the same mistake:). You'll need to change more than just new(). Post what you have now, then we can figure out what's wrong.

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://864499]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others surveying the Monastery: (8)
As of 2024-04-19 17:21 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found