Solved

Using perl script to extract data

Posted on 2013-12-16
1
399 Views
Last Modified: 2013-12-16
I have lines of text like this:

LINE="dn:cn=mysdsp_rx8e,cn=oraclecontext,dc=hit,dc=com,dc=hkorclnetdescstring:(description=(address_list=(address=(protocol=tcp)(host=rx800e)(port=15023)))(connect_data(sid=mysdsp)))"

Pls help to write a perl program to:

perl get_data "${line}" "cn="    -> mysdsp_rx8e  oraclecontext   { notice 2 values return}
perl get_data "${line}" "host=" -> rx800e
perl get_data "${line}" "sid=" -> mysdsp
0
Comment
Question by:tindavid
1 Comment
 
LVL 84

Accepted Solution

by:
ozo earned 300 total points
ID: 39720983
#!/usr/bin/perl
use warnings;
use strict;
die qq{Usage: $0 "\${line}" cn=|host=|sid=\n} unless @ARGV==2;
print join(" ",$ARGV[0]=~/\b$ARGV[1]([^,()]+)/g),$/;
0

Featured Post

ScreenConnect 6.0 Free Trial

Explore all the enhancements in one game-changing release, ScreenConnect 6.0, based on partner feedback. New features include a redesigned UI, app configurations and chat acknowledgement to improve customer engagement!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Hyper-threading config in Solaris 6 136
dot directory in FreeBSD??? 4 80
check unix curl command return value 7 117
Unix Script: Loop over all days of a month 17 99
In tuning file systems on the Solaris Operating System, changing some parameters of a file system usually destroys the data on it. For instance, changing the cache segment block size in the volume of a T3 requires that you delete the existing volu…
Installing FreeBSD… FreeBSD is a darling of an operating system. The stability and usability make it a clear choice for servers and desktops (for the cunning). Savvy?  The Ports collection makes available every popular FOSS application and packag…
Learn several ways to interact with files and get file information from the bash shell. ls lists the contents of a directory: Using the -a flag displays hidden files: Using the -l flag formats the output in a long list: The file command gives us mor…
Learn how to find files with the shell using the find and locate commands. Use locate to find a needle in a haystack.: With locate, check if the file still exists.: Use find to get the actual location of the file.:

777 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question