Beefy Boxes and Bandwidth Generously Provided by pair Networks
laziness, impatience, and hubris
 
PerlMonks  

Control Statements #1

by vroom (His Eminence)
on Nov 24, 1999 at 01:15 UTC ( [id://1015]=note: print w/replies, xml ) Need Help??


in reply to Control Statement Exercises

# Reads in lines of text until "quit" is read. # Then prints duplicates, or prints "No duplicates seen." my %lines; # holds lines of text encountered along with a count # of how many times it has been seen my @dups; while ( $_ = <> and $_ ne "quit\n" ) { $lines{$_}++; # increment value. if it dosn't exist yet, initializ +es to 1 if ( $lines{$_} == 2 ) # been seen before so add to dupes list { push @dups, $_; } } if ( @dups ) { print "Here are your duplicate lines:\n\n"; foreach ( @dupes ) { print; } } else { print "No duplicates seen.\n"; }

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://1015]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others studying the Monastery: (5)
As of 2024-03-29 07:36 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found