Hello,
I was wondering if anyone could help me sort a hash by values.
Essentially my structure is this:
$hash = { id1 => { 'company' = value,
'units' = value,
'url' = value, },
id2 => { 'company' = value,
'units' = value...
Well. I have 300 different config files. Right now, the easiest way to get my answer is something like this:
my @results =
`grep -c 'HidePrivacyStatement] t' /some/file/here.config`;
foreach (@results) {
if ($_ =~ /1$/) {
$cnt += 1;
}
}
print "$cnt\n";
But this seems costly do...
Hi all-
I'm basically trying to write a script that will generate statistics for each configuration setting we have in our application.
There is about 70 settings. There's about 300 configuration files. I need to generate reports for each of the 70 settings. Basically: Setting A is "true" for...
Miller-
Looks like I was on the right track :) I posted that seconds after you posted your response. Which is good--at least my thinking is on the right track.
Thanks for the notes. Also, thanks for not just telling me how to do it :) This is far more helpful then I could express to you...
Miller,
Hmmm. I guess I'm assuming that @keys will be defined, and I'm also assuming the $ref is a hash ref (although that seems a little less important).
Then, if I believe what I just wrote to be true, my first test should deal with whether or not @keys holds any data.
At that point, I...
Hi Miller-
Actually, it's not for homework. I was recently hired into the technology department at my company. Having no formal experience in programming (it was a hobby of mine for a long time) the lead developer assigns me tasks that he thinks will be beneficial for me to learn in order to...
Ok, so that second post won't work for beacuse it isn't incrementing the hash ref:
sub nested_exists {
my ($ref, @keys) = @_;
if (exists $ref->{$keys[0]}) {
my $new_ref = $ref->{$keys[0]};
nested_exists(\$new_ref, shift(@keys));
}
else { return 0; }...
I've come up with this, but I know it won't work... But this is similar to what I want done:
sub nested_exists {
my ($ref, @keys) = @_;
if (exists $ref->{$keys[0]}) { nested_exists(\$ref, shift(@keys)); }
else { return 0; };
return 1;
}
Thanks
Hi guys-
I'm trying to test whether nested hash refrences exist, like so:
my %ref = (
'app' => {
'next' => {
'further' => 10
}
}
);
if (nested_exists(\%ref, 'app', 'next', 'further')) {
do whatever.....
}
sub nested_exists {
my ($ref, @keys) = @_;
.....i just...
Hey guys, I wasn't actually using 'id' heh, I just used that as an example because I was lazy and didn't want to type out the *real* id.. Anyway, I got it to work using getElementsByTagName("*") so thanks for the help :)
Hey guys-
I can't seem to do this. Everything I try fails.
I have the ID of the Div... and I create controls dynamically within that div. I want to change the styles of those elements within the div.
How can I do this?
I've tried: var children = document.getElementById('id').getChildren()...
Hi guys-
Here's what I have thus far:
#!/usr/bin/perl
use strict;
my $var = 'C:\Documents and Settings\blah\File-Upload1.doc';
$var = ($var =~ /\\([\w\- ]+\.[\w]+)$/) ? $1 : $var;
print "$var\n";
Everything works. The only problem is *special* characters. If I add in support for all the...
Hi Miller-
I've worked my way through most of the code, and I understand how it's finding the parenthesis and everything. I've been working on my own regex, to handle pulling out the first param.... my main question is, is it possible to do this in a similar way as the way you accomplished...
Nevermind. It works beautifully. The only thing it doesn't do, is grab nested gettext()'s from a gettext() function. This is a huge improvement though. Now I'm gonna play with the regular expression until I can figure it out. Again, thanks :)
Wow, I certainly wasn't expecting such a response. Thank you very much. Now I can spend the rest of the day trying to figure how that's supposed to work :) This sure proves I was doing things the wrong way. Thanks again, I truly appreciate your help.
~Eric
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.