Solved

Using perl script to extract data

Posted on 2013-12-16
1
398 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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
error while running the scirpt 24 125
Samsung memory install did'nt recognize by new hardware 5 25
nodeip 9 75
Convert OverPunch 25 62
Hello fellow BSD lovers, I've created a patch process for patching openjdk6 for BSD (FreeBSD specifically), although I tried to keep all BSD versions in mind when creating my patch. Welcome to OpenJDK6 on BSD First let me start with a little …
Attention: This article will no longer be maintained. If you have any questions, please feel free to mail me. jgh@FreeBSD.org Please see http://www.freebsd.org/doc/en_US.ISO8859-1/articles/freebsd-update-server/ for the updated article. It is avail…
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.:

920 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

Need Help in Real-Time?

Connect with top rated Experts

17 Experts available now in Live!

Get 1:1 Help Now