Beefy Boxes and Bandwidth Generously Provided by pair Networks
The stupid question is the question not asked
 
PerlMonks  

Re: parse problem

by DrManhattan (Chaplain)
on Apr 20, 2003 at 02:05 UTC ( #251761=note: print w/replies, xml ) Need Help??


in reply to parse problem

The first argument to split() needs to be a regular expression matching the string that delimits the fields in your data. In your case, the fields in your line are separated by a '|', so the code could look like this:
#!/usr/bin/perl use strict; my $data = 'gi|12345678|ref|NP_001234.1|'; my @data = split /\|/, $data; my $number = $data[1];
Or more concisely:
#!/usr/bin/perl use strict; my $data = 'gi|12345678|ref|NP_001234.1|'; my $number = (split(/\|/, $data))[1];

-Matt

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://251761]
help
Chatterbox?
[Tabish]: Hi to everyone :). Can i use cgi table in package index.pm to return data in test.pl?
[Tabish]: return data in table

How do I use this? | Other CB clients
Other Users?
Others lurking in the Monastery: (6)
As of 2017-12-13 07:46 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    What programming language do you hate the most?




















    Results (350 votes). Check out past polls.

    Notices?