Solved

Using perl script to extract data

Posted on 2013-12-16
1
402 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

When you do backups in the Solaris Operating System, the file system must be inactive. Otherwise, the output may be inconsistent. A file system is inactive when it's unmounted or it's write-locked by the operating system. Although the fssnap utility…
My previous tech tip, Installing the Solaris OS From the Flash Archive On a Tape (http://www.experts-exchange.com/articles/OS/Unix/Solaris/Installing-the-Solaris-OS-From-the-Flash-Archive-on-a-Tape.html), discussed installing the Solaris Operating S…
This video shows how to set up a shell script to accept a positional parameter when called, pass that to a SQL script, accept the output from the statement back and then manipulate it in the Shell.
In a previous video, we went over how to export a DynamoDB table into Amazon S3.  In this video, we show how to load the export from S3 into a DynamoDB table.
Suggested Courses

752 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