[Melbourne-pm] $0 behaviour

Ben Hare benhare at gmail.com
Fri Jul 20 03:54:30 PDT 2012


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


More information about the Melbourne-pm mailing list