[Date Prev][Date Next][Thread Prev][Thread Next][Interchange by date
][Interchange by thread
]
[ic] interchange and external perl packages
Quoting David McGuire (dmcguire@bresystems.com):
> I'm trying to build a UserTag that has to use an external library. I'm not
> all that familiar with interchange as of yet being that I just got moved
> into this project, but here's what I've written so far:
>
> UserTag thumb Order path
> UserTag thumb PosNumber 1
> UserTag thumb Routine <<EOR
> eval {
> require Image::Magick;
> };
> if($@) {
> return sub {
> ::logError("Cannot generate thumbnail, Image::Magick module not
> installed: $@");
> };
> }
> use Image::Magick;
> sub {
> my ($path) = @ ;
> my $srcImage = Image::Magick->new;
> my $x = $srcImage->Read($path);
> $x = $srcImage->Resize(geometry=>'100x100');
> $x = $srcImage->Write($path);
> return;
> }
> EOR
>
> the "use Image::Magick;" part is something I was just trying recently
>
> however when I try to start the server it gives me this error:
>
>
> UserTag 'thumb' subroutine failed compilation:
>
> Global symbol "$srcImage" requires explicit package name at (eval
> 99) line 12, <GLOBAL> chunk 426.
> syntax error at (eval 99) line 12, near "@ ;
> my "
Please pay attention to the error -- it is telling you exactly what is
going wrong. Your routine's syntax is bad.
If you use a reasonable programmer's editor (I use VIM), then you
can do in-editor syntax checks.
For VIM, I just use the visual highlighting feature and do
!perl -Mstrict -wc
to pipe it through "perl -Mstrict -wc". That will check the syntax,
enforcing strict as we are wont to do.
Once I fix your syntax error by placing an underscore after
the @ sign, I do that and get:
Useless use of reference constructor in void context at - line 18.
- syntax OK
Note also that your eval is a good idea, but the "use Image::Magick"
below it ruins the concept. You don't need the "use".
--
Mike Heins
Perusion -- Expert Interchange Consulting http://www.perusion.com/
phone +1.513.523.7621 <mike@perusion.com>
Being against torture ought to be sort of a bipartisan thing.
-- Karl Lehenbauer