Beefy Boxes and Bandwidth Generously Provided by pair Networks
We don't bite newbies here... much

Re^4: REGEX omit dashes - simple but ...

by wrkrbeee (Scribe)
on Apr 04, 2016 at 17:17 UTC ( #1159517=note: print w/replies, xml ) Need Help??

in reply to Re^3: REGEX omit dashes - simple but ...
in thread REGEX omit dashes - simple but ...

Thanks guys, here's the revised statement, along with the result: if($line=~m/^\s*ACCESSION\s*NUMBER:\s*/m){$access_num=$1; $access_num =~ tr/-//d;} Result is the error message stating "Use of uninitialized value ...." ?? Thanks!!!

  • Comment on Re^4: REGEX omit dashes - simple but ...

Replies are listed 'Best First'.
Re^5: REGEX omit dashes - simple but ...
by stevieb (Canon) on Apr 04, 2016 at 17:23 UTC

    You forgot to add your capture group of (\d*). However, that won't really help, as that won't capture your - (dashes), or any numbers after it.

    Why don't you show us a few lines of example data you're trying to match?

    Also, Use of uninitialized... is not an error, it's a warning. It's most likely saying that $1 is uninitialized (because you didn't capture anything).

Re^5: REGEX omit dashes - simple but ...
by kennethk (Abbot) on Apr 04, 2016 at 17:28 UTC
    You are getting an uninitialized error because you are trying to change the content of $access_num, to which you've assigned $1, but there were no parentheses in your first regular expression. Maybe you mean something like:
    if ($line =~ s/^\s*ACCESSION\s*NUMBER:\s*/) { $line =~ tr/-//; }
    or possibly
    if ($line =~ s/^\s*ACCESSION\s*NUMBER:\s*([-\d]+)$/m) { $access_num = $1; $access_num =~ tr/-//; }

    #11929 First ask yourself `How would I do this without a computer?' Then have the computer do it the same way.

Log In?

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

How do I use this? | Other CB clients
Other Users?
Others drinking their drinks and smoking their pipes about the Monastery: (1)
As of 2023-09-24 04:52 GMT
Find Nodes?
    Voting Booth?

    No recent polls found