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

Re: [MacPerl] truncating



>how do i truncate something?  say...a variable or an element in an
>array...  i tried
>
>truncate($cm[1][0],300);
>
>and it definately did not truncate the element.  does the number mean 300
>bytes or characters or what?  the help file is very vague.  how does this
>work exactly?  please help.  thanx.

Which bit of:

truncate FILEHANDLE,LENGTH

truncate EXPR,LENGTH

	Truncates the file opened on FILEHANDLE, or named by EXPR, to the
specified length.
	Produces a fatal error if truncate isn't implemented on your system.


is it thats vague?

Truncates "Truncates the file", does $cm[1][0] name a file?

perhaps you wanted substr?

substr EXPR,OFFSET,LEN

substr EXPR,OFFSET

	Extracts a substring out of EXPR and returns it.  First character
is at offset 0, or
	whatever you've set $[ to (but don't do that). If OFFSET is
negative, starts that far
	from the end of the string.  If LEN is omitted, returns everything
to the end of the
	string.  If LEN is negative, leaves that many characters off the
end of the string.

try:

$cm[1][0]=substr($cm[1][0],0,300);

and see if it does what you need...

Iain

===== Want to unsubscribe from this list?
===== Send mail with body "unsubscribe" to macperl-request@macperl.org