Beefy Boxes and Bandwidth Generously Provided by pair Networks
Problems? Is your data what you think it is?
 
PerlMonks  

Re: Re: Service controller for Linux/Unix

by jjhorner (Hermit)
on Feb 09, 2001 at 01:29 UTC ( [id://57271]=note: print w/replies, xml ) Need Help??


in reply to Re: Service controller for Linux/Unix
in thread Service controller for Linux/Unix

In

my $action = $0 =~ /([^/]+)$/;

You need to escape your forward slash, and in this format, $action is given a true value ('1'), but is not given the result of the match.

The following works and is added to the code:

$0 =~ /([^\/]+)$/; my $action = $1;

Thanks for your comments.

J. J. Horner
Linux, Perl, Apache, Stronghold, Unix
jhorner@knoxlug.org http://www.knoxlug.org/

Replies are listed 'Best First'.
Re: Re: Re: Service controller for Linux/Unix
by Fastolfe (Vicar) on Feb 09, 2001 at 01:50 UTC
    You're right; I had intended to write something more like this:
    my ($action) = $0 =~ m!([^/]+)$!;
    Either way, you figured it out. I usually prefer the one-line form like this, because with the two-line form, if the regex fails, an assignment to $1 might get you something you do not expect (the results from a previous regex, for example).

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://57271]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others making s'mores by the fire in the courtyard of the Monastery: (4)
As of 2024-04-20 10:10 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found