Re: Parsing web pages

2017-03-02 Thread X Dungeness
Take a look a WWW::Mechanize. The older web suite LWP is an alternative and that may be enough if you only need a specific item. LWP::Simple is a possibility to see if you can mine the info from the page. If there's more complexity, then LWP::UserAgent is a starting point. A couple of books too:

Re: Parsing Logfiles and fetching Macs programmed and putting in another file.

2017-02-01 Thread Shlomi Fish
On Tue, 31 Jan 2017 17:29:10 +0530 Uday Vernekar wrote: > Thanks shlomi ,working on your inputs...Thanks:) > You're welcome, Uday! -- - Shlomi Fish http://www.shlomifish.org/ http://www.shlomifish.org/humour/bits/facts/Emma

Re: Parsing Logfiles and fetching Macs programmed and putting in another file.

2017-01-31 Thread Shlomi Fish
Hi Uday, see my reply interim with your code. On Tue, 31 Jan 2017 15:31:59 +0530 Uday Vernekar wrote: > Requirement: > > I have Test log files with filename as SerialNumber of tested Product and > the log file consist of > below data and other Text.the IP addresses can be repeated need to fet

Re: Parsing Logfiles and fetching Macs programmed and putting in another file.

2017-01-31 Thread Uday Vernekar
Thanks shlomi ,working on your inputs...Thanks:) On Tue, Jan 31, 2017 at 4:34 PM, Shlomi Fish wrote: > Hi Uday, > > see my reply interim with your code. > > On Tue, 31 Jan 2017 15:31:59 +0530 > Uday Vernekar wrote: > > > Requirement: > > > > I have Test log files with filename as SerialNumber o

Re: Parsing multi column files

2015-01-18 Thread Mike
Thanks for quick lesson and pro-tips. I'll be sure to implement some of these. In case you were wondering, I am indeed using strict and warnings. diagnostics, too. Thanks again. On 1/18/15 9:05 PM, Brandon McCaig wrote: Mike: On Sun, Jan 18, 2015 at 07:00:05PM -0500, Mike wrote: So I've g

Re: Parsing multi column files

2015-01-18 Thread Brandon McCaig
Mike: On Sun, Jan 18, 2015 at 07:00:05PM -0500, Mike wrote: > So I've got a text file in a multi column format (three > columns), each column is separated by a single space. Here is a > snippet for reference: > > artless base-court apple-john > bawdy bat-fowling baggage > beslubbering beef-witted

Re: Parsing multi column files

2015-01-18 Thread Brandon McCaig
On Sun, Jan 18, 2015 at 07:24:21PM -0500, Shawn H Corey wrote: > my @line = ( > @first[rand(@first)], > @second[rand(@second)], > @third[rand(@third)], >); Sorry to beat on you, Shawn, but I missed this the first time around. T

Re: Parsing multi column files

2015-01-18 Thread Charles DeRykus
On Sun, Jan 18, 2015 at 4:00 PM, Mike wrote: > So I've got a text file in a multi column format (three columns), each > column is separated by a single space. Here is a snippet for reference: > > artless base-court apple-john > bawdy bat-fowling baggage > beslubbering beef-witted barnacle > > I wa

Re: Parsing multi column files

2015-01-18 Thread Mike
Thanks. I'll give this a shot. On 1/18/15 7:44 PM, Brandon McCaig wrote: On Sun, Jan 18, 2015 at 07:24:21PM -0500, Shawn H Corey wrote: You would need an array for each column: my $MAX = 10; my @first = (); my @second = (); my @third = (); sub get_columns { my $file = shift @_; o

Re: Parsing multi column files

2015-01-18 Thread Brandon McCaig
On Sun, Jan 18, 2015 at 07:24:21PM -0500, Shawn H Corey wrote: > You would need an array for each column: > > my $MAX = 10; > > my @first = (); > my @second = (); > my @third = (); > > sub get_columns { > my $file = shift @_; > > open my $fh, '<', $file or die "could not open $file: $!\

Re: Parsing multi column files

2015-01-18 Thread Shawn H Corey
On Sun, 18 Jan 2015 19:00:05 -0500 Mike wrote: > sub gen_ins { > open(FH, '<', 'insults2.txt') or die "[-] ERROR: Can't find > insult list."; > my @cols = split (" ", ); > print "$cols[0]"; > close FH; > } > > gen_ins(); > > When currently run, gen_ins() will print out the f

Re: parsing string output that isn't CSV, but similar; what module would parse these kind of key-value pairs?

2014-12-19 Thread Mike Raynham
On 16/12/2014 20:05, Kenneth Wolcott wrote: > Hi; > > I've got some strings that I need to parse the value(s) off of the key. > > The key is (possibly) space-separated and terminate by a colon, and > the value is delimited by single quotes. But there are (potentially) > additional values for

Re: parsing string output that isn't CSV, but similar; what module would parse these kind of key-value pairs?

2014-12-16 Thread Brandon McCaig
On Tue, Dec 16, 2014 at 4:29 PM, Kenneth Wolcott wrote: > Well, I had to look at > http://perldoc.perl.org/perlrequick.html#Extracting-matches to find > out how much I had forgotten about extracting matches from a regex :-) > > This might be inefficient, but it seems to work: > > $shared_folder =~

Re: parsing string output that isn't CSV, but similar; what module would parse these kind of key-value pairs?

2014-12-16 Thread Kenneth Wolcott
On Tue, Dec 16, 2014 at 12:18 PM, Tiago Hori wrote: > Have you tried Text::CSV_XS? It allows you to set both the separatist and eol > and it also lets you use complex separators. > > T. > > Sent from my iPhone > >> On Dec 16, 2014, at 4:05 PM, Kenneth Wolcott >> wrote: >> >> Hi; >> >> I've got

Re: parsing string output that isn't CSV, but similar; what module would parse these kind of key-value pairs?

2014-12-16 Thread Tiago Hori
Have you tried Text::CSV_XS? It allows you to set both the separatist and eol and it also lets you use complex separators. T. Sent from my iPhone > On Dec 16, 2014, at 4:05 PM, Kenneth Wolcott wrote: > > Hi; > > I've got some strings that I need to parse the value(s) off of the key. > > T

Re: parsing html

2013-08-08 Thread Rob Dixon
On 08/08/2013 18:18, David Precious wrote: On Thu, 8 Aug 2013 22:42:01 +0530 Unknown User wrote: What would be the best module available for parsing html in your opinion? My intention is to parse html that contains a table of 5 columns and any number of rows For parsing HTML tables, you want

Re: parsing html

2013-08-08 Thread Charles DeRykus
On Thu, Aug 8, 2013 at 10:18 AM, David Precious wrote: > On Thu, 8 Aug 2013 22:42:01 +0530 > Unknown User wrote: > > > What would be the best module available for parsing html in your > > opinion? My intention is to parse html that contains a table of 5 > > columns and any number of rows > > For

Re: parsing html

2013-08-08 Thread timothy adigun
On 8 Aug 2013 18:19, "Unknown User" wrote: > > > What would be the best module available for parsing html in your opinion? I would also say look at HTML::TreeBuilder > My intention is to parse html that contains a table of 5 columns and any number of rows, and have a hash ref like > $html->{1}->

Re: parsing html

2013-08-08 Thread Chankey Pathak
Have a look at HTML::PARSER. On Aug 8, 2013 10:50 PM, "Unknown User" wrote: > > What would be the best module available for parsing html in your opinion? > My intention is to parse html that contains a table of 5 columns and any > number of rows, and have a hash ref like > $html->{1}->{col1}=data

Re: parsing html

2013-08-08 Thread David Precious
On Thu, 8 Aug 2013 22:42:01 +0530 Unknown User wrote: > What would be the best module available for parsing html in your > opinion? My intention is to parse html that contains a table of 5 > columns and any number of rows For parsing HTML tables, you want HTML::TableExtract, IMO. https://metacp

Re: Parsing a email attachment over SSL

2013-07-29 Thread John SJ Anderson
(a) Your subject line doesn't seem to have anything to do with the question in your message. (b) The documentation for Mail::IMAPClient says that the search() method arguments are appended to an IMAP SEARCH command. I think if you look at the relevent section of the IMAP RFC (https://tools.ietf.or

Re: Parsing Data

2013-07-23 Thread Omega -1911
Thanks Michael!! Between you and Rob, I have been able to transfer my contacts from my old cell phone to a text file on a local machine and then upload them to my database. It is a shame to have a cell company not provide a better service during an phone upgrade. You guys have helped me come up wit

Re: Parsing Data

2013-07-23 Thread John SJ Anderson
Okay, enough. This thread derail ends now. Shlomi, Rob, if you feel you need to continue this discussion in front of witnesses, feel free to continue CCing me on your private discussion -- but leave perl-beginners out of it. This type of nitpicking and sniping back and forth does not foster a welc

Re: Parsing Data

2013-07-23 Thread Rob Dixon
On 23/07/2013 19:00, Shlomi Fish wrote: Why do you feel that I've been "promoting" XML::LibXML in this thread? Because you say Instead one should use [XML::LibXML] I call that promotion. Why does the fact that I'm affiliated with it, prevent me from recommending it over a different alter

Re: Parsing Data

2013-07-23 Thread Shlomi Fish
Hi Rob, On Tue, 23 Jul 2013 18:15:07 +0100 Rob Dixon wrote: > On 23/07/2013 14:39, Shlomi Fish wrote: > > Hi Rob, > > > > I recommend against using XML::XPath because it's been undermaintained, is > > slower than XML::LibXML's XPath support, may be more incomplete and I > > believe it has poorer

Re: Parsing Data

2013-07-23 Thread Rob Dixon
On 23/07/2013 14:39, Shlomi Fish wrote: Hi Rob, I recommend against using XML::XPath because it's been undermaintained, is slower than XML::LibXML's XPath support, may be more incomplete and I believe it has poorer support for XML namespaces. Instead one should use https://metacpan.org/module/X

Re: Parsing Data

2013-07-23 Thread Shlomi Fish
Hi Rob, On Mon, 22 Jul 2013 21:48:33 +0100 Rob Dixon wrote: > On 22/07/2013 10:55, Omega -1911 wrote: > > > > Hello all - I am working on a small address book conversion where I need > > to convert a text file in where I dumped the addresses and post them to > > my database/website using the Mec

Re: Parsing Data

2013-07-22 Thread Michael Brader
On 07/23/2013 11:08 AM, Omega -1911 wrote: Rob - Thanks for the tip. I am not familiar with the module (XML::XPath) but tried to play with the code a little more to also retain the URL as well but was not successful. What would I need to modify or add to do this? After a 14 hour work day, I wo

Re: Parsing Data

2013-07-22 Thread Andy Bach
On Mon, Jul 22, 2013 at 4:55 AM, Omega -1911 <1911...@gmail.com> wrote: > Can anyone shed some light and point me in the right direction? Specifically, your REs are failing because there is a space in the data after the close quote for the class attribute that your REs don't have. This a good ex

Re: parsing website

2013-02-26 Thread David Christensen
On 02/26/13 10:46, Noah wrote: I want to parse text from a website. what are some good methods and modules to do this? Any tutorial links? "Perl & LWP" is the canonical book on the subject: http://shop.oreilly.com/product/9780596001780.do HTH, David -- To unsubscribe, e-mail: begin

Re: parsing website

2013-02-26 Thread Jim Gibson
On Feb 26, 2013, at 10:46 AM, Noah wrote: > Hi there, > > I want to parse text from a website. what are some good methods and modules > to do this? Any tutorial links? I am currently using LWP::UserAgent to scrape some websites and HTML::TokeParser and HTML::TableExtract to extract links an

Re: parsing website

2013-02-26 Thread Mike
On 2/26/2013 1:46 PM, Noah wrote: Hi there, I want to parse text from a website. what are some good methods and modules to do this? Any tutorial links? Cheers WWW::Mechanize http://search.cpan.org/dist/WWW-Mechanize/lib/WWW/Mechanize.pm -- To unsubscribe, e-mail: beginners-unsubscr...@

Re: parsing multiple logins logs (create a unique hash name for every user)

2012-09-11 Thread Brandon McCaig
On Mon, Sep 10, 2012 at 02:45:20PM -0500, Andy Bach wrote: > On Mon, Sep 10, 2012 at 7:12 AM, Danny Gratzer > wrote: > > while (){ > > my ($logindate, $dbserver, $hostname, $status ) = split (/,/); > > $info{$username} = {$logindate=>[$dbserver, $hostname, $status]}; > > } > > One thing to w

Re: parsing multiple logins logs (create a unique hash name for every user)

2012-09-10 Thread Praveen Kumar
On Mon, Sep 10, 2012 at 5:14 PM, andrew sison wrote: > Hi, > > I'm confronted with this problem.I've done this before but I just > can't remember how. > > There is a log file I am trying to parse: > > open FILE , 'C:\test.csv' or die $!; > Use below method to open the file , $file now contain fil

Re: parsing multiple logins logs (create a unique hash name for every user)

2012-09-10 Thread Andy Bach
On Mon, Sep 10, 2012 at 7:12 AM, Danny Gratzer wrote: > while (){ > my ($logindate, $dbserver, $hostname, $status ) = split (/,/); > $info{$username} = {$logindate=>[$dbserver, $hostname, $status]}; > } One thing to watch for - logins on the same day will overwrite here, so while (){ my

Re: parsing multiple logins logs (create a unique hash name for every user)

2012-09-10 Thread Shawn H Corey
On 10 Sep 2012 13:44:20 - Peter Scott wrote: > On Mon, 10 Sep 2012 20:52:41 +0800, andrew sison wrote: > > I don't get how you can actually print the contents of the subhash. > > Generic hash-of-hashes iteration example: > > for my $outer_key ( keys %hash ) > { > print "Outer key: $outer_

Re: parsing multiple logins logs (create a unique hash name for every user)

2012-09-10 Thread Peter Scott
On Mon, 10 Sep 2012 20:52:41 +0800, andrew sison wrote: > I don't get how you can actually print the contents of the subhash. Generic hash-of-hashes iteration example: for my $outer_key ( keys %hash ) { print "Outer key: $outer_key:\n"; for my $inner_key ( sort keys %{ $hash{$outer_key} } )

Re: parsing multiple logins logs (create a unique hash name for every user)

2012-09-10 Thread andrew sison
I don't get how you can actually print the contents of the subhash. foreach my $user(keys %info){ print $info{$user}; #This gives me hash print $user, "\n"#Here I can retrieve the usernames that were made hash keys } Now here is where I hit a dead e

Re: parsing multiple logins logs (create a unique hash name for every user)

2012-09-10 Thread Danny Gratzer
I would create a hash with hash references containing the date and an anonymous array as members. Something like this: open FILE , 'C:\test.csv' or die $!; my %info while (){ my ($logindate, $dbserver, $hostname, $status ) = split (/,/); $info{$username} = {$logindate=>[$dbserver, $hostname, $

Re: parsing script help please

2012-05-31 Thread nathalie
You want something like this: #!/software/bin/perl use warnings; use strict; my $file = "example.txt"; open my $in, '<', $file or die "Cannot open '$file' because: $!"; while ( <$in> ) { next if /^#/; chomp; my ( $key, @fields ) = split /\t/; print map "$key\t$_\n", @fields;

Re: parsing script help please

2012-05-31 Thread nathalie
thanks a lot Rob I would like an output without the $VAR... so I did add this after the push function and it is perfect, thanks a lot again foreach my $number(@othernumbers){print $rownum,"\t",$elet, "\n";} #!/usr/local/bin/perl use strict; use warnings; my $fh; my %results; open ( $fh,

Re: parsing script help please

2012-05-31 Thread John W. Krahn
nathalie wrote: Hi Hello, I have this format of file: (see attached example) 1 3206102-3207048 3411782-3411981 3660632-3661428 2 4481796-4482748 4483180-4483486 and I would like to change it to this 1 3206102-3207048 1 3411782-3411981 1 3660632-3661428 2 4481796-4482748 2 4483180-4483486

Re: parsing script help please

2012-05-31 Thread Rob Coops
On Thu, May 31, 2012 at 11:37 AM, nathalie wrote: > > > Hi > I have this format of file: (see attached example) > 1 3206102-3207048 3411782-3411981 3660632-3661428 > 2 4481796-4482748 4483180-4483486 > > > and I would like to change it to this > 1 3206102-3207048 > 1 34117

Re: Parsing repetitive lines

2012-05-03 Thread Jim Gibson
In addition to what Shlomi has mentioned, I will add: On May 3, 2012, at 4:34 AM, venkates wrote: > sub parse { > >my $pazar_file_path = shift; >my $pazar_data; # ref to a hash holding the parsed data > >open FH, '<', $pazar_file_path or croak ( "Cannot open file > '$pazar_file_pat

Re: Parsing repetitive lines

2012-05-03 Thread Shlomi Fish
Hi Aravind, On Thu, 03 May 2012 13:34:35 +0200 venkates wrote: > Hi all, > > I am trying to parse a tab-delimited file which has repeating lines. > This is causing problems while parsing it to the data structure (see > below). I would appreciate if you could help me solve this. > If your f

Re: Parsing Question

2012-02-02 Thread Brandon Phelps
Thanks everyone for the great ideas. After I implemented the solution(s) you guys proposed I stumbled upon Nagios::Object (http://search.cpan.org/~duncs/Nagios-Object-0.21.16/). I did learn a few things from your ideas though so I am grateful none the less! I recommend anyone working with Na

Re: Parsing Question

2012-02-02 Thread Rob Dixon
On 31/01/2012 22:43, Brandon Phelps wrote: Hello all, I am attempting to parse a Nagios status.dat file and am curious about what the most efficient way to do this would be. I'm sure I could come up with something but it would be very convoluted and I'm sure there is a better way. Below is a sam

RE: Parsing Question

2012-02-02 Thread Kronheim, David (Contr)
February 01, 2012 2:11 PM To: jbiskofski Cc: Brandon Phelps; beginners@perl.org Subject: Re: Parsing Question Hi jbiskofski, This script will not work WHY? -- Scalar found where operator expected at . [ Please Check ] line 72, near "$we_are_inside_hoststatus_block" .. This commun

Re: Parsing Question

2012-02-01 Thread jbiskofski
ah - i get it now. thanks. On Wed, Feb 1, 2012 at 3:05 PM, Jim Gibson wrote: > On 2/1/12 Wed Feb 1, 2012 11:24 AM, "jbiskofski" > scribbled: > > > Your comment about the open statement is OK. I guess it really comes down > > to style. I was trying to write something clear that Brandon could

Re: Parsing Question

2012-02-01 Thread Jim Gibson
On 2/1/12 Wed Feb 1, 2012 11:24 AM, "jbiskofski" scribbled: > Your comment about the open statement is OK. I guess it really comes down > to style. I was trying to write something clear that Brandon could improve > upon. It is not simply a matter of style. Because of operator precedence, the s

Re: Parsing Question

2012-02-01 Thread jbiskofski
Timothy Could it be that when you copy pasted the script the line wrap got messed up? It works fine for me. Im using perl 5.12.3 Your comment about the open statement is OK. I guess it really comes down to style. I was trying to write something clear that Brandon could improve upon. Here is a p

Re: Parsing Question

2012-02-01 Thread timothy adigun
Hi jbiskofski, This script will not work WHY? -- Scalar found where operator expected at . [ Please Check ] line 72, near "$we_are_inside_hoststatus_block" .. On Wed, Feb 1, 2012 at 6:38 PM, jbiskofski wrote: > Hey Brandon > > Here is a solution to this problem. It is purposely r

Re: Parsing Question

2012-02-01 Thread jbiskofski
Hey Brandon Here is a solution to this problem. It is purposely really long. It takes the simplest most understandable solution. If you have questions about it let me know. #!/usr/local/bin/perl # always a good idea, forces scope to if/for/foreach/while blocks use strict; # open the file, int

Re: Parsing Question

2012-02-01 Thread Igor Dovgiy
Just my $0.02... can't help offering a slight rewrite of David's great program. Now it's runnable on 5.010 and earlier, and should give out some warnings if hoststatus sections are somehow corrupt: $|++; # comment it out if you don't need to buffer the output my $section_started; my ($host, $state

RE: Parsing Question

2012-02-01 Thread Kronheim, David (Contr)
Brandon, I took most of your comments and sample data and put it in the following program. Taking the data out of the program and parsing it from files and directories, might be a good exercise for you. Generally variables are best declared close to where they are first used. Since the scope of

Re: Parsing Question

2012-01-31 Thread Brandon Phelps
Thanks a ton David, This will definitely help! Not able to try it now but I'll give it a shot first thing tomorrow. -Brandon On 1/31/2012 8:15 PM, Kronheim, David (Contr) wrote: Brandon, I took most of your comments and sample data and put it in the following program. Taking the data out

Re: Parsing a microarray data file

2012-01-26 Thread John W. Krahn
Steve Bertrand wrote: On 2012.01.26 12:59, Chris Stinemetz wrote: #!/usr/bin/perl use warnings; use strict; while ( ) { chomp; my @array = split; my $GeneID = $array[6]; if ($GeneID =~ /^C|D/) { print $_,"\n"; } } __DATA__ Line1 c 2 3 4 5 C 7 8 9 Line2 1 2 3 4 5 6 7 8 9 Line3 1 2 3 4 5 D 7 8

Re: Parsing a microarray data file

2012-01-26 Thread John W. Krahn
Chris Stinemetz wrote: ***tested*** #!/usr/bin/perl use warnings; use strict; while ( ) { chomp; my @array = split; my $GeneID = $array[6]; if ($GeneID =~ /^C|D/) { I'm still learning regex but it could be better written with; if ($GeneID =~ /^[CD]/) { Plus they do two different t

Re: Parsing a microarray data file

2012-01-26 Thread Steve Bertrand
On 2012.01.26 12:59, Chris Stinemetz wrote: Hello Tiago, On Thu, Jan 26, 2012 at 11:08 AM, Tiago Hori wrote: Hi All, I need some help to get started on a script. I have these huge data files 16K rows and several columns. I need to parse the rows into a subset of these 16K rows. Each rows has

Re: Parsing a microarray data file

2012-01-26 Thread Tiago Hori
Thanks Chris! I am going to give this a go now! Cheers, T. On Thu, Jan 26, 2012 at 2:40 PM, Chris Stinemetz wrote: > > ***tested*** > > > > #!/usr/bin/perl > > use warnings; > > use strict; > > > > while ( ) { > > chomp; > > my @array = split; > > my $GeneID = $array[6]; > > > > if ($Ge

Re: Parsing a microarray data file

2012-01-26 Thread Chris Stinemetz
> ***tested*** > > #!/usr/bin/perl > use warnings; > use strict; > > while ( ) { >  chomp; >  my @array = split; >  my $GeneID = $array[6]; > >  if ($GeneID =~ /^C|D/) { I'm still learning regex but it could be better written with; if ($GeneID =~ /^[CD]/) { -- To unsubscribe, e-mail: beginners-u

Re: Parsing a microarray data file

2012-01-26 Thread Chris Stinemetz
Hello Tiago, On Thu, Jan 26, 2012 at 11:08 AM, Tiago Hori wrote: > Hi All, > > I need some help to get started on a script. > > I have these huge data files 16K rows and several columns. I need to parse > the rows into a subset of these 16K rows. Each rows has a identifier made > up of 2 letters

RE: parsing data

2011-12-21 Thread Ken Slater
> -Original Message- > From: Chris Stinemetz [mailto:chrisstinem...@gmail.com] > Sent: Wednesday, December 21, 2011 11:18 AM > To: Binish A.R > Cc: John W. Krahn; Perl Beginners > Subject: Re: parsing data > > I'm trying to implement the advice that Bin

Re: parsing data

2011-12-21 Thread Chris Stinemetz
I'm trying to implement the advice that Binish, and John gave. I am getting the following error: Can't use an undefined value as a HASH reference at ./format.pl line 16, line 2. Any help is greatly appreciated, Chris #!/usr/bin/perl use warnings; use strict; my $csno; while( ) { chomp;

Re: parsing data

2011-12-20 Thread Binish A.R
catch    From: John W. Krahn To: Perl Beginners Sent: Wednesday, December 21, 2011 12:25 PM Subject: Re: parsing data Binish A.R wrote: > If you can guarantee the order in which the keys appear, you may not have to > build a hash to hold the entire data. &

Re: parsing data

2011-12-20 Thread John W. Krahn
Binish A.R wrote: If you can guarantee the order in which the keys appear, you may not have to build a hash to hold the entire data. Instead you can read block by block and print the result. -- my $csno; while (<>) { chomp; s/^\s+//g; s/\s+$//g; ### weed out all w

Re: parsing data

2011-12-20 Thread Binish A.R
If you can guarantee the order in which the keys appear, you may not have to build a hash to hold the entire data. Instead you can read block by block and print the result. -- my $csno; while (<>) {         chomp;         s/^\s+//g; s/\s+$//g;                     ### weed out all whitespaces    

Re: parsing data

2011-12-20 Thread David Christensen
On 12/20/2011 05:16 PM, Chris Stinemetz wrote: I am having some trouble coming up with a solution for what I am trying to accomplish. Any advice is greatly appreciated. ... *** input *** csno=1 rfpi=1 vrp0=3423000 vrp1=3423000 trl=170 line= low= high=5 csno=1 rfpi=2 vrp0=3423000 vrp1=

Re: parsing script misbehaving...

2011-10-21 Thread Rob Dixon
On 21/10/2011 19:16, Brandon McCaig wrote: Thanks for the explanation, Rob. :) use strict; use warnings; use v5.010; my $data = 'aaa bbb ccc'; say $data; for my $pattern (qw(bbb aaa ccc)) { say join ' ', pos($data) // 'undef', $pattern, scalar $data =~ /$pattern/g; } __EN

Re: parsing script misbehaving...

2011-10-21 Thread Brandon McCaig
On Fri, Oct 21, 2011 at 1:52 PM, Rob Dixon wrote: > It is nothing to do with matched patterns overlapping. As I tried to > describe, it is the designed behaviour of m//g in scalar context to find > just one match, searching from the end of the previous match if it was > successful, or restarting f

Re: parsing script misbehaving...

2011-10-21 Thread Rob Dixon
On 21/10/2011 16:32, Jim Gibson wrote: > > I ran the provided program and was going to say that the /g modifier is > unnecessary. I took it out and noticed that the results differed. I > believe the difference is that some of the matched patterns overlap, and > whether or not you want to count

Re: parsing script misbehaving...

2011-10-21 Thread Jim Gibson
At 11:55 AM +0100 10/21/11, Rob Dixon wrote: On 21/10/2011 11:31, Nathalie Conte wrote: HI Rob, Hello Nat Please keep your replies to the Perl beginners list, so that other people can both help and learn from the discussion. (It would also help if you could bottom-post your replies (put the

Re: parsing script misbehaving...

2011-10-21 Thread John W. Krahn
Rob Dixon wrote: On 21/10/2011 00:32, nac wrote: I have corrected myself a bit, I think the script is now giving me what I want, having said that, I guess it is not the best way ( even if there is more than one way), again any pointer are welcome. many thanks Nat #!/usr/bin/perl use strict;

Re: parsing script misbehaving...

2011-10-21 Thread Nathalie Conte
Rob Dixon wrote: On 21/10/2011 11:31, Nathalie Conte wrote: HI Rob, Hello Nat Please keep your replies to the Perl beginners list, so that other people can both help and learn from the discussion. (It would also help if you could bottom-post your replies (put the response after the text you

Re: parsing script misbehaving...

2011-10-21 Thread Rob Dixon
On 21/10/2011 11:31, Nathalie Conte wrote: HI Rob, Hello Nat Please keep your replies to the Perl beginners list, so that other people can both help and learn from the discussion. (It would also help if you could bottom-post your replies (put the response after the text you are quoting). It i

Re: parsing script misbehaving...

2011-10-21 Thread Rob Dixon
On 21/10/2011 00:32, nac wrote: > HI again, > I have corrected myself a bit, I think the script is now giving me what I > want, having said that, I guess it is not the best way ( even if there is > more than one way), again any pointer are welcome. > many thanks > Nat Hi Nat > #!/usr/bin/perl > u

Re: parsing script misbehaving...

2011-10-21 Thread Rob Dixon
On 21/10/2011 02:50, John W. Krahn wrote: nac wrote: HI again, Hello, I have corrected myself a bit, I think the script is now giving me what I want, having said that, I guess it is not the best way ( even if there is more than one way), again any pointer are welcome. many thanks Nat #!/usr/

Re: parsing script misbehaving...

2011-10-20 Thread John W. Krahn
nac wrote: HI again, Hello, I have corrected myself a bit, I think the script is now giving me what I want, having said that, I guess it is not the best way ( even if there is more than one way), again any pointer are welcome. many thanks Nat #!/usr/bin/perl use strict; use warnings; my @seq;

Re: parsing script misbehaving...

2011-10-20 Thread Rob Dixon
On 21/10/2011 00:32, nac wrote: > HI again, > I have corrected myself a bit, I think the script is now giving me what I > want, having said that, I guess it is not the best way ( even if there is > more than one way), again any pointer are welcome. > many thanks > Nat > #!/usr/bin/perl > use strict

Re: parsing script misbehaving...

2011-10-20 Thread John W. Krahn
nac wrote: HI, Hello, I need your wisdom on this parsing script. I have a fastq file,this contains info for reads ( from nextGen), 1 line starts with a @, second contain the sequence info from which I want to count pattern, third line with a sign, fourth with info about the sequence quality (

Re: parsing script misbehaving...

2011-10-20 Thread nac
HI again, I have corrected myself a bit, I think the script is now giving me what I want, having said that, I guess it is not the best way ( even if there is more than one way), again any pointer are welcome. many thanks Nat #!/usr/bin/perl use strict; use warnings; my @seq; @seq=qw{^TGGCAGTGGAGG

Re: parsing script removing some lines help please

2011-09-30 Thread Chris Charley
John W. Krahn wrote: Mariano Loza Coll wrote: Hi John, Hello, I'm trying to learn a little bit more of Perl everyday, and I was intrigued about your earlier suggestion in a thread. my $bad_chromosomes = qr/^(?:6|8|14|16|18|Y)\t/; while (<$IN> ) { print $OUT $_ if !/$bad_chromosomes/

Re: parsing script removing some lines help please

2011-09-30 Thread John W. Krahn
Mariano Loza Coll wrote: Hi John, Hello, I'm trying to learn a little bit more of Perl everyday, and I was intrigued about your earlier suggestion in a thread. my $bad_chromosomes = qr/^(?:6|8|14|16|18|Y)\t/; while (<$IN> ) { print $OUT $_ if !/$bad_chromosomes/; } I get the s

Re: parsing script removing some lines help please

2011-09-30 Thread John W. Krahn
Nathalie Conte wrote: Hi, Hello, I am lost in my script, and would need to basic help please. I have got a file , separated by tabs, and the first column contain a chromosome number, then several other column with different infos. Basically I am trying to created a script that would take a f

RE: parsing script removing some lines help please

2011-09-30 Thread Ken Slater
> From: Nathalie Conte [mailto:n...@sanger.ac.uk] > Sent: Friday, September 30, 2011 9:38 AM > To: beginners@perl.org > Subject: parsing script removing some lines help please > > > > Hi, > I am lost in my script, and would need to basic help please. > I have got a file , separated by tabs, and

Re: parsing script removing some lines help please

2011-09-30 Thread John SJ Anderson
On Fri, Sep 30, 2011 at 09:37, Nathalie Conte wrote: > thanks for any clues It's a simple one, really.. 8^) > #!/software/bin/perl > use warnings; > use strict; > open(IN, " open(OUT, ">>removed.txt") or die( $! ); ObCorrectness: you should say something more like open( my $IN , '<' , 'example

Re: parsing and adding back this string

2011-09-03 Thread Rajeev Prasad
er. From: Rob Dixon To: Perl Beginners Cc: Rajeev Prasad Sent: Saturday, September 3, 2011 4:13 AM Subject: Re: parsing and adding back this string On 02/09/2011 23:33, Rajeev Prasad wrote: > friends, > > I am now trying to parse this string in this way... > > x= could be a

Re: parsing and adding back this string

2011-09-03 Thread Rob Dixon
On 02/09/2011 23:33, Rajeev Prasad wrote: friends, I am now trying to parse this string in this way... x= could be anything including special character string = xx:ABC,xx,x,x,x,"x,x,x",x,x,x,"x,x",x string0=ABC string2="x,x,x" string3="x,x" string1=xx:string0,tt,x,x,x,string2,x,x,x,string3,x

Re: parsing and adding back this string

2011-09-02 Thread Brandon McCaig
On Fri, Sep 2, 2011 at 6:54 PM, Rob Dixon wrote: > I'm afraid your post doesn't make very much sense to me, and doesn't > contain a question. Can you give an example showing what you want from > some real data? Agreed. As you describe, "x" can be anything, yet your sample is full of x's all over

Re: parsing and adding back this string

2011-09-02 Thread Rob Dixon
On 02/09/2011 23:33, Rajeev Prasad wrote: friends, I am now trying to parse this string in this way... x= could be anything including special character string = xx:ABC,xx,x,x,x,"x,x,x",x,x,x,"x,x",x string0=ABC string2="x,x,x" string3="x,x" string1=xx:string0,tt,x,x,x,string2,x,x,x,string3,x

Re: Parsing a Text File using regex

2011-08-06 Thread Rob Dixon
On 06/08/2011 15:14, Emeka wrote: John, Thanks for making things pretty simple for mere mortals .. Hi Emeka chomp( my $raw_file = glob "@ARGV" ); I am of the view that glob sub is used for as tree (that is to get all the files in a folder and all its sub-folders. From the above, it see

Re: Parsing a Text File using regex

2011-08-06 Thread Emeka
John, Thanks for making things pretty simple for mere mortals .. >> > chomp( my $raw_file = glob "@ARGV" ); > I am of the view that glob sub is used for as tree (that is to get all the files in a folder and all its sub-folders. From the above, it seems like it could be used for something else.

Re: Parsing a Text File using regex

2011-08-04 Thread Uri Guttman
> "ta" == timothy adigun <2teezp...@gmail.com> writes: ta> I believe you know that in Perl there are more than one way to do ta> it! i.e solve a problem. And that one way is no better than the ta> other, it only depend on what the programmer preferred to use, as ta> long as the syntax

Re: Parsing a Text File using regex

2011-08-04 Thread timothy adigun
Hi John, I believe you know that in Perl there are more than one way to do it! i.e solve a problem. And that one way is no better than the other, it only depend on what the programmer preferred to use, as long as the syntax are correct. Secondly, most of your why would have been answered, if only y

Re: Parsing a Text File using regex

2011-08-04 Thread John W. Krahn
timothy adigun wrote: Hi Ryan, Try the the code below, it should help. === #!/usr/bin/perl -w use strict; my $ln=""; my ($yr,$cat,$win)=("","",""); my $filename="New_output.txt"; chomp(my $raw_file=<@ARGV>); That is the same as saying: chomp( my $raw_file = glob

Re: Parsing a Text File using regex

2011-08-04 Thread Ryan
Timothy, That worked like a charm. Thank you so much for the help. -Ryan On Thu, Aug 4, 2011 at 4:41 AM, timothy adigun <2teezp...@gmail.com> wrote: > Hi Ryan, > Try the the code below, it should help. > > === > > #!/usr/bin/perl -w > use strict; > > my $ln=""; > my ($yr,

Re: Parsing a Text File using regex

2011-08-04 Thread timothy adigun
Hi Ryan, Try the the code below, it should help. === #!/usr/bin/perl -w use strict; my $ln=""; my ($yr,$cat,$win)=("","",""); my $filename="New_output.txt"; chomp(my $raw_file=<@ARGV>); open READFILE,"<","$raw_file" or die "can't open $!"; open OUTPUTFILE,">","$filenam

Re: parsing script duplication of lines issue, please advise

2011-07-21 Thread John W. Krahn
Rob Dixon wrote: After these changes, the loop looks like this while (){ chomp; my @line=split(/\t/); if ($line[3] == -1) { print OUT "$_\n"; } } You can make it much simpler than that: while ( ) { print OUT if /\t-1$/; } John -- Any intelligent fool can make

Re: parsing script duplication of lines issue, please advise

2011-07-21 Thread Shlomi Fish
Hi Nathalie, On Thu, 21 Jul 2011 12:00:57 +0100 Nathalie Conte wrote: > HI, > I want to create a simple script where I am parsing a file and writing > only the lines where I can find a certain value in a new output file > this is my Infile format: workable example attached > I want to keep only

Re: parsing script duplication of lines issue, please advise

2011-07-21 Thread Rob Dixon
On 21/07/2011 12:00, Nathalie Conte wrote: HI, I want to create a simple script where I am parsing a file and writing only the lines where I can find a certain value in a new output file this is my Infile format: workable example attached I want to keep only the lines where there is a 1 not the o

  1   2   3   4   5   6   >