Types of attribute and then describe it.



Types of attribute and then describe it...

Answer / mahesh

use Attribute::Types;

my $count : INTEGER; # Can only store an integer
my $date : INTEGER(1..31); # Can only store an int
between 1..31
my $value : NUMBER; # Can only store a number
my $score : NUMBER(0.1..9.9); # Can only store a num
between 0.1..9.9
my @rain : NUMBER; # Elements can only
store numbers
my %vars : SCALAR; # Entries can only
store scalar refs
my %handler : CODE; # Entries can only
store sub refs
my $arr : ARRAY; # Can only store array ref
my @hashes : HASH; # Elements can only
store hash refs
my $glob : GLOB; # Can only store a
typeglob ref
my $pattern : REGEX; # Can only store a qr'd
regex
my $ref2 : REF; # Can only store a
meta-reference

my $obj : Type(My::Class); # Can only store
objects of (or
# derived from) the
specified class

my $x : Type(/good|bad|ugly/); # Can only store
strings matching
# the specified regex

sub odd { no warnings; $_[0]%2 }

my $guarded : Type(&odd); # Can only store values
for which
# odd($value) returns true

Is This Answer Correct ?    0 Yes 0 No

Post New Answer

More General Aptitude Interview Questions

Can there be a line which can cut all the four quadrants?

6 Answers   HCL,


1. Which is the greatest 3 u/root 7, 6 u/r 5, 2 u/r 20 is

1 Answers   SSC,


If each of the odd digits in the number 54638 is decreased by ?1? and each of the even digits is increased by ?1?, then which of the following will be the sum of the digits of the new number? (a) 26 (b) 29 (c) 25 (d) 28 (e) None of these

4 Answers  


what types of question tricom will ask

0 Answers   Tricom,


at a certain ice cream parlour customer can choose among three different ice cream flavour and can choose either a sugar cone or a waffle cone. considerig both ice cream flavour and cone type how many distinct tripple scoop cone with three different ice cream flavour and available.

2 Answers   MNIT,






There is a room with 6' x 8'. A 1' tile is fixed along the 4 walls in one row. How many 1" tiles require to finish the work.

0 Answers   Hexaware,


how to prepare for karnataka bank po exam? what'll be the topics in the exam?

1 Answers   Bhel, Karnataka Bank,


Which of the following is not a valid DEFINE GDG parameter a) OWNER b)LIMIT c) SCRATCH c)ALTER

0 Answers   HDFC,


A worker earns a 5% raise. A year later, the worker receives a 2.5% cut in pay, & now his salary is Rs.22702.68 What was his salary to begin with?

3 Answers  


The ratio of the present ages of Suman and Renu is 5 : 7 respectively. Four years hence the ratio will become 3 : 4 respectively. What is the present age of Renu in years? (a) 28 (b) 24 (c) 20 (d) 21 (e) None of these

5 Answers   iGate,


In the reading room of a library, there are 10 tables, 4 chairs per table. In each table there are different numbers of people seated. How many ways they will sit in the library so that no chair would be blank? plz explain how can this quetions can b solved???

5 Answers   TCS,


There are two balls touching each other circumferentially. The radius of the big ball is 4 times the diameter of the small ball.The outer small ball rotates in anticlockwise direction circumferentially over the bigger one at the rate of 16 rev/sec. The bigger wheel also rotates anticlockwise at N rev/sec. what is 'N' for the horizontal line from the centre of small wheel always is horizontal.

0 Answers   Infosys,


Categories