Saurabh Singhvi wrote:
> Hi

Hello,

> the format of split() defines that one
> can split a string into a fixed number
> of specifies strings. for eg
> 
> ($login, $passwd, $remainder) = split(/:/, $_, 3);
> 
> Now, the thing is, it splits on first 3 parts.
> Can i do the reverse?? as in instead of the output
> being the first 3 parts of split, the last 3 parts of
> split for the same string.

$ perl -le'
$_ = q[a:b:c:d:e:f:g];
( $login, $passwd, $remainder ) = split /:/, $_, 3;
print "$login, $passwd, $remainder";
( $login, $passwd, $remainder ) = map scalar reverse, split /:/, reverse, 3;
print "$login, $passwd, $remainder";
'
a, b, c:d:e:f:g
g, f, a:b:c:d:e




John
-- 
use Perl;
program
fulfillment

-- 
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