SPUG: $0 dispatch for named links (on Windows without links)

Michael R. Wolf MichaelRWolf at att.net
Mon Jun 23 11:10:48 PDT 2008


No, it doesn't preclude that.  Thanks for the suggestion.

It's how I ultimately worked around it.  I had to add some logic, however.
I didn't want to blindly grab the first argument.  In effect, my code
enforced the requirement for a limited number of values instead of allowing
a filename to do the same thing.


-- 
Michael R. Wolf
    All mammals learn by playing!
        MichaelRWolf at att.net

> -----Original Message-----
> From: spug-list-bounces+michaelrwolf=att.net at pm.org [mailto:spug-list-
> bounces+michaelrwolf=att.net at pm.org] On Behalf Of DeRykus, Charles E
> Sent: Monday, June 23, 2008 9:43 AM
> To: spug-list at pm.org
> Subject: Re: SPUG: $0 dispatch for named links (on Windows without links)
> 
> 
> > I want to have one script that does different things based on $0
> (think vi vs vim).  If it were > a vanilla *nix issue, I'd make many
> hard links and branch based on $0, but since Windows (or
> > more accurately some combination of emacs and cygwin creating a useful
> interface to the native
> > OS) doesn't preserve links across edit cycles, I'm left with one
> updated file and N-1 co-linked > old versions.
> 
> > I tried to use the 'exec' trick to "lie to the program you are
> executing about its own name"
> > trick, but it doesn't work on my cygwin (nor even from XP's command
> line).
> 
> >     exec {"$FindBin::Bin/real_name"} 'fake_name', @ARGV;
> 
> > Does anyone have a better (for the "less fragile" definition of
> "better") suggestion?
> 
> 
> Hm, does your scenario preclude just passing
> the 'fake_name' as the first argument for
> instance:
> 
> $0 = shift;
> if ( $0 eq "foo" ) { ...
> elsif ( ... )
> 
> --
> Charles DeRykus
> _____________________________________________________________
> Seattle Perl Users Group Mailing List
>      POST TO: spug-list at pm.org
> SUBSCRIPTION: http://mail.pm.org/mailman/listinfo/spug-list
>     MEETINGS: 3rd Tuesdays
>     WEB PAGE: http://seattleperl.org/



More information about the spug-list mailing list