tutorials:perl_exercises
Differences
This shows you the differences between two versions of the page.
Both sides previous revisionPrevious revision | |||
tutorials:perl_exercises [2010/08/07 00:20] – chkuo | tutorials:perl_exercises [2010/08/07 00:42] (current) – chkuo | ||
---|---|---|---|
Line 92: | Line 92: | ||
</ | </ | ||
See a sample answer [[tutorials: | See a sample answer [[tutorials: | ||
+ | |||
+ | |||
+ | ===== combine_files ===== | ||
+ | The opposite of write_lines_to_files; | ||
+ | |||
+ | **Hint: learn about filehandle, directory operation, and pattern matching before attempting this exercise.** | ||
+ | |||
+ | <code bash> | ||
+ | $ head output/* | ||
+ | ==> output/1 <== | ||
+ | George Washington | ||
+ | |||
+ | ==> output/2 <== | ||
+ | John Adams | ||
+ | |||
+ | ==> output/3 <== | ||
+ | Thomas Jefferson | ||
+ | |||
+ | ==> output/4 <== | ||
+ | James Madison | ||
+ | |||
+ | ==> output/5 <== | ||
+ | James Monroe | ||
+ | $ perl combine_files.pl output/ combined.txt | ||
+ | $ cat combined.txt | ||
+ | George Washington | ||
+ | John Adams | ||
+ | Thomas Jefferson | ||
+ | James Madison | ||
+ | James Monroe | ||
+ | </ | ||
+ | See a sample answer [[tutorials: | ||
+ | |||
tutorials/perl_exercises.1281111659.txt.gz · Last modified: by chkuo