Sponsored Content
Top Forums Shell Programming and Scripting Replacing variable value in perl script Post 302407316 by tententen on Thursday 25th of March 2010 05:55:01 AM
Old 03-25-2010
Question Replacing variable value in perl script

hi I have this line in my perl script

Code:
 
if (($cookie =~ /^cookie(.*)\/(.*)/) && ($ !~ /^cookie(10)\/(.*)|/)) {
                        $cookienumber = "$1.$2";
                        }

now if the result is cookie1/0,

my $cookienumber would be 1.0

but if the result is cookie1/0/0

my $cookienumber would be 1/0.0

how can I replace the variable for result 1/0.0 to 1.0.0?

How can I change $1 value from 1/0 to 1.0?

Please help thanks

---------- Post updated at 05:55 PM ---------- Previous update was at 05:30 PM ----------

Quote:
Originally Posted by tententen
hi I have this line in my perl script

Code:
 
if (($cookie =~ /^cookie(.*)\/(.*)/) && ($ !~ /^cookie(10)\/(.*)|/)) {
                        $cookienumber = "$1.$2";
                        }

now if the result is cookie1/0,

my $cookienumber would be 1.0

but if the result is cookie1/0/0

my $cookienumber would be 1/0.0

how can I replace the variable for result 1/0.0 to 1.0.0?

How can I change $1 value from 1/0 to 1.0?

Please help thanks
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Perl script variable passed to Oracle query

Hi All, I pass a Perl script variable, whch is passed to a query to be prepared. But the problem is I have special character like '&' in this variable which are handled in a special way by the Oracle query parser. How do I get over this? my $cust_name='A&B'; my $sql="Select cust_short_name... (1 Reply)
Discussion started by: rahulrathod
1 Replies

2. Shell Programming and Scripting

replacing a number with random variable inside shell script

Hi All. I need help for the below logic. I ve a file like following input file: NopTX(5) // should be remain same as input ----Nop(@100); //1 Nop(90); //2 --Nop(80); //3 @Nop(70); //4 --@Nop(60); //5 @Nop@(@50); //6 --Nop@( 40); ... (3 Replies)
Discussion started by: user_prady
3 Replies

3. Shell Programming and Scripting

visibility of a variable in Perl script.

I am writing a script to cross check the dbscript. For that I am searching the SQL manipulators in the dbscript as shown below. But my problem is the variable $pattern is coming as null when comes out of the foreach loop. File content: ========= vi /home2/niroj_p/dbscript.sql -------... (1 Reply)
Discussion started by: Niroj
1 Replies

4. Shell Programming and Scripting

How to return a value of a variable from shell script to perl script

HI , Is there any way to return a value of variable from shell to perl script. Code: === Perl file my $diff1=system("sh diff.sh"); my $diff2=system("sh diff1.sh"); I need exit status of below commands i.e 0 and 1 respectively. Since in both the cases diff is working so system... (3 Replies)
Discussion started by: srkelect
3 Replies

5. Shell Programming and Scripting

Increment a date variable in perl script

Hi, I have a perl script which prints epoch value of date in milliseconds as the output. My reuirement is that once the output is printed,the day variable shld increment by 1 and when i execute the script for the second time the output shld be for the new day value. My script looks as... (11 Replies)
Discussion started by: jyothi_wipro
11 Replies

6. Shell Programming and Scripting

Perl Variable Check Script

I am working on a perl script that is used to update a list of hosts to a certain file but I am having an issue when I try to perform a check to make sure the user enters valid information. The following is what I have currently written for the script: IPINPUT: print "Enter IP Address: ";... (2 Replies)
Discussion started by: Takau
2 Replies

7. Shell Programming and Scripting

Replacing strings in perl script

HI all, These are examples of the original value from a variable $abc can be FastEthernet1/0 GigabitEthernet3/1 Serial1/0 If $abc is FastEthernet*/* (where * can be any number), replace $abc value to fa*/* (same number as the original value). GigabitEthernet becomes ga*/* and Serial... (2 Replies)
Discussion started by: tententen
2 Replies

8. Shell Programming and Scripting

Using variable from shell script in perl file

Hey, So I have a shell script that outputs some variables, call them $a and $b. I know in shell scripting if I wanted to use the variables in another shell script I'd do sh code.sh "$a" "$b" How can I do something similar with perl? (2 Replies)
Discussion started by: viored
2 Replies

9. Shell Programming and Scripting

Passing variable from bash to perl script

Hi All, I need to pass a variable from bash script to perl script and in the perl script i am using those variables in the sql query but its giving error : Use of uninitialized value $ENV{"COUNTRYCD"} in concatenation (.) or string at /GIS_ROOT/custom/tables/DBread_vendor.pl line 50. Can ... (6 Replies)
Discussion started by: NileshJ
6 Replies

10. UNIX for Beginners Questions & Answers

Perl one liner in bash script not replacing hours and minutes [HH:MM]

Hi I want to replace time stamp in the following line PROCNAME.Merge.exchMon.CODE.T_QSTART 08:45 read assuming the new time stamp is 09:45 ; the line is getting replaced as below :45 read I'm trying to use the perl one liner in bash script perl -pi... (4 Replies)
Discussion started by: charlie87
4 Replies
ldi_ev_get_type(9F)					   Kernel Functions for Drivers 				       ldi_ev_get_type(9F)

NAME
ldi_ev_get_type - get event name string from event cookie SYNOPSIS
#include <sys/sunldi.h> int ldi_ev_get_type(ldi_ev_cookie_t cookie); INTERFACE LEVEL
Solaris DDI specific (Solaris DDI) PARAMETERS
ldi_ev_cookie_t cookie An opaque event cookie for the event type returned by a previous call to ldi_ev_get_cookie(9F). DESCRIPTION
The ldi_ev_get_type() function returns the event string represented by the LDI event cookie "cookie". RETURN VALUES
On success, this function returns the event string represented by "cookie". On failure, this function returns NULL. CONTEXT
This function can be called from user and kernel contexts only. SEE ALSO
ldi_ev_get_cookie(9F), ldi_ev_register_callbacks(9F), ldi_ev_remove_callbacks(9F) SunOS 5.11 21 Aug 2007 ldi_ev_get_type(9F)
All times are GMT -4. The time now is 08:39 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy