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

8400 ? 120 x 15 + 150 = ? (a) 1050 (b) 1200 (c) 1100 (d) 1514 (e) None of these

3 Answers  


9 laboures can complete the construction of a wall in 18 days. How many less days will 12 laboures take to complete the same wall?

1 Answers   Wipro,


a train runs first half of the distance at 40 km/hr and the remaining half at 60 km/hr. What is the average speed for the entire journey?

0 Answers   Infosys,


In school there are some bicycles and 4 wheeler wagons. One tuesday there are 190 wheels in the campus. How many bicycles are there?

0 Answers   TCS,


While packing some return gifts, a mother decides to put some toffees in each gift packet. If she keeps 5 toffees in each packet, she is left with none. But if she keeps 2, 3 or 4 toffees in a packet, she is left with 1 toffee . What is the minimum number of toffees that she needs?

13 Answers   Infosys,






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

0 Answers   Accenture,


Sir, I'm sonjoy bhadra, plz send me previous 10 years solved question papers for sbi clarical exam and also send one model paper pattern for this year

0 Answers  


2 persons can finish a job in 8 days. First person alone can finish the work in 24 days. How many days does the second person take to finish the job?

0 Answers   Hexaware,


Company A owns 40% of the stocks in the XYZ corporation. company B ownz 15000 shares. company C owns all the shares not owned by the companies A or B. How many shares of stock does Company A own if company C has 25% more shares than Company A? a) 450000 b) 50000 c) 750000 d) 60000

6 Answers   eClerx,


1. 10 men and 10 women are there, they dance with each other, is there possibility that 2 men are dancing with same women and vice versa? a) 22 b) 20 c) 10 d) none

2 Answers   TCS,


1. 2 containers labeled A and B are filled with red and blue marbles in given quantities: - Container RED BLUE A 6 4 B 60 40 Each container is shaken vigorously. After choosing 1 of the container, without looking, draw out a marble. From which container you have the max probability of choosing a blue marble?

3 Answers  


There are 200 employees in a company. An external vendor is chosen to Serve coffee twice a day. 100 coffee cups were offered by the company but as an incentive to have the cups in tact at the end of the day, the company offered 30 paise for every cup remained safely and charged 90 paise for every broken cup. At an end of a day, the vendor received Rs. 24. How many cups did the vendor break? 10, 20, 8, 5?

0 Answers   Accenture,


Categories