""Chris Charley"" wrote in message
"Chris Stinemetz" wrote in message news
Hello List,
I have input data such as far below:
I would like to read the data into an array and modify the 2nd index if
the
0th and first indices are identical.
I would like the updated 2nd index to be an avera
"Chris Stinemetz" wrote in message news
Hello List,
I have input data such as far below:
I would like to read the data into an array and modify the 2nd index if the
0th and first indices are identical.
I would like the updated 2nd index to be an average of the 2nd index where
both occurences o
Hi Chris,
On Sun, 19 Aug 2012 08:49:25 -0500
Chris Stinemetz wrote:
> Hello List,
>
> I have input data such as far below:
>
> I would like to read the data into an array and modify the 2nd index
> if the 0th and first indices are identical.
> I would like the updated 2nd index to be an averag
>
>> or the File::Find module to find files without resorting
>> to the use of separate processes and shell commands.
>
>
> Me second.
> File::Find is your friend.
>
Also, since you seem to be familiar with find use find2perl and you barely
have to lift a finger. Its like training wheels for File::
于 2010-12-15 1:38, Jim Gibson 写道:
or the File::Find module to find files without resorting
to the use of separate processes and shell commands.
Me second.
File::Find is your friend.
--
To unsubscribe, e-mail: beginners-unsubscr...@perl.org
For additional commands, e-mail: beginners-h...@perl.o
Matt wrote:
I am assigning a number of elements to an array like so:
my @new = `find /home/*/new -cmin 1 -type f`;
That works fine. I would also like to append more lines to that array
from here:
find /home/*/filed -cmin 1 -type f
How do I do that without losing whats in the array already?
On 12/14/10 Tue Dec 14, 2010 9:18 AM, "Matt" scribbled:
> I am assigning a number of elements to an array like so:
>
> my @new = `find /home/*/new -cmin 1 -type f`;
>
> That works fine. I would also like to append more lines to that array
> from here:
>
> find /home/*/filed -cmin 1 -type f
Dave Tang wrote:
On Tue, 31 Mar 2009 04:49:17 +1000, John W. Krahn wrote:
Or instead of using arrays you could store the 1s and 0s in strings:
$ perl -le'
my $string = "10110111001";
print $-[0] while $string =~ /0/g;
'
1
4
8
9
Could you explain how the above code works please?
while $str
On Tue, 31 Mar 2009 04:49:17 +1000, John W. Krahn wrote:
Or instead of using arrays you could store the 1s and 0s in strings:
$ perl -le'
my $string = "10110111001";
print $-[0] while $string =~ /0/g;
'
1
4
8
9
Hi John,
Could you explain how the above code works please? I looked up perl -l
ANJAN PURKAYASTHA wrote:
Hi,
Hello,
Here is my problem;
I have a series of arrays with 0s and 1s. here is an example: (1, 0, 1, 1).
I need to parse through this series of arrays and extract the index of the
0s in the array.
Is there any quick way of doing this?
$ perl -le'
my @array = ( 1,
On Mon, Mar 30, 2009 at 14:28, Rodrick Brown wrote:
snip
> Millions of ways here is one:
snip
> my $pos = 0;
>
> for my $index (@arr) {
> if ( $index == 0 ) {
> printf ("%d ", $pos );
> }
> $pos++;
> }
snip
If you are going to go with a full bore for loop, you might as well
get rid of the
On Mon, Mar 30, 2009 at 14:20, ANJAN PURKAYASTHA
wrote:
> Hi,
> Here is my problem;
> I have a series of arrays with 0s and 1s. here is an example: (1, 0, 1, 1).
> I need to parse through this series of arrays and extract the index of the
> 0s in the array.
> Is there any quick way of doing this?
On Mon, Mar 30, 2009 at 2:20 PM, ANJAN PURKAYASTHA
wrote:
> Hi,
> Here is my problem;
> I have a series of arrays with 0s and 1s. here is an example: (1, 0, 1, 1).
> I need to parse through this series of arrays and extract the index of the
> 0s in the array.
> Is there any quick way of doing this
Paul Lalli wrote:
On Feb 26, 11:07 am, [EMAIL PROTECTED] (Irfan Sayed) wrote:
Hello All,
I have two arrays contains exact no. of elements. Now what I need to do
is , I want to execute certain commands to each elements of the array at
a time.
It means that I want take first element of first ar
On Feb 26, 11:07 am, [EMAIL PROTECTED] (Irfan Sayed) wrote:
> Hello All,
>
> I have two arrays contains exact no. of elements. Now what I need to do
> is , I want to execute certain commands to each elements of the array at
> a time.
>
> It means that I want take first element of first array and f
On Tue, Feb 26, 2008 at 8:07 AM, <[EMAIL PROTECTED]> wrote:
> Hello All,
>
>
>
> I have two arrays contains exact no. of elements. Now what I need to do
> is , I want to execute certain commands to each elements of the array at
> a time.
>
>
>
> It means that I want take first element of firs
On Tue, Feb 26, 2008 at 10:07 AM, <[EMAIL PROTECTED]> wrote:
> Hello All,
>
>
>
> I have two arrays contains exact no. of elements. Now what I need to do
> is , I want to execute certain commands to each elements of the array at
> a time.
@array1 = (1,2,3);
@array2 = (4,5,6);
for (my $i=0; $
for (my $i = 0; $i < @arry; $i++) {
splice (@arry, $i, 1, split (' ', $arry[$i], 2));
}
If one of the elements of @arry contains "one two three" then using "2" will
add the two elements "one" and "two three" instead of the three elements
"one", "two" and "three" so you may still be left with
M. Kristall wrote:
> John W. Krahn wrote:
>>> for (my $i = 0; $i < @arry; $i++) {
>>> splice (@arry, $i, 1, split (' ', $arry[$i], 1));
>>> }
>>
>> How does that populate the @new_array variable?
>
> Mine doesn't populate @new_array. It takes the original array and
> replaces it with the equiv
"Timothy Johnson" schreef:
> if I had my way, I'd remove
> [...] the default variable $_.
But why would you want that?
#!/usr/bin/perl
use strict;
use warnings;
sub say
{
print +(@_ ? @_ : $_), $/ ;
1
}
say for 'A' .. 'Z' ;
for ( 'a' .. 'z' ) { say } ;
for my $c ( 'A' .. 'Z' ) { say $c
John W. Krahn wrote:
for (my $i = 0; $i < @arry; $i++) {
splice (@arry, $i, 1, split (' ', $arry[$i], 1));
}
How does that populate the @new_array variable?
Mine doesn't populate @new_array. It takes the original array and
replaces it with the equivalent of everyone else's @new_array :-)
On Tue, May 09, 2006 at 11:52:26AM -0700, Timothy Johnson wrote:
>
> As much as I would hate to make you cry, if I had my way, I'd remove
> that as well as the default variable $_. It would be like the first
> time you had to convert all of your scripts to use the strict pragma,
> but in the end
On Tue, 2006-09-05 at 14:54 -0700, Bryan R Harris wrote:
> Regarding Timothy's thoughts, I tend to believe perl wouldn't be as popular
> if the "use strict" pragma defaulted to on. I don't code in C because it's
> too hard to get all the little details right. Perl is very forgiving, and
> for my
> On Tue, 2006-09-05 at 11:52 -0700, Timothy Johnson wrote:
>> It's the Perl
>> equivalent of having to remember 'I before E except after C...'.
>
> '.. except where it's not.'
>
> E.g:
> height
> weight
> sex
>
> (OK, I included 'sex' just to get your attention.)
On some platforms:
"Mr. Shawn H. Corey" schreef:
> Dr.Ruud:
>> One exception: the pattern / / does not work like the pattern ' '.
>
> But it should, that's my point.
Not for / / vs. ' ', because that is a special case. It is far too late
to change the special case to undef or whatever.
I like your example that sh
On Tue, 2006-09-05 at 11:52 -0700, Timothy Johnson wrote:
> It's the Perl
> equivalent of having to remember 'I before E except after C...'.
'.. except where it's not.'
E.g:
height
weight
sex
(OK, I included 'sex' just to get your attention.)
--
__END__
Just my 0.0002 million dolla
-Original Message-
From: Bryan R Harris [mailto:[EMAIL PROTECTED]
Sent: Tuesday, May 09, 2006 11:24 AM
To: Beginners Perl
Subject: Re: array question
>> On Tue, 2006-09-05 at 18:33 +0200, Dr.Ruud wrote:
>>> One exception: the pattern / / does not work like the pattern
On Tue, 2006-09-05 at 11:23 -0700, Bryan R Harris wrote:
> Are you proposing that the special case be removed? If so, PLEASE NO! I
> use that special case in almost every script I write, and if they removed it
> I would probably shed tears over it.
Don't worry; they won't. Well, maybe in Perl6;
> On Tue, 2006-09-05 at 18:33 +0200, Dr.Ruud wrote:
>> One exception: the pattern / / does not work like the pattern ' '.
>
> But it should, that's my point.
Are you proposing that the special case be removed? If so, PLEASE NO! I
use that special case in almost every script I write, and if t
Mr. Shawn H. Corey wrote:
> On Tue, 2006-09-05 at 09:05 -0700, John W. Krahn wrote:
>>I don't understand what you are trying to say.
>
> I saying this should work:
>
> split '+', 'this+is+a+test';
>
> Yes, I know how to fix it. I'm saying it _should_ work, not that it
> does. If split is follo
On Tue, 2006-09-05 at 09:44 -0700, chen li wrote:
> split /PATTERN/,EXPR,LIMIT
> split /PATTERN/,EXPR
> split /PATTERN/
> split
>
> 1. I check the perldoc -f split but I am not quite
> sure what EXPR really means. Does it refer to a
> string, or a scalar variable contaning a string, or an
> ar
On Tue, 2006-09-05 at 18:33 +0200, Dr.Ruud wrote:
> One exception: the pattern / / does not work like the pattern ' '.
But it should, that's my point.
--
__END__
Just my 0.0002 million dollars worth,
--- Shawn
"For the things we have to learn before we can do them, we learn by doing t
On Tue, 2006-09-05 at 09:05 -0700, John W. Krahn wrote:
> I don't understand what you are trying to say.
I saying this should work:
split '+', 'this+is+a+test';
Yes, I know how to fix it. I'm saying it _should_ work, not that it
does. If split is followed by a string, the string should be quot
chen li wrote:
>
> --- "John W. Krahn" <[EMAIL PROTECTED]> wrote:
>>
>>$ perl -le'
>>my $string = q[ a b c d ];
>>print join "\t", map "<$_>", split q[\s+],
>>qq[$string], q[4];
>>print join "\t", map "<$_>", split /\s+/,
>>$string,4;
>>'
>><>
>><>
>>
>
Mr. Shawn H. Corey" schreef:
> John W. Krahn:
>> Anything used as a pattern is a string. See the "Quote and
>> Quote-like Operators" section of perlop:
>
> Huh?
>
> Do you mean all strings can be used as a pattern?
>
> split( quotemeta( $split_string ), $data_string );
>
>
> Or that patterns ar
--- "John W. Krahn" <[EMAIL PROTECTED]> wrote:
> Mr. Shawn H. Corey wrote:
> > On Tue, 2006-09-05 at 01:33 +0200, Paul Johnson
> wrote:
> >>Um, that's not quite correct.
> >>
> >>See `perldoc -f split` for details.
> >
> > Oh, yes, a special case. I have long ago abandoned
> special cases since
Mr. Shawn H. Corey wrote:
> On Tue, 2006-09-05 at 01:30 -0700, John W. Krahn wrote:
>>Anything used as a pattern is a string. See the "Quote and Quote-like
>>Operators" section of perlop:
>
> Huh?
>
> Do you mean all strings can be used as a pattern?
A pattern is a string. Perl does string int
M. Kristall wrote:
> chen li wrote:
I have an arry like this:
@arry=('AA bb','BB','CC AG')
How do I turn it into new array like this:
> TMTOWTDI
@new_array=('AA','bb','BB','CC','AG')
>>> my @new_array = split ' ', "@arry";
>>
>> Both line codes work perfectly:
>>
chen li wrote:
I have an arry like this:
@arry=('AA bb','BB','CC AG')
How do I turn it into new array like this:
TMTOWTDI
@new_array=('AA','bb','BB','CC','AG')
my @new_array = split ' ', "@arry";
Both line codes work perfectly:
my @new_array = map { split } @arry;
or
my @new_array = spl
On Tue, 2006-09-05 at 01:30 -0700, John W. Krahn wrote:
> Anything used as a pattern is a string. See the "Quote and Quote-like
> Operators" section of perlop:
Huh?
Do you mean all strings can be used as a pattern?
split( quotemeta( $split_string ), $data_string );
Or that patterns are buil
Mr. Shawn H. Corey wrote:
> On Tue, 2006-09-05 at 01:33 +0200, Paul Johnson wrote:
>>Um, that's not quite correct.
>>
>>See `perldoc -f split` for details.
>
> Oh, yes, a special case. I have long ago abandoned special cases since
> they lead to errors. Note that `perldoc -f split` starts with:
>
> Oh, yes, a special case. I have long ago abandoned special cases since
> they lead to errors. Note that `perldoc -f split` starts with:
>
> split /PATTERN/,EXPR,LIMIT
> split /PATTERN/,EXPR
> split /PATTERN/
> split
>
> Note: no strings. Strings do not work well when used as the patte
Mr. Shawn H. Corey wrote:
> On Mon, 2006-08-05 at 15:15 -0700, chen li wrote:
>>Both line codes work perfectly:
>>
>>my @new_array = map { split } @arry;
>>or
>>my @new_array = split ' ', "@arry";
>
> The second statement will work perfectly if every element has only one
> space character separat
On Tue, 2006-09-05 at 01:33 +0200, Paul Johnson wrote:
> Um, that's not quite correct.
>
> See `perldoc -f split` for details.
>
Oh, yes, a special case. I have long ago abandoned special cases since
they lead to errors. Note that `perldoc -f split` starts with:
split /PATTERN/,EXPR,LIMIT
s
Mr. Shawn H. Corey schreef:
> chen li:
>> Both line codes work perfectly:
>>
>> my @new_array = map { split } @arry;
>> or
>> my @new_array = split ' ', "@arry";
>
> The second statement will work perfectly if every element has only one
> space character separating its components and has no leadin
On Mon, May 08, 2006 at 07:07:14PM -0400, Mr. Shawn H. Corey wrote:
> On Mon, 2006-08-05 at 15:15 -0700, chen li wrote:
> > Both line codes work perfectly:
> >
> > my @new_array = map { split } @arry;
> > or
> > my @new_array = split ' ', "@arry";
>
> The second statement will work perfectly if
On Mon, 2006-08-05 at 15:15 -0700, chen li wrote:
> Both line codes work perfectly:
>
> my @new_array = map { split } @arry;
> or
> my @new_array = split ' ', "@arry";
The second statement will work perfectly if every element has only one
space character separating its components and has no lead
> > I have an arry like this:
> >
> > @arry=('AA bb','BB','CC AG')
> >
> > How do I turn it into new array like this:
> >
> > @new_array=('AA','bb','BB','CC','AG')
>
> my @new_array = split ' ', "@arry";
Both line codes work perfectly:
my @new_array = map { split } @arry;
or
my @new_array =
chen li wrote:
> Hi all,
Hello,
> I have an arry like this:
>
> @arry=('AA bb','BB','CC AG')
>
> How do I turn it into new array like this:
>
> @new_array=('AA','bb','BB','CC','AG')
my @new_array = split ' ', "@arry";
John
--
use Perl;
program
fulfillment
--
To unsubscribe, e-mail: [EMA
On Mon, 2006-08-05 at 22:35 +0200, Dani Pardo wrote:
> On 5/8/06, Mr. Shawn H. Corey <[EMAIL PROTECTED]> wrote:
>
> > Do you mean to break the elements on whitespace?
> >
> > my @new_array = map { split } @arry;
>
> Sorry but, can you explain the brackets? I just don't get it. Wich is
> the diff
On Mon, 2006-08-05 at 12:58 -0700, chen li wrote:
> Hi all,
>
> I have an arry like this:
>
> @arry=('AA bb','BB','CC AG')
>
> How do I turn it into new array like this:
>
> @new_array=('AA','bb','BB','CC','AG')
Do you mean to break the elements on whitespace?
my @new_array = map { split } @a
You could cycle through the array and use split() to split each element
by whitespace and then append the result to the @new_array array using
push();
-Original Message-
From: chen li [mailto:[EMAIL PROTECTED]
Sent: Monday, May 08, 2006 12:58 PM
To: beginners@perl.org
Subject: array qu
Boris Volf wrote:
Can anyone help with this
I have the following array:
1,1040209458
2,1040328655
3,1040847094
4,1041030406
5,1042093756
I need to create a script that goes through this array(@temp_array), and
creates various output files with
Boris Volf wrote:
Can anyone help with this
I have the following array:
1,1040209458
2,1040328655
3,1040847094
4,1041030406
5,1042093756
I need to create a script that goes through this array(@temp_array), and
creates various output files with
> >
> > Can anyone help with this
> > I have the following array:
> > 1,1040209458..
> > WRITE CONTENTS OF AN ARRAY TO OUTPUT FILES
> > for ($i=0; $i < $num_of_files; $i++){
> > open(OUT,">$file_$seq_num.txt");
> > foreach $item (@temp_array){
> >
>
> Can anyone help with this
> I have the following array:
> 1,1040209458
> 2,1040328655
> 3,1040847094
> 4,1041030406
> 5,1042093756
> I need to create a script that goes through this
> array(@temp_array), and
> creates various output fi
"R. Joseph Newton" wrote:
> Chris wrote:
>
> > my %found = ();
> > foreach (@emails) { $found{$_}++ };
> > foreach (@exclude) { exists $found{$_} and delete $found{$_} }
>
> Too complicated. Check Wolf's suggestion:
Ooops, excuse the brain fart:
>
> $unwanted{$_} = 1 foreach @exclude;
> my @tem
Chris wrote:
> my %found = ();
> foreach (@emails) { $found{$_}++ };
> foreach (@exclude) { exists $found{$_} and delete $found{$_} }
Too complicated. Check Wolf's suggestion:
$unwanted{$_} = 1 foreach @exclude;
my @temp;
push @temp
while (my $email = shift @emails) {
push @temp, $email unles
At 07:18 PM 2/26/04 -0500, you wrote:
Hi Guys,
I have a problem with e-mail address's and an array. I have some code that
will be a documentation spider to go through all our technical
documentation, extract e-mail address's and attempt to sort and exclude
certain e-mails/patterns. All documentati
On Friday 27 February 2004 01:18, Chris generously enriched virtual reality by
making up this one:
> Hi Guys,
>
> I have a problem with e-mail address's and an array. I have some code that
> will be a documentation spider to go through all our technical
> documentation, extract e-mail address's a
In article <[EMAIL PROTECTED]>,
Anthony Beaman wrote:
> Here's what I got when I ran it:
>
> C:\>perl hello2.pl
> Name your friends: Joe Sam Sally
> I know .
This has been answered already (you have one item in your array), so
$array[1] is empty.
> (good news is that ctrl-z appears to be wor
Alan [mailto:[EMAIL PROTECTED]
Sent: Wednesday, June 25, 2003 1:38 PM
To: '[EMAIL PROTECTED]'
Cc: Anthony Beaman
Subject:RE: Array Question
Oops, the second batch of code
ek
Byrne
I know Byrne
.
--END--
-Original Message-
From: Anthony Beaman [mailto:[EMAIL PROTECTED]
Sent: 25 June 2003 19:16
To: Perry, Alan; [EMAIL PROTECTED]
Subject: RE: Array Question
Here's what I got when I ran it:
C:\>perl hello2.pl
Name your friends: Joe Sam Sally
I kn
25, 2003 1:38 PM
To: '[EMAIL PROTECTED]'
Cc: Anthony Beaman
Subject:RE: Array Question
Oops, the second batch of code has a problem... It should read:
print "Name your frien
TED]
Sent: Wednesday, June 25, 2003 12:34
To: 'Anthony Beaman'; [EMAIL PROTECTED]
Subject: RE: Array Question
Unlike others that are suggesting that you forget about user input, I
thought you might want to see how it can work on Windows. I know that it
would bug me as to how to do t
e character, so you will only
have three elements in your array.
There are a lot of other tricks you can do, but I have probably confused you
enough for now... :)
- Alan
-Original Message-----
From: Anthony Beaman [mailto:[EMAIL PROTECTED]
Sent: Wednesday, June 25, 2003 11:01
To: [EMAIL PR
Anthony Beaman <[EMAIL PROTECTED]> wrote:
:
: I still can't grab the element of an array that
: requests user input though.
Forget about the user input part. You're
getting hung up on the wrong concept. The
exercise is about arrays not user input.
HTH,
Charles K. Clarkson
--
Head Bottle W
ray that requests user input though.
-Original Message-
From: Derek Byrne [mailto:[EMAIL PROTECTED]
Sent: Wednesday, June 25, 2003 8:33 AM
To: [EMAIL PROTECTED]
Subject:RE: Array Question
H
Sorry, I'm a unix guy...ctrl-d works on my unix box.
You might try that instead, just to see :)
richf
-Original Message-
From: Anthony Beaman [mailto:[EMAIL PROTECTED]
Sent: Wednesday, June 25, 2003 10:24 AM
To: Rich Fernandez
Cc: [EMAIL PROTECTED]
Subject: RE: Array Question
al Message-
From: Rich Fernandez [mailto:[EMAIL PROTECTED]
Sent: Wednesday, June 25, 2003 9:30 AM
To: Anthony Beaman
Cc: [EMAIL PROTECTED]
Subject: RE: Array Question
or 2 entries?
Apologies if I'm asking a no-brainer question here, have yet to reach the
chapter on arrays and thought I'd ask considering i'll be using it a lot.
DerekB
-Original Message-
From: Rob Anderson [mailto:[EMAIL PROTECTED]
Sent: 25 June 2003 14:33
To: [EMAIL PROTECTED
>"Anthony Beaman" <[EMAIL PROTECTED]> wrote in message ?
>news:[EMAIL PROTECTED]
>I typed in 3. For example, "Sam Mary Joe". I expect to get "I know Mary",
since she's [1] but I'm getting
>a blank space. I've tried this on NT and on my 98 machine here at work.
Hmm, are you just putting spaces bet
"Wilma Betty" because each will add a LF.
HTH
richf
-Original Message-
From: Anthony Beaman [mailto:[EMAIL PROTECTED]
Sent: Wednesday, June 25, 2003 9:18 AM
To: Paul Johnson
Cc: [EMAIL PROTECTED]
Subject: RE: Array Question
I typed in 3. For example, "Sam Mary Joe"
ul Johnson [mailto:[EMAIL PROTECTED]
Sent: Wednesday, June 25, 2003 9:13 AM
To: Anthony Beaman
Cc: [EMAIL PROTECTED]
Subject:Re: Array Question
Anthony Beaman said:
> Hi! I'm still wall
hen I got the same results that I've been getting ("I know .").
-Original Message-
From: Rob Anderson [mailto:[EMAIL PROTECTED]
Sent: Wednesday, June 25, 2003 9:12 AM
To: [EMAIL PROTECTED]
Anthony Beaman said:
> Hi! I'm still wallowing in Chapter 3 (Arrays. Why can't I get it?!?!?!?
> ARGH!) of Learning Perl on Win32 Systems. I'm trying to create an
> exercise but I'm not getting the results that I want. Here's what I'm
> trying to do:
>
> I'm asking for a list of names:
>
> p
Hi Anthony
>"Anthony Beaman" <[EMAIL PROTECTED]> wrote in message
>news:[EMAIL PROTECTED]
>Hi! I'm still wallowing in Chapter 3 (Arrays. Why can't I get it?!?!?!?
ARGH!) of Learning Perl on >Win32 Systems. I'm trying to create an
exercise but I'm not getting the results that I want. Here's wha
Hi Anthony,
grabbed this from O'Reilly's Learning Perl :
@rocks = qw/ bedrock slate lava /;
foreach $rock (@rocks) {
$rock = "\t$rock"; # put a tab in front of each element of
@rocks
$rock .= "\n"; # put a newline on the end of each
}
print "The rocks are:\n", @r
Anthony Beaman wrote:
> Ahh...that's it! I didn't realize that. Now it makes sense! Thanks for clearing
> this up! Any other advice on getting through this book? Thanks again!
For right now, let this concept absorb deeply.Understanding the cardinal/ordinal
numbering systems and how they int
Sent: Friday, June 20, 2003 1:56 PM
To: Anthony Beaman
Cc: Jenda Krynicky; [EMAIL PROTECTED]
Subject: RE: Array Question (Learning Perl/Win32 Chapter Test
Question)
On Jun 20, Anthony Beaman said:
Anthony Beaman wrote:
>
> But what's the "-1" for? Why not just "$b[$a]" instead? That's what I'm confused
> about.
Suppose that you want the first line so you enter "1". Because indexing
starts at zero using $b[$a] will print out the second line. If you
enter "4" for the fourth line $b[$a] wi
On Jun 20, Anthony Beaman said:
>But what's the "-1" for? Why not just "$b[$a]" instead? That's what I'm
>confused about.
Arrays start at 0. Thus, the first element of an array is $array[0].
Line numbers (as far as human think of them) start at 1. The first line
is considered line 1. Therefor
To: [EMAIL PROTECTED]
Subject:Re: Array Question (Learning Perl/Win32 Chapter Test
Question)
From: "Anthony Beaman" <[EMAIL PROTECTED]>
> 2. Write a program that reads a number and then a list of strings
(all
From: "Anthony Beaman" <[EMAIL PROTECTED]>
> 2. Write a program that reads a number and then a list of strings (all
> on separate lines), and then prints one of the lines from the list as
> selected by the number.
>
> One way to do this is:
> print "Enter the line number: "; chomp($a = );
> print
Bob Showalter a *crit :
>
> [redirecting back to list. keep the discussions on-list, folks.]
Yes :-)
>
> PL LAMBALLAIS wrote:
> > Well, markers type don't change. :-/
> >
> > Try this:
> > http://www.parx.net/cgi-bin/samples/bob_1.pl
> > and
> > http://www.parx.net/cgi-bin/samples/bob_2.pl
> >
[redirecting back to list. keep the discussions on-list, folks.]
PL LAMBALLAIS wrote:
> Well, markers type don't change. :-/
>
> Try this:
> http://www.parx.net/cgi-bin/samples/bob_1.pl
> and
> http://www.parx.net/cgi-bin/samples/bob_2.pl
>
> (force refresh as it display a generated GIF so runni
PL LAMBALLAIS wrote:
> Hello,
>
>
> I'm working with a GIF generator and I've a little problem using
> array as parameters:
>
> This call works perfectly:
>
> $my_graph->set(
> markers => [1,2],
> # kind of markers (here, 2 markers)
> marker_size => $mar
Thanks for your help. I finally got it to work.
Allison
-Original Message-
From: drieux [mailto:[EMAIL PROTECTED]]
Sent: Monday, April 01, 2002 3:44 PM
To: [EMAIL PROTECTED]
Subject: Re: Array question
On Monday, April 1, 2002, at 11:11 , Aman Raheja wrote:
> $array-prob.pl
p1
On Monday, April 1, 2002, at 11:11 , Aman Raheja wrote:
> $array-prob.pl
p1: I loved the
$field{$_}++;
p2: but since you have stashed it all in a Hash, why not
unpack the hash with
my @arr = keys(%field);
the counter proposal -
http:
Sorry, there were a couple typos in my earlier response:
> %count = ();
> foreach $element (@array1) { $count{$element}++ }
I should've included the semicolon at the end of the second line.
> Your array of unique names is now available from the keys of %count;
> the number of occurences of each
Here's my solution.
There will be shorter ways. I am new to perl, so this is how did it.
At the prompt do
$array-prob.pl
#!/usr/bin/perl
#File name : array-prob.pl
my @arr;
while(<>)
{
chomp($_);
$field{$_}++;
print "$_ $field{$_}\n";
my $set = 0;
my $r
On Mon, 1 Apr 2002, Allison Ogle wrote:
> I don't know how long the list is and eventually in the list some of
> the names will repeat. I want to put these names in an array but I
> don't want to repeat any names in the array and I want to keep a count
> of how many times the name appears in the
You could always put them into a hash and then put them into an array later.
foreach(@names){
$hash{$_} = 1;
}
my @array = keys %hash;
-Original Message-
From: Allison Ogle [mailto:[EMAIL PROTECTED]]
Sent: Monday, April 01, 2002 8:08 AM
To: a a
Subject: Array question
Hi,
I have
Allison, Check out pages 133 - 135 in Learning Perl (3rd Edition) - the
section "AutoIncrement and Autodecrement" section _ particularly the top of
page 135 has an example for just this very question! I just read that last
week so it popped right up in my mind.
If you don't have the book, h
On Thu, 2002-03-28 at 08:54, Michael D. Risser wrote:
> OK here's the problem:
>
> I have an array that may or may not have been assigned to, if it has been
> assigned to I need to do one thing, otherwise I need to do something else.
>
> I've tried many variations, but I'm having trouble determ
On Thursday 28 March 2002 08:54 am, you wrote:
> OK here's the problem:
>
> I have an array that may or may not have been assigned to, if it has been
> assigned to I need to do one thing, otherwise I need to do something else.
>
> I've tried many variations, but I'm having trouble determining if i
try
if (defined @array) {
# do something
} else {
# It's not been created, do something else
}
HTH
John
-Original Message-
From: Michael D. Risser [mailto:[EMAIL PROTECTED]]
Sent: 28 March 2002 13:55
To: [EMAIL PROTECTED]
Subject: Array question...
OK here's the problem:
I
You and Mike showed me my error. I placed a 1 in the
length field. It was inserting the element member I
wanted but also removing one.
Thanks,
K
--- "Brett W. McCoy" <[EMAIL PROTECTED]>
wrote:
> On Tue, 12 Feb 2002, Michael Fowler wrote:
>
> > Consider:
> >
> > @week = qw(Monday Wednesday Fr
On Wed, Feb 13, 2002 at 01:14:50PM -0800, John wrote:
> Recently someone pointed out that it's better to use:
>
> while( defined( my $line = ))
>
> than
>
> while( my $line = )
In more recent versions of Perl (5.00503 and above) there is no need to wrap
a defined around this specific loopin
On Tue, 12 Feb 2002, Pankaj Warade wrote:
> This is work
>
> my @array = ( 1, 2, 3, 4 );
>
> print $#array; ---> size of array.
No, $#array is the index of the last element of the array. To get the
size of an array, just put the array into a scalar context:
my $size = @array;
print scalar(@ar
1 - 100 of 110 matches
Mail list logo