Yet Another *::Util Plug: Scalar::Util::reftype finds the underlying type even for objects. (Unfortunately for non-refs it returns undef instead of '' as the builtin ref does.)
In article <[EMAIL PROTECTED]>, Abigail <[EMAIL PROTECTED]> wrote: >#!/usr/bin/perl -w > >use strict; >use warnings 'all'; use Scalar::Util 'reftype'; >sub rotate { no integer; # I like to explictly say it per sub when I'm depending on it > return () unless $_ [1]; > die "Not an array ref" unless "ARRAY" eq ref $_ [1]; die "Not an array ref" unless ref $_ [1] && "ARRAY" eq reftype $_ [1]; > return [] unless @{$_ [1]}; > my $l = $_ [0] % @{$_ [1]}; > [@{$_ [1]} [$l .. $#{$_ [1]}, 0 .. $l - 1]] >} > >my $array = ['A' .. 'E']; bless $array; # simulate rotating an array-based object >for my $r (-15 .. 15) { > printf "Rotate %3d: @{rotate $r, $array}\n", $r; >} I didn't think that was obfuscated. How about this: sub rotate {[$#{$_[!$||$|]}*@{$_[!!$_^!$_]}?@{$_[!$..!!$.]}[$_[@--@+]%@ {$_[$==~/(?=)//!$`]}..$#{$_[$??!!$?:!$?]},($)?!$):!!$))..$_[$--$-]%@{$_ [$]/$]]}-(!!$++!$+)]:@{$_[!!$^^^!$^^]}]}
