Learning Perl

Learning PerlSearch this book
Previous: 18.3 Converting Shell Programs to PerlChapter 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 PerlLearning PerlNext: 19. CGI Programming
18.3 Converting Shell Programs to PerlBook Index19. CGI Programming



Banner.Novgorod.Ru