in reply to Remove leading character from string

Just to show that it can be done differently and inefficiently:

use strict; use warnings; $_="1234"; $_=join '', reverse split ''; chop; $_=join '', reverse split ''; print ;

or

print drop_the_first('1234'); sub drop_the_first { split '', shift; shift; return join '',@_; }

But that last one only works in a subroutine and give a deprecation warning.

CountZero

"If you have four groups working on a compiler, you'll get a 4-pass compiler." - Conway's Law

Replies are listed 'Best First'.
Re: Re: Remove leading character from string
by Anonymous Monk on Feb 02, 2004 at 07:26 UTC
    why don't you throw in a couple of map { $_ }s in there?
    $_ = 1234; $_ = reverse $_; chop; $_ = reverse $_; print __END__ 234
Re: Re: Remove leading character from string
by japhy (Canon) on Feb 02, 2004 at 14:18 UTC
    I'd do:
    sub drop_the_first { (split '', shift, 2)[1]; }
    if I was going to use split().
    _____________________________________________________
    Jeff[japhy]Pinyan: Perl, regex, and perl hacker, who'd like a job (NYC-area)
    s++=END;++y(;-P)}y js++=;shajsj<++y(p-q)}?print:??;