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
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
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
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
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
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
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
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
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
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
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
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
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
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
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.
>
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
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+(.*)$/;
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"
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
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
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
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
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
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
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";
>
>
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 +
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,
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
>
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
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(/\./,"$
>
> 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
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/
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
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
>
> 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
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.
> >>
> 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
>
> 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:
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
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
> -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
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
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
> -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
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
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
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
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
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
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
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
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
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.
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
>
> For a Windows shop, the overhead of platform independence is redundant,
>
Premature optimization much?
Brian.
> "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
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
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
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...@
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 = @
>>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
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.
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
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
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:
$!";
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
>
> >
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
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
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
>
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
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
>
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
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)
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
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
> 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
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
> "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
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
>
> "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
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
> "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
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;
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
>
>
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
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
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
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
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
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 =
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
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
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,
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
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
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.
> -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
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
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
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 - 100 of 438 matches
Mail list logo