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

4,44,444,4444. Something like this.

4 Answers   3D PLM,


Complete the series 2, 7, 24, 77,__ (hint: 2*12= 24, 7*11= 77, therefore 24*10= 240)

0 Answers   TCS,


A shopkeeper bought a watch for Rs.400 and sold it for Rs.500.What is his profit percentage?

0 Answers   Accenture,


Two chords of lengths L1 and L2 are drawn in a circle. Their lengths are inversely proportional to the straight distance joining the centre.Find the radius of circle.

0 Answers  


five cities. city1 is west to city3. city4 is east to city 5.__ etc.which is farthest on west side.

0 Answers   IBM, IPCA, TATA,


If a car starts from A towards B with some velocity due to some problem in the engine after travelling 30km.If the car goes with 4/5 th of its actual velocity the car reaches B 45min later to the actual time. If the car engine fails after travelling 45km, the car reaches the destination B 36min late to the actual time , what is the initial velocity of car and what is the distance between A and B in km

0 Answers   IBM,


If substitution is as it's burnout. Didn't remember. But this is one.

0 Answers   3D PLM,


if hdfc bank takes written test of fresher before giving job then which sections they cover in it?

1 Answers   HDFC,


How many digits will be there to the right of the decimal point in the product of 95.75 and .02554 ?

0 Answers  


3 dice and 4 coin are tossed together. so what is a sample space

2 Answers   TCS,


Consider the set P = {-5, -3, -1, 1, 3, 5 ...} consisting of 1998 numbers. If a be the average of the elements in P and b be twice the average of the first 1998 natural numbers, then which of the following is equal to (a - b)?

1 Answers  


please send the marketing aptitude,computer knowldege for sbi clerical exam ........

0 Answers   NFL, State Bank Of India SBI,


Categories