2
votes
6answers
64 views

Perl - Check if any elements in each different array matches a variable

I have a problem I am hoping someone can help with (greatly simplified for the purposes of explaining what I am trying to do)... I have three different arrays: my @array1 = ("DOG","CAT","HAMSTER"); ...
1
vote
2answers
49 views

Trying to understand context in arrays/list in Perl

I am trying to understand the context (array/list/scalar) in Perl. I tried the following: @array = qw (john bill george); print @array; print "\n"; @sorted = sort (array); print @sorted; ...
0
votes
5answers
96 views

Array lowercase

I'm new to Perl and I've ran into a little problem. I'm trying to pick one value out of an array to make it lowercase. E.g. my @letters = qw(A B C D E F F A S D F E S F); Now I want to pick the ...
1
vote
3answers
80 views

Arrays and negative indexes in Perl

I am newbie in Perl and I am reading about arrays. As I understand the arrays expand automatically as needed (cool!) But I also read that we can use negative indexes to access the arrays in reverse ...
-3
votes
1answer
45 views

Verify if email sender has permission to send to a certain address

I am forced to implement a sender policy in qmail. I have a file describing the policies: [email protected]:*@domain1.com,[email protected],[email protected] [email protected]:*@* [email protected]: This ...
0
votes
2answers
36 views

how to avoid pushing duplicate values into an array in perl

how to avoid pushing duplicate values into an array in Perl i need to add unique elements in an array from inputs which contains several duplicate values.
1
vote
2answers
48 views

Writing contents of an array to txt file in perl

The output I'm trying to achieve would look like this: Name age gpa for every element in each array, however when I write the contents of the array to a file it over writes somewhere and is ...
-2
votes
5answers
63 views

Taking the average of many N sized arrays

Can anyone help me fix this? I'm trying to write a script that takes the sum of many N sized arrays. In the example below the average of the arrays would be (1,2) since (0+1+2+1)/4 = 1 and (2+3+2+1)/4 ...
0
votes
2answers
52 views

Subroutine that takes average of one or more arrays

I'm working on a subroutine that takes the average of 1 or more arrays. I would like to do this without using a module. use strict; use warnings; use List::Util 'sum'; my @w = (0, 2); my @x = (1, ...
1
vote
2answers
91 views

Perl grep two arrays

I have one array filled with short strings (@pos), and a second larger array (@exome). I want to search the second array for any match with strings from the first. The goal is to print all lines from ...
2
votes
1answer
65 views

Unresolvable perl error?

use strict; my @array = (); my @nums = [3, 4]; foreach my $i ( 0 .. 10 ) { foreach my $j ( 0 .. 10 ) { $nums[0] = 4+1; push @{ $array[$i] }, @nums; } } print $array[6][2][0]. ...
2
votes
3answers
67 views

Perl: quick replacing of occurrences of multiple words in an array

Sorry if it is a duplicate topic, but I've searched inside the forum and I've only found similar but not identical questions. My problem is: I've got an array of strings like this one: @array = ...
3
votes
2answers
58 views

Join elements of two arrays and create a result array in perl

Basically what i need if i have two arrays like below: my @a=("a","b","c"); my @z=("x","y","z"); I want the result array to be: ("a x","b y","c z") pre condition is the number is elements in ...
0
votes
1answer
61 views

Can someone explain this bug to me? [closed]

I'm trying to compare two arrays using the smart ~~ match operator. However, it's not working properly. I think I may have I've found a bug in it. See below. use strict; use warnings; use ...
0
votes
2answers
40 views

Perl, check if last char is a bracket

I want to check the last char of an array entry, if it's a bracket or not. My code looks like this: my $lastchar = substr $blub[8],-1,1; print ...

1 2 3 4 5 52
15 30 50 per page