O'Reilly logo

Learning Perl, Second Edition by Randal L. Schwartz, Tom Christiansen

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

18.4. Exercise

See Appendix A 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

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required