Beefy Boxes and Bandwidth Generously Provided by pair Networks
Your skill will accomplish
what the force of many cannot
 
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
Domain Nodelet?
Node Status?
node history
Node Type: note [id://800852]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others musing on the Monastery: (3)
As of 2023-12-01 03:05 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found

    Notices?