[Canberra-pm] how to tell if a library is available?

Kim Holburn kim at holburn.net
Wed Jun 18 03:42:18 PDT 2008


Yeah, I got to that point just after sending my previous email ;-)   
and my next email to the list bounced ;-(

I think I just copied that line from the man page.  Normally I try  
follow Perl Best Practises - sort of ;-)

On 2008/Jun/18, at 12:06 PM, Jacinta Richardson wrote:

> Kim Holburn wrote:
>
>> I tried your constant solution.  It works fine when it can find the
>> library but produces a strange error when it can't.  So there still
>> appears to be some compiling going on.
>
> There is.  I think it occurs when perl attempts to identify the code  
> blocks.
> The end result of compiling is:
>
> perl -MO=Deparse test.pl
> BEGIN { $^W = 1; }
> sub BEGIN {
>    eval 'use Text::Autoformat';
> }
> use constant ('AUTOFORMAT', $INC{'Text/Autoformat.pm'});
> my $data = "\n >> That bundle of copyrights relates to the very  
> considerable\n
>>> investment required to make a succession of feature films.\n\nIt's  
>>> a kind of
> circular argument.  People make an investment in a\nmovie in order  
> to make a
> profit because they know they have these\ncopyrights and a bunch of  
> people who
> earn their living helping them\nprotect those copyrights.\n\n";
> do {
>    print "no\n"
> };
> test.pl syntax OK
>
>
> Which is what we're expecting, but the warning happens before it  
> finishes the
> compile.  The problem line is this one:
>
>>   $data = autoformat $data, { right=>$width } ;
>
> Perl's telling you that - at first glance - this looks wrong.   
> Perhaps it's
> interpreting it as:
>
> 	($data = autoformat $data), { right => $width };
>
> I don't know exactly what it's doing, but it's seeing your hash  
> reference as a
> constructor in void context.  You can make this error go away, just  
> by giving
> Perl another hint of what you mean:
>
> 	$data = autoformat( $data, { right=>$width } );
>
> Now there's no error.  :)  I always recommend using parentheses  
> around your
> arguments for all non-core subroutines.  It makes hitting this kind  
> of warning
> pretty much impossible.
>
> All the best,
>
> 	J
>
> -- 
>   ("`-''-/").___..--''"`-._          |  Jacinta Richardson         |
>    `6_ 6  )   `-.  (     ).`-.__.`)  |  Perl Training Australia    |
>    (_Y_.)'  ._   )  `._ `. ``-..-'   |      +61 3 9354 6001        |
>  _..`--'_..-_/  /--'_.' ,'           | contact at perltraining.com.au |
> (il),-''  (li),'  ((!.-'             |   www.perltraining.com.au   |

--
Kim Holburn
IT Network & Security Consultant
Ph: +39 06 855 4294  M: +39 3494957443
mailto:kim at holburn.net  aim://kimholburn
skype://kholburn - PGP Public Key on request

Democracy imposed from without is the severest form of tyranny.
                           -- Lloyd Biggle, Jr. Analog, Apr 1961





More information about the Canberra-pm mailing list