summaryrefslogtreecommitdiff
path: root/t/op/splice.t
Commit message (Collapse)AuthorAgeFilesLines
* Make push/shift $scalar accept only unblessed aryrefsFather Chrysostomos2011-04-181-3/+3
| | | | See ticket #80626.
* Allow push/pop/keys/etc to act on referencesDavid Golden2010-10-311-1/+6
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | All built-in functions that operate directly on array or hash containers now also accept hard references to arrays or hashes: |----------------------------+---------------------------| | Traditional syntax | Terse syntax | |----------------------------+---------------------------| | push @$arrayref, @stuff | push $arrayref, @stuff | | unshift @$arrayref, @stuff | unshift $arrayref, @stuff | | pop @$arrayref | pop $arrayref | | shift @$arrayref | shift $arrayref | | splice @$arrayref, 0, 2 | splice $arrayref, 0, 2 | | keys %$hashref | keys $hashref | | keys @$arrayref | keys $arrayref | | values %$hashref | values $hashref | | values @$arrayref | values $arrayref | | ($k,$v) = each %$hashref | ($k,$v) = each $hashref | | ($k,$v) = each @$arrayref | ($k,$v) = each $arrayref | |----------------------------+---------------------------| This allows these built-in functions to act on long dereferencing chains or on the return value of subroutines without needing to wrap them in C<@{}> or C<%{}>: push @{$obj->tags}, $new_tag; # old way push $obj->tags, $new_tag; # new way for ( keys %{$hoh->{genres}{artists}} ) {...} # old way for ( keys $hoh->{genres}{artists} ) {...} # new way For C<push>, C<unshift> and C<splice>, the reference will auto-vivify if it is not defined, just as if it were wrapped with C<@{}>. Calling C<keys> or C<values> directly on a reference gives a substantial performance improvement over explicit dereferencing. For C<keys>, C<values>, C<each>, when overloaded dereferencing is present, the overloaded dereference is used instead of dereferencing the underlying reftype. Warnings are issued about assumptions made in the following three ambiguous cases: (a) If both %{} and @{} overloading exists, %{} is used (b) If %{} overloading exists on a blessed arrayref, %{} is used (c) If @{} overloading exists on a blessed hashref, @{} is used
* Make splice invoke set magicFlorian Ragwitz2010-10-151-1/+11
|
* Mark all .t and .pm files as non executableRafael Garcia-Suarez2009-06-061-0/+0
|
* Re: [perl #30568] splice generates undef? [PATCH]LAUN Wolfgang2004-07-131-1/+31
| | | | | Message-ID: <DF27CDCBD2581D4B88431901094E4B4D02B0C7D2@attmsx1.aut.alcatel.at> p4raw-id: //depot/perl@23092
* PATCH: "splice() offset past end of array" warning. (take 2) Jarkko Hietaniemi2002-03-021-1/+1
| | | | | | | | | | | | From: Schuyler Erle <schuyler@oreilly.com> Date: Fri, 01 Mar 2002 14:22:19 -0800 Message-ID: <3C7FFF1B.E74979B1@oreilly.com> Subject: Re: PATCH: "splice() offset past end of array" warning. From: Mark-Jason Dominus <mjd@plover.com> Date: Fri, 01 Mar 2002 17:19:49 -0500 Message-ID: <20020301221949.7610.qmail@plover.com> p4raw-id: //depot/perl@14939
* [ID 20010711.005] in Tie::Array, SPLICE ignores context, breaking SHIFT daniel@biz.bitpusher.com2001-07-121-1/+15
| | | | | Message-Id: <200107120625.f6C6PkJ13065@biz.bitpusher.com> p4raw-id: //depot/perl@11306
* RE: [20000223.001] no test cases for splice(@array) Richard Soderberg2001-05-281-1/+7
| | | | | Message-ID: <NAEKLNAAHLMBPMPNBMLEOEFLDFAA.rs@crystalflame.net> p4raw-id: //depot/perl@10265
* avoid creation of %^RIlya Zakharevich1998-06-281-0/+0
| | | | | | Message-Id: <199806241825.OAA06346@monk.mps.ohio-state.edu> Subject: Re: [5.004_68] What is %^R ? [PATCH?] p4raw-id: //depot/perl@1238
* Negative LENGTH argument to spliceGisle Aas1998-06-281-0/+34
Message-ID: <m3g1gvc5bs.fsf@furu.g.aas.no> p4raw-id: //depot/perl@1237