CGI/Perl Guide | Learning Center | Forums | Advertise | Login
Site Search: in

  Main Index MAIN
INDEX
Search Posts SEARCH
POSTS
Who's Online WHO'S
ONLINE
Log in LOG
IN

Home: Perl Programming Help: Beginner:
Get value in single quote

 



askforunix
New User

Jan 17, 2013, 4:47 AM

Post #1 of 3 (913 views)
Get value in single quote Can't Post

I am trying to create a script in linux but facing some problem.

In single quote, i cannot get any value from outside as per rule.

Suppose my raw data is

134 PTR server1.example.com.
135 PTR server2.example.com.

and i want to change it to

134.0.168.192.in-addr.arpa. PTR server1.example.com.
135.0.168.192.in-addr.arpa. PTR server2.example.com.

below value get always change

0.168.192

so i have set one variable i.e.

VALUE=0.168.192

if i use this command then it is not taking value. Can we achieve this with perl ?

cat file.txt | awk '{print $1".$VALUE.in-addr.arpa.", $2, $3}'

so please suggest


Laurent_R
Veteran / Moderator

Jan 17, 2013, 5:06 AM

Post #2 of 3 (910 views)
Re: [askforunix] Get value in single quote [In reply to] Can't Post

What about using double quotes?

Something like: $value = "0.168.192";


FishMonger
Veteran / Moderator

Jan 17, 2013, 8:23 AM

Post #3 of 3 (906 views)
Re: [askforunix] Get value in single quote [In reply to] Can't Post

perl -pe 's/^(\d+)/$1.0.168.192.in-addr.arpa/' file.txt


(This post was edited by FishMonger on Jan 17, 2013, 8:24 AM)

 
 


Search for (options) Powered by Gossamer Forum v.1.2.0

Web Applications & Managed Hosting Powered by Gossamer Threads
Visit our Mailing List Archives