Beefy Boxes and Bandwidth Generously Provided by pair Networks
Syntactic Confectionery Delight
 
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 not a whimper to be heard...

How do I use this? | Other CB clients
Other Users?
Others pondering the Monastery: (9)
As of 2018-02-20 09:48 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    When it is dark outside I am happiest to see ...














    Results (268 votes). Check out past polls.

    Notices?