Skip to content

Commit da7aa16

Browse files
committed
Add Chap 16
1 parent fbfda74 commit da7aa16

File tree

14 files changed

+175
-0
lines changed

14 files changed

+175
-0
lines changed

Chapter-16/312-1.pl

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
#!/usr/bin/env perl
2+
3+
use 5.010;
4+
use utf8;
5+
use strict;
6+
use warnings;
7+
8+
system 'ls -l $HOME';

Chapter-16/312.pl

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
#!/usr/bin/env perl
2+
3+
use 5.010;
4+
use utf8;
5+
use strict;
6+
use warnings;
7+
8+
system "date";

Chapter-16/314.pl

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
#!/usr/bin/env perl
2+
3+
use 5.010;
4+
use utf8;
5+
use strict;
6+
use warnings;
7+
8+
my $tarfile = "something*wicked.tar";
9+
my @dirs = qw ( fred|flintstone<barney&rubble> betty );
10+
system "tar", "cvf", $tarfiles, @dirs;

Chapter-16/318.pl

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
#!/usr/bin/env perl
2+
3+
use 5.010;
4+
use utf8;
5+
use strict;
6+
use warnings;
7+
8+
my $now = `date`;
9+
print "The time is now $now";
10+
11+
my @functions = qw{ int rand sleep length hex eof not exit sqrt umast };
12+
my %about;
13+
foreach (@functions) {
14+
$about{$_} = `perldoc -t -f $_`;
15+
}
16+
say %about;

Chapter-16/321.pl

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
#!/usr/bin/env perl
2+
3+
use 5.010;
4+
use utf8;
5+
use strict;
6+
use warnings;
7+
8+
my $who_test = `who`;
9+
say "$who_test";
10+
11+
my @who_lines = `who`;
12+
say @who_lines;

Chapter-16/322.pl

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
#!/usr/bin/env perl
2+
3+
use 5.010;
4+
use utf8;
5+
use strict;
6+
use warnings;
7+
8+
open DATE, "date|" or die "cannot pipe from date: $!";
9+
#open MAIL, "|mail newbcode" or die "cannot pipe to mail: $!";
10+
11+
my $now = <DATE>;
12+
say $now;

Chapter-16/324.pl

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
#!/usr/bin/env perl
2+
3+
use 5.010;
4+
use utf8;
5+
use strict;
6+
use warnings;
7+
8+
9+
open F, "find / -atime +90 -size +1000 -print|" or die "fork: $!";
10+
while (<F>) {
11+
chomp;
12+
printf "%s size %dK last accessd in %s\n", $_, (1023 + -s $_)/1024, -A $_;
13+
}

Chapter-16/325.pl

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
#!/usr/bin/env perl
2+
3+
use 5.010;
4+
use utf8;
5+
use strict;
6+
use warnings;
7+
8+
defined(my $pid = fork) or die "Can not fork:$!";
9+
unless ($pid) {
10+
exec "date";
11+
die "cannot exec date: $!";
12+
}
13+
waitpid($pid, 0);
14+

Chapter-16/327.pl

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
#!/usr/bin/env perl
2+
3+
use 5.010;
4+
use utf8;
5+
use strict;
6+
use warnings;
7+
8+
my $temp_directory = "/tmp/myprog.$$";
9+
mkdir $temp_directory, 0700 or die "Cannot create $temp_directory: $";
10+
11+
sub clean_up {
12+
unlink glob "$temp_directory/*";
13+
rmdir $temp_directory;
14+
}
15+
16+
sub my_init_handler {
17+
&clean_up;
18+
die "interrupted, exiting....\n";
19+
}
20+
21+
$SIG{'INT'} = 'my_init_handler';
22+
&clean_up;

Chapter-16/ex-1.pl

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
#!/usr/bin/env perl
2+
3+
use 5.010;
4+
use utf8;
5+
use strict;
6+
use warnings;
7+
8+
9+
chdir "/" or die "Cannot move /";
10+
system "ls -l";

0 commit comments

Comments
 (0)