10 More Discussions You Might Find Interesting
1. UNIX for Beginners Questions & Answers
sub uniq {
my %h;
return grep { !$h{$_}++ } @_
}
The above code is to remove duplicates from array.
I am having hard time understanding below things (basically around highlighted code in bold)-
when was the value inserted in hash?
and are we only adding a key in Hash not... (1 Reply)
Discussion started by: Tanu
1 Replies
2. Shell Programming and Scripting
HI I ma using perl programming
my perl is like this
$InputFile = $ENV{UDE_TMP} . "/" ."cre_fmr_gen.temp_data_file_gen.dat";
@duplicates = `cat $InputFile | cut -d "|" -f 1,1 | sort | uniq -c | awk '{ if(\$1>1) {print \$2;}}'`;
my $cusiplist ;
foreach $cusip (@duplicates)
{... (1 Reply)
Discussion started by: ptappeta
1 Replies
3. Shell Programming and Scripting
Hi all,
Not sure if this should be in the programming forum, but I believe it will get more response under the Shell Programming and Scripting FORUM.
Am trying to write a customized df script in Perl and need some help with regards to using arrays and file handlers.
At the moment am... (3 Replies)
Discussion started by: newbie_01
3 Replies
4. Shell Programming and Scripting
I have an array and two variables as below,
I need to check if $datevar is present in $filename.
If so, i need to replace $filename with the values in the array.
I need the output inside an ARRAY
How can this be done.
Any help will be appreciated. Thanks in advance. (2 Replies)
Discussion started by: irudayaraj
2 Replies
5. Shell Programming and Scripting
Hi,
I would like to do the following sorting, but the output is not what i expected. Why 222 and 2222 are not at the last two elements of array?
awk 'BEGIN{a="22";a="2222";a="33";a="44";a="222";a="11";a="22";a="33";asort(a); for (i=1;i<=8;i++) print a}'
11
22
22
222
2222
33
33
44... (1 Reply)
Discussion started by: phoeberunner
1 Replies
6. Shell Programming and Scripting
#!/usr/bin/perl
my @arr=("hello", "how", "are", "you");
$l=length(@arr);
print $l;
This print 1.Why?
How can i print the array size = 4?
I want to store these in an array.
hello
how
are
you
And then i want to access these element through indexing.
How can i do this? (4 Replies)
Discussion started by: cola
4 Replies
7. Shell Programming and Scripting
Hi All,
I have an array in perl as @match = (201001,201002,201001,201002);
I am trying to sort this array as
@match = sort(@match);
print "@match";
I dont see the output sorted any answers
I also tried another way, but still the results are not sorted
foreach my $match (sort { $a... (2 Replies)
Discussion started by: bsdeepu
2 Replies
8. Shell Programming and Scripting
Hi All
I want to search a string from an array in Perl. If a match occurs, assign that string to a variable else assign 'No match'. I tried writing the script as follows but it's in vain. Please help me..
#!/usr/bin/perl
use strict;
my $NER;
my @text=("ORG","PER");
... (4 Replies)
Discussion started by: my_Perl
4 Replies
9. Shell Programming and Scripting
I have an array full of string values that need to be sorted, but if a value starts with (regex) 0^ it should be at the beginning of the array. Otherwise the array should be sorted normally using ascii sort.
Please help me create the sub to pass to the sort function. (7 Replies)
Discussion started by: dangral
7 Replies
10. Shell Programming and Scripting
Hi,
When using sort on an associative array:
foreach $key (sort(keys(%opalfabet))){
$value = $opalfabet{$key};
$result .= $value;
}
How does it handle double values?
It seems to me that it removes them, is that true? If so, is there a way to get... (2 Replies)
Discussion started by: tine
2 Replies