Re: split regex

2015-03-21 Thread Brandon McCaig
Danny Wong: Hello, On Thu, Mar 19, 2015 at 09:25:02PM +, Danny Wong (dannwong) wrote: > Hi Perl GURU, I have a string like this: > > 'Baseline: (_bMgvUBQ_EeKsP6DECdq0Lg) 1 "Initial Baseline" > "Initial Baseline of Component NGP-Diagnostics" Sivakumar Subas > Oct 12, 2012 12:35:41 AM'; > > I

Re: split regex

2015-03-20 Thread Shlomi Fish
Hi Danny, On Thu, 19 Mar 2015 21:42:53 + "Danny Wong (dannwong)" wrote: > Nevermind. I used regex to accomplish what I wanted instead of the split > command. Thanks guys! > Just a note in general: sometimes when a simple split or a regex match fails you may opt to employ more complex pars

Re: split regex

2015-03-19 Thread Danny Wong (dannwong)
Nevermind. I used regex to accomplish what I wanted instead of the split command. Thanks guys! From: Danny H Wong mailto:dannw...@cisco.com>> Date: Thursday, March 19, 2015 at 2:25 PM To: Perl List mailto:beginners@perl.org>>, Perl Beginners mailto:beginners@perl.org>> Subject: split regex Hi P

Re: split an html file

2014-04-22 Thread Mike McClain
On Sat, Apr 19, 2014 at 08:30:50AM +0100, Maurice McCarthy wrote: > On 2014-04-17 18:01, Mike McClain wrote: > >Hi, > >My brother Rick, a windrider, put together a webpage, > >http://www.photographers1.com/Sailing/NauticalTerms&Nomenclature.html > >about sailing and wind surfing that has grown

Re: split an html file

2014-04-21 Thread Uday Vernekar
Awesome..Lesley On Mon, Apr 21, 2014 at 4:00 PM, lesleyb wrote: > On Thu, Apr 17, 2014 at 10:01:35AM -0700, Mike McClain wrote: > > Hi, > > My brother Rick, a windrider, put together a webpage, > > http://www.photographers1.com/Sailing/NauticalTerms&Nomenclature.html > > about sailing

Re: split an html file

2014-04-21 Thread 'lesleyb'
On Thu, Apr 17, 2014 at 10:01:35AM -0700, Mike McClain wrote: > Hi, > My brother Rick, a windrider, put together a webpage, > http://www.photographers1.com/Sailing/NauticalTerms&Nomenclature.html > about sailing and wind surfing that has grown too large and should be > split into smaller sectio

Re: split an html file

2014-04-19 Thread Maurice McCarthy
On 2014-04-17 18:01, Mike McClain wrote: Hi, My brother Rick, a windrider, put together a webpage, http://www.photographers1.com/Sailing/NauticalTerms&Nomenclature.html about sailing and wind surfing that has grown too large and should be split into smaller sections to reduce load time. C

Re: split an html file

2014-04-19 Thread Shlomi Fish
Hi Mike, On Thu, 17 Apr 2014 10:01:35 -0700 Mike McClain wrote: > Hi, > My brother Rick, a windrider, put together a webpage, > http://www.photographers1.com/Sailing/NauticalTerms&Nomenclature.html > about sailing and wind surfing that has grown too large and should be > split into smaller s

Re: split

2013-05-03 Thread Edward and Erica Heim
Thanks to everyone for the answers provided. I will work through them. Just as background, I've been on an intense learning curve over the last several weeks - object oriented Perl, LWP, getting access to secure websites (HTTPS) to work etc. I got to the point where I wanted to prototype acce

Re: split

2013-05-03 Thread Shlomi Fish
Hi Rahim, On Fri, 3 May 2013 18:39:57 +0100 Rahim Fakir wrote: > Sorry i not in your level of experience. > If i want to start a mail about perl to wich email should i adress? > I just got started with hello world, and nothing else run's, iam so sad. > Please write a new message to beginners@p

Re: split

2013-05-03 Thread timothy adigun
OR On Fri, May 3, 2013 at 6:53 PM, timothy adigun <2teezp...@gmail.com> wrote: > > Hi, > Please check my reply below. > > On Fri, May 3, 2013 at 12:59 PM, Edward and Erica Heim < > edh...@bigpond.net.au> wrote: > >> Hi all, >> >> I'm using LWP::UserAgent to access a website. One of the methods re

Re: split

2013-05-03 Thread timothy adigun
Hi, Please check my reply below. On Fri, May 3, 2013 at 12:59 PM, Edward and Erica Heim < edh...@bigpond.net.au> wrote: > Hi all, > > I'm using LWP::UserAgent to access a website. One of the methods returns > HTML data e.g. > > my $data = $response->content; > > I.e. $data contains the HTML cont

Re: split

2013-05-03 Thread Rahim Fakir
Sorry i not in your level of experience. If i want to start a mail about perl to wich email should i adress? I just got started with hello world, and nothing else run's, iam so sad. On Fri, May 3, 2013 at 3:45 PM, Brandon McCaig wrote: > On Fri, May 03, 2013 at 09:59:49PM +1000, Edward and Eric

Re: split

2013-05-03 Thread Brandon McCaig
On Fri, May 03, 2013 at 09:59:49PM +1000, Edward and Erica Heim wrote: > Hi all, Hello, > I'm using LWP::UserAgent to access a website. One of the methods > returns HTML data e.g. > > my $data = $response->content; > > I.e. $data contains the HTML content. I want to be able to parse it > line

Re: split

2013-05-03 Thread Jim Gibson
On May 3, 2013, at 4:59 AM, Edward and Erica Heim wrote: > Hi all, > > I'm using LWP::UserAgent to access a website. One of the methods returns > HTML data e.g. > > my $data = $response->content; > > I.e. $data contains the HTML content. I want to be able to parse it line by > line e.g. >

Re: split

2013-05-03 Thread Mike Dunaway
So you want to split the HTML in a way that $_ becomes one full line of text? It really depends how the HTML is written. If it's written all on one line (which is the case sometimes) you would probably need to go another route. If the HTML is written on multiple lines (and it should be for reada

Re: split

2012-04-09 Thread John W. Krahn
Matthew Bonner wrote: Hi Anamika I know this thread has focussed on using split -- thought I'd add a regex powered version for reference/comparison. cheers Matthew use strict; use warnings; while () { my @keys; @keys = $_ =~ m/(NM_\d+)+/g; $_ =~ m/\:1\s+(.*)$/;

Re: split

2012-04-09 Thread Matthew Bonner
Hi Anamika I know this thread has focussed on using split -- thought I'd add a regex powered version for reference/comparison. cheers Matthew use strict; use warnings; while () { my @keys; @keys = $_ =~ m/(NM_\d+)+/g; $_ =~ m/\:1\s+(.*)$/; print "$_ = $1\n"

Re: split

2012-04-05 Thread Dr.Ruud
On 2012-04-04 16:33, lina wrote: my ($keys, $value) = split /[ ]+/, $line; That is better written as split " ", $line; See perldoc -f split, about this special (and default) split mode. -- Ruud -- To unsubscribe, e-mail: beginners-unsubscr...@perl.org For additional commands, e-mail: beg

Re: split

2012-04-05 Thread mohan . p
Not sure about the code but i think below logic might work, 1) split the line into two parts , one is patterns and another is values 2) split /assign the patterns to an array and take the count 3) write a loop till the above count is reach and use the value taken in first step for each pattern in

Re: split

2012-04-04 Thread Rob Dixon
On 04/04/2012 13:57, Anamika K wrote: Hello All, I have a file like this: NM_009648,NM_001042541:10.955794504181601 NM_019584:1 0.900900900900901 NM_198862:1 0.835755813953488 NM_001039093,NM_001039092,NM_153080:1 0.805008944543828 and want output like this: NM_009648 0.955

Re: split

2012-04-04 Thread lina
On Wed, Apr 4, 2012 at 8:57 PM, Anamika K wrote: > Hello All, > I have a file like this: > > > NM_009648,NM_001042541:1        0.955794504181601 > NM_019584:1     0.900900900900901 > NM_198862:1     0.835755813953488 > NM_001039093,NM_001039092,NM_153080:1   0.805008944543828 > > and want output l

Re: split

2012-04-04 Thread Shawn H Corey
On 12-04-04 08:57 AM, Anamika K wrote: Could you please suggest my how to proceed? You should use two splits: one to separate the data by white space into two; and another to separate the first datum by commas. -- Just my 0.0002 million dollars worth, Shawn Programming is as much abo

Re: split

2012-04-04 Thread timothy adigun
Hi Anamika, Please, check my comments and suggestion below: On Wed, Apr 4, 2012 at 1:57 PM, Anamika K wrote: > Hello All, > I have a file like this: > > > NM_009648,NM_001042541:10.955794504181601 > NM_019584:1 0.900900900900901 > NM_198862:1 0.835755813953488 > NM_001039093,NM_0

Re: Split and concatenation

2011-12-19 Thread Brandon McCaig
On Sat, Dec 17, 2011 at 08:22:31AM +, vishnu.kuma...@wipro.com wrote: > Hi, Hello: > I am trying to convert the string abc.def.ghi.amm to > abcdefghiamm using split and concatenation. I am missing > something somewhere.. please help me to fix the code > > my $string = "abc.def.ghi.amm"; > >

RE: Split and concatenation

2011-12-19 Thread T D, Vishnu
Thanks guys for your suggestion -Original Message- From: Shlomi Fish [mailto:shlo...@shlomifish.org] Sent: Saturday, December 17, 2011 2:48 PM To: vishnu.kuma...@wipro.com Cc: beginners@perl.org Subject: Re: Split and concatenation Hi Vishnu, On Sat, 17 Dec 2011 08:22:31 +

Re: Split and concatenation

2011-12-18 Thread Dr.Ruud
On 2011-12-17 09:20, T D, Vishnu wrote: I am trying to convert the string abc.def.ghi.amm to abcdefghiamm $string =~ s/\.+//g using split and concatenation. join "", split /\.+/, $string -- Ruud -- To unsubscribe, e-mail: beginners-unsubscr...@perl.org For additional commands,

Re: split function

2011-12-17 Thread Brandon McCaig
On Fri, Dec 16, 2011 at 09:36:53PM -0600, Chris Stinemetz wrote: > This program does all I need it to do. I am having some difficulty > wrapping my head around it though. Mainly the for loop. Did Rob use > special varible? > > If any one can explain it to me so I can have a better understanding >

Re: Split and concatenation

2011-12-17 Thread John W. Krahn
vishnu.kuma...@wipro.com wrote: Hi, Hello, I am trying to convert the string abc.def.ghi.amm to abcdefghiamm using split and concatenation. I am missing something somewhere. . please help me to fix the code my $string = "abc.def.ghi.amm"; my @d = split(/\./,"$string"); my $e = @d; for (my

Re: Split and concatenation

2011-12-17 Thread Shlomi Fish
Hi Vishnu, On Sat, 17 Dec 2011 08:22:31 + wrote: > Hi, > > I am trying to convert the string abc.def.ghi.amm to abcdefghiamm using split > and concatenation. I am missing something somewhere.. please help me to fix > the code > > my $string = "abc.def.ghi.amm"; > > my @d = split(/\./,"$

Re: split function

2011-12-16 Thread Chris Stinemetz
> > However I think it's more likely that you need /all/ of the data to be > output, so I suggest something like my program below. > > HTH, > > Rob > > > use strict; > use warnings; > > my @headers; > > while () { >  if (@headers) { >    my @data = split; >    for my $i (0 .. $#headers) { >      pr

Re: split function

2011-12-16 Thread thebarn...@gmail.com
split() splits on whitespace by default. so the "\s+/" is optional. $_ = "3 element array"; @words = split; -- To unsubscribe, e-mail: beginners-unsubscr...@perl.org For additional commands, e-mail: beginners-h...@perl.org http://learn.perl.org/

Re: split function

2011-12-16 Thread shawn wilson
On Thursday, December 15, 2011, Chris Stinemetz wrote: > > It isn't a company policy just circumstance. The unix box I'm using > doesn't support DNS nameserver lookup or a C compiler. > > I'm currently using Perl 5.6.1 which doesnt' support local::lib and I > can't install perlbrew to upgrade my

Re: split function

2011-12-16 Thread Shlomi Fish
Hi Chris, On Thu, 15 Dec 2011 15:29:08 -0600 Chris Stinemetz wrote: > > > > Is that your company's policy, or do you just lack root access? If it's the > > latter, then see the various resources at > > http://perl-begin.org/topics/cpan/ , > > so you can see how to install Perl modules from CPAN

Re: split function

2011-12-15 Thread Chris Stinemetz
> > Is that your company's policy, or do you just lack root access? If it's the > latter, then see the various resources at http://perl-begin.org/topics/cpan/ , > so you can see how to install Perl modules from CPAN under your home > directory. > It isn't a company policy just circumstance. The u

Re: split function

2011-12-15 Thread Shlomi Fish
Hi Chris, On Thu, 15 Dec 2011 11:58:00 -0600 Chris Stinemetz wrote: > On Thu, Dec 15, 2011 at 10:42 AM, Dr.Ruud wrote: > > On 2011-12-14 05:43, Chris Stinemetz wrote: > > > >> I am trying to split the first element of an array by white space then > >> continue reading the rest of the file. > >>

RE: split function

2011-12-15 Thread Ken Slater
> To: Perl Beginners > Cc: Ken Slater; Chris Stinemetz > Subject: Re: split function > > On 15/12/2011 16:09, Ken Slater wrote: > > > > I have not been following this too closely, but I don't understand > the > > algorithm used to get the above ou

Re: split function

2011-12-15 Thread Chris Stinemetz
> > Tool completed successfully > Thank you Rob! This is what I was trying to accomplish. I'm going to have to research to find out exactly what you did. Thanks agian, Chris -- To unsubscribe, e-mail: beginners-unsubscr...@perl.org For additional commands, e-mail: beginners-h...@perl.org http:

Re: split function

2011-12-15 Thread Rob Dixon
On 15/12/2011 16:09, Ken Slater wrote: I have not been following this too closely, but I don't understand the algorithm used to get the above output. What is that Ken? If you don't understand the question then ask some questions of your own! I would have named it @fieldValues since arrays

Re: split function

2011-12-15 Thread Rob Dixon
On 15/12/2011 15:47, Chris Stinemetz wrote: > > I'm getting a bit closer. There a couple roadblocks I am up against. > > I am able to split the lines by white space, but for some reason the > program isn't capturing the first lines to the @fieldValue array after > the @headerNames array. > > Once I

RE: split function

2011-12-15 Thread Ken Slater
> -Original Message- > From: Ken Slater [mailto:kl...@psu.edu] > Sent: Thursday, December 15, 2011 11:09 AM > To: 'Chris Stinemetz'; 'John W. Krahn' > Cc: 'Perl Beginners' > Subject: RE: split function > > > -Original M

Re: split function

2011-12-15 Thread Chris Stinemetz
On Thu, Dec 15, 2011 at 10:42 AM, Dr.Ruud wrote: > On 2011-12-14 05:43, Chris Stinemetz wrote: > >> I am trying to split the first element of an array by white space then >> continue reading the rest of the file. >> Thus far I am having trouble figuring out how to split the first line. > > > You h

Re: split function

2011-12-15 Thread Dr.Ruud
On 2011-12-14 05:43, Chris Stinemetz wrote: I am trying to split the first element of an array by white space then continue reading the rest of the file. Thus far I am having trouble figuring out how to split the first line. You have an XY problem, you are probably looking for http://search.c

RE: split function

2011-12-15 Thread Ken Slater
> -Original Message- > From: Chris Stinemetz [mailto:chrisstinem...@gmail.com] > Sent: Thursday, December 15, 2011 10:47 AM > To: John W. Krahn > Cc: Perl Beginners > Subject: Re: split function > > I'm getting a bit closer. There a couple roadblocks I am

Re: split function

2011-12-15 Thread Chris Stinemetz
I'm getting a bit closer. There a couple roadblocks I am up against. I am able to split the lines by white space, but for some reason the program isn't capturing the first lines to the @fieldValue array after the @headerNames array. Once I get all the lines to go into the array correctly I would l

Re: split function

2011-12-14 Thread John W. Krahn
timothy adigun wrote: Hi Chris, Please check added code to yours, in addition to what John wrote; I am trying to split the first element of an array by white space then continue reading the rest of the file. Thus far I am having trouble figuring out how to split the first line. I would like

Re: split function

2011-12-14 Thread timothy adigun
Hi Chris, Please check added code to yours, in addition to what John wrote; I am trying to split the first element of an array by white space then continue reading the rest of the file. Thus far I am having trouble figuring out how to split the first line. I would like the first line to be spli

Re: split function

2011-12-13 Thread John W. Krahn
Chris Stinemetz wrote: I am trying to split the first element of an array by white space then continue reading the rest of the file. Thus far I am having trouble figuring out how to split the first line. I would like the first line to be split so it looks like the following with the "=" sign add

Re: split & re

2011-05-16 Thread Mike McClain
On Sun, May 15, 2011 at 11:51:35AM -0700, John W. Krahn wrote: > > split ' ', $line; > > John Smacking my forehead in chagrin. :-) You're absolutely right John, I just didn't read far enough. Thank you, Mike -- Satisfied user of Linux since 1997. O< ascii ribbon campaign - stop html mail - w

Re: split & re

2011-05-16 Thread Dr.Ruud
On 2011-05-15 18:28, Mike McClain wrote: In reading in a file of space separated columns of numbers and stuffing them into an array, I used: while( my $line =<$FH> ) { my @arr = split /\s+/, $line; push @primes_array, @arr; } but kept getting empty array entries until

Re: split & re

2011-05-15 Thread charley
On May 15, 12:28 pm, mike.j...@cox.net (Mike McClain) wrote: > In reading in a file of space separated columns of numbers > and stuffing them into an array, I used: >     while( my $line = <$FH> ) >     {   my @arr = split /\s+/, $line; >         push @primes_array, @arr; >     } > > but kept getti

Re: split & re

2011-05-15 Thread John W. Krahn
Mike McClain wrote: In reading in a file of space separated columns of numbers and stuffing them into an array, I used: while( my $line =<$FH> ) { my @arr = split /\s+/, $line; push @primes_array, @arr; } but kept getting empty array entries until I switched to: w

Re: Split function

2010-11-29 Thread Kenneth Wolcott
Hi; >>   The reason one should use File::Basename and File::Spec is that you >> can become platform-independent instead of Windoze-worshipping :-) > > What does the operating system have to do with this? > > OP asked how to split a string, I gave an example how to do it character by > character.

Re: Split function

2010-11-29 Thread Dr.Ruud
On 2010-11-29 02:27, Kenneth Wolcott wrote: On Sun, Nov 28, 2010 at 12:31, Dr.Ruud wrote: On 2010-11-28 10:54, Chaitanya Yanamadala wrote: How do i split a value like this F:\test\test123\test1233 For example: ruud$ perl -wle 'print for split //, q{F:\test\test123\test1233}' F : -snip- 3

Re: Split function

2010-11-29 Thread Brian Fraser
> > For a Windows shop, the overhead of platform independence is redundant, > Premature optimization much? Brian.

Re: Split function

2010-11-29 Thread Uri Guttman
> "ES" == Erez Schatz writes: ES> On 11/29/2010 03:27 AM, Kenneth Wolcott wrote: >> >> The reason one should use File::Basename and File::Spec is that you >> can become platform-independent instead of Windoze-worshipping :-) >> >> Ken Wolcott >> ES> I worship whatever I'm

Re: Split function

2010-11-29 Thread Erez Schatz
On 11/29/2010 03:27 AM, Kenneth Wolcott wrote: > > The reason one should use File::Basename and File::Spec is that you > can become platform-independent instead of Windoze-worshipping :-) > > Ken Wolcott > I worship whatever I'm paid to work on. For a Windows shop, the overhead of platform in

Re: Split function

2010-11-28 Thread Kenneth Wolcott
Hi; On Sun, Nov 28, 2010 at 12:31, Dr.Ruud wrote: > On 2010-11-28 10:54, Chaitanya Yanamadala wrote: > >> How do i split a value like this >> F:\test\test123\test1233 > > For example: > > ruud$ perl -wle 'print for split //, q{F:\test\test123\test1233}' > F > : > \ > t > e > s > t > \ > t > e > s

Re: Split function

2010-11-28 Thread Dr.Ruud
On 2010-11-28 10:54, Chaitanya Yanamadala wrote: How do i split a value like this F:\test\test123\test1233 For example: ruud$ perl -wle 'print for split //, q{F:\test\test123\test1233}' F : \ t e s t \ t e s t 1 2 3 \ t e s t 1 2 3 3 -- Ruud -- To unsubscribe, e-mail: beginners-unsubscr...@

Re: Split function

2010-11-28 Thread Téssio Fechine
Take extra caution with the backslash-scapes.. --- use 5.010; use strict; use warnings; my $str1 = "F:\test\test123\test1233"; #Wrong! Backslash being expanded! my $str2 = 'F:\test\test123\test1233'; my @array1 = split(/\\/, $str1); my @array2 = split(/\\/, $str2); my $n1 = @array1; my $n2 = @

Re: Split function

2010-11-28 Thread Parag Kalra
>>How do i split a value like this >>F:\test\test123\test1233 use strict; use warnings; my $str='F:\test\test123\test1233'; my @values = split /\\/, $str; print "@values"; Cheers, Parag On Sun, Nov 28, 2010 at 1:54 AM, Chaitanya Yanamadala < dr.virus.in...@gmail.com> wrote: > How do i split a

Re: Split function

2010-11-28 Thread Shlomi Fish
Hi Chaitanya, On Sunday 28 November 2010 11:54:14 Chaitanya Yanamadala wrote: > How do i split a value like this > F:\test\test123\test1233 > > please help me with this.. > You should use File::Spec (and related modules such as File::Basename) to manipulate path names, instead of using split.

Re: split log file

2010-10-18 Thread Shlomi Fish
Hi Agnello, On Monday 18 October 2010 15:01:56 Agnello George wrote: > I know the problem is solved but Could the script be done like this ?? > OK, I'll answer it. > #!/usr/bin/perl > > use strict; > use warnings; > > > while (my $line = ) { Why are you using *DATA and __DATA__ for the data

Re: split log file

2010-10-18 Thread Agnello George
On Sat, Oct 16, 2010 at 2:11 PM, Shlomi Fish wrote: > On Thursday 14 October 2010 16:54:32 yo RO wrote: > > Hello I need to split a log file per days > > I have a file in txt format and I want to create a file with all data > > from one day in one file > > I will give example > > > > I have this

Re: split log file

2010-10-18 Thread Agnello George
I know the problem is solved but Could the script be done like this ?? #!/usr/bin/perl use strict; use warnings; while (my $line = ) { chomp($line); my ($out_file) = $line =~ m/^(\d+_\d+_\d+);/; open (WRT,">>$out_file.log" ) or die " cannot opne file: $!";

Re: split log file

2010-10-18 Thread yo RO
On Oct 16, 10:41 am, shlo...@iglu.org.il (Shlomi Fish) wrote: > On Thursday 14 October 2010 16:54:32 yo RO wrote: > > > > > Hello I need to split a log file per days > > I have a file in txt format and I want to create a file with all data > > from one day in one file > > I will give example > > >

Re: split log file

2010-10-16 Thread Parag Kalra
use strict; use warnings; my %log; while(){ chomp; my ($key, $value) = split /;/, $_; push @{$log{$key}}, $value; } foreach my $k (keys %log){ open my $k_fh, '>', "$k.log" or die "Could not open the file - $k.log : $! \n"; foreach my $v (@{$log{$k}}) { print $k_f

Re: split log file

2010-10-16 Thread Shlomi Fish
On Thursday 14 October 2010 16:54:32 yo RO wrote: > Hello I need to split a log file per days > I have a file in txt format and I want to create a file with all data > from one day in one file > I will give example > > I have this imput > 3_21_2010;11:12\\trafic info > 3_21_2010;11:34\\trafic info

Re: split log file

2010-10-16 Thread Rob Coops
On Thu, Oct 14, 2010 at 4:54 PM, yo RO wrote: > Hello I need to split a log file per days > I have a file in txt format and I want to create a file with all data > from one day in one file > I will give example > > I have this imput > 3_21_2010;11:12\\trafic info > 3_21_2010;11:34\\trafic info >

Re: split ',' sometimes

2010-06-21 Thread C.DeRykus
On Jun 21, 3:30 am, chas.ow...@gmail.com ("Chas. Owens") wrote: > On Sun, Jun 20, 2010 at 20:49, C.DeRykus wrote: > > On Jun 19, 5:07 pm, stu21...@lycos.com wrote: > >> I have some text that specifies inherited runners in baseball: > > >>  'Hughes, D 2-0, O'Flaherty 2-0, Moylan 1-1' > > >> I want

Re: split ',' sometimes

2010-06-21 Thread Chas. Owens
On Sun, Jun 20, 2010 at 20:49, C.DeRykus wrote: > On Jun 19, 5:07 pm, stu21...@lycos.com wrote: >> I have some text that specifies inherited runners in baseball: >> >>  'Hughes, D 2-0, O'Flaherty 2-0, Moylan 1-1' >> >> I want to split on the comma and associate the numbers with that player.  The >

Re: split ',' sometimes

2010-06-21 Thread C.DeRykus
On Jun 19, 5:07 pm, stu21...@lycos.com wrote: > I have some text that specifies inherited runners in baseball: > >  'Hughes, D 2-0, O'Flaherty 2-0, Moylan 1-1' > > I want to split on the comma and associate the numbers with that player.  The > problem is that sometimes the player's first initial is

Re: split ',' sometimes

2010-06-19 Thread Chas. Owens
On Sat, Jun 19, 2010 at 20:21, Jim Gibson wrote: snip >>  'Hughes, D 2-0, O'Flaherty 2-0, Moylan 1-1' snip > The "clever" way is to use a regular expression that covers all of the > possible cases. Here is one that works for your sample string: > > $x = q(Hughes, D 2-0, O'Flaherty 2-0, Moylan 1-1)

Re: split ',' sometimes

2010-06-19 Thread Chas. Owens
On Sat, Jun 19, 2010 at 20:07, wrote: > I have some text that specifies inherited runners in baseball: > >  'Hughes, D 2-0, O'Flaherty 2-0, Moylan 1-1' > > I want to split on the comma and associate the numbers with that player.  The > problem is that sometimes the player's first initial is used

Re: split ',' sometimes

2010-06-19 Thread Jim Gibson
At 8:07 PM -0400 6/19/10, stu21...@lycos.com wrote: I have some text that specifies inherited runners in baseball: 'Hughes, D 2-0, O'Flaherty 2-0, Moylan 1-1' I want to split on the comma and associate the numbers with that player. The problem is that sometimes the player's first initial is u

Re: split value when there's nothing to split

2010-05-30 Thread Grant
> snip >>        $foo = $string =~ /^([^-])+-/ ? $1 : '' ; >> >> that will grab something from the start to the first - and grab it. if >> it matched it will assign it to $foo, otherwise assign ''. (and '' is >> called the null string, not null. perl has no null things unlike >> databases). > snip

Re: split value when there's nothing to split

2010-05-28 Thread Chas. Owens
On Fri, May 28, 2010 at 14:46, Uri Guttman wrote: >> "CO" == Chas Owens writes: > >  CO> On Fri, May 28, 2010 at 12:44, Uri Guttman wrote: > >  >> the negated char class is usually faster than most similar methods. i >  >> just like it as it says what i really want - a string without any - c

Re: split value when there's nothing to split

2010-05-28 Thread Uri Guttman
> "CO" == Chas Owens writes: CO> On Fri, May 28, 2010 at 12:44, Uri Guttman wrote: >> the negated char class is usually faster than most similar methods. i >> just like it as it says what i really want - a string without any - chars. >> also anchoring helps too in saying this string

Re: split value when there's nothing to split

2010-05-28 Thread Chas. Owens
On Fri, May 28, 2010 at 12:44, Uri Guttman wrote: >> "CO" == Chas Owens writes: > >  CO> On Fri, May 28, 2010 at 01:05, Uri Guttman wrote: >  CO> snip >  >>        $foo = $string =~ /^([^-])+-/ ? $1 : '' ; >  >> >  >> that will grab something from the start to the first - and grab it. if >  

Re: split value when there's nothing to split

2010-05-28 Thread Uri Guttman
> "CO" == Chas Owens writes: CO> On Fri, May 28, 2010 at 01:05, Uri Guttman wrote: CO> snip >>        $foo = $string =~ /^([^-])+-/ ? $1 : '' ; >> >> that will grab something from the start to the first - and grab it. if >> it matched it will assign it to $foo, otherwise assign

Re: split value when there's nothing to split

2010-05-28 Thread Chas. Owens
On Fri, May 28, 2010 at 01:05, Uri Guttman wrote: snip >        $foo = $string =~ /^([^-])+-/ ? $1 : '' ; > > that will grab something from the start to the first - and grab it. if > it matched it will assign it to $foo, otherwise assign ''. (and '' is > called the null string, not null. perl has

Re: split value when there's nothing to split

2010-05-27 Thread Uri Guttman
> "G" == Grant writes: G> The value of $string could include dashes or not. If it is, I'd like G> the value of $foo to be set to the portion of the string to the left G> of the first dash. If not, I'd like the value of $foo to be null. G> I'm doing the following, but $foo is equal

Re: split n characters into n chunks

2009-10-27 Thread Dr.Ruud
Shawn H Corey wrote: Dr.Ruud wrote: push @list, unpack "x${_}a$size", $word for 0 .. $max; Funnily enough, that is somehow&what faster than push @list, map unpack( "x${_}a$size", $word ), 0 .. $max; You don't need the push: my @list = map unpack( "x${_}a$size", $word ), 0 .. $max;

Re: split n characters into n chunks

2009-10-27 Thread mahesh bhasme
Hi, you can use substr $myword, 1,3 function Thanks, Mahesh On Sun, Oct 25, 2009 at 3:13 PM, Michael Alipio wrote: > Hi, > > How do I split a word into n subsets? > > my $word = "thequickbrown" > > > If I want three subsets I should be able to create: > > the > heq > equ > > upto > >

Re: split n characters into n chunks

2009-10-26 Thread Shawn H Corey
Dr.Ruud wrote: > Shawn H Corey wrote: > > >> push @list, (unpack( "A${i}A$size", $word ))[1]; > > Be careful with unpack "A", because it rtrims. > > > Best use "x" to skip, and "a" to capture. > > push @list, unpack "x${_}a$size", $word for 0 .. $max; > > > Funnily enough, that is som

Re: split n characters into n chunks

2009-10-26 Thread Dr.Ruud
Shawn H Corey wrote: push @list, (unpack( "A${i}A$size", $word ))[1]; Be careful with unpack "A", because it rtrims. Best use "x" to skip, and "a" to capture. push @list, unpack "x${_}a$size", $word for 0 .. $max; Funnily enough, that is somehow&what faster than push @list, map

Re: split n characters into n chunks

2009-10-26 Thread Dr.Ruud
Shawn H Corey wrote: John W. Krahn wrote: $ perl -le' my $word = "thequickbrown"; my $subsets = 3; print for $word =~ /(?=(.{$subsets}))/g; Getting up there but substr is still the fastest. I had to set the iterations to 300_000, to get rid of warnings. $ perl5.8.8 3.pl Rate

Re: split n characters into n chunks

2009-10-25 Thread Shawn H Corey
John W. Krahn wrote: > Why the for loop? > > my @list = $word =~ /(?=(.{$size}))/g; > > >> # print Dumper \...@list; #for testing only >> } Because you sent it with a loop. It also seems faster. #!/usr/bin/env perl use strict; use warnings; use Data::Dumper; # Make Data::Dumper pretty

Re: split n characters into n chunks

2009-10-25 Thread John W. Krahn
Shawn H Corey wrote: John W. Krahn wrote: $ perl -le' my $word = "thequickbrown"; my $subsets = 3; print for $word =~ /(?=(.{$subsets}))/g; Getting up there but substr is still the fastest. #!/usr/bin/env perl use strict; use warnings; use Data::Dumper; # Make Data::Dumper pretty $Data::Du

Re: split n characters into n chunks

2009-10-25 Thread Shawn H Corey
John W. Krahn wrote: > $ perl -le' > my $word = "thequickbrown"; > my $subsets = 3; > print for $word =~ /(?=(.{$subsets}))/g; Getting up there but substr is still the fastest. #!/usr/bin/env perl use strict; use warnings; use Data::Dumper; # Make Data::Dumper pretty $Data::Dumper::Sortkeys =

Re: split n characters into n chunks

2009-10-25 Thread John W. Krahn
Michael Alipio wrote: Hi, Hello, How do I split a word into n subsets? my $word = "thequickbrown" If I want three subsets I should be able to create: the heq equ upto own $ perl -le' my $word = "thequickbrown"; my $subsets = 3; print for $word =~ /(?=(.{$subsets}))/g; ' the he

Re: split n characters into n chunks

2009-10-25 Thread Shawn H Corey
Dr.Ruud wrote: > print substr( $word, $-[0], 3 ) > while $word =~ /.(?=..)/g; > Doesn't beat substr. #!/usr/bin/env perl use strict; use warnings; use Data::Dumper; # Make Data::Dumper pretty $Data::Dumper::Sortkeys = 1; $Data::Dumper::Indent = 1; # Set maximum depth for Data::Dumper

Re: split n characters into n chunks

2009-10-25 Thread Dr.Ruud
Michael Alipio wrote: my $word = "thequickbrown" If I want three subsets I should be able to create: the heq equ . upto . own print substr( $word, $-[0], 3 ) while $word =~ /.(?=..)/g; -- Ruud -- To unsubscribe, e-mail: beginners-unsubscr...@perl.org For additional commands,

Re: split n characters into n chunks

2009-10-25 Thread Shawn H Corey
Shlomi Fish wrote: > Why not use perldoc -f substr ( http://perldoc.perl.org/functions/substr.html > ) in a loop? Alternatively one can use unpack but I'm not sure how well it > would handle Unicode characters. You're right, substr works best. #!/usr/bin/env perl use strict; use warnings; use

Re: split n characters into n chunks

2009-10-25 Thread Shlomi Fish
On Sunday 25 Oct 2009 14:39:32 Shawn H Corey wrote: > Michael Alipio wrote: > > Any idea how to do this? I'm thinking maybe I can just > > split the whole string and push each character into array, > > then loop through the array, getting 3 elements set in the > > proces.. > > Split the string int

Re: split n characters into n chunks

2009-10-25 Thread Shawn H Corey
Michael Alipio wrote: > Any idea how to do this? I'm thinking maybe I can just > split the whole string and push each character into array, > then loop through the array, getting 3 elements set in the > proces.. Split the string into an array, loop through it and use a slice to join the elements.

RE: split() does not work with all characters

2009-06-03 Thread Wagner, David --- Senior Programmer Analyst --- CFS
> -Original Message- > From: Tony Esposito [mailto:tony1234567...@yahoo.co.uk] > Sent: Tuesday, June 02, 2009 15:29 > To: Beginners Perl > Subject: split() does not work with all characters > > When trying to use split() where the delimiter is passed from > the command-line ( as seen in

Re: split() does not work with all characters

2009-06-02 Thread Chas. Owens
On Tue, Jun 2, 2009 at 17:29, Tony Esposito wrote: > When trying to use split() where the delimiter is passed from the > command-line ( as seen in stub code that follows ), > the code fails to parse/split input file via some characters (e.g. | ) but it > runs ok for others (e.g. , ). > > Any ide

Re: Split on " or '

2009-03-03 Thread Chas. Owens
On Tue, Mar 3, 2009 at 14:56, Karyn Stump wrote: > I need to split a string on " or '. > > I have tried following lines in my script: > > my @fields = split(/["']/,$_); snip > Is it possible the missed " is a unicode char or something like that ? snip split /["']/ should work. It is possible tha

Re: Split not acting the way I want it to

2008-12-15 Thread Todd
Another fun way is to use `reverse' and `numeric/string conversion' as below. perl -le 'print 0+reverse int 0+reverse "1.2.3.45"' 45 Best regards, Todd -- To unsubscribe, e-mail: beginners-unsubscr...@perl.org For additional commands, e-mail: beginners-h...@perl.org http://learn.perl.org/

  1   2   3   4   5   >