> Where did $var come from?
Sorry about that. That was a left over from the actual code that I
tried to pare down to be a small example. Messed that up as badly as
the copy/paste of the code made it really very ugly.
Addie
--
To unsubscribe, e-mail: beginners-unsubscr...@perl.org
For additional
> "JWK" == John W Krahn writes:
JWK> Uri Guttman wrote:
>>> "a" == addie writes:
>>
a> %hash = split(/\s/, $locus_line);
>>
>> that assigns a single pair to the hash. a SINGLE PAIR to the WHOLE
>> HASH. anything in the hash before that is wiped out. also the values
>> w
On 21/11/2010 09:56, addie wrote:
I have been fighting with this problem for over a week now he really
aggravating thing is that I had it working for over a year without
problem. have tried everything I can imagine. I've cut the code down
to a toy version to isolate the problem and it is no help
Uri Guttman wrote:
"a" == addie writes:
a> %hash = split(/\s/, $locus_line);
that assigns a single pair to the hash. a SINGLE PAIR to the WHOLE
HASH. anything in the hash before that is wiped out. also the values
will have newlines on them which isn't the main bug but is usually wrong
> "SHC" == Shawn H Corey writes:
SHC> On 10-11-21 12:49 PM, Uri Guttman wrote:
a> my %hash = ();
>>
>> no need to initialize a lexical hash with ().
SHC> Sorry but you should initialize all your variables. At one time
SHC> mod_perl did not initialize the data space; it simply r
> "a" == addie writes:
a> #!/usr/bin/
a> perl
a> \
that is VERY strange line wrapping. please be careful how you paste code
so it doesn't do that. readers can't then paste the code and run it
without cleaning up the wrapped lines.
a> use strict;
a> use warnings;
a> my %hash =
On 10-11-21 12:49 PM, Uri Guttman wrote:
a> my %hash = ();
no need to initialize a lexical hash with ().
Sorry but you should initialize all your variables. At one time
mod_perl did not initialize the data space; it simply re-used it. So
your variables started with whatever was in them
On 10-11-21 04:56 AM, addie wrote:
#!/usr/bin/
perl
\
use strict;
use warnings;
my %hash = ();
my $key = '';
open ACCESSIONS, "fix.txt" or die "Can't open fix.txt: $!\n";
while (my $locus_line =){
#This is supposed to populate
%hash.
%hash = split(/\s/, $locus_line);
foreach my $k (ke
Stanisław T. Findeisen wrote:
use constant {
SOME_CONSTANT => 'some value'
};
$hash{SOME_CONSTANT} = 'value 1';
Not weird at all, just works as documented.
So change to either:
$hash{ +SOME_CONSTANT } = 'value 1';
or:
$hash{ SOME_CONSTANT() } = 'value 1';
--
Ruud
--
To uns
On Fri, Mar 6, 2009 at 03:31, "Stanisław T. Findeisen"
wrote:
> Chas. Owens wrote:
>>
>> SOME_CONSTANT is being interpreted as the string "SOME_CONSTANT".
>
> Why is it so? This is crazy.
Because it is nicer to say $hash{key} than $hash{"key"} and Perl is
optimized for the common case. When you
From: "Stanisław T. Findeisen"
> Chas. Owens wrote:
> > SOME_CONSTANT is being interpreted as the string "SOME_CONSTANT".
>
> Why is it so? This is crazy.
Because most often you want it that way. Most often you do want the
$hash{BLAHBLAH} to mean $hash{'BLAHBLAH'} and not have to put qu
On Fri, Mar 06, 2009 at 09:31:44AM +0100, "Stanisław T. Findeisen" wrote:
> Chas. Owens wrote:
>> SOME_CONSTANT is being interpreted as the string "SOME_CONSTANT".
>
> Why is it so? This is crazy.
Were it not so, every time you created a sub with the same name as one
of your hash keys you would f
Chas. Owens wrote:
SOME_CONSTANT is being interpreted as the string "SOME_CONSTANT".
Why is it so? This is crazy.
This is one of the drawbacks to the constant pragma. Change the code
hash keys to one of these and it will work the way you want it to:
$hash{+SOME_CONSTANT} #unary plus
What
Stanisław T. Findeisen wrote:
#!/usr/bin/perl
use warnings;
use strict;
use constant {
SOME_CONSTANT => 'some value'
};
my $index = 'some value';
my %hash = ();
$hash{SOME_CONSTANT} = 'value 1';
$hash{$index} = 'value 2';
print("The value is: " . $hash{SOME_CONSTANT} . '/' . $hash{$index
On Thu, Mar 5, 2009 at 12:23, "Stanisław T. Findeisen"
wrote:
> #!/usr/bin/perl
>
> use warnings;
> use strict;
>
> use constant {
> SOME_CONSTANT => 'some value'
> };
>
snip
> print("The value is: " . $hash{SOME_CONSTANT} . '/' . $hash{$index} . "\n");
snip
SOME_CONSTANT is being interpreted
On Feb 4, 2008 10:05 PM, <[EMAIL PROTECTED]> wrote:
> Hi
>
> i am not able to declare hases
>
> first i tried this
>
> *
> use strict
> my %familyname;
> $familyname{"mark"}="antony";
>
> and i get an error "Global symbol
Jason Malburg wrote:
> Hi,
Hello,
> I'm working on a complex data structure with hashes of hashes and
> hashes of arrays and I noticed a weird behavior I was hoping someone
> could explain.
Put these two lines at the beginning of your program:
use warnings;
use strict;
and perl will tell you w
On 12/28/06, Jason Malburg <[EMAIL PROTECTED]> wrote:
Hi,
I'm working on a complex data structure with hashes of hashes and
hashes of arrays and I noticed a weird behavior I was hoping someone
could explain. Here's a sample:
$Data{US17}{1}{GROUP} = "STRING";
$Data{US17}{1}{GROUP}{.001} = 5;
$Da
On Thursday 20 April 2006 21:48, Tom Phoenix wrote:
> On 4/20/06, Allister <[EMAIL PROTECTED]> wrote:
> > %qnums_quests = ($quest_number, $quest_string);
>
> The assignment operator replaces the entire variable on the left with
> the value on the right. If you wish to modify the hash, instead of
>
On 4/20/06, Allister <[EMAIL PROTECTED]> wrote:
> %qnums_quests = ($quest_number, $quest_string);
The assignment operator replaces the entire variable on the left with
the value on the right. If you wish to modify the hash, instead of
replacing everything it contains, you probably want a stateme
Karyn Williams wrote:
At 07:42 AM 6/15/05 -0700, you wrote:
Karyn Williams wrote:
Also,
there are just a handful of files BUT they are ever changing, so I would
like to not list the statically in the code.
but this would work:
chomp( my @lists = qx(ls /usr/local/dir) );
But this would
At 07:42 AM 6/15/05 -0700, you wrote:
>Karyn Williams wrote:
>> Also,
>> there are just a handful of files BUT they are ever changing, so I would
>> like to not list the statically in the code.
>>
>but this would work:
>
>chomp( my @lists = qx(ls /usr/local/dir) );
>
>But this would work a lot
Karyn Williams wrote:
[snip]
So, first question is why is this happenning ? Then how do I fix it ?
What is happening that you didn't want to happen? What is NOT happening that
you did want to happen?
http://www.catb.org/~esr/faqs/smart-questions.html
Also,
there are just a handful of
On 6/14/05, Karyn Williams <[EMAIL PROTECTED]> wrote:
> Below is code that I found on the web that I slightly modified. I am trying
> to create a script to remove from a file (tlist) the items in another file
> (tnames). This works but I have multiple files (tlist) I need to check
> against. I'm no
At 04:37 PM 6/14/05 -0700, you wrote:
>Karyn Williams wrote:
>> Below is code that I found on the web that I slightly modified. I am
>> trying to create a script to remove from a file (tlist) the items in
>> another file (tnames). This works but I have multiple files (tlist) I
>> need to check agai
On Jun 14, Karyn Williams said:
Below is code that I found on the web that I slightly modified. I am trying
to create a script to remove from a file (tlist) the items in another file
(tnames). This works but I have multiple files (tlist) I need to check
against. I'm not sure how/where to put the
Karyn Williams wrote:
> Below is code that I found on the web that I slightly modified. I am
> trying to create a script to remove from a file (tlist) the items in
> another file (tnames). This works but I have multiple files (tlist) I
> need to check against. I'm not sure how/where to put the loop
On Jun 3, 2005, at 23:56, The Ghost wrote:
[EMAIL PROTECTED];
print "Answers:$surveyQuestions{answers}[$x]\n; # <--- Prints the
number of answers instead
My problem is that I always get the number of answers instead of the
answers. What am I doing wrong?
Perl struct
Andrianoelison Joël [AJ], on Tuesday, January 25, 2005 at 18:59
(+0100) has on mind:
AJ> my %myhash; # you'd better declare it outside the while()
I always initalize hashes and arrays like this:
my %myhash = ();
--
...m8s, cu l8r, Brano.
[I feel alephed out]
--
To unsubscribe, e-mail: [E
It is possible to store an array in a hash by using references
#foreach $destination (@dest_users) { # NO NEED FOR THIS
#print "==>$destination\n";
push( @{$aliases{$alias}}, @dest_users );
foreach $key ( keys %aliases ){
print "$key: @{$aliases{$key}}\n
Hum, use hash like this :
my %myhash; # you'd better declare it outside the while()
foreach $destination (@dest_user) {
if (/$destination/) {
s/(\s+):*/defined($myhash{$destination})?$myhash{$destination}=$myhash{$dest
ination}.",".$1:$myhash{$destination}=$1/e }
}
guess it'd work :-( not teste
From: Schoenwaelder Oliver <[EMAIL PROTECTED]>
> I have some problems with a script using hashes.
> I use hashes for years but never had this kind of problem before...
I
> have a ascii file with 6.5 MB of data. This file is tokenized by
> Parse:Lex module. The tokens are then stored in a two level
Schoenwaelder Oliver wrote:
> Hi list members,
>
> I have some problems with a script using hashes.
> I use hashes for years but never had this kind of problem before...
> I have a ascii file with 6.5 MB of data. This file is tokenized by
> Parse:Lex module.
i never use this module before so i d
Simas
Sorry if I'm too late, but:
my $hours;
my $hours_flags = "0000";
@$hours{'00' .. '23'} = split '', $hours_flags;
Cheers,
Rob
- Original Message -
From: "Simas Mockevicius" <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Sent: Sunday, December 01, 2
Thanx,
but i have writen my code (maybe huge, but :)...
for (my $a = 0; $a < 24; $a++) {
my $value = substr $hours_flags, $a, $a;
$Hours->{$a} = $value;
}
:-)
Symka.
> $_ = "0000";
> @h{grep~s/^.$/0$&/,0..23} = /./g;
>
> I hope that works
>
> --
> To unsubscribe
$_ = "0000";
@h{grep~s/^.$/0$&/,0..23} = /./g;
I hope that works
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
$_ = "0000";
@h{0..23} = /./g;
(no '00' keys)
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
On Wed, 27 Nov 2002, Ben Crane wrote:
> Cheers,
>
> I was going to think about using a hash for a text
> file that contains information from a
> file::find...there are thousands and thousands of
> files I want to x-check and update it the modified
> date differs...at the moment, arrays work fine
Cheers,
I was going to think about using a hash for a text
file that contains information from a
file::find...there are thousands and thousands of
files I want to x-check and update it the modified
date differs...at the moment, arrays work fine, but I
was hoping a hash would mean a slightly quick
On Wed, 27 Nov 2002, Ben Crane wrote:
> Hi all,
>
> One quick Q about hashes:
>
> they contain a key and data?
> e.g: %stuff=(A => 'one',
> B => 'two');
>
> where A and B are keys to data one and two...but what
> happens if you have a massive text file wher you had
> one key, but 2
From: Ben Crane <[EMAIL PROTECTED]>
> Hi all,
>
> One quick Q about hashes:
>
> they contain a key and data?
> e.g: %stuff=(A => 'one',
> B => 'two');
>
> where A and B are keys to data one and two...but what
> happens if you have a massive text file wher you had
> one key, but 20 o
Colin Johnstone wrote:
>
> Gidday from Downunder,
Hello,
> Im writing the script to read the the contetns of a text file into a hash,
> the text file has two records
>
> [EMAIL PROTECTED]|html
> [EMAIL PROTECTED]|txt
Hash keys have to be unique so the key "[EMAIL PROTECTED]"
can either have t
Hi All,
Yes silly me, I found the problem the second record replaced the first as the key was
the same.
Thank You
Colin Johnstone
Website Project Officer
Corporate Website Unit
Public Affairs Directorate
ph 9561 8643
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e
> List,
>
> I have the following while loop that goes and pings a whole heap of
servers around our company. If one is broken or doesn't respond to the
ping my code e-mails me the results of which server isn't responding.
This all works well but I really need it to be able to keep pinging all
the
> -Original Message-
> From: Casey West [mailto:[EMAIL PROTECTED]]
> Sent: Tuesday, August 07, 2001 5:23 PM
> To: Bob Showalter
> Cc: '[EMAIL PROTECTED]'
> Subject: Re: Hashes with multiple values per key
>
> ...
> That's not very nice dude. I d
--- Casey West <[EMAIL PROTECTED]> wrote:
> On Tue, Aug 07, 2001 at 05:42:55PM -0400, Bob
> Showalter wrote:
> : > -Original Message-
> : > From: Sophia Corwell
> [mailto:[EMAIL PROTECTED]]
> : > Sent: Tuesday, August 07, 2001 5:24 PM
> : > To: Casey W
On Tue, Aug 07, 2001 at 05:42:55PM -0400, Bob Showalter wrote:
: > -Original Message-
: > From: Sophia Corwell [mailto:[EMAIL PROTECTED]]
: > Sent: Tuesday, August 07, 2001 5:24 PM
: > To: Casey West
: > Cc: [EMAIL PROTECTED]
: > Subject: Re: Hashes with multi
> -Original Message-
> From: Sophia Corwell [mailto:[EMAIL PROTECTED]]
> Sent: Tuesday, August 07, 2001 5:24 PM
> To: Casey West
> Cc: [EMAIL PROTECTED]
> Subject: Re: Hashes with multiple values per key
>
>
> Thanks for the reply eventhough my question w
Thanks for the reply eventhough my question was not
clear.
Let me explain what I am trying to do.
I have a hash named %orgjobs whose keys have multiple
values. The keys are department numbers and the
values are job_titles. There is a also a text file
that has a list of departments, users, and
@{$hash{'jmj'}};
};
close(INP);
timethis(100, $expressiveCode);
timethis(100, $idiomaticCode);
Please refer attachment for the stats(small file).
-- Rex
-Original Message-
From: Luke Bakken [mailto:[EMAIL PROTECTED]]
Sen
> #Mode Idiomatic Way and is more efficient too!
> map { print "Take working vacation bud\n"; } grep{$_ eq 'george'}
> @{$hash{'jmj'}};
>
> I would prefer the second way -- the idiomatic way of doing it in Perl. I
> have read, somewhere that the second approach is more efficient.
Actually discard
ere that the second approach is more efficient.
-- Rex
-Original Message-
From: Luke Bakken [ mailto:[EMAIL PROTECTED]
<mailto:[EMAIL PROTECTED]> ]
Sent: Tuesday, August 07, 2001 3:59 PM
To: Sophia Corwell
Cc: [EMAIL PROTECTED]
Subject: Re: Hashes with multiple values per key
> D
> Does anyone have any ideas on what is a good way to
> check the existance of a value for a key that has
> multiple values?
I'll assume that your hash table has the following structure:
$hash{$key} = [ ];
that is, the value of each hash element is an array reference.
Let's say you're looking
On Tue, Aug 07, 2001 at 12:14:55PM -0700, Sophia Corwell wrote:
: Hello Perl Help,
:
: Does anyone have any ideas on what is a good way to
: check the existance of a value for a key that has
: multiple values?
I'm not quite sure what you're asking for so I'm going to try and
rephrase your questi
--- Oliver Glass <[EMAIL PROTECTED]> wrote:
> Paul, thanks so much for all this information!
You're welcome. I'm glad somebody appreciated it. =o)
> As well as helping me learn your kindness really brightened up a
> dreary day at the office :)
lol -- worth the time, also.
> Well, I've been w
Paul, thanks so much for all this information!
As well as helping me learn your kindness really brightened up a dreary
day at the office :)
Well, I've been working on hashes for the last few weeks and have some
more questions now. I've dropped them into our original correspondence.
Best wishes,
56 matches
Mail list logo