start page | rating of books | rating of authors | reviews | copyrights

Learning Perl

Learning PerlSearch this book
Previous: 18.3 Converting Shell Programs to Perl Chapter 18
Converting Other Languages to Perl
Next: 19. CGI Programming
 

18.4 Exercise

See Appendix A, Exercise Answers for the answer.

  1. Convert the following shell script into a Perl program:

    cat /etc/passwd | awk -F: '{print $1, $6}' | while read user home do   newsrc="$home/.newsrc"   if [ -r $newsrc ]   then     if grep -s '^comp\.lang\.perl\.announce:' $newsrc     then       echo -n "$user is a good person, ";       echo "and reads comp.lang.perl.announce!"     fi   fi done


Previous: 18.3 Converting Shell Programs to Perl Learning Perl Next: 19. CGI Programming
18.3 Converting Shell Programs to Perl Book Index 19. CGI Programming