[Melbourne-pm] The magic of shebang (was Re: programming tutorials: Perl)

Mathew Robertson mathew.blair.robertson at gmail.com
Tue Nov 16 15:34:48 PST 2010


And just to be pedantic, dont forget $#var... eg:

my @list;
foreach (0..$#list) ...

regards,
Mathew Robertson

On 17 November 2010 10:22, <wigs at stirfried.org> wrote:

> On Mon, Nov 15, 2010 at 05:09:33PM +1100, Alec Clews wrote:
> > [1] That was a lie. As a special case Perl will look at the line and use
> > any flags it sees.
>
> Just like English there are always exceptions to rules in Perl.  There is
> at
> least one other special case where perl does not ignore lines starting with
> a
> '#'.  Specifically, the '#line' pragma.
>
> This tells the perl compiler to reset the source-code line counter.  For
> example:
>
>  01 #!/bin/env perl -p
>  02 use strict;
>  03
>  04 #line 1001
>  05 my $x = 2;
>  05 $m = 1;
>
> If you run that code an error will be reported in line 1002, and not line 5
> as
> you would otherwise expect.
>
> --
> Wigs
> _______________________________________________
> Melbourne-pm mailing list
> Melbourne-pm at pm.org
> http://mail.pm.org/mailman/listinfo/melbourne-pm
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.pm.org/pipermail/melbourne-pm/attachments/20101117/dfe34184/attachment.html>


More information about the Melbourne-pm mailing list