Solved

Using perl script to extract data

Posted on 2013-12-16
1
397 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
Comment Utility
#!/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

What Is Threat Intelligence?

Threat intelligence is often discussed, but rarely understood. Starting with a precise definition, along with clear business goals, is essential.

Join & Write a Comment

A metadevice consists of one or more devices (slices). It can be expanded by adding slices. Then, it can be grown to fill a larger space while the file system is in use. However, not all UNIX file systems (UFS) can be expanded this way. The conca…
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 navigate the file tree with the shell. Use pwd to print the current working directory: Use ls to list a directory's contents: Use cd to change to a new directory: Use wildcards instead of typing out long directory names: Use ../ to move…

763 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

9 Experts available now in Live!

Get 1:1 Help Now