PEPPLER.ORG
Michael Peppler
Sybase Consulting
Menu
Home
Sybase on Linux
Install Guide for Sybase on Linux
General Sybase Resources
General Perl Resources
Freeware
Sybperl
Sybase::Simple
DBD::Sybase
BCP Tool
Bug Tracker
Mailing List Archive
Downloads Directory
FAQs
Sybase on Linux FAQ
Sybperl FAQ
Personal
Michael Peppler's resume

sybperl-l Archive

Up    Prev    Next    

From: Michael Peppler <mpeppler at peppler dot org>
Subject: Re: splitting a field by an unrecognizable null field
Date: Sep 25 2000 2:26PM

Andrew Armstrong writes:
 > > When using the split function, to return to an array.
 > > Add parenthesis as follows:
 > > ($first, $last) = split(/\s/, $name);
 > > print "s   first=$first last= $last name= $name \n";
 > > Brian
 > 
 > In the above example if the fname and lname were seperated by more that one 
 > space you would get back strange results. So change the regex to look for 1 or 
 > more spaces .
 > 
 > for example
 > 
 > ($first , $last , $other) = split(/\s+/ , $name , 3) ;
 > print "s+ first=$first  last=$last other=$other  name=$name \n" ;

You may also be interested in the 

	($first, $last) = split(' ', $name);

form. Splitting on ' ' will split on whitespace, and remove all
trailing/leading whitespace...

Michael
-- 
Michael Peppler         -||-  Data Migrations Inc.
mpeppler@peppler.org    -||-  http://www.mbay.net/~mpeppler
Int. Sybase User Group  -||-  http://www.isug.com
Sybase on Linux mailing list: ase-linux-list@isug.com