[Israel.pm] how do i cut the first 2 characters/digits of astring?

Alex Behar alex-b at actcom.net.il
Fri Jul 16 07:35:22 PDT 2004


-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

On Thursday 15 July 2004 14:04, Ernst, Yehuda wrote:
> but chop take the end no?
>
Yes, thats why he reversed the string, chopped twice and reversed it back 
again. Though, that might be a bit slow, it still works. The most elegant 
solution my count was the one Yossi Klein pointed out.

Best regards,
Alex

> -----Original Message-----
> From: perl-bounces at perl.org.il [mailto:perl-bounces at perl.org.il]On Behalf
> Of Gaal Yahas Sent: Thursday, July 15, 2004 1:51 PM
> To: Perl in Israel
> Subject: Re: [Israel.pm] how do i cut the first 2 characters/digits of
> astring?
>
> On Thu, Jul 15, 2004 at 01:47:49PM +0300, Shlomi Fish wrote:
> > You can also do it in place using "substr":
> >
> > <<<
> > $mystring="abcdefgh";
> > substr($mystring,0,2)="";
> >
> >
> > As substr returns an lvalue.
> >
> > There's more than one way to do it.
>
> Speaking of which, the following may be self-referentially fastest:
>
>      chop; chop

- -- 
The difference between theory and practice, is that in theory, 
there is no difference between theory and practice.
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.2.4 (GNU/Linux)

iD8DBQFA9+ezfDQ3s2iW3q0RAjs1AKDIFATZLKf24UOREOXTg791q7eFAQCgkzxS
4J7NPJz7iE4C78IfuvXfDkM=
=X2nm
-----END PGP SIGNATURE-----




More information about the Perl mailing list