in reply to My first module

Because $in_arg is scalar my $in_arg=@_; assigns the number of elements in @_ (1) to $in_arg.

Instead either:

my ($in_arg)=@_;

or:

my $in_arg=shift;

DWIM is Perl's answer to Gödel

Replies are listed 'Best First'.
Re^2: My first module
by blazar (Canon) on Apr 26, 2006 at 13:19 UTC
    Because $in_arg is scalar my $in_arg=@_;

    I would say, if I really wanted to say that,

    my $in_arg=scalar @_;

    but then I would just say that @array evaluated in scalar context returns the number of elements in @array and that assignment to a scalar imposes scalar context. Or something like that...

    Update: since this was downvoted, why don't you actually try?

    $ perl -e 'scalar my $in_arg=@_' Can't modify scalar in scalar assignment at -e line 1, at EOF Execution of -e aborted due to compilation errors.

    Update2: I read Re: My first module once again and now I realize I read it uncorrectly. I use a theme in which occasionally inline code is not visually distinctive enough, and GrandFather didn't put a suitable interpunction sign, so this added to my confusion and misreading. Sorry, my apologies...