On Nov 21, [EMAIL PROTECTED] said:

In my situation I have a string like so:

my $string = '20050516';

and I want to rearrange it to look like: 05162005, so I tried:

my $newstring =
substr($string,0,8).substr($string,0,4).substr($string,8,0);

That should be:

  substr($string, 4, 2) . substr($string, 6, 2) . substr($string, 0, 4)

The first argument is the OFFSET, and the second argument is the LENGTH.

--
Jeff "japhy" Pinyan        %  How can we ever be the sold short or
RPI Acacia Brother #734    %  the cheated, we who for every service
http://www.perlmonks.org/  %  have long ago been overpaid?
http://princeton.pm.org/   %    -- Meister Eckhart

--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
<http://learn.perl.org/> <http://learn.perl.org/first-response>


Reply via email to