Re: Extracting value from regex

2016-06-09 Thread Shlomi Fish
Hi Punit, see below for my reply. On Thu, 9 Jun 2016 14:17:17 +0530 Punit Jain wrote: > Hi , > > Below is the problem I am facing : > > #!/usr/bin/perl > Always start your program with "use strict;" and "use warnings;" or equivalent. See: * http://perl-begin.org/tutorials/bad-elements/ >

Re: Extracting value from regex

2016-06-09 Thread Neil Bowers
Hi Punit, > /ldap:\/\/\/(.+)|mailto:(.+)/; > When i run this I get uid=user1,ou=People,o=test.com as > output however don't get y...@gmail.com printed. > The mailto is matched by $2, not $1. You can confirm this by changing your print line

Extracting value from regex

2016-06-09 Thread Punit Jain
Hi , Below is the problem I am facing : #!/usr/bin/perl my @str = ('mailto:y...@gmail.com','ldap:///uid=user1,ou=People,o=test.com '); foreach (@str) { # split off ldaps and mailtos my @addr = $_ =~ /ldap:\/\/\/(.+)|mailto:(.+)/; print $1; } When i run

extracting images and cells from spreadsheet

2015-12-02 Thread lee
Hi, how can I extract images and information from another cell in the same row from a spreadsheet? The spreadsheet is in xls and can be converted to ods (or other formats Libreoffice supports). The sheet has over 1000 rows that look like this: | [image] | irrelevant cell | irrelevant cell | ex

Re: Extracting Columns from tab delimited files

2013-02-11 Thread Tiago Hori
Thanks, Jim. This awesome! T. Sent from my iPhone On 2013-02-11, at 11:49 AM, Jim Gibson wrote: > > On Feb 10, 2013, at 5:57 PM, Tiago Hori wrote: > >> Hi All, >> >> I am trying to force myself to not use one of perl's modules to parse tab >> delimited files (like TXT::CSV), so please be p

Re: Extracting Columns from tab delimited files

2013-02-11 Thread Jim Gibson
On Feb 10, 2013, at 5:57 PM, Tiago Hori wrote: > Hi All, > > I am trying to force myself to not use one of perl's modules to parse tab > delimited files (like TXT::CSV), so please be patient and don't tell me > just to go and use them. I am trying to re-ivent the wheel, so to speak, > because as

Re: Extracting Columns from tab delimited files

2013-02-10 Thread timothy adigun
> my @array = split("\t", $line); > $key = shift(@array); > print $key, "\n"; > push @{ $hash{$key} }, @array; > } > > my $out = join("\t",@{$hash{Row}}); > print $out,"\n"; > print $hash{Row}[1]; > > > close

Extracting Columns from tab delimited files

2013-02-10 Thread Tiago Hori
; That works fine and reads the lines into an array with the elements separated into the hash. So my questions are: is this the best way of accomplishing this two tasks? I am really looking for suggestions to improve what I am doing. Is using the hashes the best way? I am have trying to figure

Re: extracting exif information from images

2012-02-11 Thread Harry Putnam
"John W. Krahn" writes: >> #!/usr/local/bin/perl >> >> use strict; >> use warnings; > > Could it be that your editor is putting a BOM as the first two > characters of your program? It never has before but if so would that show up using the `l' (ell) operator in sed? Or could a BOM sneak right by

Re: extracting exif information from images

2012-02-11 Thread John W. Krahn
Harry Putnam wrote: A brief aside to John K: Harry wrote: Outputs a mess: ./myscript t1.jpg , | sh: 1: Syntax error: Unterminated quoted string | sh: 1: ��:+Y�0y�: not found | sh: 1: �: not found | sh: 1: Syntax error: EOF in backquote substitution | | [...] ` [...] "John W.

Re: extracting exif information from images

2012-02-11 Thread Harry Putnam
Ken Slater writes: Harry wrote: >>  use Image::ExifTool qw(:Public); >> >>  # Simple procedural usage >> >>  # Get hash of meta information tag names/values from an image >>  $info = ImageInfo('a.jpg'); >> >>  # Object-oriented usage >> >>  # Create a new Image::ExifTool objec

Re: extracting exif information from images

2012-02-06 Thread John W. Krahn
Harry Putnam wrote: I've been looking around, googling for a way to extract exif info from images. There are many tools out there. But I wanted to fiddle with the information in very specific ways. I hit on the perl module: Image-ExifTool (Phil Harvey) on cpan. However I am apparently badly mi

Re: extracting exif information from images

2012-02-06 Thread Ken Slater
On Mon, Feb 6, 2012 at 6:59 AM, Harry Putnam wrote: > I've been looking around, googling for a way to extract exif info from > images. There are many tools out there.  But I wanted to fiddle with > the information in very specific ways. > > I hit on the perl module: Image-ExifTool (Phil Harvey) on

extracting exif information from images

2012-02-06 Thread Harry Putnam
I've been looking around, googling for a way to extract exif info from images. There are many tools out there. But I wanted to fiddle with the information in very specific ways. I hit on the perl module: Image-ExifTool (Phil Harvey) on cpan. However I am apparently badly misunderstanding the usa

Re: extracting email addresses from a file

2011-12-06 Thread Brian Fraser
On Tue, Dec 6, 2011 at 2:38 PM, Randal L. Schwartz wrote: > > "Rob" == Rob Coops writes: > > Rob> The biggest problem with email addresses is that the rules of how an > email > Rob> address can be formatted are so relaxed and thus so complex that > there is > Rob> to the best of my knowledge

Re: extracting email addresses from a file

2011-12-06 Thread Randal L. Schwartz
> "Rob" == Rob Coops writes: Rob> The biggest problem with email addresses is that the rules of how an email Rob> address can be formatted are so relaxed and thus so complex that there is Rob> to the best of my knowledge not a single person that has ever managed to Rob> create a 100% correct

Re: extracting email addresses from a file

2011-11-29 Thread Rob Dixon
On 29/11/2011 15:13, Rajeev Prasad wrote: hello, i am trying to extract email address from a afile, but not quite succesful. here is what i have: the file: myterqlqt qntmrq Prqtesm qltul qzeez Smqik qltulqzee...@jmqil.com 976665 myterqlqt qntmrq Prqtesm teepqk Mittql teep...@jmqil.com 939383 O

Re: extracting email addresses from a file

2011-11-29 Thread Rajeev Prasad
thx Sheppy, good enough for me. i am a beginner in perl. From: Sheppy R To: Rob Coops Cc: Rajeev Prasad ; perl list Sent: Tuesday, November 29, 2011 9:54 AM Subject: Re: extracting email addresses from a file Couldn't you just use the non-white

Re: extracting email addresses from a file

2011-11-29 Thread Rob Coops
On Tue, Nov 29, 2011 at 4:54 PM, Sheppy R wrote: > Couldn't you just use the non-whitespace character to capture everything > before and after the @ symbol? > > s/^.*\s(\S+@\S+)\s.*$/$1/ > > > Yes you could of course but... this is why I was saying nearly no syntax checking... the minor check to

Re: extracting email addresses from a file

2011-11-29 Thread Sheppy R
Couldn't you just use the non-whitespace character to capture everything before and after the @ symbol? s/^.*\s(\S+@\S+)\s.*$/$1/

Re: extracting email addresses from a file

2011-11-29 Thread Rob Coops
On Tue, Nov 29, 2011 at 4:13 PM, Rajeev Prasad wrote: > hello, > > i am trying to extract email address from a afile, but not quite > succesful. here is what i have: > > the file: > myterqlqt qntmrq Prqtesm qltul qzeez Smqik qltulqzee...@jmqil.com 976665 > myterqlqt qntmrq Prqtesm teepqk Mittql t

extracting email addresses from a file

2011-11-29 Thread Rajeev Prasad
hello,   i am trying to extract email address from a afile, but not quite succesful. here is what i have:   the file: myterqlqt qntmrq Prqtesm qltul qzeez Smqik qltulqzee...@jmqil.com 976665 myterqlqt qntmrq Prqtesm teepqk Mittql teep...@jmqil.com 939383 Onjole qntmrq Prqtesm lmqrqtm Etqrq cont.

Re: Extracting Data from PDF files

2011-03-03 Thread Joe
I basically run our pdfs through a pdf 2 txt converter and extract the data from the text files. It is pretty simple. On 3/3/2011 6:21 AM, Mike Blezien wrote: - Original Message - From: "shawn wilson" Cc: "Perl List" Sent: Thursday, March 03, 2011 6:04 AM Sub

Re: Extracting Data from PDF files

2011-03-03 Thread Mike Blezien
- Original Message - From: "shawn wilson" Cc: "Perl List" Sent: Thursday, March 03, 2011 6:04 AM Subject: Re: Extracting Data from PDF files On Mar 3, 2011 6:35 AM, "Mike Blezien" wrote: - Original Message - From: "shawn wilson" C

Re: Extracting Data from PDF files

2011-03-03 Thread shawn wilson
On Mar 3, 2011 6:35 AM, "Mike Blezien" wrote: > > - Original Message - From: "shawn wilson" > Cc: "Perl List" > Sent: Thursday, March 03, 2011 5:22 AM > Subject: Re: Extracting Data from PDF files > > > >> On Mar 3, 2011

Re: Extracting Data from PDF files

2011-03-03 Thread Mike Blezien
- Original Message - From: "shawn wilson" Cc: "Perl List" Sent: Thursday, March 03, 2011 5:22 AM Subject: Re: Extracting Data from PDF files On Mar 3, 2011 6:07 AM, "Mike Blezien" wrote: Hello, I posted a question earlier about creating a PDF fi

Re: Extracting Data from PDF files

2011-03-03 Thread shawn wilson
On Mar 3, 2011 6:07 AM, "Mike Blezien" wrote: > > Hello, > > I posted a question earlier about creating a PDF file from a PDF form submission which we now have working. We are able to create the PDF file to be attached to an email. > > The issue I'm having now is the ability to extract some specif

Extracting Data from PDF files

2011-03-03 Thread Mike Blezien
Hello, I posted a question earlier about creating a PDF file from a PDF form submission which we now have working. We are able to create the PDF file to be attached to an email. The issue I'm having now is the ability to extract some specific data from these PDF file created. We need to extrac

Re: Extracting properties from objects.

2011-01-24 Thread Ben Lavery
Hi Sean, In your given example, $l becomes a link object, so you go: $l->url(); to get the URL, for example. After using your code below, look at this page: http://search.cpan.org/~petdance/WWW-Mechanize-1.66/lib/WWW/Mechanize/Link.pm That will show you how to use $l. Hope that helps, Ben On 2

Extracting properties from objects.

2011-01-24 Thread Sean Murphy
Hi All. I am wondering how do you extract properties from objects. If we use WWW:Mechanize as an example. How would you get the properties of the first link. Lets say: my $l = $mec->find_link (text => 'link'); So I would like to find out the text of the link, URL, attribs, etc. This is just a

Re: extracting href parts

2008-10-04 Thread Rob Dixon
Ankur wrote: > > I am trying to develop an app for my website for which i need to get > the name of the Shows from http://tv.yahoo.com/listings. > > If you go over the code you can see that some of the rows have the > shows with hyperlink and others without. How do i get the Hyperlink > and the s

extracting href parts

2008-10-04 Thread Ankur
Hi, I am trying to develop an app for my website for which i need to get the name of the Shows from http://tv.yahoo.com/listings. If you go over the code you can see that some of the rows have the shows with hyperlink and others without. How do i get the Hyperlink and the show's name from the hyp

Re: extracting multiple statements ...

2008-09-23 Thread Sharan Basappa
On Mon, Sep 22, 2008 at 9:02 PM, Thomas Bätzler <[EMAIL PROTECTED]> wrote: > Hi, > > Sharan Basappa <[EMAIL PROTECTED]> asked: >> I have a code snippet as follows: >> >> keyword id1 = a x b x c; >> keyword id2 = c x d x e; >> >> I would like to extract strings "a x b x c" and "c x d x e". >> I know

Re: extracting multiple statements ...

2008-09-22 Thread Mr. Shawn H. Corey
On Mon, 2008-09-22 at 19:11 +0200, Dr.Ruud wrote: > "Mr. Shawn H. Corey" schreef: > > > my $text = undef; > > You don't trust much anymore I see. :-) Just because you're not paranoid doesn't mean computers don't hate me! -- Just my 0.0002 million dollars worth, Shawn Linux is obsolete

Re: extracting multiple statements ...

2008-09-22 Thread Dr.Ruud
"Mr. Shawn H. Corey" schreef: > my $text = undef; You don't trust much anymore I see. :-) -- Affijn, Ruud "Gewoon is een tijger." -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/

Re: extracting multiple statements ...

2008-09-22 Thread John W. Krahn
Sharan Basappa wrote: Hi, Hello, I have a code snippet as follows: keyword id1 = a x b x c; keyword id2 = c x d x e; I would like to extract strings "a x b x c" and "c x d x e". I know I can loop through the code and extract the strings, but is there a RE that can do this with a single stat

RE: extracting multiple statements ...

2008-09-22 Thread Thomas Bätzler
Hi, Sharan Basappa <[EMAIL PROTECTED]> asked: > I have a code snippet as follows: > > keyword id1 = a x b x c; > keyword id2 = c x d x e; > > I would like to extract strings "a x b x c" and "c x d x e". > I know I can loop through the code and extract the strings, > but is there a RE that can

Re: extracting multiple statements ...

2008-09-22 Thread Mr. Shawn H. Corey
On Mon, 2008-09-22 at 20:37 +0530, Sharan Basappa wrote: > I have a code snippet as follows: > > keyword id1 = a x b x c; > keyword id2 = c x d x e; > > I would like to extract strings "a x b x c" and "c x d x e". I know I > can loop through the > code and extract the strings, but is there a RE t

extracting multiple statements ...

2008-09-22 Thread Sharan Basappa
Hi, I have a code snippet as follows: keyword id1 = a x b x c; keyword id2 = c x d x e; I would like to extract strings "a x b x c" and "c x d x e". I know I can loop through the code and extract the strings, but is there a RE that can do this with a single statement. My first guess was to use /

Re: Extracting data from log and reformating

2008-08-19 Thread John W. Krahn
John W. Krahn wrote: Kashif Salman wrote: How can I capture "Start" as well? putting brackets around it like so doesn't work: /^(Start)/ && <> =~ /^(\d+)\/(\d+)\/(\d+)/ && print "$1=> 20$4-$2-$3"; I know it seems pointless to capture start but it doesn't always say "Start" so I want to capt

Re: Extracting data from log and reformating

2008-08-19 Thread John W. Krahn
Kashif Salman wrote: How can I capture "Start" as well? putting brackets around it like so doesn't work: /^(Start)/ && <> =~ /^(\d+)\/(\d+)\/(\d+)/ && print "$1=> 20$4-$2-$3"; I know it seems pointless to capture start but it doesn't always say "Start" so I want to capture it. for simplicity l

Re: Extracting data from log and reformating

2008-08-19 Thread Kashif Salman
On Fri, Aug 15, 2008 at 9:03 AM, Chris Charley <[EMAIL PROTECTED]> wrote: > On Wed, Aug 13, 2008 at 10:05 AM, John W. Krahn <[EMAIL PROTECTED]> wrote: >> >> Kashif Salman wrote: >>> >>> Greetings, >>> Hello, >>> >>> I have a log file like so, and I am trying to get the date on the nex

Re: Extracting data from log and reformating

2008-08-15 Thread Chris Charley
On Wed, Aug 13, 2008 at 10:05 AM, John W. Krahn <[EMAIL PROTECTED]> wrote: Kashif Salman wrote: Greetings, Hello, I have a log file like so, and I am trying to get the date on the next line after "Start..." line. So for the log below I'd like to get the output 04/06/05 05/06/05 06/06/05

Re: Extracting data from log and reformating

2008-08-14 Thread Kashif Salman
On Wed, Aug 13, 2008 at 10:05 AM, John W. Krahn <[EMAIL PROTECTED]> wrote: > Kashif Salman wrote: > >> Greetings, >> > > Hello, > > I have a log file like so, and I am trying to get the date on the next >> line >> after "Start..." line. So for the log below I'd like to get the output >> >> 04/06/

Re: Extracting data from log and reformating

2008-08-13 Thread Kashif Salman
On Wed, Aug 13, 2008 at 10:05 AM, John W. Krahn <[EMAIL PROTECTED]> wrote: > Kashif Salman wrote: > >> Greetings, >> > > Hello, > > I have a log file like so, and I am trying to get the date on the next >> line >> after "Start..." line. So for the log below I'd like to get the output >> >> 04/06/

Re: Extracting data from log and reformating

2008-08-13 Thread John W. Krahn
Kashif Salman wrote: Greetings, Hello, I have a log file like so, and I am trying to get the date on the next line after "Start..." line. So for the log below I'd like to get the output 04/06/05 05/06/05 06/06/05 But I also need to re-format that so the end result becomes: 2005-04-06 2005-

Extracting data from log and reformating

2008-08-13 Thread Kashif Salman
Greetings, I have a log file like so, and I am trying to get the date on the next line after "Start..." line. So for the log below I'd like to get the output 04/06/05 05/06/05 06/06/05 But I also need to re-format that so the end result becomes: 2005-04-06 2005-05-06 2005-06-06 Any hints? M

Re: Extracting data from a string

2008-03-15 Thread Dr.Ruud
[EMAIL PROTECTED] schreef: > $_ = "aaa_b_c_.ddd"; > ($a, $b, $c, $d, $e, $e) = (split /_|\./)[1,2,3,4,5,6]; > I am not getting the "aaa". I am getting b when I should be getting a. As mentioned already, you missed that indexes start at 0. Consider: my %data; my @keys = qw/a b c d e f/

Re: Extracting data from a string

2008-03-14 Thread John W. Krahn
[EMAIL PROTECTED] wrote: Hello Hello, I have a string that I am trying to parse out into separate variables. I am having problems getting the first field extracted. I want to extract fields using period (.) and underline (_) delimineters. Here is the string aaa_b_c_.ddd The string is c

Extracting data from a string

2008-03-14 Thread andrewmchorney
Hello I have a string that I am trying to parse out into separate variables. I am having problems getting the first field extracted. I want to extract fields using period (.) and underline (_) delimineters. Here is the string aaa_b_c_.ddd The string is contained in $_. Here is my code

Re: extracting values from split without using an array

2008-03-10 Thread Chas. Owens
On Mon, Mar 10, 2008 at 1:49 AM, Rodrick Brown <[EMAIL PROTECTED]> wrote: snip > For example if you we're only interested in fields 1,3, and 5 you > could do something like > ($field1,undef,$field3,undef,$field5) = split/.../; > > Or you can do something like (split//...)[3] snip You can also

Re: extracting values from split without using an array

2008-03-09 Thread J. Peng
On Mon, Mar 10, 2008 at 1:37 PM, igotux igotux <[EMAIL PROTECTED]> wrote: >I tried > split(/\s+/,$var)[1] which is not working as i expected. You may be moving from python,:) In perl you should say, (split /\s+/,$var)[1]; because split /\s+/$var returns a list, use () to enclose the list's sco

Re: extracting values from split without using an array

2008-03-09 Thread Rodrick Brown
On Mon, Mar 10, 2008 at 1:37 AM, igotux igotux <[EMAIL PROTECTED]> wrote: > Hi, > I want to extract values from split without defining an array. Say i want to > access second element in the split output :- split (/\s+/,$var) . I tried > split(/\s+/,$var)[1] which is not working as i expected. C

extracting values from split without using an array

2008-03-09 Thread igotux igotux
Hi, I want to extract values from split without defining an array. Say i want to access second element in the split output :- split (/\s+/,$var) . I tried split(/\s+/,$var)[1] which is not working as i expected. Can someone please correct me on this ? Thanks, IGotux

Re: Regular expression for extracting hrefs from HTML file

2008-02-04 Thread R (Chandra) Chandrasekhar
Chas. Owens wrote: This is a job for an HTML parser, not a single regex. Thank you for telling me about HTML::Parser, which I will use in future. Gunnar Hjalmarsson wrote: print "$1\n" while $content =~ m|(http://.*?";>)|gis; Thank you for your script (which works!) and most of all for th

Re: Regular expression for extracting hrefs from HTML file

2008-02-03 Thread Gunnar Hjalmarsson
R (Chandra) Chandrasekhar wrote: Dear Folks, I am trying to construct a regular expression to extract strings having the structure http://...";> from HTML files, as part of learning regexes. I have used the script below to do this: -- #!/usr/bin/perl use warnings; use diagnostics;

Re: Regular expression for extracting hrefs from HTML file

2008-02-03 Thread Chas. Owens
On Feb 3, 2008 8:50 AM, R (Chandra) Chandrasekhar <[EMAIL PROTECTED]> wrote: > Dear Folks, > > I am trying to construct a regular expression to extract strings having the > structure > > http://...";> > > from HTML files, as part of learning regexes. I have used the script below to > do > this: sn

Regular expression for extracting hrefs from HTML file

2008-02-03 Thread R (Chandra) Chandrasekhar
Dear Folks, I am trying to construct a regular expression to extract strings having the structure http://...";> from HTML files, as part of learning regexes. I have used the script below to do this: -- #!/usr/bin/perl use warnings; use diagnostics; use strict; # Detect and print ou

Re: extracting data from websites

2008-01-21 Thread jm
On Jan 21, 2008 12:39 PM, Chas. Owens <[EMAIL PROTECTED]> wrote: > On Jan 21, 2008 1:21 PM, jm <[EMAIL PROTECTED]> wrote: > > i need to extract data from websites, tracking the status of various > > shipments. i'm aware of the LWP module but wondered how many other > > modules may be useful. i've

Re: extracting data from websites

2008-01-21 Thread Chas. Owens
On Jan 21, 2008 1:21 PM, jm <[EMAIL PROTECTED]> wrote: > i need to extract data from websites, tracking the status of various > shipments. i'm aware of the LWP module but wondered how many other > modules may be useful. i've just glanced over the LWP documentation > (not in-depth at all yet) and

extracting data from websites

2008-01-21 Thread jm
i need to extract data from websites, tracking the status of various shipments. i'm aware of the LWP module but wondered how many other modules may be useful. i've just glanced over the LWP documentation (not in-depth at all yet) and i'm not sure if it will actually allow me to pull the bits of d

Re: extracting fields from a matching line

2007-12-04 Thread John W . Krahn
On Tuesday 04 December 2007 07:28, ciwei2103 wrote: > thans for the reply. > > I modify the program a bit , the $cmd output looks like: > >Ident Symbolic Numeric Slot Type Status > > DF-1A 01A 1 1 DISK Online > FA-4A 04A

Re: extracting fields from a matching line

2007-12-04 Thread ciwei2103
thans for the reply. I modify the program a bit , the $cmd output looks like: Ident Symbolic Numeric Slot Type Status DF-1A 01A 1 1 DISK Online FA-4A 04A 4 4 FibreChannel Online FA-13A13A 13 1

Re: extracting fields from a matching line

2007-11-29 Thread John W . Krahn
On Wednesday 28 November 2007 16:07, ciwei2103 wrote: > > Given a code segment: > > my $cmd = "/usr/symcli/bin/something"; > open (SYMCFG, " $cmd |" ) or die "cannot open $!\n"; > > while ( ) { > #print $_ if /FibreChannel Online$/ ; > # extract fields from the matching line > my ( $ident,

extracting fields from a matching line

2007-11-29 Thread ciwei2103
Given a code segment: my $cmd = "/usr/symcli/bin/something"; open (SYMCFG, " $cmd |" ) or die "cannot open $!\n"; while ( ) { #print $_ if /FibreChannel Online$/ ; # extract fields from the matching line my ( $ident, $fa , $type, $status ) = (split )[0,1,4,5] if / FibreChannel Online$/

re: extracting fields from a matching line

2007-11-29 Thread ciwei2103
Given a code segment: my $cmd = "/usr/symcli/bin/something"; open (SYMCFG, " $cmd |" ) or die "cannot open $!\n"; while ( ) { #print $_ if /FibreChannel Online$/ ; # extract fields from the matching line my ( $ident, $fa , $type, $status ) = (split )[0,1,4,5] if / FibreChannel Online$/

Re: Extracting one record from multiple-records textfile

2007-11-28 Thread John W . Krahn
On Wednesday 28 November 2007 14:05, Giuseppe.G. wrote: > > On 28 Nov, 01:44, [EMAIL PROTECTED] (Jeff Pang) wrote: > > > > Just show another way to do it. > > > > use strict; > > > > local $/="\n\n"; > > while() { > > next unless /^DOC-START\n(.*?)\nDOC-END$/sm; > > my $content = $1; > >

Re: Extracting one record from multiple-records textfile

2007-11-28 Thread Giuseppe.G.
On 28 Nov, 01:44, [EMAIL PROTECTED] (Jeff Pang) wrote: > Hello, > > Just show another way to do it. > > use strict; > > local $/="\n\n"; > while() { > next unless /^DOC-START\n(.*?)\nDOC-END$/sm; > my $content = $1; > parse($content); > > } Thank you all for your answers. In particula

Re: Extracting one record from multiple-records textfile

2007-11-27 Thread John W . Krahn
On Tuesday 27 November 2007 11:29, Giuseppe.G. wrote: > Hello there. Hello, > I'm a real beginner and I was wondering if you could be > so kind to help me on this. > I have a text file, containing a number of varying length documents, > all tagged with DOC-START and DOC-END, structured as follows

Re: Extracting one record from multiple-records textfile

2007-11-27 Thread Jeff Pang
Hello, Just show another way to do it. use strict; local $/="\n\n"; while() { next unless /^DOC-START\n(.*?)\nDOC-END$/sm; my $content = $1; parse($content); } sub parse { my $c = shift; print length($c),"\n"; } __DATA__ DOC-START content of the document DOC-END DOC-START

Re: Extracting one record from multiple-records textfile

2007-11-27 Thread Tom Phoenix
On 11/27/07, Giuseppe.G. <[EMAIL PROTECTED]> wrote: > I have a text file, containing a number of varying length documents, > all tagged with DOC-START and DOC-END, structured as follows: > > > DOC-START > content of the document > DOC-END > I need to take every document and pass it to a parsing f

Extracting one record from multiple-records textfile

2007-11-27 Thread Giuseppe.G.
Hello there. I'm a real beginner and I was wondering if you could be so kind to help me on this. I have a text file, containing a number of varying length documents, all tagged with DOC-START and DOC-END, structured as follows: DOC-START content of the document DOC-END DOC-START some text DOC-EN

Re: Extracting file name from full name

2007-09-27 Thread John W. Krahn
[EMAIL PROTECTED] wrote: Hello Hello, I have a string that contains a full path and file name. What is the easiest way to extract the file name? For example the path is /dir1/dir2/dir3/file.txt. $ perl -le' use File::Basename; my $full_path = q[/dir1/dir2/dir3/file.txt]; my $file_name =

Extracting file name from full name

2007-09-27 Thread andrewmchorney
Hello I have a string that contains a full path and file name. What is the easiest way to extract the file name? For example the path is /dir1/dir2/dir3/file.txt. Andrew -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/

Re: extracting common substrings...

2006-12-12 Thread D. Bolliger
D. Bolliger am Mittwoch, 13. Dezember 2006 02:25: Sorry for answering my own post... [snipped] > The script contains a testcase with "long" strings, it takes 1.2 secs on my > old machine (the test case is certainly not a worst case scenario). [snipped] > ### Test case: > > my $pat=join '', 'hello

Re: extracting common substrings...

2006-12-12 Thread D. Bolliger
Tom Phoenix am Mittwoch, 13. Dezember 2006 02:32: > On 12/12/06, D. Bolliger <[EMAIL PROTECTED]> wrote: > > $found{$1}++ for ($s2=~/($search)/g); # although count not used > > below > > Didn't $search just come from the data? It's a string, not a pattern. > If it's got any metacharacters, it

Re: Re: extracting common substrings...

2006-12-12 Thread Tom Phoenix
On 12/12/06, D. Bolliger <[EMAIL PROTECTED]> wrote: $found{$1}++ for ($s2=~/($search)/g); # although count not used below Didn't $search just come from the data? It's a string, not a pattern. If it's got any metacharacters, it could break your pattern, or worse. Cheers! --Tom Phoenix S

Re: extracting common substrings...

2006-12-12 Thread D. Bolliger
Helliwell, Kim am Dienstag, 12. Dezember 2006 21:56: > Is there a function (perhaps in a library module) that would take two > strings and return the common substring (if any) contained in the > arguments? I've been looking for such a beast on CPAN, but no luck so > far. > > > > If not, I guess I h

Re: extracting common substrings...

2006-12-12 Thread John W. Krahn
Helliwell, Kim wrote: > Is there a function (perhaps in a library module) that would take two > strings and return the common substring (if any) contained in the > arguments? I've been looking for such a beast on CPAN, but no luck so > far. Perhaps this is what you require: http://search.cpan.org

Re: extracting common substrings...

2006-12-12 Thread Tom Phoenix
On 12/12/06, Helliwell, Kim <[EMAIL PROTECTED]> wrote: Is there a function (perhaps in a library module) that would take two strings and return the common substring (if any) contained in the arguments? You want the longest possible common substring? Or all of the longest ones, if there's more

extracting common substrings...

2006-12-12 Thread Helliwell, Kim
Is there a function (perhaps in a library module) that would take two strings and return the common substring (if any) contained in the arguments? I've been looking for such a beast on CPAN, but no luck so far. If not, I guess I have to write it myself... Any help appreciated. Kim Helli

Re: Extracting only images from a mime mail

2006-12-06 Thread Tom Phoenix
On 12/6/06, Nagrale, Ajay <[EMAIL PROTECTED]> wrote: My requirement is to extract only images from an multipart email. I could see perl package (MIME::Parser) related to extraction of various parts of a given mail (mail txt, attachments). It extracts all the parts from a given mail. I am not

Extracting only images from a mime mail

2006-12-06 Thread Nagrale, Ajay
Hi, My requirement is to extract only images from an multipart email. I could see perl package (MIME::Parser) related to extraction of various parts of a given mail (mail txt, attachments). It extracts all the parts from a given mail. I am not able to give condition to extract only image from

Re: extracting several text from logs using regex

2006-09-15 Thread Dr.Ruud
Michael Alipio schreef: > A log file contains several of these lines: > > session.blablahbla > blablabla proto:6 blablabla srcip:90.0.0.1 blablabla > blablabla srcport:3243 blablabla dstport:23 blablabla > > session.blablahbla > blablabla proto:6 blablabla srcip:90.0.0.1 blablabla > blabla

Re: extracting several text from logs using regex

2006-09-15 Thread John W. Krahn
Michael Alipio wrote: > Hi, Hello, > A log file contains several of these lines: > > session.blablahbla > blablabla proto:6 blablabla srcip:90.0.0.1 blablabla > blablabla srcport:3243 blablabla dstport:23 blablabla > > session.blablahbla > blablabla proto:6 blablabla srcip:90.0.0.1 blab

Re: extracting several text from logs using regex

2006-09-15 Thread Mumia W.
On 09/14/2006 11:04 PM, Michael Alipio wrote: Hi, A log file contains several of these lines: session.blablahbla blablabla proto:6 blablabla srcip:90.0.0.1 blablabla blablabla srcport:3243 blablabla dstport:23 blablabla session.blablahbla blablabla proto:6 blablabla srcip:90.0.0.1 blab

extracting several text from logs using regex

2006-09-14 Thread Michael Alipio
Hi, A log file contains several of these lines: session.blablahbla blablabla proto:6 blablabla srcip:90.0.0.1 blablabla blablabla srcport:3243 blablabla dstport:23 blablabla session.blablahbla blablabla proto:6 blablabla srcip:90.0.0.1 blablabla blablabla srcport:3243 blablabla dstport:2

Re: extracting line between words

2006-09-14 Thread John W. Krahn
John W. Krahn wrote: > [EMAIL PROTECTED] wrote: >> >>But the output is coming like this TheSunrisesintheeast >> >>But I want the output like this The Sun rises in the east > > my @line = "The Sun rises in > the east and "; > print join ' ', split ' ', $line[ 0 ]; print map { join(

Re: extracting line between words

2006-09-14 Thread John W. Krahn
[EMAIL PROTECTED] wrote: > Hi Perlers... Hello, > I need to extract line between two words > > like > > > @line = "The Sun rises in > the east and "; > > Now I want to extract the line from The word to east > > For tht I am using the following code: > > #!

RE: extracting line between words

2006-09-14 Thread Nagasamudram, Prasanna Kumar
ile(<@line>){ print if $_ =~ /The/ .. /east/ ; } print "\n"; Thanks Prasannna -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] Sent: Thursday, September 14, 2006 4:57 PM To: beginners@perl.org Subject: extracting line between words Hi Perlers

Re: extracting line between words

2006-09-14 Thread Igor Sutton
while(<@line>){ print if $_ =~ /The/ .. /east/ ; I suggest this: print join " ", (grep { /The/ .. /east/ } <@line>); -- Igor Sutton Lopes t: +55 51 9627.0779 e: [EMAIL PROTECTED]

extracting line between words

2006-09-14 Thread mayank . ahuja
Hi Perlers... I need to extract line between two words like @line = "The Sun rises in the east and "; Now I want to extract the line from The word to east For tht I am using the following code: #!/usr/bin/perl use warnings; use strict; my @line = "The Sun r

Re: extracting NAME and DESCRIPTION sections from pod text file

2006-08-13 Thread Ken Foskey
On Sun, 2006-08-13 at 10:48 -0500, Mumia W. wrote: > On 08/13/2006 08:36 AM, Ken Perl wrote: > > what's correct regular expression on extracting only NAME and > > DESCRIPTION section from pod text file? > > I have tried this, but failed! > > > > perl -e

Re: extracting NAME and DESCRIPTION sections from pod text file

2006-08-13 Thread Dr.Ruud
Mumia W. schreef: > Ken: >> what's correct regular expression on extracting only NAME and >> DESCRIPTION section from pod text file? >> I have tried this, but failed! >> >> perl -e '$c=`pod2text /data/WebGUI/lib/WebGUI/User.pm`;$c =~ >> s/(NAME.*

Re: extracting NAME and DESCRIPTION sections from pod text file

2006-08-13 Thread Mumia W.
On 08/13/2006 08:36 AM, Ken Perl wrote: what's correct regular expression on extracting only NAME and DESCRIPTION section from pod text file? I have tried this, but failed! perl -e '$c=`pod2text /data/WebGUI/lib/WebGUI/User.pm`;$c =~ s/(NAME.*)SYNOPSIS/$1/;print $c' foreac

extracting NAME and DESCRIPTION sections from pod text file

2006-08-13 Thread Ken Perl
what's correct regular expression on extracting only NAME and DESCRIPTION section from pod text file? I have tried this, but failed! perl -e '$c=`pod2text /data/WebGUI/lib/WebGUI/User.pm`;$c =~ s/(NAME.*)SYNOPSIS/$1/;print $c' -- perl -e 'print unpack(u,"62V5N\"

Re: Extracting a Range of Lines

2006-06-04 Thread joseph
""Mr. Shawn H. Corey"" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] > On Mon, 2006-05-06 at 10:20 +0800, joseph wrote: >> @line = () if /^DATE:/; ## set array @line to an empty list if line begin >> DATE? > > Yes, this will clear out the previous record. > >> push @line, $_; ## th

Re: Extracting a Range of Lines

2006-06-04 Thread Mr. Shawn H. Corey
On Mon, 2006-05-06 at 10:20 +0800, joseph wrote: > @line = () if /^DATE:/; ## set array @line to an empty list if line begin > DATE? Yes, this will clear out the previous record. > push @line, $_; ## then push the value of line to an empty @line array? @line is empty only if this is the first

Re: Extracting a Range of Lines

2006-06-04 Thread joseph
""Mr. Shawn H. Corey"" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] > On Mon, 2006-05-06 at 08:51 +0800, joseph wrote: >> Hello List, >> >> I need help in extracting a range of lines from a log files, i tried to >> do &

Re: Extracting a Range of Lines

2006-06-04 Thread Mr. Shawn H. Corey
On Mon, 2006-05-06 at 08:51 +0800, joseph wrote: > Hello List, > > I need help in extracting a range of lines from a log files, i tried to do > it with this script: > > > #!/bin/perl > > use strict; > use warnings; > > open(FILE,"/home/teragram/stat

  1   2   3   4   5   >