in reply to Perl templates for Emacs?

Latest update: varying emacs versions seem to have varying macro support for this, it appears to be necessary to code the macro in a .el file (emacs lisp); .

Original post: (no longer relevant) I don't know the symptoms you had, but what screams at me is that the bare array needs instead to be expressed in list mode by encasing it in round brackets, so that it forms a valid RHS for the list assignment.e.g.:

sub FeetIntact{ my ($self,$shootSomeoneElse) = (@_); # ... }

Update: Oops overkill there - this is only necessary for reading parameters in hash form, e.g.:-

FeetIntact( toe => big, smell => roquefort ); sub FeetIntact{ my %par = (@_); # $par { smell } now has value 'roquefort' }

One world, one people

Replies are listed 'Best First'.
Re^2: Perl templates for Emacs?
by holli (Abbot) on Jun 30, 2005 at 12:37 UTC
    the bare array needs instead to be expressed in list mode by encasing it in round brackets
    Why should it??
    use strict; use warnings; foo ("Darth", "Vader"); sub foo { my ($bar,$baz) = @_; print "$bar $baz"; }
    prints "Darth Vader", as expected.


    holli, /regexed monk/
Re^2: Perl templates for Emacs?
by holli (Abbot) on Jun 30, 2005 at 12:53 UTC
    First, you have syntax error in that code (the opening curly in the sub call). Second, braces are unneccessary too.

    Do you test your code before posting?
    FeetIntact(toe => big, smell => roquefort ); sub FeetIntact { my %par = @_; print $par{smell}; #roquefort }


    holli, /regexed monk/
      hmmm looks like you're right.

      One world, one people

Re^2: Perl templates for Emacs?
by loris (Hermit) on Jun 30, 2005 at 12:42 UTC

    Well, actually I always write

    my ($self,$inTheFootShoot) = @_;

    (apart from when I am shooting myself in the foot). It was the missing

    $self

    that was causing me problems. Are the brackets really necessary?

    loris