Re: shifting 100 at a time

2006-08-20 Thread Gerald Host
Yes! I just wasn't sure if I'd get undefs in my array or not (I don't). Thanks! On 8/20/06, Tom Phoenix <[EMAIL PROTECTED]> wrote: On 8/20/06, Gerald Host <[EMAIL PROTECTED]> wrote: > No. I want the most efficient way to do this: > my @array0=(0..1000); > my @array1; > for (0..100) { >

Re: shifting 100 at a time

2006-08-20 Thread Tom Phoenix
On 8/20/06, Gerald Host <[EMAIL PROTECTED]> wrote: No. I want the most efficient way to do this: my @array0=(0..1000); my @array1; for (0..100) { if (defined $array0[0]) { #accept 0 as a valid item push(@array1, shift @array0); } } Do you want splice? @array1 = splice @array0

Re: shifting 100 at a time

2006-08-20 Thread Gerald Host
No. I want the most efficient way to do this: my @array0=(0..1000); my @array1; for (0..100) { if (defined $array0[0]) { #accept 0 as a valid item push(@array1, shift @array0); } } I want to stop at the end of the @array0 too, so if it only had 20 items in it I would break the loop (

Re: shifting 100 at a time

2006-08-20 Thread Xavier Mas i Ramón
A Diumenge 20 Agost 2006 22:49, Gerald Host va escriure: > What is the most efficient way to shift the first 100 items off an array? > > Thanks! if you mean that first element be the last one and so on, use reverse. -- Xavier Mas -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional com

shifting 100 at a time

2006-08-20 Thread Gerald Host
What is the most efficient way to shift the first 100 items off an array? Thanks!

Re: popping, shifting or splicing an array???

2005-08-09 Thread DBSMITH
ubject Re: popping, shifting or splicing an

Re: popping, shifting or splicing an array???

2005-08-09 Thread Offer Kaye
On 8/9/05, DBSMITH wrote: > > Hello ... > > I am trying to figure out, which operator to use; pop, shift or splice. > My goal is, as an option is selected from user input, pop or splice or > shift elements off ( those selected from user input ) and repopulate array > with remaining elements. >

popping, shifting or splicing an array???

2005-08-09 Thread DBSMITH
selection list. This could be replace with a loop that is popping, shifting or splicing foreach (@ArrayA) { shift @number to remove; } print @ArrayA # Array A now has 05-1000 OR @ArrayA=(0 .. 1000); print @array; ## User now sees selection list. This could be replaced with splice or shift or

Re: shifting through arrays of line data

2003-03-04 Thread Deb
John W. Krahn <[EMAIL PROTECTED]> had this to say, > Ok, here it is using the code you posted elsethread. Much more elegant than mine, but by looking at the output, it's still not quite right. Note that there really is no -m option. > After running it I get this output: > > direct >

Re: shifting through arrays of line data

2003-03-04 Thread John W. Krahn
Deb wrote: > > John wrote: > > Did you try the code I posted Friday? (Message-ID: <[EMAIL PROTECTED]>) > > Thanks, yes, I did. But, the syntax was new to me, and I've been reading > up on it. I couldn't really get it to do what I want (see my previous > post to this one). But, that's probably

Re: STILL shifting through arrays of line data

2003-03-04 Thread Rob Dixon
Hi Deb. Let me put you out of your misery. It's a shame because you were s close! Deb wrote: > > Here's the modified script. I made some changes, as suggested, but > there > was no change in the output. I've included my entire script. My > head is getting mighty flat from banging it against

Re: STILL shifting through arrays of line data

2003-03-04 Thread Sudarshan Raghavan
On Tue, 4 Mar 2003, Sudarshan Raghavan wrote: > The problem is with the last \s+, when you are parsing the final tuple > $rest contains this '-h ten-me-900'. Due to the final \s+ the above regex > will not match. This leaves $opt, $arg and $newRest as undefined. Change > the final \s+ to \s* an

Re: STILL shifting through arrays of line data

2003-03-04 Thread Sudarshan Raghavan
On Mon, 3 Mar 2003, Deb wrote: > Here's the modified script. I made some changes, as suggested, but there > was no change in the output. I've included my entire script. My head is > getting mighty flat from banging it against the wall. Oh, and I added "use > warnings;" and I haven't got a clu

Re: STILL shifting through arrays of line data

2003-03-03 Thread Deb
Sudarshan Raghavan <[EMAIL PROTECTED]> had this to say, > > Did you look at the code that I posted at the end of my last mail? I'm so embarrassed! I totally missed it! Wow. This is just what I'm looking for. I'm going to try it out - but it will have to wait until morning (it's 2315 here, a

Re: STILL shifting through arrays of line data

2003-03-03 Thread Sudarshan Raghavan
On Mon, 3 Mar 2003, Deb wrote: > Here's the modified script. I made some changes, as suggested, but there > was no change in the output. I've included my entire script. My head is > getting mighty flat from banging it against the wall. Oh, and I added "use > warnings;" and I haven't got a clu

Re: STILL shifting through arrays of line data

2003-03-03 Thread Deb
(H, this should have been posted, but I don't see it - sorry if this actually becomes a double-posting...) Here's the modified script. I made some changes, as suggested, but there was no change in the output. I've included my entire script. My head is getting mighty flat from banging it ag

Re: STILL shifting through arrays of line data

2003-03-03 Thread Deb
Here's the modified script. I made some changes, as suggested, but there was no change in the output. I've included my entire script. My head is getting mighty flat from banging it against the wall. Oh, and I added "use warnings;" and I haven't got a clue what I need to do to fix those. I'd

Re: shifting through arrays of line data

2003-03-03 Thread Deb
John wrote: > Did you try the code I posted Friday? (Message-ID: <[EMAIL PROTECTED]>) John, Thanks, yes, I did. But, the syntax was new to me, and I've been reading up on it. I couldn't really get it to do what I want (see my previous post to this one). But, that's probably b/c I didn't expl

Re: STILL shifting through arrays of line data

2003-03-03 Thread John W. Krahn
Deb wrote: > > Okay, I'm still struggling.I just cannot seem to get my mind to > stop, look, and listen. Here's some code I'm working on: Did you try the code I posted Friday? (Message-ID: <[EMAIL PROTECTED]>) John -- use Perl; program fulfillment -- To unsubscribe, e-mail: [EMAIL PRO

Re: STILL shifting through arrays of line data

2003-03-03 Thread Sudarshan Raghavan
> Okay, I'm still struggling.I just cannot seem to get my mind to > stop, look, and listen. Here's some code I'm working on: > - 8-< > use strict; You might also want to add a use warnings after use strict and check how y

Re: STILL shifting through arrays of line data

2003-03-03 Thread George P.
On Mon, 3 Mar 2003, Deb wrote: > Okay, I'm still struggling.I just cannot seem to get my mind to > stop, look, and listen. Here's some code I'm working on: > > - 8-< > use strict; > my %cmdLine; > my $DBG = 1; > > while (

STILL shifting through arrays of line data

2003-03-03 Thread Deb
Okay, I'm still struggling.I just cannot seem to get my mind to stop, look, and listen. Here's some code I'm working on: - 8-< use strict; my %cmdLine; my $DBG = 1; while () { chomp; my ($adx, $rest) = (spl

Re: shifting through arrays of line data

2003-03-02 Thread R. Joseph Newton
Deb wrote: > This (code below) makes sense to me, but I was talking this over with a > co-worker on Friday, and then I tried putting together some 2-dimensional > hashes - which hurts my head at the moment. Hi Deb Actually, the hash hee--so far, anyway--is not two-dimensional. More later > So

RE: shifting through arrays of line data

2003-03-01 Thread Beau E. Cox
Hi Deb - > -Original Message- > From: Deb [mailto:[EMAIL PROTECTED] > Sent: Saturday, March 01, 2003 7:17 PM > To: R. Joseph Newton; Perl List > Subject: Re: shifting through arrays of line data > > > This (code below) makes sense to me, but I was talking this ov

Re: shifting through arrays of line data

2003-03-01 Thread Deb
This (code below) makes sense to me, but I was talking this over with a co-worker on Friday, and then I tried putting together some 2-dimensional hashes - which hurts my head at the moment. So I went to perl.plover.com/FAQs to read (again) his article on references, and I still have a mental block

Re: shifting through arrays of line data

2003-02-28 Thread R. Joseph Newton
Deb wrote: > Hi Guys, > > I have an array in which each element is a line commandline data. It looks > something like this - > > @Array contains lines: > > post1: -r [EMAIL PROTECTED] -x cat-100 -h post1 > post2: -x tel -h post2 > post3: -h post3 -x hifi The getRelationships sub here has a few l

Re: shifting through arrays of line data

2003-02-28 Thread R. Joseph Newton
"John W. Krahn" wrote: > "R. Joseph Newton" wrote: > > > > Deb wrote: > > > > > > I have an array in which each element is a line commandline data. It looks > > > something like this - > > >... > > > post1: -r [EMAIL PROTECTED] -x cat-100 -h post1 > > > post2: -x tel -h post2 > > > post3: -h post

Re: shifting through arrays of line data

2003-02-28 Thread John W. Krahn
"R. Joseph Newton" wrote: > > Deb wrote: > > > > I have an array in which each element is a line commandline data. It looks > > something like this - > > > > @Array contains lines: > > > > post1: -r [EMAIL PROTECTED] -x cat-100 -h post1 > > post2: -x tel -h post2 > > post3: -h post3 -x hifi > > >

Re: shifting through arrays of line data

2003-02-28 Thread R. Joseph Newton
Deb wrote: > Hi Guys, > > I have an array in which each element is a line commandline data. It looks > something like this - > > @Array contains lines: > > post1: -r [EMAIL PROTECTED] -x cat-100 -h post1 > post2: -x tel -h post2 > post3: -h post3 -x hifi > > What I really need to do is build a re

Re: shifting through arrays of line data

2003-02-28 Thread John W. Krahn
Deb wrote: > > Hi Guys, > > I have an array in which each element is a line commandline data. It looks > something like this - > > @Array contains lines: > > post1: -r [EMAIL PROTECTED] -x cat-100 -h post1 > post2: -x tel -h post2 > post3: -h post3 -x hifi > > And so on. The order of the opt

RE: shifting through arrays of line data

2003-02-28 Thread Dan Muey
> > Thanks, I know how to use split (I think). Since the data > comes in any order, and I have to corellate it, I can't think > of a way that split will fix me up - Maybe I'm missing > something. Can you give me an example? > Ok I'll give her a go my %results; my $cnt = 1; foreach $line(

Re: shifting through arrays of line data

2003-02-28 Thread Deb
Thanks, I know how to use split (I think). Since the data comes in any order, and I have to corellate it, I can't think of a way that split will fix me up - Maybe I'm missing something. Can you give me an example? deb Dan Muey <[EMAIL PROTECTED]> had this to say, > perldoc -f split > > Will

RE: shifting through arrays of line data

2003-02-28 Thread Dan Muey
perldoc -f split Will fic you up! Dmuey > Hi Guys, > > I have an array in which each element is a line commandline > data. It looks something like this - > > @Array contains lines: > > post1: -r [EMAIL PROTECTED] -x cat-100 -h post1 > post2: -x tel -h post2 > post3: -h post3 -x hifi > > An

shifting through arrays of line data

2003-02-28 Thread Deb
Hi Guys, I have an array in which each element is a line commandline data. It looks something like this - @Array contains lines: post1: -r [EMAIL PROTECTED] -x cat-100 -h post1 post2: -x tel -h post2 post3: -h post3 -x hifi And so on. The order of the options varies, and there may or may not

Re: Shifting

2003-02-26 Thread Bernhard van Staveren
splice is your friend :) splice(@data, 0, 9); will solve all your problems ;) On Tue, 25 Feb 2003, dan wrote: > Hi, > > I've come across a dilemma, I can solve it the long way round, I'm enquiring > if there's a shorter way to do this. > > I have an array, @data, which contains a lot of data w

Re: Shifting

2003-02-25 Thread Pete Emerson
There are probably oodles of ways of doing this. Here are two: # An array slice @[EMAIL PROTECTED]; or # start at position 0, remove 9 elements splice @data, 0, 9; Pete On Tue, 2003-02-25 at 14:39, dan wrote: > onwards. My way of doing this was: > shift(@data); x 9 -- To unsubscribe, e-mail

Shifting

2003-02-25 Thread dan
Hi, I've come across a dilemma, I can solve it the long way round, I'm enquiring if there's a shorter way to do this. I have an array, @data, which contains a lot of data which has been received from a socket. The problem is I want to have the 10th item (9th index) onwards. My way of doing this w

Re: shifting solved (was "Re: chomp-ing DOS lines, shifting, and a variable variable")

2002-06-09 Thread David T-G
Timothy, et al -- ...and then Timothy Johnson said... % % David->"Hmmm... OK, so that explains it, but I still don't get it... So % the match is going to spit out a scalar but in order to use it you have to % capture it in a list context?" % % No, actually the opposite. The match returns a l

RE: shifting solved (was "Re: chomp-ing DOS lines, shifting, and a variable variable")

2002-06-09 Thread Timothy Johnson
as a scalar. Thus: ($fullpath =~ m:/mp3/(.+):)[0] is element 0 of the list created by evaluating the match. That way what split sees is a scalar (the element), so it can split it accordingly. -Original Message- From: David T-G To: perl beginners Cc: Timothy Johnson Sent: 6/9/02 7:51 PM Sub

Re: shifting solved (was "Re: chomp-ing DOS lines, shifting, and a variable variable")

2002-06-09 Thread David T-G
Timothy, et al -- ...and then Timothy Johnson said... % % Ok, I finally got a chance to test it, and the problem with my code is that % split expects a scalar as the second argument. This does work: % % ($temp) = $fullpath =~ m:/mp3/(.+):; % @working = split /\//,$temp; % % because it is

RE: shifting solved (was "Re: chomp-ing DOS lines, shifting, and a variable variable")

2002-06-09 Thread Timothy Johnson
Try this: @working = split(/\//,($fullpath =~ m:/mp3/(.+):)[0]); -Original Message- From: David T-G [mailto:[EMAIL PROTECTED]] Sent: Sunday, June 09, 2002 1:43 PM To: perl beginners Cc: Timothy Johnson Subject: Re: shifting solved (was "Re: chomp-ing DOS lines, shifting, and a variabl

Re: shifting solved (was "Re: chomp-ing DOS lines, shifting, and a variable variable")

2002-06-09 Thread David T-G
Timothy, et al -- ...and then David T-G said... % % ...and then Timothy Johnson said... % % % % I can't test this where I am right now, but would something like this work? % % % % @working = split /\//,($fullpath =~ m|/mp3/(.+)|); #changed match delimiter % % I'm surprised to find that it doe

Re: shifting solved (was "Re: chomp-ing DOS lines, shifting, and a variable variable")

2002-06-09 Thread David T-G
Timothy, et al -- ...and then Timothy Johnson said... % % I can't test this where I am right now, but would something like this work? % % @working = split /\//,($fullpath =~ m|/mp3/(.+)|); #changed match delimiter I'm surprised to find that it does, but I'm glad I tested it. I thought that ma

RE: shifting solved (was "Re: chomp-ing DOS lines, shifting, and a variable variable")

2002-06-09 Thread Timothy Johnson
Elias Assmann Subject: Re: shifting solved (was "Re: chomp-ing DOS lines, shifting, and a variable variable") Elias, et al -- and then Elias Assmann said... % % Oh my, what a bad day for my poor little brain... Sorry for all that % confusion. *grin* No problem; it made me c

Re: shifting solved (was "Re: chomp-ing DOS lines, shifting, and a variable variable")

2002-06-09 Thread David T-G
Elias, et al -- ...and then Elias Assmann said... % % Oh my, what a bad day for my poor little brain... Sorry for all that % confusion. *grin* No problem; it made me check my answers :-) % % On Sun, 9 Jun 2002, David T-G wrote: % % > ...and then Elias Assmann said... % > % > % be two lines

Re: shifting solved (was "Re: chomp-ing DOS lines, shifting, and avariable variable")

2002-06-09 Thread Elias Assmann
Oh my, what a bad day for my poor little brain... Sorry for all that confusion. On Sun, 9 Jun 2002, David T-G wrote: > Elias, et al -- > > ...and then Elias Assmann said... > > % be two lines, so how about this: @working = m'/mp3(/[^/]+)+';? It seems I have suffered a misconception about what

Re: shifting solved (was "Re: chomp-ing DOS lines, shifting, and a variable variable")

2002-06-09 Thread David T-G
Elias, et al -- ...and then Elias Assmann said... % % On Sat, 8 Jun 2002, David T-G wrote: % % > % I can't modify $fullpath because I'll use it later, but for parsing I % > % don't need the leading "/mp3/" part, and the only way I've found to get ... % > While it may not be a perfect solution,

Re: shifting solved (was "Re: chomp-ing DOS lines, shifting, and a variable variable")

2002-06-09 Thread David T-G
Elias -- ...and then Elias Assmann said... % % On Sun, 9 Jun 2002, Elias Assmann wrote: % % > be two lines, so how about this: @working = m'/mp3(/[^/]+)+';? % % So much for posting code without trying it... This isn't working, but *grin* % it isn't obvious to me why, and I don't have time r

Re: no chop chop - Re: chomp-ing DOS lines, shifting, and a variable variable

2002-06-09 Thread David T-G
drieux, et al -- ...and then drieux said... % % On Saturday, June 8, 2002, at 08:13 , David T-G wrote: % >drieux, et al -- % >...and then drieux said... % >% On Saturday, June 8, 2002, at 04:47 , David T-G wrote: ... % > % >Tell me about the standard... Should perl happily chomp either a UNIX o

Re: shifting solved (was "Re: chomp-ing DOS lines, shifting, and avariable variable")

2002-06-09 Thread Elias Assmann
On Sun, 9 Jun 2002, Elias Assmann wrote: > be two lines, so how about this: @working = m'/mp3(/[^/]+)+';? So much for posting code without trying it... This isn't working, but it isn't obvious to me why, and I don't have time right now :-( Elias -- Gefängnis für Hans Mustermann wegen

Re: shifting solved (was "Re: chomp-ing DOS lines, shifting, and avariable variable")

2002-06-09 Thread Elias Assmann
On Sat, 8 Jun 2002, David T-G wrote: > % I can't modify $fullpath because I'll use it later, but for parsing I > % don't need the leading "/mp3/" part, and the only way I've found to get > % rid of it elegantly is > % > % ... > % @working = split(/\//,$fullpath) ; # cut path in

Re: no chop chop - Re: chomp-ing DOS lines, shifting, and a variable variable

2002-06-09 Thread drieux
On Saturday, June 8, 2002, at 08:13 , David T-G wrote: > drieux, et al -- > ...and then drieux said... > % On Saturday, June 8, 2002, at 04:47 , David T-G wrote: [..] > % >... > % >chop ; chop ; # strip \n\r (no chomp here) > ... > % > % that is way too weird - si

shifting solved (was "Re: chomp-ing DOS lines, shifting, and a variable variable")

2002-06-08 Thread David T-G
Hi, all -- ...and then David T-G said... % ... % I can't modify $fullpath because I'll use it later, but for parsing I % don't need the leading "/mp3/" part, and the only way I've found to get % rid of it elegantly is % % ... % @working = split(/\//,$fullpath) ;# cut path

Re: no chop chop - Re: chomp-ing DOS lines, shifting, and a variable variable

2002-06-08 Thread David T-G
drieux, et al -- ...and then drieux said... % % On Saturday, June 8, 2002, at 04:47 , David T-G wrote: % [..] % > ... % >... % >chop ; chop ;# strip \n\r (no chomp here) ... % % that is way too weird - since that means that what % ever dos app you were using

no chop chop - Re: chomp-ing DOS lines, shifting, and a variable variable

2002-06-08 Thread drieux
On Saturday, June 8, 2002, at 04:47 , David T-G wrote: [..] > > The files were written in DOS format (\r\n or, I am more inclined to > think, \n\r) and chomp doesn't work; instead I have to > > ... > while (<>) > { > ... > chop ; chop ; # strip \n\r (no c

chomp-ing DOS lines, shifting, and a variable variable

2002-06-08 Thread David T-G
Hi, all -- [I should probably note early on that I do have some preferences that don't match what many coders do but which I will very probably continue anyway, like how I place braces, but that I quite welcome perl style tips along with the rest of the answers begged below because lots of the ot

Re: shifting scalars ??

2001-12-08 Thread Maxim Berlin
Hello Craig, Saturday, December 08, 2001, Craig Inman <[EMAIL PROTECTED]> wrote: CI> As I'm new to perl, I'm more or less trying to write a 'nested while CI> read' loop (atleast that is what my attempts come out to look like so CI> far). CI> trying something like CI> open (A, $list1) or di

shifting scalars ??

2001-12-07 Thread Craig Inman
Hello all. I'm trying to find an easy way to 'diff' two files and print what is missing from each file. Let me start by saying that the system I'm working on does not seem to like File::compare or &main::compare_text. As I'm new to perl, I'm more or less trying to write a 'nested while read' loo