Cartwright 2012 Summer
Computer Sciences 368 Introduction to Perl
Day 11: System Interaction
Suggested reading: Learning Perl (6th Ed.) Chapter 16: Process Management
1
Day 11: System Interaction Suggested reading: Learning Perl (6th Ed.) - - PowerPoint PPT Presentation
Computer Sciences 368 Introduction to Perl Day 11: System Interaction Suggested reading: Learning Perl (6th Ed.) Chapter 16: Process Management 2012 Summer Cartwright 1 Computer Sciences 368 Introduction to Perl Homework Review 2012 Summer
Cartwright 2012 Summer
1
Cartwright 2012 Summer
2
Cartwright 2012 Summer
3
Cartwright 2012 Summer
4
Cartwright 2012 Summer
5
Cartwright 2012 Summer
6
while (1) { print '% '; my $cmd = <STDIN>; do($cmd); }
if [ $# -lt 3 ]; then echo 'Too few args!'; fi
gcc foo.c -o foo > compile.log 2> errors.log
grep '^[0-9]' file.txt | sort | uniq -c
Cartwright 2012 Summer
7
Cartwright 2012 Summer
8
% foo -x
PWD: ~/scripts PATH: /usr/bin:/usr/local/bin:…
chdir 'data'; system('bar');
PWD: ~/scripts/data PATH: /usr/bin:/usr/local/bin:…
printf("hi\n"); exit(2);
PWD: ~/scripts/data PATH: /usr/bin:/usr/local/bin:…
%
Cartwright 2012 Summer
9
Cartwright 2012 Summer
10
+ Easy to code – Must change script to change input
+ Easy to code, no script changes each run – Cannot automate (easily) — user must type input each run
+ No script changes each run, can automate – Must parse file contents; separate file to manage
+ No script changes each run, can automate – Must parse arguments; cumbersome for many or long inputs
+ No script changes each run, can automate – Must parse arguments; cumbersome for many or long inputs
Cartwright 2012 Summer
11
Cartwright 2012 Summer
12
Cartwright 2012 Summer
13
Cartwright 2012 Summer
14
Cartwright 2012 Summer
15
Cartwright 2012 Summer
16
Cartwright 2012 Summer
17
Cartwright 2012 Summer
18
Cartwright 2012 Summer
19
Cartwright 2012 Summer
20
Cartwright 2012 Summer
21
Cartwright 2012 Summer
22
Cartwright 2012 Summer
23
Cartwright 2012 Summer
24
Cartwright 2012 Summer
25