SPUG: regular expression difficulty, plus compiled perl

David Corcoran davec at icthus.net
Tue Mar 28 00:51:14 CST 2000


Not the most elegant, but it works:

print "First: $0\n";

split(/\\/,$0);
pop @_;
$test1 = join "\\", at _;

print "Second: $test1\n";

>From: Todd Wells <toddw at wrq.com>
>To: "'spug-list at pm.org'" <spug-list at pm.org>
>Subject: SPUG: regular expression difficulty, plus compiled perl
>Date: Mon, 27 Mar 2000 20:20:46 -0800
>
>I'm using ActiveState Perl on NT4 and trying to set a variable to be equal
>to the directory name that the script was ran in.
>
>So, I look at $0 which contains the name of the script I ran... in this case
>"D:\PERL\COUNTP~1.PL"
>
>But when I try to strip the filename off the end, I can't seem to do it.
>
>print "First: $0\n";
>($test1 = $0)=~ m#.*\\#;
>#$test1 =~ s/(.*\\)/$1/;     # I tried this too, and it didn't work
>either.
>print "Second: $test1\n";
>
>The output:
>First: D:\PERL\COUNTP~1.PL
>Second: D:\PERL\COUNTP~1.PL
>
>What's going on here?  Is the .* just being _really_ greedy?  I'm expecting
>$test1 to be "D:\PERL\"  
>I know this is silly, but I can't figure out the problem here.  
>
>BTW, someone at the last SPUG meeting mentioned they were playing around
>with compiled Perl using ActiveState.  I can't seem to find any specifics on
>how to do this.  Perlfaq3 mentions it, but gives no specifics on how to
>actually do it, nor can I find any at Malcolm Beattie's site.
>
>- Todd
>
> - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
>     POST TO: spug-list at pm.org       PROBLEMS: owner-spug-list at pm.org
> Seattle Perl Users Group (SPUG) Home Page: http://www.halcyon.com/spug/
> SUBSCRIBE/UNSUBSCRIBE: Replace "action" below by subscribe or unsubscribe
>           Email to majordomo at pm.org: "action" spug-list your_address


------------------------------------------------------------
Get your FreeMail @ Icthus.Net - http://freemail.icthus.net

 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
     POST TO: spug-list at pm.org       PROBLEMS: owner-spug-list at pm.org
 Seattle Perl Users Group (SPUG) Home Page: http://www.halcyon.com/spug/
 SUBSCRIBE/UNSUBSCRIBE: Replace "action" below by subscribe or unsubscribe
           Email to majordomo at pm.org: "action" spug-list your_address





More information about the spug-list mailing list