[Melbourne-pm] $0 behaviour

Ben Hare benhare at gmail.com
Fri Jul 20 04:09:40 PDT 2012


BTW Mathew, your code has reminded me of a few modules I can use
instead of FindBin. I'm a huge FindBin fan but recently was caught out
when writing a script to be executed by the mail server ( ie; under
the mail server's shell ). I remember being warned about this by
someone once but I'd forgotten :) It was rush rush at the time so I
hardcoded the script ( which I can't stand and never usually do ) but
now of course that is catching me out ie; releasing to production with
hardcoded dev paths! I need to rewrite with Cwd / File::*.

Cheers!

Ben.


On 20 July 2012 20:24, Ben Hare <benhare at gmail.com> wrote:
> On 20 July 2012 19:30, Alfie John <alfiej at opera.com> wrote:
>> Hey Matthew,
>>
>> On Fri, Jul 20, 2012, at 01:17 PM, Mathew Robertson wrote:
>>> Ignoring the globals, this sets $0 to something useful for
>>> top/ps/pidof/killall.
>>
>> I know it's not what you're asking, but have you thought about just
>> setting +x and running all scripts directly?
>>
>>   # perl /tmp/test.pl
>>   # killall test.pl
>>   test.pl: no process found
>>
>>   # /tmp/test.pl
>>   # killall test.pl
>>   Terminated
>>
>> That way (unless you've abstracted all of the above), you don't need to
>> much boilerplate?
>
> Yes I was thinking same thing. In devel stage, I tend to write a shell
> script to stop / start if it's something I'm doing over and over and
> in production I would usually have an init.d script to
> stop|start|restart etc. In both cases the script name is going to show
> up in top because it's being run directly. I do run code via perl (
> eg; perl -Ilib [ -wc ] script ) all day but when I think about it that
> is usually to test compilation or to run a test. Maybe you don't
> really need all this Mat? :D
>
> PS: I'm sure you do for some reason as I know you would already know
> all of the above - just another 2 cents :)
>
> Ben.
>
>>
>> And if you're running scripts using their full pathnames, it could all
>> simplify down to:
>>
>>   $0 = __FILE__;
>>
>> Alfie
>>
>> --
>>   Alfie John
>>   alfiej at opera.com
>> _______________________________________________
>> Melbourne-pm mailing list
>> Melbourne-pm at pm.org
>> http://mail.pm.org/mailman/listinfo/melbourne-pm
>
>
>
> --
> Ben Hare
> Professional Web Development Services
> ABN: 22-48-55-71-887
> Phone: +61-415-607-197
> Web: http://www.benhare.com
> Email: ben at benhare.com



-- 
Ben Hare
Professional Web Development Services
ABN: 22-48-55-71-887
Phone: +61-415-607-197
Web: http://www.benhare.com
Email: ben at benhare.com


More information about the Melbourne-pm mailing list