perl.beginners
[Top] [All Lists]

Extracting data from a string

Subject: Extracting data from a string
From:
Date: Fri, 14 Mar 2008 16:46:41 -0400
Newsgroups: perl.beginners

Hello

I have a string that I am trying to parse out into separate variables. I am 
having problems getting the first field extracted. I want to extract fields 
using period (.) and underline (_) delimineters.

Here is the string

aaa_b_ccccc_.ddd

The string is contained in $_.

Here is my code 

($a, $b, $c, $d, $e, $e) = (split /_|\./)[1,2,3,4,5,6];

I am not getting the "aaa". I am getting b when I should be getting a.

Andrew

<Prev in Thread] Current Thread [Next in Thread>