Quality Testing

Quality is delighting customers

can anyone explore this topic ???

Views: 64

Reply to This

Replies to This Discussion

There is no specific slice() function for slicing up elements of an array. Instead PERL allows us to create a new array with elements of another array using array indexing.

#!/usr/bin/perl

print "content-type: text/html \n\n"; #HTTP HEADER

@coins = qw(Quarter Dime Nickel Penny);
@slicecoins = @coins[0,2];
print "@slicecoins\n";
print "
";
Replacing elements is possible with the splice() function. Splice() requires a handful of arguments and the formula reads: splice(@array,first-element,sequential_length,name of new elements).

splice ( @array_name , offset , no of elements to be removed , list to be added)
Eg : @array = ( a, b , c , d , e , f )
splice ( @array , 2 , 3 , A , B , C )

The array is now ( a b A B C f )
thanks smita for this information...

RSS

TTWT Magazine


Advertisement

Advertisement

Advertisement

Advertisement

© 2021   Created by Quality Testing.   Powered by

Badges  |  Report an Issue  |  Terms of Service