[Date Prev][Date Next][Thread Prev][Thread Next] [Search] [Date Index] [Thread Index]

Re: [MacPerl] working with strings



On Fri, 22 Jan 1999 09:42:06 -0800, Adam Bridge wrote:

>I'm reading in a file whose data is written in fixed length records.  Fields are
>defined within each record.

"fixed length" = "unpack"

>Lets say there is a field called full_name which is 40 characters long and I've
>read it into a variable $full_name.
>
>It looks like "ATKINSON, TINA                     "

	$_ = unpack("A40", $full_name);

or, if you're less adventurous:

	$full_name =~ s/ +$//;

>What I need to do is:
>
>1) reverse the name parts and
	$_ = join " ",reverse split /, */,$_, 2;
>2) have only the first character in upper case
	s/(\w+)/\u\L$1/g;

Watch out with "McDonald" etc.

	Bart.

***** Want to unsubscribe from this list?
***** Send mail with body "unsubscribe" to mac-perl-request@iis.ee.ethz.ch