Beefy Boxes and Bandwidth Generously Provided by pair Networks
There's more than one way to do things
 
PerlMonks  

Re: Adding element to Array?

by bichonfrise74 (Vicar)
on Oct 13, 2009 at 05:49 UTC ( #800852=note: print w/replies, xml ) Need Help??


in reply to Adding element to Array?

Try something like this. You need a hash so that you do not store repeated elements.
#!/usr/bin/perl use strict; my %record; while (my $line = <DATA>) { $record{$line}++ if ( $line =~ /\S/ ); } print for sort keys %record; __DATA__ a b c d a a c d c

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://800852]
help
Chatterbox?
and all is quiet...

How do I use this? | Other CB clients
Other Users?
Others romping around the Monastery: (2)
As of 2018-07-19 21:31 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    It has been suggested to rename Perl 6 in order to boost its marketing potential. Which name would you prefer?















    Results (420 votes). Check out past polls.

    Notices?