On Wed, Aug 29, 2001 at 06:42:11PM +0100, Jose Abilio Oliveira Matos wrote:
> On Wed, Aug 29, 2001 at 03:28:53PM +0200, Michael Schmitt wrote:
> > On Wed, 29 Aug 2001, Jose Abilio Oliveira Matos wrote:
> > 
> > syntax error at /home/schmitt/LyX/lyx-devel/lib/reLyX/MakePreamble.pm line
> > 310, near "}("
> 
>   This is my code.
>   Amir could have a look and teel me why there is a syntax error there? The
> context of that line is:
> 
>  305      if( $Latex_Preamble =~ /\\geometry\{(.*)\}/) {
>  306          my $geom_options = $1;
>  307          my $op;
>  308          foreach $op (keys %Geometry_Options) {
>  309              $geom_options =~ s/$op// && do {
>  310                  $LyX_Preamble .= $Geometry_Options{$op}();

I'm pretty sure that the problem here is that you're missing a &.
I think you have to write:

    $LyX_Preamble .= &{$Geometry_Options{$op}}();

That is, $Geometry_Options{$op} is a reference to a subroutine, so you need
to &{...}() it to actually call the subroutine.

>  311                  print "Geometry option $op\n" if $debug_on;
>  312              }
>  313          }
> ...
> 
>   I'm using perl 5.6.0 and I don't have a problem with it, while Michael is
> using  perl 5.004 or 5.005, I can't decide from the @INC...

Actually, I'm a bit surprised that 560 works on that. Could it be that if
you try to stringify a code reference, Perl calls the sub with no arguments?
Or maybe the parentheses make Perl realize it's a sub.

-Amir

Reply via email to