in reply to Deciding unique elements of an array
For the second problem, I think that you want to write something like#!/usr/bin/perl -w use strict; my @dup_array = qw/this this array has has duplicates/; my @unique_array; my %uniques; foreach my $elem (@dup_array) { push @unique_array, $elem unless $unique{$elem}++; } print "Unique elements are @unique_array";
Using <> in a list context gives you every line of input as an element of your array. That is $line[0] is your first line of code.my @lines = <>;
Mind you, what a line of input is depends on whether you've messed around with $/;
|
|---|