perl combine if


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting perl combine if
# 1  
Old 03-29-2010
perl combine if

Hi Evereyone,
Code:
%q = ();
$q{"a"} = 0;
$q{"b"} = 0;
$q{"c"} = 0;

if ($q{"a"} !=0 || $q{"b"} !=0 || $q{"c"} !=0) {
print "non-zero"
}

if any simple way to do that? assume you have not only a, b, c inside %q, but a, b, c, d, e, ... ...

Thanks
# 2  
Old 03-29-2010
One approch.

Code:
print "Non-zero"  if  int(join "", values(%q));

# 3  
Old 03-29-2010
Quote:
Originally Posted by dennis.jacob
One approch.

Code:
print "Non-zero"  if  int(join "", values(%q));

Thanks, it works Smilie
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Programming

PERL: In a perl-scripttTrying to execute another perl-script that SETS SOME VARIABLES !

I have reviewed many examples on-line about running another process (either PERL or shell command or a program), but do not find any usefull for my needs way. (Reviewed and not useful the system(), 'back ticks', exec() and open()) I would like to run another PERL-script from first one, not... (1 Reply)
Discussion started by: alex_5161
1 Replies

2. Shell Programming and Scripting

Perl combine multiple map statements

I have a file like file. file.TODAY.THISYEAR file.TODAY.LASTYEARI want to substitute the words in caps with their actual values so that output should look like file.140805 file.140805.2014 file.140805.2013For this I am reading the file line bye line in an array and using multiple map... (1 Reply)
Discussion started by: sam05121988
1 Replies

3. Shell Programming and Scripting

Combine multiple unique lines from event log text file into one line, use PERL or AWK?

I can't decide if I should use AWK or PERL after pouring over these forums for hours today I decided I'd post something and see if I couldn't get some advice. I've got a text file full of hundreds of events in this format: Record Number : 1 Records in Seq : ... (3 Replies)
Discussion started by: Mayday22
3 Replies

4. Shell Programming and Scripting

Combine two regular expression perl

Dear All, my $tmp="*3f4#_#33#" if ($tmp =~ tr/*// > 1 || $tmp =~ tr/#// > 2) { print "yes"; } any possible to combine both regular expression into one? Thanks (3 Replies)
Discussion started by: jimmy_y
3 Replies

5. Shell Programming and Scripting

Perl: combine Backtick & system() I/O operation?

Hi - Within perl I want to execute a system command. I want to re-direct all the output from the command to a file (@result = `$cmd`;), but I ALSO want the results to be displayed on the screen (system("$cmd"); The reason is this - if the command completes, I want to process the output. If the... (6 Replies)
Discussion started by: jeffw_00
6 Replies

6. Shell Programming and Scripting

combine

Hi I am having text file like this 001|ramu|hno221|>< sheshadripuram|delhi|560061>< 002|krishna|hno225|>< newdelhimain|delhi|560061>< i want to combine every two lines as single...line... i.e 001|ramu|hno221|sheshadripuram|delhi|560061 can u pls help me (3 Replies)
Discussion started by: suryanarayana
3 Replies

7. Shell Programming and Scripting

perl: reg.expr: combine starting and ending removal in one exprecion

Hello, I am new in perl and in regular exprecion; so I am looking for help (or an experienced advise.) The target is a triming spaces from a string: i.e., remove spases from begining and from end of a string. One of main point of a searched solution is performance: for current task it is... (2 Replies)
Discussion started by: alex_5161
2 Replies

8. Shell Programming and Scripting

combine two perl lines into a single perl command

Hi Everyone, i have a string 00:44:40 so: $tmp=~ s/://gi; $tmp=~s/({2})({2})({2})/$1*3600+$2*60+$3/e; the output is 2680. Any way to combine this two lines into a single line? Thanks (4 Replies)
Discussion started by: jimmy_y
4 Replies

9. Shell Programming and Scripting

Perl - combine two xml files

Hi, I am very new to Perl scripting. I would like to how how do I pull out a group of repeated lines from one XML file and paste it into another file. I know it might be something simple, but as I said, I am very new and trying to figure out. Any help, greatly appreciated. Thanks, N M (2 Replies)
Discussion started by: nmadpl
2 Replies

10. UNIX for Dummies Questions & Answers

sed or grep or perl combine two lines

how do i search for the phrase "expected" on line one and "received" on line two. (there is a newline in between the two) I would like to know if/how this can be done in perl and/or grep and/or sed (3 Replies)
Discussion started by: artjaniger
3 Replies
Login or Register to Ask a Question