#!/usr/bin/perl
print "content-type: text/html \n\n"; #HTTP HEADER
@nums = (1 .. 20);
@alpha = ("a" .. "z");
# SCALAR FUNCTION
print scalar(@nums)."<br />";
print scalar(@alpha)."<br />";
# REDEFINE TO SCALAR
$nums = @nums;
$alpha = @alpha;
print "$nums<br />";
print "$alpha<br />";
print "There are $numofnums numerical elements<br />";
print "There are ".scalar(@alpha)." letters in the alphabet!";
#---------결과
20
26
20
26
There are 20 numerical elements
There are 26 letters in the alphabet!
2. Array에서 추가 삭제
#!/usr/bin/perl
print "content-type: text/html \n\n"; #HTTP HEADER
# AN ARRAY
@coins = ("Quarter","Dime","Nickel");
# ADD ELEMENTS
push(@coins, "Penny");
print "@coins";
print "<br />";
unshift(@coins, "Dollar");
print "@coins";
# REMOVE ELEMENTS
pop(@coins);
print "<br />";
print "@coins";
shift(@coins);
print "<br />";
# BACK TO HOW IT WAS
print "@coins";
3. 같은 값을 제거
26
20
26
There are 20 numerical elements
There are 26 letters in the alphabet!
2. Array에서 추가 삭제
#!/usr/bin/perl
print "content-type: text/html \n\n"; #HTTP HEADER
# AN ARRAY
@coins = ("Quarter","Dime","Nickel");
# ADD ELEMENTS
push(@coins, "Penny");
print "@coins";
print "<br />";
unshift(@coins, "Dollar");
print "@coins";
# REMOVE ELEMENTS
pop(@coins);
print "<br />";
print "@coins";
shift(@coins);
print "<br />";
# BACK TO HOW IT WAS
print "@coins";
3. 같은 값을 제거
댓글 없음:
댓글 쓰기