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

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: 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: 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

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

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: 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: 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