PERL: an OR inside an IF .. im stuck


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting PERL: an OR inside an IF .. im stuck
# 1  
Old 05-21-2010
PERL: an OR inside an IF .. im stuck

Hi all,

I basically have an if statement that says if you have more than 5 changes you need to have the force flag set to 1 to proceed. like this


Code:
if ((($Changes > 5) && ($force ==  1)) || (($nChanges > 0) && ($Changes < 6))) {

I now need to allow the force flag to be either 1 or 2 to proceed

could somebody advise me how i can go about making the $force bit highlighted above 1 or 2

e.g.

&& ($force == 1 or 2))

ive tried a series of combinations but i just cant seem to find something that works hence posting here.

any help would be great
# 2  
Old 05-21-2010
Code:
( $force == 1 || $force == 2 )

something like this, am not sure ? Smilie
# 3  
Old 05-21-2010
thanks for that (apologies for the basic question)
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Use of sed inside perl

$string="test.binary.value"; $toggle="test.binary.value=true"; host=test.server.com my $returnCode = system ( "ssh $host 'cp -p /tmp/testfile /tmp/testfile.bkup; sed -i 's/\$string.*/\$toggle/g' /tmp/testfile'" ); cat testfile test.binary.value=false Scenario: I am trying to... (3 Replies)
Discussion started by: Tuxidow
3 Replies

2. Shell Programming and Scripting

Perl inside shell

I am trying to find out the difference between two dates, for which I am using perl inside SHELL. Below are my codes. perl -MDate -e 'Date::Calc qw(Delta_DHMS);' perl -e '($Dd,$Dh,$Dm,$Ds) = Delta_DHMS($year1,$month1,$day1, $hour1,$min1,$sec1, $year2,$month2,$day2, $hour2,$min2,$sec2)' But... (6 Replies)
Discussion started by: sauravrout
6 Replies

3. Shell Programming and Scripting

Search inside a file, PERL

HEllo!! I need a script in perl that see inside a file(file.txt) that has only one row. The row contains only this text: logs_yearly = 20120628113345 I want that the script does this: "Search in the file, if the date 20120628 is actual date" Thank you!! ---------- Post... (4 Replies)
Discussion started by: super_sun
4 Replies

4. Shell Programming and Scripting

perl inside shell script?

Hi UNIX Pros! Newbie here, I would like to ask if it is possible to use perl commands inside a shell script? i created a simple script which connects to oracle and run queries which the script saves to a separate .txt file for each query issued. What i want to do is to create a presentable and... (7 Replies)
Discussion started by: 4dirk1
7 Replies

5. Shell Programming and Scripting

perl loop keeps getting stuck

I am using a Perl script to open a series of files in a loop, separate the paragraph into lines, and output the lines into a new file. The code works perfectly fine, except when the source file is over a certain size the loop gets stuck and won’t move on to the next file. It still does what it is... (0 Replies)
Discussion started by: renthead720
0 Replies

6. Shell Programming and Scripting

Using Perl Inside KSH

Hi there, I am new to Perl and KSH. The system I am using picks up the KSH scripts and uses them in a batch job control system. I am trying to set a variable from a perl command #!/bin/ksh -eaxp #******************************************************************************* # Testing... (5 Replies)
Discussion started by: SaadLive
5 Replies

7. Shell Programming and Scripting

doing grep inside perl file

Hi have one Perl file inside that i am defining at an array file. @temp_vmdk_files = `grep vmdk '$guest_vmx'` where my $guest_vmx=/vmfs/volumes/47e40fec-9c8bb7f7-d076-001422159f8a/BES Exchange/BES-Exchange.vmx and i am just want to do grep of "vmdk" files from the above path but when... (5 Replies)
Discussion started by: bp_vardhaman
5 Replies

8. Shell Programming and Scripting

Run the command inside perl script

I have a command which will run fine in a unix command prompt. Can you tell how to interprete this command inside perl script...... The command is : perl -pe 's/(\|333\}.*)\}$/$1|1.6}/' FIA.txt This will search for the number 333 and appends 1.6 at the end of that line....... (1 Reply)
Discussion started by: vinay123
1 Replies

9. Shell Programming and Scripting

calling a C executable from inside a Perl script

here's the Perl code snippet... how can i call my C executable 'porter-stemmer' and pass it $1 as an argument? Thanks for the help! # Read through the original topic set, and modify based on the current # pre-processing options while (<TOPIC_ORIG>) { # Run pre-processing over only the... (3 Replies)
Discussion started by: mark_nsx
3 Replies

10. Shell Programming and Scripting

stuck in perl cgi to upload a file to server

hi, i m working on a perl cgi script which uploads a file to the server. i m stuck. i hav written the errors. plz help. Sachin Kaw ______________________________________________________________________ #!/usr/bin/perl -w use CGI; use CGI qw(:standard); use strict; use POSIX... (4 Replies)
Discussion started by: sachin_kaw
4 Replies
Login or Register to Ask a Question