John W. Krahn wrote:
Angie Ahl wrote:
I've got a way to do this but I thought someone more experienced than
me might have a better way.
I have a class that is a hash and one of the hash values is an array ref.
I'd like to search that array and push to it if a value isn't there.
At the moment
Angie Ahl wrote:
> Hi List
Hello,
> I've got a way to do this but I thought someone more experienced than
> me might have a better way.
>
> I have a class that is a hash and one of the hash values is an array ref.
>
> I'd like to search that array and push to it if a value isn't there.
> At the
> I'd like to search that array and push to it if a value isn't there.
> At the moment I'm dereferencing the array, searching/pushing it and
> the passing it back to the class as an array ref again. So this mean
> copying the array. Code:
>
> my @used_images = @{$_[0]->{_used_images}};
> foreach (
Hi List
I've got a way to do this but I thought someone more experienced than
me might have a better way.
I have a class that is a hash and one of the hash values is an array ref.
I'd like to search that array and push to it if a value isn't there.
At the moment I'm dereferencing the array, sear
you can use map function, too :)
$a = 5;
@arr = qw( 7 9 3 6 );
%search = map { $_ => 1 } @arr;
if ( $search{$a} ) {
print "Found $a in the list \n";
} else {
print "Did not find $a in the list\n";
}
Mahendra Thacker wrote:
> Hi,
>
> A question from a relative newbie.
>
> How does one
From: "John W. Krahn" <[EMAIL PROTECTED]>
> Jenda Krynicky wrote:
> > And if you want 6 unique :
> >
> > my @myarr;
> > { # this block is here just to restrict the availability
> > # of %seen
> > my %seen;
> > while (@myarr < 6) {
> >
Jenda Krynicky wrote:
>
> From: "Mahendra Thacker" <[EMAIL PROTECTED]>
> >
> > # Cash5 Lotto: draw of 6 unique non-zero numbers from 1..35
> >
> > my $top = 36; # rand gives a rand numb less than top, hence
> > my @myarr = ();
> > my $myrand;
> >
> > while ( @myarr < 6 ) {
> >$myrand = rand $
From: "Mahendra Thacker" <[EMAIL PROTECTED]>
> I was trying to poplulate an array with 6 non-zero unique random
> numbers from 1 to 35; I thought this search a list for a number is so
> much being used in various tasks that there would exist some such
> function
> search ( $myvar, @myarr )
> w
an array?
>
> -Original Message-
> From: Wagner-David [mailto:[EMAIL PROTECTED]]
> Sent: Friday, March 29, 2002 4:20 PM
> To: 'Mahendra Thacker'
> Cc: [EMAIL PROTECTED]
> Subject: RE: searching an array
>
>
> Here is one shot:
>
> #!perl -w
>
Mahendra Thacker wrote:
>
> Hi,
>
> A question from a relative newbie.
>
> How does one search an array of numbers for a number?
> (without using foreach; is there any function?)
>
> Say, I want to do something like this:
>
> ==
>
> $a = 5;
> @arr = ( 7 9 3 6 );
>
> if ( seach( $a, @arr ) )
;)
-Original Message-
From: Timothy Johnson [mailto:[EMAIL PROTECTED]]
Sent: Friday, March 29, 2002 16:16
To: Wagner-David; 'Mahendra Thacker'
Cc: [EMAIL PROTECTED]
Subject: Grep (WAS RE: searching an array)
I've heard that grep is fairly resource-intensive. Is there any trut
7;Mahendra Thacker'
Cc: [EMAIL PROTECTED]
Subject: RE: searching an array
Here is one shot:
#!perl -w
my $a = 5;
my @arr = qw( 7 9 3 6 5);
my @MyHits = grep(/$a/ , @arr );
if ( @MyHits ) {
print "Found $a in the list \n";
} else {
print "Did not find $a in the list\n
al Message-
From: Mahendra Thacker [mailto:[EMAIL PROTECTED]]
Sent: Friday, March 29, 2002 16:09
To: [EMAIL PROTECTED]
Subject: searching an array
Hi,
A question from a relative newbie.
How does one search an array of numbers for a number?
(without using foreach; is there any function?
Hi,
A question from a relative newbie.
How does one search an array of numbers for a number?
(without using foreach; is there any function?)
Say, I want to do something like this:
==
$a = 5;
@arr = ( 7 9 3 6 );
if ( seach( $a, @arr ) ) {
print "Found $a in the list \n";
} else {
print
I'd split up the foreach loop and the conditional
it might be a little clunky, but here's the basic idea.
bolFound = false
foreach (@members) {
if (/($enqmem)/i) {
bolFound = true;
}
}
if (bolFound) {
do stuff
}
else {
do other stuff
}
At 18:54 27-03-02 +
ely $enqmem is not a member of our club!\n";
}
print "Thankyou for your enquiry.";
-Original Message-
From: Wytch [mailto:[EMAIL PROTECTED]]
Sent: Wednesday, March 27, 2002 10:55 AM
To: [EMAIL PROTECTED]
Subject: help on searching an array
Hi, I am new to this list and t
-
> From: Wytch [mailto:[EMAIL PROTECTED]]
> Sent: Wednesday, March 27, 2002 1:55 PM
> To: [EMAIL PROTECTED]
> Subject: help on searching an array
>
>
> Hi, I am new to this list and to Perl. I decided after years
> of promises to
> my self that I would finally tackle program
Hi, I am new to this list and to Perl. I decided after years of promises to
my self that I would finally tackle programming. I started reading up on it
and think I have got the basics but I am still very much a Perl virgin!
I decided to try to write a little script [no practical application just
--- Bob Bondi <[EMAIL PROTECTED]> wrote:
> Thanks for the feedback, everyone.
> My goal for this script is to make "this.gif" and "that.gif" change
> places in the file. I.E.
> -
> this.gif
> that.gif
> this.gif
> -
>
> after running the script I would have
>
On Jul 11, Bob Bondi said:
>Thanks for the feedback, everyone.
>My goal for this script is to make "this.gif" and "that.gif" change places
>in the file. I.E.
>-
>this.gif
>that.gif
>this.gif
>-
>
>after running the script I would have
>-
>that.gif
>
Thanks for the feedback, everyone.
My goal for this script is to make "this.gif" and "that.gif" change places
in the file. I.E.
-
this.gif
that.gif
this.gif
-
after running the script I would have
-
that.gif
this.gif
that.gif
-
usin
Lightning flashed, thunder crashed and "Bob Bondi" <[EMAIL PROTECTED]> w
hispered:
| Yep, another newbie at Perl. I have come to a wall. What I need to do is
| open a file, find a value in the file and substitute a value.
| I've gotten to the point of what to do with an open file. I have been tryi
At 08:32 10.07.2001 -0700, Bob Bondi wrote:
>Yep, another newbie at Perl. I have come to a wall. What I need to do is
>open a file, find a value in the file and substitute a value.
>I've gotten to the point of what to do with an open file. I have been trying
>the @array = statement.
>I then wante
Yep, another newbie at Perl. I have come to a wall. What I need to do is
open a file, find a value in the file and substitute a value.
I've gotten to the point of what to do with an open file. I have been trying
the @array = statement.
I then wanted to verify the contents of the array and tried p
24 matches
Mail list logo