Sponsored Content
Top Forums Shell Programming and Scripting Pulling data from a standard comment block - perl Post 302300572 by spirtle on Tuesday 24th of March 2009 01:05:44 PM
Old 03-24-2009
Since you are using Perl and I don't know much sed, here's some perl to extract the description.
I guess your biggest problem will be identifying where the description ends. In the following I have put that task into a subroutine so that it can be easily modified and
for starters I assume that a line with only a # on it ends the description.
Code:
foreach my $curapplication ( @curdirectory ){

  unless( open( SRC, "<$curapplication") ) {
    print "Failed to open $curapplication: $!\n";
    next;
  }

  sub description_start {
    $_[0] =~ /^\#\s*Description:/;
  }  

  sub description_end {
    $_[0] =~ /^\#\s*$/;
  }

  my $description = 0;
  while( <SRC> ){
    description_start( $_ ) and $description = 1 and next;
    if( $description ) {
      description_end( $_ ) and $description = 0 and last;
      s/^\#//;
      print;
    }
  }
}

 

9 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Pulling data and following lines from file

I saw a few posts close to what i want to do, but they didn't look like they would work exactly.. or I need to think out of the box on this. I have a file that I keep server stats in for my own performance analysis. this file has the output from many commands in it (uptime, vmstats, ps, swap... (2 Replies)
Discussion started by: MizzGail
2 Replies

2. Shell Programming and Scripting

Block Comment in Shell script

how to put multiline comments in a shell script like /* Some code */ in C language? (3 Replies)
Discussion started by: skyineyes
3 Replies

3. Shell Programming and Scripting

SFTP to server, pulling data and removing the data

Hi all, I have the following script, but are not too sure about the syntax to complete the script. In essence, the script must connect to a SFTP server at a client site with username and password located in a file on my server. Then change to the appropriate directory. Pull the data to the... (1 Reply)
Discussion started by: codenjanod
1 Replies

4. Shell Programming and Scripting

Help with pulling / filtering data from a .csv

Good day Gurus, I have a csv file that contains an inventory of active servers. This csv file contains a well over a hundred systems (IBM, SUN, HP). It also contains those systems details. See below for an example hostA,invver,1.02,20100430 hostA,date,08/30/2010,06:18 hostA,use,"Unknown... (4 Replies)
Discussion started by: LuffyDMonkey
4 Replies

5. Shell Programming and Scripting

Pulling data by GPS coordinates from text file

Hi there, I'm having a problem trying to extract data from within a text file. I'm trying to extract this manually for a lack of better words. I need any items that fall within latitude 36.5 to 39.5 and long -75.3 to -83.9 I have been doing this using cat neta.txt | grep '!38' and working... (6 Replies)
Discussion started by: Mikey
6 Replies

6. Shell Programming and Scripting

Pulling data from xml

Hi there, Please could anyone help with this. I have an xml file that contains repeating values eg <Rule name> AAAAA <Action> BBBBB </Action> <Data> CCCCC </Data> <Type> DDDDD </Type> </Rule name> <Rule name> A1A1A1A1 <Action> B1B1B1B1 </Action> <Data> C1C1C1C </Data> <Type>... (4 Replies)
Discussion started by: ssideel
4 Replies

7. Shell Programming and Scripting

BASH- Need help pulling data from .emlx

Hello, fellow computer junkies. First time poster! My boss wrote an application (Mavericks 10.9, Mountain Lion 10.8) that checks a user's security settings. The user runs the application, then it spits out an email that is sent back to our inbox showing the results. On our end, we have a mail rule... (5 Replies)
Discussion started by: sudo
5 Replies

8. Shell Programming and Scripting

Pulling Data, Then Moving to the Next File

I'm scanning a list of emails- I need to pull 2 pieces of data, then move to the next file: Sender's Email Address Email Date I need these to be outputted into a single column- separated by a ",". Like this: Email1's Address, Email1's Date Stamp Email2's Address, Email2's Date Stamp... (4 Replies)
Discussion started by: sudo
4 Replies

9. Shell Programming and Scripting

Pulling information from a data file by date

awk -v now="$(date +%s)" -v tDiff="${USERMINUTES}" ' BEGIN { FS="=" if (!now) now=systime() if (!tDiff) tDiff=60*60 p=1 } /{/ {rec=$0;p=1;next} /}/ && rec && p {print rec ORS $0;next} $1=="entry_time" { if (now-$2>tDiff)p=0 } {rec=rec ORS $0}'... (6 Replies)
Discussion started by: SkySmart
6 Replies
Net::UPnP::Device(3pm)					User Contributed Perl Documentation				    Net::UPnP::Device(3pm)

NAME
Net::UPnP::Device - Perl extension for UPnP. SYNOPSIS
use Net::UPnP::ControlPoint; my $obj = Net::UPnP::ControlPoint->new(); @dev_list = $obj->search(st =>'upnp:rootdevice', mx => 3); $devNum= 0; foreach $dev (@dev_list) { $device_type = $dev->getdevicetype(); if ($device_type ne 'urn:schemas-upnp-org:device:MediaServer:1') { next; } print "[$devNum] : " . $dev->getfriendlyname() . " "; unless ($dev->getservicebyname('urn:schemas-upnp-org:service:ContentDirectory:1')) { next; } $condir_service = $dev->getservicebyname('urn:schemas-upnp-org:service:ContentDirectory:1'); unless (defined(condir_service)) { next; } %action_in_arg = ( 'ObjectID' => 0, 'BrowseFlag' => 'BrowseDirectChildren', 'Filter' => '*', 'StartingIndex' => 0, 'RequestedCount' => 0, 'SortCriteria' => '', ); $action_res = $condir_service->postcontrol('Browse', \%action_in_arg); unless ($action_res->getstatuscode() == 200) { next; } $actrion_out_arg = $action_res->getargumentlist(); unless ($actrion_out_arg->{'Result'}) { next; } $result = $actrion_out_arg->{'Result'}; while ($result =~ m/<dc:title>(.*?)</dc:title>/sgi) { print " $1 "; } $devNum++; } DESCRIPTION
The package is used a object of UPnP device. METHODS
getdescription - get the description. $description = $dev->getdescription( name => $name # undef ); Get the device description of the SSDP location header. The function returns the all description when the name parameter is not specified, otherwise return a value the specified name. getdevicetype - get the device type. $description = $dev->getdevicetype(); Get the device type from the device description. getfriendlyname - get the device type. $friendlyname = $dev->getfriendlyname(); Get the friendly name from the device description. getmanufacturer - get the manufacturer. $manufacturer = $dev->getmanufacturer(); Get the manufacturer name from the device description. getmanufacturerrul - get the manufacturer url. $manufacturer_url = $dev->getmanufacturerrul(); Get the manufacturer url from the device description. getmodeldescription - get the model description. $model_description = $dev->getmodeldescription(); Get the model description from the device description. getmodelname - get the model name. $model_name = $dev->getmodelname(); Get the model name from the device description. getmodelnumber - get the model number. $model_number = $dev->getmodelnumber(); Get the model number from the device description. getmodelurl - get the model url. $model_url = $dev->getmodelurl(); Get the model url from the device description. getserialnumber - get the serialnumber. $serialnumber = $dev->getserialnumber(); Get the model description from the device description. getudn - get the device UDN. $udn = $dev->getudn(); Get the UDN from the device description. getupc - get the device UPC. $upc = $dev->getupc(); Get the UPC from the device description. getservicelist - get the device type. @service_list = $dev->getservicelist(); Get the service list in the device. Please see Net::UPnP::Service too. SEE ALSO
Net::UPnP::Service AUTHOR
Satoshi Konno skonno@cybergarage.org CyberGarage http://www.cybergarage.org COPYRIGHT AND LICENSE
Copyright (C) 2005 by Satoshi Konno It may be used, redistributed, and/or modified under the terms of BSD License. perl v5.10.1 2009-07-27 Net::UPnP::Device(3pm)
All times are GMT -4. The time now is 10:22 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy