Beefy Boxes and Bandwidth Generously Provided by pair Networks
Just another Perl shrine
 
PerlMonks  

Compilation failed, Vendor::Amazon, Vendor::BarnesNoble

by luisfagundes (Initiate)
on Feb 23, 2004 at 02:13 UTC ( #331009=perlquestion: print w/replies, xml ) Need Help??

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

Hi Monks!
I'm right on a deadline and everything was working perfect. Then I made some comments, put use strict in all modules and one 'my' that was missing to compile with strict and when trying to compile, I got this:

Unknown error
Compilation failed in require at BookRetriever.pm line 8.
BEGIN failed--compilation aborted at BookRetriever.pm line 8.
Compilation failed in require at compare_prices.pl line 4.
BEGIN failed--compilation aborted at compare_prices.pl line 4.

These are the first lines of BookRetriever:

package BookRetriever; #################################################### # This class uses Vendor plugins to retrieve book HTML pages from vend +or websites, # parse them, insert it into db and return data from db use DBI; use LWP::UserAgent; use Vendor::Amazon; # LINE 8 use Vendor::BarnesNoble; # Here is configuration for everything our %CONFIG = ('db_host' => 'localhost', 'db_name' => 'books', 'db_user' => 'user', 'db_pass' => 'pass', 'html_retrieve_timeout' => 30, 'vendors' => [ qw(Amazon BarnesNoble) ] );
error line is this use Vendor::Amazon, and error happens Vendor::BarnesNobles if I exchange them. In fact, I made one change right there. It was working, them I erased these two lines, put a BEGIN around our %CONFIG and inside the BEGIN I looped through @{$CONFIG{'vendors'}} and eval "use Vendor::$vendor;";
I kept writing comments all around before testing then noticed the eval didn't work, when I got back the old way it didn't compile
Any ideas?

janitored by ybiC: Balanced <code> tags around codeblock, renamed from "Unknown compile error - desperation"

Replies are listed 'Best First'.
Re: Unknown compile error - desperation
by ysth (Canon) on Feb 23, 2004 at 03:44 UTC
    If I understand it correctly, "Unknown error" results when a require fails in a way that should have set $@ but didn't. You can often get to the actual error by feeding perl directly the .pm file (.../Vendor/Amazon.pm or BarnesNoble.pm, in this case). You should report this using perlbug.
      I got, thanks for all! The problem was that Vendor::Amazon had:
      use base Vendor::Base;
      one thing I did but couldn't associate with was:
      use strict; use base Vendor::Base;
      then I realized that if strict goes after, no problem. Later I figured all out: base is the module and Vendor::Base is the parameter, so quotes are necessary around Vendor::Base. with strict after or without strict, no problem without quote.

      That's it. Thanks again.

Re: Unknown compile error - desperation
by AidanLee (Chaplain) on Feb 23, 2004 at 02:18 UTC
    i had an 'unknown error' earlier this week. I wrapped the offending code in an eval, and $@ pointed me to the real problem.
Re: Unknown compile error - desperation
by NetWallah (Canon) on Feb 23, 2004 at 03:05 UTC
    Your line "'vendors' => qw(Amazon BarnesNoble) " is probably not doing what you expect.assigning a list to a scalar. This will result in the first value (Amazon) being assigned to "vendors".

    Update:Valid Nit from message below has been picked.

    What I think you meant is to get a REFERENCE to a list, which you can do thus:

    our %CONFIG = ('db_host' => 'localhost', 'db_name' => 'books', 'db_user' => 'user', 'db_pass' => 'pass', 'html_retrieve_timeout' => 30, 'vendors' => [qw(Amazon BarnesNoble)] ); # Dereference thus: print @{$CONFIG{vendors}};
    "Experience is a wonderful thing. It enables you to recognize a mistake when you make it again."
      I agree that the op probably wants an anonymous reference for the value of the %CONFIG{vendors}, but here's a nit.
      Your line "'vendors' => qw(Amazon BarnesNoble) " is assigning a list to a scalar. This will result in the first value (Amazon) being assigned to "vendors"

      Actually, it's assigning an odd number of elements to a hash: 'vendors', 'Amazon', 'BarnesNoble' are the last three.

      This is a reference to a list
      use Data::Dumper; print Dumper( \( 1, 3, 4, 6, $_, %_ ) ); __END__ $VAR1 = \1; $VAR2 = \3; $VAR3 = \4; $VAR4 = \6; $VAR5 = \undef; $VAR6 = {};
      A list is not a data structure.

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others rifling through the Monastery: (4)
As of 2022-06-27 14:51 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    My most frequent journeys are powered by:









    Results (88 votes). Check out past polls.

    Notices?