[plug] Re: Perl Question

David Buddrige buddrige at wasp.net.au
Tue May 13 14:19:53 WST 2003


thanks heaps guys, that's got it. 8-) 

cheers 

David. 

Bernard Blackham writes: 

>> On Tue, May 13, 2003 at 01:51:17PM +0800, David Buddrige wrote:
>> > I have a comma-delimited text file containing records, with one line per
>> > record.  The fields are seperated by commas 
> 
>> > My question: Is there a simple perl function that will pull out each field
>> > value into a variable of some kind (I guess an array would be easiest),
>> > where each value is seperatly accessible?  
>> 
>> Yes there is such a function. At least one.
> 
> Perhaps the one you are looking for is split, eg: 
> 
> ($date, $text, $amount, $blah) = split /,/, $string; 
> 
> You can use any regular expression to split on too! If you have
> things like text between the commas,
> (eg, '"O'Brian, James",123,345,456), then you may want to look at
> the Text::CSV_XS module, designed for parsing CSV files. 
> 
> HTH, 
> 
> Bernard. 
> 
> -- 
>  Bernard Blackham 
>  bernard at blackham dot com dot au 
> 
 



More information about the plug mailing list