I am trying to match mulitple (3) variables. I found the sub given below on the web which works well when all vars are defined. But there are situations where one or two will not be defined (at least one will always be defined.)
Example of the variable content possibilities
Quote:
$p = 1676:790 #works good with sub
$l = 1676:790
$r = 1676:790
$p = 1676:790 #works good with sub
$l = 1763:890
$r = 1676:790
$p = 1676:790 #doesnt work as expected.
$l
$r
$p = 1676:790 #doesnt work as expected. Gives the "not" response when It should actually be "ok."
$l = 1676:790
$r
The sub found on the web.
If only one var is defined, then I dont want to do anything (no other var to compare)
If 2 or more vars are defined compare them, ignore the undefined.
What is known as variable substitution is your friend for such cases, you substitue a default value rather then ending with a variable not set.
Syntax:
Addendum:
Sorry I should have read to the end - Did not see you were in perl...
... But there are situations where one or two will not be defined (at least one will always be defined.)
...
If only one var is defined, then I dont want to do anything (no other var to compare)
If 2 or more vars are defined compare them, ignore the undefined.
If all 3 vars are defined compare them.
...
If only one var is defined, I assume you want to throw an exception.
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)
Hi All,
I need to read values of 10 columns from oracle query and assign the same to 10 unix variables. The query will return only one record(row).
I tried to append all these columns using a delimiter(;) in the select query and assign the same to a single variable(V) in unix. I thought I... (3 Replies)
Hello,
I would like to ask for help with csh script.
An example of an input in .txt file is below, the number of lines varies from file to file and I have 2 or 3 columns with values. I would like to read all the values (probably one by one) and set them to independent unique variables that... (7 Replies)
Hi All,
i have a requirement where i have to run a script with at least 25 arguements and position of arguements can also change. the unapropriate way is like below. can we achieve this in more good and precise way??
#!/bin/ksh
##script is sample.ksh
age=$1
gender=$2
class=$3
.
.
.... (3 Replies)
Dear Perl users,
Could somebody help me how to fix my code so I can get my desired output.
Here is the data:
Pattern Gabriel
halo1
halo2
end
Pattern Andreas
halo1
halo2
endI want to grep multiple lines between the pattern /Pattern Gabriel / and /end/.
Then I will store the output into... (6 Replies)
hi
i am writing a hangman script and am having trouble checking the correct letters against the word
i need the script to compare the word against the letters guessed that are correct so once all the letters within the word have been guessed it will alow me to create a wining senario
eg
... (3 Replies)
I am completely new to perl programming. My father is helping me learn said programming language. However, I am stuck on one of the assignments he has given me, and I can't find very much help with it via google, either because I have a tiny attention span, or because I can be very very dense.
... (4 Replies)
I need a way to extract data from
X 4T Solution 21 OCT 2011 37 .00
to account 12345678 User1 user2
X 4T Solution Solution Unlimited 11 Sep 2009 248 .00
to account 87654321 user3 user4
I need it to extract 'X' '37.00' and account number 12345678.
I have extracted above stuff... (3 Replies)
Hi everyone, and thank you for your help with this. I am VERY new with perl so all of your help is appreciated. I have tried google but as I don't know the proper terms to search for and could be daunting for a newbie scripter... I know this is very easy for most of you! Thanks!
I have a... (4 Replies)