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) {
>
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
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 (
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
What is the most efficient way to shift the first 100 items off an array?
Thanks!
ubject
Re: popping, shifting or splicing
an
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.
>
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
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
>
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
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
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
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
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
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
(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
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
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
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
> 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
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 (
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
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
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
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
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
"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
"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
> >
>
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
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
>
> 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(
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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,
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
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
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
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
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
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
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
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
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
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
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
58 matches
Mail list logo