wfischer has asked for the wisdom of the Perl Monks concerning the following question:
substr('abcdefg',3,2)
returns 'de' (as expected)
However,
@a = (3,2); substr('abcdefg',@a)
returns 'cdefg'
What? I mean to say, "What?"
I care because I'd like to do this: substr($string,a_subroutine_call_that_returns_offset_and_length(@some_args))
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: substr odd behavior with list arguments
by choroba (Cardinal) on Mar 22, 2021 at 16:13 UTC | |
by wfischer (Novice) on Mar 22, 2021 at 16:26 UTC | |
|
Re: substr odd behavior with list arguments
by haukex (Archbishop) on Mar 22, 2021 at 16:19 UTC | |
by LanX (Saint) on Mar 22, 2021 at 16:33 UTC | |
by wfischer (Novice) on Mar 22, 2021 at 16:29 UTC | |
by haukex (Archbishop) on Mar 22, 2021 at 16:46 UTC |