Skip to content

Commit 7191089

Browse files
committed
New Folder
1 parent 9b4db92 commit 7191089

File tree

4 files changed

+65
-0
lines changed

4 files changed

+65
-0
lines changed

arrays.pl

+12
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
#!/usr/bin/perl
2+
3+
4+
print "content-type: text/html \n\n";#HTTP HEADER
5+
6+
# DEFINE AN ARRAY
7+
@coins = ("Quarter","Dime","Nickel");
8+
9+
# PRINT THE ARRAY
10+
print "@coins";
11+
print "<br />";
12+
print @coins;

arrays.pl~

+12
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
#!/usr/bin/perl
2+
3+
4+
print "content-type: text/html \n\n";#HTTP HEADER
5+
6+
# DEFINE AN ARRAY
7+
@coins = ("Quarter","Dime","Nickel");
8+
9+
# PRINT THE ARRAY
10+
print "@coins";
11+
print "<br />";
12+
print @coins;

typtd/typ21days4_q1.pl

+17
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
#!/usr/bin/perl -w
2+
3+
$one = 0;
4+
$two = 0;
5+
6+
print ' Enter a range boundry: ';
7+
chomp($one = <STDIN>);
8+
print ' Enter the other range boundry: ';
9+
chomp($two = <STDIN>);
10+
11+
if ($one < $two) {
12+
@array = ($one .. $two);
13+
} else {
14+
@array = ($two .. $one);
15+
}
16+
17+
print "@array\n";

typtd/typ21days4_q2.pl

+24
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
#!/usr/bin/perl
2+
# Script which prompt you for two arrays and then creates a third array that contains only the element prenset in the first two( the intersection of those arrays
3+
4+
$in = ''; #temo input
5+
@array1 = ();
6+
@array2 = ();
7+
@final = ();
8+
9+
print 'Enter the first array: ';
10+
chomp($in = <STDIN>);
11+
@array1 = split(' ', $in);
12+
print 'Enter the second array: ';
13+
chomp($in = <STDIN>);
14+
@array2 = split(' ', $in);
15+
16+
foreach $el (@array1) {
17+
foreach $el2 (@array2) {
18+
if (defined $el2 && el eq $el2) {
19+
$final[$#final+1];
20+
undef el2;
21+
last;
22+
}
23+
}
24+
}

0 commit comments

Comments
 (0)