Sponsored Content
Top Forums Shell Programming and Scripting Perl match multiple numbers from a variable similar to egrep Post 302769710 by guruprasadpr on Wednesday 13th of February 2013 06:25:15 AM
Old 02-13-2013
One way:

Code:
#!/usr/bin/perl
use strict;
use warnings;

my $num = "148|1|0|256";
my $inp = $ARGV[0];

my %h1=map{$_ => 1}split(/\|/,$num);

if (exists($h1{$inp})){
        print "Found";
}else{
        print "Not Found";
}

 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

read and match multiple lines in perl

Could any one tell me how to read and match multiple lines in perl? Did this code below still work in this situation? while (<FILE>) { if (/ /) { } } Thanks a lot! (5 Replies)
Discussion started by: zx1106
5 Replies

2. UNIX for Dummies Questions & Answers

match similar rows. uniq?

hi i have data which is in two columns (such as below). i need to compare two rows against each other and if one row matches the other row (except for different case), and their values in the second column are different, then it prints out one of the rows (either is fine). here is an... (5 Replies)
Discussion started by: Streetrcr
5 Replies

3. Shell Programming and Scripting

Perl: Match a line with multiple search patterns

Hi I'm not very good with the serach patterns and I'd need a sample how to find a line that has multiple patterns. Say I want to find a line that has "abd", "123" and "QWERTY" and there can be any characters or numbers between the serach patterns, I have a file that has thousands of lines and... (10 Replies)
Discussion started by: Juha
10 Replies

4. Shell Programming and Scripting

Multiple variable in a variable in Perl

Hi All, I am trying to convert the below Csh while loop into Perl while loop but the problem is that in this csh script, i have 2 variables inside a variable -> $count is a variable {SB$count} as a whole is another variable. Csh is able to assign values to such variable like the below but i do... (3 Replies)
Discussion started by: Raynon
3 Replies

5. Shell Programming and Scripting

Perl: Printing Multiple Lines after pattern match

Hello People, Need some assistance/guidance. OUTLINE: Two files (File1 and File2) File1 has some ids such as 009463_3922_1827 897654_8764_5432 File2 has things along the lines of: Query= 009463_3922_1827 length=252 (252 letters) More stufff here ... (5 Replies)
Discussion started by: Deep9000
5 Replies

6. Shell Programming and Scripting

Perl - match e-mail addresses in multiple files

Hi, I'm trying to write a script that will check multiple files in a directory (all the relevant filenames begin "TT04.NOTES") for e-mail addresses, and then print these addresses to screen with a count at the bottom. I'm a bit of a novice with Perl but thought it would be the best tool for the... (2 Replies)
Discussion started by: wf1974
2 Replies

7. Shell Programming and Scripting

Joining multiple files based on one column with different and similar values (shell or perl)

Hi, I have nine files looking similar to file1 & file2 below. File1: 1 ABCA1 1 ABCC8 1 ABR:N 1 ACACB 1 ACAP2 1 ACOT1 1 ACSBG 1 ACTR1 1 ACTRT 1 ADAMT 1 AEN:N 1 AKAP1File2: 1 A4GAL 1 ACTBL 1 ACTL7 (4 Replies)
Discussion started by: seqbiologist
4 Replies

8. Shell Programming and Scripting

Regex/egrep matching numbers in brackets

Experts: I don't know that regular expressions will ever be easy for me, so if one of you guru's could help out, I'd appreciate it. I'm trying to match a line in our syslog, but I can't figure out how to match a number inside a bracket. This is what I'm trying to match. "Jul 16 00:01:34... (2 Replies)
Discussion started by: jdveencamp
2 Replies

9. UNIX for Dummies Questions & Answers

egrep getting numbers only

Hello, I am kind of a noob with unix, so i'd like some help. I am trying to get some ip address with an nmap scan and then put from the result of the scan only the ip numbers this is an example Starting Nmap 5.21 ( Nmap - Free Security Scanner For Network Exploration & Security Audits )... (3 Replies)
Discussion started by: AscaL
3 Replies

10. Shell Programming and Scripting

Egrep - Only Match First Occurrence

echo 'String#1 and String#2' | egrep -o -m 1 'String#.{1}' String#1 String#2 I'm trying to just match the first occurrence of 'String#' + 1 character. I thought the "-m 1" switch would do that for me. Instead I get both occurrences. Can somebody provide some insight? Thanks! (5 Replies)
Discussion started by: sudo
5 Replies
giiSetEventMask(3)							GGI							giiSetEventMask(3)

NAME
giiSetEventMask, giiGetEventMask, giiAddEventMask, giiRemoveEventMask - Set the types of events queued SYNOPSIS
#include <ggi/gii.h> int giiSetEventMask(gii_input_t inp, gii_event_mask evm); gii_event_mask giiGetEventMask(gii_input_t inp); int giiAddEventMask(gii_input_t inp, gii_event_mask evm); int giiRemoveEventMask(gii_input_t inp, gii_event_mask evm); DESCRIPTION
Calling giiSetEventMask indicates to LibGII that only the types of events that match the specified event mask will be read by the applica- tion in subsequent giiEventPoll(3) or giiEventRead(3) calls. LibGII can then save time and memory by skipping checks and not allocating queues for events that will never be read out. The default mask allows all events. giiAddEventMask and giiRemoveEventMask are macros that set or delete individual bits in the bitmask. Note: giiSetEventMask is an advisory call. For correct operation, the application still needs to pass a restrictive event mask to the event reading functions. RETURN VALUE
giiSetEventMask, giiAddEventMask and giiRemoveEventMask return 0 on success or an gii-error(3) code otherwise. giiGetEventMask returns the currently set mask. SEE ALSO
gii_event_mask(3) libgii-1.0.x 2006-12-30 giiSetEventMask(3)
All times are GMT -4. The time now is 04:41 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy