Go Premium for a chance to win a PS4. Enter to Win

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 405
  • Last Modified:

Using perl script to extract data

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
tindavid
Asked:
tindavid
1 Solution
 
ozoCommented:
#!/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

Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now