PREE HW#6 - 1/usr/local/bin/perl-w#This program prints...

Info iconThis preview shows pages 1–3. Sign up to view the full content.

View Full Document Right Arrow Icon
1. #!/usr/local/bin/perl -w #This program prints lines that contain only three characters. while(<STDIN>) { if(m/^.{3}$/) { print($_); } } #End 2. #!/usr/local/bin/perl -w #This program prints only lines with at least three characters. while(<STDIN>) { if(m/^.{3,}$/) { print($_); } } #End 3. #!/usr/local/bin/perl -w #This program prints non-blank lines while(<STDIN>) { unless(m/^$/) { print($_); } } #End 4. #!/usr/local/bin/perl -w #This program prints number of non-blank lines. while(<STDIN>) { unless(m/^$/)
Background image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
$counter++; } } print("\n$counter\n"); #End 5. #!/usr/local/bin/perl -w #This program prints lines that starts with a digit. while(<>) { if(m/^\d/) { print ; } } #End 6. #!/usr/local/bin/perl -w #This program prints lines that starts and ends with the same char. while(<STDIN>) { if(m/^(.).*\1$/) { print($_); } } #End 7. #!/usr/local/bin/perl -w #This program prints the line in which two consecutive words are the same. while(<STDIN>)
Background image of page 2
Image of page 3
This is the end of the preview. Sign up to access the rest of the document.

This note was uploaded on 12/11/2010 for the course MSEE 1 taught by Professor Alex during the Spring '10 term at Northwestern Polytechnic University.

Page1 / 6

PREE HW#6 - 1/usr/local/bin/perl-w#This program prints...

This preview shows document pages 1 - 3. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online