Sponsored Content
Full Discussion: Perl Array Condition
Top Forums Shell Programming and Scripting Perl Array Condition Post 302484834 by radoulov on Monday 3rd of January 2011 11:31:08 AM
Old 01-03-2011
Quote:
Also I tried to change the value of one element of the array to be different values but I got the same output !!!!!!
Could you post an example? I mean, the exact code you run.

This is supposed to be a readable version:
Code:
use warnings;
use strict;

my @arrys = (
  [ qw( 44 44 44 44 ) ],
  [ qw( 55 55 55 55 55 55 56 ) ],
  );

my %h;  
  
for my $arry (@arrys) {
  $h{$_} = undef for @$arry;
  if (keys %h > 1) {
    print "@$arry is not OK\n"
    }
  else {
    print "@$arry is OK\n";
    }  
  }

This User Gave Thanks to radoulov For This Post:
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

[Perl] Accessing array elements within a sed command in Perl script

I am trying to use a script to replace the header of each file, whose filename are stored within the array $test, using the sed command within a Perl script as follows: $count = 0; while ( $count < $#test ) { `sed -e 's/BIOGRF 321/BIOGRF 332/g' ${test} > 0`; `cat 0 >... (2 Replies)
Discussion started by: userix
2 Replies

2. Shell Programming and Scripting

awk - array elements as condition

Hi, can I use array elements ( all ) in conditional statements? the problem is ,the total number of elements is not known. e.g A is an array with elements - 1,2,3 now if i want to test if the 1 st field of input record is either 1,2 or 3, i can do something like this if ( $1 ~... (1 Reply)
Discussion started by: shellwell
1 Replies

3. Shell Programming and Scripting

Perl grep array against array

Hi, Is there any way I can grep an array against another array? Basically here's what I need to do. There will be an array containing some fixed texts and I have to check whether some files contain these lines. Reading the same files over and over again for each different pattern doesnt seem... (1 Reply)
Discussion started by: King Nothing
1 Replies

4. Shell Programming and Scripting

IF condition against a ARRAY in shell script

Hi, I want to check a particular string inserted by User to be checked against the values i already have in a ARRAY string using IF condition. Is this possible? if yes how to do that. example : i have a,b,c,d,e,f values in a array called values i asked user to enter a value: user entered... (2 Replies)
Discussion started by: kukretiabhi13
2 Replies

5. Shell Programming and Scripting

perl, put one array into many array when field is equal to sth

Hi Everyone, #!/usr/bin/perl use strict; use warnings; my @test=("a;b;qqq;c;d","a;b;ggg;c;d","a;b;qqq;c;d"); would like to split the @test array into two array: @test1=(("a;b;qqq;c;d","a;b;qqq;c;d"); and @test2=("a;b;ggg;c;d"); means search for 3rd filed. Thanks find the... (0 Replies)
Discussion started by: jimmy_y
0 Replies

6. Shell Programming and Scripting

Array in Perl - Detect several file to be in one array

Hi everyone I have one question about using array in perl. let say I have several log file in one folder.. example test1.log test2.log test3.log and the list goes on.. how to make an array for this file? It suppose to detect log file in the current directory and all the log file will... (3 Replies)
Discussion started by: sayachop
3 Replies

7. Shell Programming and Scripting

PERL : Read an array and write to another array with intial string pattern checks

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

8. Shell Programming and Scripting

HELP on Perl array / sorting - trying to convert Korn Shell Script to Perl

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

9. Shell Programming and Scripting

ksh : Building an array based on condition result

I want to build an Errorlog. I would like to build an array as I move through the if statements and print the array once all error conditions have been defined. The results need to be comma delimited. tsver will be static "1.9.6(2)" other vars $prit $lt $rt can have the same or a different... (1 Reply)
Discussion started by: popeye
1 Replies

10. UNIX for Dummies Questions & Answers

If condition with array

hi, say if my array has the following integer values.array=( 5 10 15 20 )and A assigns to 5.A=5How do I if condition to check against if value A is in this array or not, in shell script? thx (5 Replies)
Discussion started by: martin5kh
5 Replies
PERLDELTA(1)						 Perl Programmers Reference Guide					      PERLDELTA(1)

NAME
perldelta - what is new for perl v5.8.1 DESCRIPTION
This document describes differences between the 5.8.0 release and the 5.8.1 release. Incompatible Changes Core Enhancements Tied Arrays with Negative Array Indices Formerly, the indices passed to "FETCH", "STORE", "EXISTS", and "DELETE" methods in tied array class were always non-negative. If the actual argument was negative, Perl would call FETCHSIZE implicitly and add the result to the index before passing the result to the tied array method. This behavior is now optional. If the tied array class contains a package variable named $NEGATIVE_INDICES which is set to a true value, negative values will be passed to "FETCH", "STORE", "EXISTS", and "DELETE" unchanged. Warnings Perl 5.8.0 forgot to add some deprecation warnings. These warnings have now been added. Pseudo-hashes really are deprecated Pseudo-hashes were deprecated in Perl 5.8.0 and will be removed in Perl 5.10.0, see perl58delta for details. Each attempt to access pseudo-hashes will trigger the warning "Pseudo-hashes are deprecated". If you really want to continue using pseudo-hashes but not to see the deprecation warnings, add: no warnings 'deprecated'; 5.005-style threads really are deprecated 5.005-style threads (activated by "use Thread;") were deprecated in Perl 5.8.0 and will be removed in Perl 5.10.0, see perl58delta for details. Each attempt to create a 5.005-style thread will trigger the warning "5.005 threads are deprecated". If you really want to con- tinue using 5.005 threads but not to see the deprecation warnings, add: no warnings 'deprecated'; Modules and Pragmata Utility Changes New Documentation Performance Enhancements Installation and Configuration Improvements Selected Bug Fixes New or Changed Diagnostics Changed Internals New Tests Known Problems Platform Specific Problems Reporting Bugs If you find what you think is a bug, you might check the articles recently posted to the comp.lang.perl.misc newsgroup and the perl bug database at http://bugs.perl.org/ . There may also be information at http://www.perl.com/ , the Perl Home Page. If you believe you have an unreported bug, please run the perlbug program included with your release. Be sure to trim your bug down to a tiny but sufficient test case. Your bug report, along with the output of "perl -V", will be sent off to perlbug@perl.org to be analysed by the Perl porting team. SEE ALSO
The Changes file for exhaustive details on what changed. The INSTALL file for how to build Perl. The README file for general stuff. The Artistic and Copying files for copyright information. perl v5.8.0 2003-02-18 PERLDELTA(1)
All times are GMT -4. The time now is 10:13 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy