logo       
Google Custom Search
    AddThis Social Bookmark Button

Re: [Boston.pm] Regex warning: msg#00023

Subject: Re: [Boston.pm] Regex warning
On 3/11/06, Joel Gwynn <joelman-Re5JQEeQqe8AvxtiuMwx3w@xxxxxxxxxxxxxxxx> wrote:
> I know I've done this before, but I'm not sure what I'm doing
> differently today.  I'm trying to capture a simple command-line option
> like so:
>
> my $debug = 0;
>
> if(grep(/--debug=(\d+)/, @ARGV)){
>     $debug = $1;
>     print "debug: $debug\n"; # Error here
> }
>
> But I keep getting "Use of uninitialized value in concatenation (.) or
> string" when I try to do something with the debug variable.  How can
> $1 not be initialized?  If it's matching, then it should have a value,
> no?

That looks like a bug to me.  But you can work around it as follows:

while(grep(/--debug=(\d+)/, @ARGV)){
    $debug = $1;
    print "debug: $debug\n";
    last;
}

Cheers,
Ben



Try Searching:
servers, voip, java, networking, microsoft ...
<Prev in Thread] Current Thread [Next in Thread>