[Israel.pm] Is there an operator like IN in perl

Offer Kaye offer.kaye at gmail.com
Thu Mar 5 07:50:44 PST 2009


On Thu, Mar 5, 2009 at 5:10 PM, Berler Chanan wrote:
>
> Since I got some background as DBA also, some operators would have make it
> easy for me working with Perl.
> Tell you what, I would have prefer a set of operators dedicated for arrays
> Like "in"  find the value in the array
>     "max" find the max value
>     "min" find the min value
>     "avg" find the avg value (assume numeric)
>     "first" find the first elemnt
>     "last" / "top" find the last element
>     "find" find the location of the element in the array
>
> These are useful operators, which as I believe should be part of the Perl
> standard,
> Without using any external modules.

List::Util is part of the core modules in 5.8.0 so you should have it
and be able to use it. It implements most of the above functionality.
See "perldoc List::Util"on your system for more details.

>
> As for if numeric or character, I would suggest adding a default: numeric,
> option for strings compare.
> PS: why not adding also:
>
> @array + elemnt -> adds the element
> @array - elemnt -> removes first element

See "perldoc -f" for the following functions: push, pop, shift, unshift.

> The list can go on....but all these are not implemented as far as I know as
> operators
> Please correct me if I am missing anything, would help me a lot
>
> PS: using modules, well I can but why shouldn't these be standard ?
> Thanks
> Chanan
>

The short answer is, because most of these are trivially easy to
implement and the rest can be gotten from CPAN.

Why can't you use external modules?

-- 
Offer Kaye



More information about the Perl mailing list