develooper Front page | perl.perl5.porters | Postings from March 2012

Re: deprecate #line 1 side effects?

Thread Previous | Thread Next
From:
zengargoyle
Date:
March 16, 2012 14:41
Subject:
Re: deprecate #line 1 side effects?
Message ID:
CAGdnNgMPT3k0=rePAZWWe4aqY_jawuusiUuO-WTqY8rVLfkdjg@mail.gmail.com
On Fri, Mar 16, 2012 at 10:16 AM, Nicholas Clark <nick@ccl4.org> wrote:
> On Fri, Mar 16, 2012 at 09:14:39AM -0500, Jesse Luehrs wrote:
>
>> I've seen this used to enable the debugger, as in:
>>
>>   #!/usr/bin/perl
>>
>>   BEGIN {
>>     unless ($ENV{AUTHOR_TESTING}) {
>>       require Test::More;
>>       Test::More::plan(skip_all => 'these tests are for testing by the
>> author');
>>     }
>>   }
>>
>>
>>   use FindBin qw/ $Bin /;
>>
>>   #line 1
>>   #!/usr/bin/perl -d
>>
>>   # ...
>>
>> That's one that doesn't really have a good alternative at the moment.
>
> Yes, it looks like the easiest solution, given the #line 1 "feature".
> However, I don't think it's impossible to replace, by keeping the skip
> as-is,
> and exec-ing the actual test (with PERL5LIB set appropriately) if the
> script
> should run.

oops, didn't send to the list last time.

If I had known about this "feature" I would have been using it heavily.

#!/usr/bin/env perl
#line 1
#! perl -wT
...

to wrap CPAN installed scripts to let them keep Perl flags *and* run
with perl from the users PATH (when: perl: bad interpreter: Permission denied)
requires use of /usr/bin/env and on Solaris /usr/bin/env doesn't allow
flags passed to the executable.

I have a NFS mounted Perl shared between architectures with:
/usr/local/perl/5.14.2/bin/sparc-solaris/perl
/usr/local/perl/5.14.2/bin/i86pc-solaris/perl

and scripts shared between them in:
/usr/local/perl/5.14.2/bin

and I have to manually patch up scripts that use flags on the shebang
line when installing.  I would be re-writing my 'fix shebang line' script to
use this feature *right now* if it wasn't going away...

----
Carl

Thread Previous | Thread Next


nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About