GreenLake Administration
- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- Re: PERL Question
Operating System - HP-UX
1848296
Members
7503
Online
104024
Solutions
Forums
Categories
Company
Local Language
back
Forums
Discussions
Forums
- Data Protection and Retention
- Entry Storage Systems
- Legacy
- Midrange and Enterprise Storage
- Storage Networking
- HPE Nimble Storage
Discussions
Forums
Discussions
Discussions
Forums
Discussions
back
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Blogs
Information
Community
Resources
Community Language
Language
Forums
Blogs
Topic Options
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-25-2004 07:54 AM
10-25-2004 07:54 AM
PERL Question
I am trying to extract a piece of code from a number of files in a directory.
It looks a little something like this:
STATUS: CLOSED
ABSTRACT:
THIS EFFORT INVOLVES RESEARCHING THE STATE OF THE ART TRACKING ASSET
TRACKING TECHNOLOGIES WITH SPECIAL EMPHASIS ON REUSABLE CONTAINERS/PACKING
AND PACKAGING SUPPLIES.
CONTRACT SPECIALIST: CHUCK
There are a series of other fields in the file. I have split the values on the left and right side of the colon and place them into a hash (each file is a unique number for the key of the hash). I am having trouble figuring out the best way to extract everything from the right side of the ABSTRACT colon down to the beginning of CONTRACT SPECIALIST. Eventually these values will go into a Oracle database. Any help would be greatly appreciated.
Thanks
Scott
It looks a little something like this:
STATUS: CLOSED
ABSTRACT:
THIS EFFORT INVOLVES RESEARCHING THE STATE OF THE ART TRACKING ASSET
TRACKING TECHNOLOGIES WITH SPECIAL EMPHASIS ON REUSABLE CONTAINERS/PACKING
AND PACKAGING SUPPLIES.
CONTRACT SPECIALIST: CHUCK
There are a series of other fields in the file. I have split the values on the left and right side of the colon and place them into a hash (each file is a unique number for the key of the hash). I am having trouble figuring out the best way to extract everything from the right side of the ABSTRACT colon down to the beginning of CONTRACT SPECIALIST. Eventually these values will go into a Oracle database. Any help would be greatly appreciated.
Thanks
Scott
- Tags:
- Perl
3 REPLIES 3
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-25-2004 08:58 AM
10-25-2004 08:58 AM
Re: PERL Question
In this type of situation you need to determine when the block of text begins and when it ends. It begins after "ABSTRACT" and ends prior to "CONTRACT SPECIALIST".
A program reading through the file might set a flag to indicate when it is accumulating the lines for the ABSTRACT and when the end of the ABSTRACT occurs, put those lines into your hash table.
I hope I understood what your question...
-- Rod Hills
A program reading through the file might set a flag to indicate when it is accumulating the lines for the ABSTRACT and when the end of the ABSTRACT occurs, put those lines into your hash table.
I hope I understood what your question...
-- Rod Hills
There be dragons...
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-25-2004 09:26 AM
10-25-2004 09:26 AM
Re: PERL Question
lt09:/tmp 119 > perl -ne's/^(\w.*?)://and$k=$1;$h{$k}.=$_}END{print"[[$_]]\n--$h{$_}"for keys%h' file
[[ABSTRACT]]
--
THIS EFFORT INVOLVES RESEARCHING THE STATE OF THE ART TRACKING ASSET
TRACKING TECHNOLOGIES WITH SPECIAL EMPHASIS ON REUSABLE CONTAINERS/PACKING
AND PACKAGING SUPPLIES.
[[STATUS]]
-- CLOSED
[[CONTRACT SPECIALIST]]
-- CHUCK
lt09:/tmp 120 >
Enjoy, Have FUN! H.Merijn
[[ABSTRACT]]
--
THIS EFFORT INVOLVES RESEARCHING THE STATE OF THE ART TRACKING ASSET
TRACKING TECHNOLOGIES WITH SPECIAL EMPHASIS ON REUSABLE CONTAINERS/PACKING
AND PACKAGING SUPPLIES.
[[STATUS]]
-- CLOSED
[[CONTRACT SPECIALIST]]
-- CHUCK
lt09:/tmp 120 >
Enjoy, Have FUN! H.Merijn
Enjoy, Have FUN! H.Merijn
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-25-2004 09:54 PM
10-25-2004 09:54 PM
Re: PERL Question
Scott,
You can try the following PERL script.
In the script, replace with your filename within codes.
%hashArr;
open(FILE,)||die("Cannot open file");
$line =;
while(defined($line)){
if(length($line)>1)
{
if(($line) =~ /:/)
{
($key,$val)=split(/:/,$line);
}
else
{
$val=$line;
}
}
if(length($key)>1 && length($val) >1)
{
$hashArr{$key}=$val;
}
$line=;
}
foreach $key (keys %hashArr) {
print "\$hashArr{$key} = $hashArr{$key}\n";
}
This script will store the data in a Hash (key,value pair).
After doing this, you can connect to Oracle & store the values.
Hope this helps you.
Geetha
You can try the following PERL script.
In the script, replace
%hashArr;
open(FILE,
$line =
while(defined($line)){
if(length($line)>1)
{
if(($line) =~ /:/)
{
($key,$val)=split(/:/,$line);
}
else
{
$val=$line;
}
}
if(length($key)>1 && length($val) >1)
{
$hashArr{$key}=$val;
}
$line=
}
foreach $key (keys %hashArr) {
print "\$hashArr{$key} = $hashArr{$key}\n";
}
This script will store the data in a Hash (key,value pair).
After doing this, you can connect to Oracle & store the values.
Hope this helps you.
Geetha
The opinions expressed above are the personal opinions of the authors, not of Hewlett Packard Enterprise. By using this site, you accept the Terms of Use and Rules of Participation.
Company
Events and news
Customer resources
© Copyright 2026 Hewlett Packard Enterprise Development LP