Beefy Boxes and Bandwidth Generously Provided by pair Networks
Think about Loose Coupling
 
PerlMonks  

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

by wrkrbeee (Scribe)
on Apr 04, 2016 at 17:17 UTC ( [id://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?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others lurking in the Monastery: (3)
As of 2025-01-14 17:21 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    Which URL do you most often use to access this site?












    Results (43 votes). Check out past polls.