Sponsored Content
Top Forums Shell Programming and Scripting Perl: One action if an element doesn't exist in array Post 302487318 by pludi on Wednesday 12th of January 2011 03:29:09 AM
Old 01-12-2011
The solution bartus gave is quite valid, you'll just have to change the syntax a bit.
Code:
if ( grep /yournumberhere/, @array ) {
    # Code if number was found
} else {
    # Code if number was not found
}

 

10 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

What hapens if a group member doesn't exist?

As part of a NIS implementation, (I think) I want to create a group (in /etc/group) that has users that do not exist on the target machine. What effect will this have? Will it cause any problems? Thanks, Gary Cooper (1 Reply)
Discussion started by: Gary Cooper
1 Replies

2. Shell Programming and Scripting

Perl delete an element from array

Probably I am not seeing it or I am not using the "delete" correctly I had the following codes but it does not work for me #!/bin/perl -w ... @sysFile1 = (a_b, a_c, a_d); @sysFile2 = (a_c, a_e, b_f); foreach $line1 (@sysFile1){ trim(\$line1); (my $tmp1, my $tmp2) = split/_/,... (6 Replies)
Discussion started by: ahtat99
6 Replies

3. Shell Programming and Scripting

Remove an element from an array in PERL

Hello guys, I have the following question. Consider the following code in PERL for($xeAnumber=0; $xeAnumber<@xeAnumber; $xeAnumber++) { if(@xeAnumber==@final_file) { @final_file=@xeTimeStamp; }... (3 Replies)
Discussion started by: chriss_58
3 Replies

4. Shell Programming and Scripting

sftp mget where file doesn't exist BASH

I have a script that is working: #!/bin/bash sftp user@domain.com <<EOF cd somedir mget *.csv quit EOF but on a crontab I want to only pull newer files, so I want to do something like: while read ls current dir local file != true do mget that new file but I'm not sure the syntax... (2 Replies)
Discussion started by: unclecameron
2 Replies

5. Programming

Kernel module - How to test if file doesn't exist

Hey, I'm currently getting into some kernel module progamming. As a little exercise I want to read the headers out of an ELF file. My code is very simple, here is the important part: struct file *fp; /* ... */ fp = filp_open("some/file/on/my/pc", O_RDONLY, 0); if(fp == NULL) { ... (15 Replies)
Discussion started by: disaster
15 Replies

6. Shell Programming and Scripting

previous element in the array perl

Hi, How to get previous/next element in the array perl Example @queue = (1, 2 ,3 , 4); I want to get value of 1 and 2, or, 2 and 3, or 3 and 4...etc and compare to value which one is greater to do that I need to get previous and next element of array ? (1 Reply)
Discussion started by: guidely
1 Replies

7. Solaris

User directory doesn't exist

Hii all, i create the user useradd -d /home/kk kk passwd kk when i tried to login to kk i get a error user directory doesn't exist then i tried useradd kkk passwd kkkwhen i tried to login to kkk i get the same error user directory doesn't exist. (4 Replies)
Discussion started by: vipinkumarr89
4 Replies

8. Shell Programming and Scripting

Perl: How to check whether my array contains element x

Hi All, I am new to perl I am stuck in simple problem I need your help I want to define a subroutine. sub check_if_entity_exists(@array_to_be_checked,$entityName) I have array as http-listener-1 http-listener-2 http-listener-3 http-listener-4 If i send http-listener-3 my... (1 Reply)
Discussion started by: javaholics
1 Replies

9. Shell Programming and Scripting

Perform an action if certain text exist in output (PERL)

Hello, I'm attempting to write a tool that checks an IP address for existing PTR records then if there are no PTR records does a ping to see if it response. Then if there is no response, it should print a message saying This is what I have so far. #!/usr/bin/perl $nxdomain =... (4 Replies)
Discussion started by: spartan22
4 Replies

10. Homework & Coursework Questions

Group Doesn't Exist

Use and complete the template provided. The entire template must be completed. If you don't, your post may be deleted! 1. The problem statement, all variables and given/known data: I'm able to create a group but when I'm trying to delete the group it keeps stating Group Doesn't Exist. I know... (2 Replies)
Discussion started by: GoBoyGo
2 Replies
PPIx::Regexp::Token::GroupType::Code(3) 		User Contributed Perl Documentation		   PPIx::Regexp::Token::GroupType::Code(3)

NAME
PPIx::Regexp::Token::GroupType::Code - Represent one of the embedded code indicators SYNOPSIS
use PPIx::Regexp::Dumper; PPIx::Regexp::Dumper->new( 'qr{(?{print "hello world! ")}smx' ) ->print(); INHERITANCE
"PPIx::Regexp::Token::GroupType::Code" is a PPIx::Regexp::Token::GroupType. "PPIx::Regexp::Token::GroupType::Code" has no descendants. DESCRIPTION
This method represents one of the embedded code indicators, either '?' or '??', in the zero-width assertion (?{ print "Hello, world! " }) or the old-style deferred expression syntax my $foo; $foo = qr{ foo (??{ $foo }) }smx; METHODS
This class provides no public methods beyond those provided by its superclass. SUPPORT
Support is by the author. Please file bug reports at <http://rt.cpan.org>, or in electronic mail to the author. AUTHOR
Thomas R. Wyant, III wyant at cpan dot org COPYRIGHT AND LICENSE
Copyright (C) 2009-2013 by Thomas R. Wyant, III This program is free software; you can redistribute it and/or modify it under the same terms as Perl 5.10.0. For more details, see the full text of the licenses in the directory LICENSES. This program is distributed in the hope that it will be useful, but without any warranty; without even the implied warranty of merchantability or fitness for a particular purpose. perl v5.16.3 2014-06-10 PPIx::Regexp::Token::GroupType::Code(3)
All times are GMT -4. The time now is 05:40 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy