[25257] in Perl-Users-Digest
Perl-Users Digest, Issue: 7502 Volume: 10
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Thu Dec 9 18:05:59 2004
Date: Thu, 9 Dec 2004 15:05:06 -0800 (PST)
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)
Perl-Users Digest Thu, 9 Dec 2004 Volume: 10 Number: 7502
Today's topics:
Re: $300 reward for identity of poster with email addre <dha@panix.com>
Re: die'ing with the caller's line number xhoster@gmail.com
Re: Facile user-agent statistics tool <rob@nova.hbx.us>
Re: Facile user-agent statistics tool <abigail@abigail.nl>
Litigation on its way. <electrician@nospam.com>
Need help with froogle and cart id prob <shagyez@gmx.net>
Re: Need help with froogle and cart id prob <aditya.singh@gmail.com>
Re: Parsing Huge Files xhoster@gmail.com
passing string to ksh with system command joez3@yahoo.com
Re: passing string to ksh with system command <mritty@gmail.com>
Re: Recognize directories and files. (Mitchell Hulscher)
Re: Recognize directories and files. <mritty@gmail.com>
Re: Recognize directories and files. (Mitchell Hulscher)
Re: Recognize directories and files. <mritty@gmail.com>
Re: Recognize directories and files. <1usa@llenroc.ude.invalid>
Re: Reg Hash of Hash <mritty@gmail.com>
Re: Retrieving web pages <lawshouse.public@btconnect.com>
Re: Retrieving web pages <spamtrap@dot-app.org>
Re: Using MIME::Lite for multipart message - trouble w <tintin@invalid.invalid>
Re: why the following HereDoc print don't work? <spamtrap@dot-app.org>
Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: Thu, 9 Dec 2004 21:48:06 +0000 (UTC)
From: "David H. Adler" <dha@panix.com>
Subject: Re: $300 reward for identity of poster with email address: my_stu_pitt@yahoo.com
Message-Id: <slrncrhi0m.3ou.dha@panix2.panix.com>
On 2004-12-09, Joe Smith <joe@inwap.com> wrote:
> Gerald Newton3 wrote:
>
>> This perosn has posted slander and obscenitieis under my name
>>
>> From: "Gerald Newton" <my_stu_pitt@yahoo.com>
>> Newsgroups: alt.engineering.electrical, alt.culture.alaska
>> Subject: Re: Merry Christmas from electrician.com - North Pole, Alaska
>
> Didn't Kira claim to be a slandered electrician in Alaska?
Two entirely separate entities, iirc.
dha
--
David H. Adler - <dha@panix.com> - http://www.panix.com/~dha/
We thought we were the best thing since sliced nuclear energy... We
were Captain Beefheart meets the Archies. - Andy Partridge
------------------------------
Date: 09 Dec 2004 21:35:18 GMT
From: xhoster@gmail.com
Subject: Re: die'ing with the caller's line number
Message-Id: <20041209163518.205$xg@newsreader.com>
carloschoenberg@yahoo.com wrote:
> With DBI, it seems that if I want to use the "?" placeholders that I
> must
> use prepare and execute.
Why? What is wrong with:
$dbh->do('select something where ?=? and ?>?', undef, @bind_vars);
?
> So I made a simple helper function to do both
> for
> me, saving some typing and making the code slightly cleaner:
>
> sub sql_do($@) {
> my $q = shift;
>
> my $sth = $dbh->prepare($q);
> $sth->execute(@_);
> }
This seems like a pointless abstraction. (And it depends on the apparently
global $dbh, which is nasty).
Xho
--
-------------------- http://NewsReader.Com/ --------------------
Usenet Newsgroup Service $9.95/Month 30GB
------------------------------
Date: Thu, 9 Dec 2004 20:08:06 +0100
From: Robert Manea <rob@nova.hbx.us>
Subject: Re: Facile user-agent statistics tool
Message-Id: <mq7apc.gal.ln@rob.unisolblade.de>
Segfault in module "Christopher Nehren" - dump details are as follows:
> On 2004-12-09, Robert Manea scribbled these
> curious markings:
> [...]
>> 4. Mozilla Thunderbird : 33
> [...]
>> 12. trn : 6
> [...]
>> 22. trn : 1
>> 27. Thunderbird : 1
>> 28. Sylpheed version : 1
> [...]
>> 30. Sylpheed-Claws : 1
> I hope that you like dealing with inconsistencies. :)
Well, since the 'User-Agent' header's format conforms to absolutly no
standard or RFC one must be compromising.
I understand, that that piece of information is most important in my
programm but really can't come up with anything significantly better.
Maybe you have a better RegEx or method to extract it? (see TODO)
( Some kind of comparision function which detects common words in
different strings would be a solution, but still not the right
one.
E.g.: 'Mozilla Thunderbird' and 'Thunderbird' should be the same
but 'Mozilla' and 'Mozilla Thunderbird' must not.
How could one solve this without hardcoding the names? )
> Best Regards,
> Christopher Nehren
Greets, Rob
--
The Enterprise meets God, and it's a child, a computer, or a C program.
------------------------------
Date: 09 Dec 2004 20:15:10 GMT
From: Abigail <abigail@abigail.nl>
Subject: Re: Facile user-agent statistics tool
Message-Id: <slrncrhcie.k4s.abigail@alexandra.abigail.nl>
Christopher Nehren (apeiron+usenet@coitusmentis.info) wrote on MMMMCXVIII
September MCMXCIII in <URL:news:slrncrh1e0.6jk.apeiron+usenet@prophecy.dyndns.org>:
// On 2004-12-09, AD scribbled these
// curious markings:
// > Two small things.
// > 1. my $from_header =
// > qr/From:.*?([A-Za-z0-9\.]+@[A-Za-z0-9\.]+)\s*.*/;
// > This won't catch email addresses having '_', or '-'.
// > More importantly see $perldoc -q 'mail address'
//
// Or + characters, like mine.
But it does match yours:
print "Match!\n" if 'From: apeiron+usenet@coitusmentis.info' =~
/From:.*?([A-Za-z0-9\.]+@[A-Za-z0-9\.]+)\s*.*/
__END__
Match
It only requires that the last character before the @ is a letter, digit
or a dot. And that the domain name doesn't contain a dash.
While the regex isn't perfect, and it won't capture in $1 what the OP
expects it to capture, I doubt the number of postings in this group
that will not be counted this way is statistically significant.
Abigail
--
$" = "/"; split // => eval join "+" => 1 .. 7;
*{"@_"} = sub {foreach (sort keys %_) {print "$_ $_{$_} "}};
%_ = (Just => another => Perl => Hacker); &{%_};
------------------------------
Date: Thu, 9 Dec 2004 13:45:01 -0900
From: "Gerald Newton3" <electrician@nospam.com>
Subject: Litigation on its way.
Message-Id: <41b8d56f$1@news.acsalaska.net>
Keep posting the more evidence the better.
"Gerald Newton" <my_stu_pitt@yahoo.com> wrote in message
news:1102560884.078109.165180@f14g2000cwb.googlegroups.com...
> Waaaaaaaaaaaaaaaa. You are a whinny baby old man.
>
> Did you give someone a hicky?
>
> You do provide funny entertainment...at least for me. I'm sure other
> can appreciate your ignorant control of your personality.
> Waaaaaaaaaaaaa,...it's me Gerry the pecker head Newton and I want
> everyone to post like I do. Waaaaaaaaaaa.
>
------------------------------
Date: Thu, 9 Dec 2004 23:12:57 +0100
From: "dave" <shagyez@gmx.net>
Subject: Need help with froogle and cart id prob
Message-Id: <cpajbe$9ge$04$1@news.t-online.com>
Hi folks,
I'm using a variation of Selena Sol's web_store.cgi as my online shop (or
trying to, that is).
I'm currently trying to put a product page on Froogle.
Froogle requires that the url from the Froogle results list, to the vendor
site, be directly to the product page and not to any category page or other
page before the product page.
My problem is that a cart id doesn't get created unless the shopper starts
at the storefront page, or at least at the category page.
So how would I modify the product page so that when the "buy this item"
button is clicked, a cart id is created and passed to the checkout page?
Any and all help will be really appreciated.
David Bryson
------------------------------
Date: 9 Dec 2004 14:52:19 -0800
From: "AD" <aditya.singh@gmail.com>
Subject: Re: Need help with froogle and cart id prob
Message-Id: <1102632739.795412.294240@f14g2000cwb.googlegroups.com>
Dave said:
"My problem is that a cart id doesn't get created unless the shopper
starts
at the storefront page, or at least at the category page."
I think this is not a good design. If a customer is directed to your
product from another website, he should be able to add that item to
cart from that page itself and checkout. If you expect customers to go
back to your main page, then it won't work. You'll lose customers.
BTW, there is no Perl question in your post. The least you could do is
put some sample code through which clpm users could have tried out the
problem you were facing.
HTH,
AD
------------------------------
Date: 09 Dec 2004 23:04:10 GMT
From: xhoster@gmail.com
Subject: Re: Parsing Huge Files
Message-Id: <20041209180410.675$Cv@newsreader.com>
BigDaDDY <ihatespam@hotmail.com> wrote:
> All,
>
> I have a huge text file (around 700MB) that I am trying to parse.
Whether that is huge depends on your RAM. I just might be able to throw
that into a big old hash and work with it that way. Can you?
> I was
> successful, but I don't think I have done it very efficiently.
What kind of efficiency are you concerned with? CPU, memory, programmer
time, maintainer time?
> Basically
> in my program I have a hash containing some unique id numbers which are
> keyed by cartesian (x,y,z) coordinates.
>
> #!/usr/bin/perl -w
>
> use strict;
>
> my %id;
>
> $id{"200"}{"-11"}{"199.5"} = 123456;
> $id{"201"}{"-11"}{"199.5"} = 246891;
> $id{"202"}{"-11"}{"199.5"} = 169245;
> $id{"200"}{"-45"}{"199.5"} = 274321;
>
> # End of example code
>
> Here is where it is getting difficult for me. I have 8 possible
> y-values, 420 x-values and 1 z-value
If there is only one possible z-value, what is the point of having a
z-value?
1*8*420 = 3360 different IDs (assuming all are different)
It seems like you only really care about the Y value of any given ID,
and not the X or Z.
So invert and prune the hashes so that $nid{123456}="-11", etc.
my %nid;
foreach (values %id) {
foreach my $y (keys %$_) {
foreach (values %{$_->{$y}}) {
die "duplicate $_!" if exists $nid{$_};
$nid{$_}=$y;
}
}
}
> The format of my 700MB file is something like
>
> #ID Value
> 123456 200
> 274321 100
> 246891 400
> 169245 600
> 123456 300
> 274321 50
> 246891 600 #each element id occurs 24 times once for each
> subcase
Well then, I assume the subcases must occur in order?
3360 different IDs, times 24 occurences, = 80640 lines you care about.
Out of 700MB/15char per line = 50 million lines.
You can surely store 80640 lines, no?
> What I want to do is for each unique y value, I want to create a file
> named after each y-value which looks like the following
>
> element ID Value(subcase1) Value(subcase2) Value(subcase3) . . .
> 123456 200 300 400
> 246891 400 600 800
> 169245 600 800 999
>
> So basically, given a fixed y and z value, loop over all x values and get
> element ids which are then searched for in the big file and reformatted
> into individual files for each unique y-value. Is there a very efficient
> way to do this in Perl?
my %y_stuff; # hash by Y of hash by ID of list of values
while (<>) { chomp;
my ($id,$v)=split;
next unless exists $nid{$id};
push @{$y_stuff{$nid{$id}}{$id}}, $v;
};
Printing this out is left as an exercise.
Xho
--
-------------------- http://NewsReader.Com/ --------------------
Usenet Newsgroup Service $9.95/Month 30GB
------------------------------
Date: 9 Dec 2004 11:39:29 -0800
From: joez3@yahoo.com
Subject: passing string to ksh with system command
Message-Id: <1102621169.885302.22250@c13g2000cwb.googlegroups.com>
Hi all,
I have a perl scirpt that needs to pass some data to a ksh script, but
my problem is that one of the strings that I need to pass has a space
in it. So my ksh script thinks that this is 2 different strings. This
is how I have this coded right now:
$type = "com+ app";
system "runshell.ksh ".$item." "$type;
When the runshell.ksh run it looks like it only sees the com+ and not
the 2nd half of the string. Is there a way to encase my type string in
"". I have already tried using "/"com+ app/"" that that didn't seam to
help.
Thanks,
Zim
------------------------------
Date: Thu, 09 Dec 2004 19:43:02 GMT
From: "Paul Lalli" <mritty@gmail.com>
Subject: Re: passing string to ksh with system command
Message-Id: <aV1ud.1335$eO5.404@trndny08>
<joez3@yahoo.com> wrote in message
news:1102621169.885302.22250@c13g2000cwb.googlegroups.com...
> Hi all,
> I have a perl scirpt that needs to pass some data to a ksh script, but
> my problem is that one of the strings that I need to pass has a space
> in it. So my ksh script thinks that this is 2 different strings. This
> is how I have this coded right now:
> $type = "com+ app";
> system "runshell.ksh ".$item." "$type;
>
> When the runshell.ksh run it looks like it only sees the com+ and not
> the 2nd half of the string. Is there a way to encase my type string in
> "". I have already tried using "/"com+ app/"" that that didn't seam to
> help.
You escape quotes with a backslash, not a forward slash:
$type = "\"com+ app\"";
However, this is ugly. You have no reason for the perl string itself to
be enclosed in double quotes. Use single quotes:
$type = '"com+ app"';
Paul Lalli
------------------------------
Date: 09 Dec 2004 19:32:31 GMT
From: unacceptable@gmail.com (Mitchell Hulscher)
Subject: Re: Recognize directories and files.
Message-Id: <41b8a84e$0$1257$ba620dc5@nova.planet.nl>
Hey all,
I just took a look at the replies to my post, and I was glad
there were people that could help me to find an answer.
I must say I found the first reply kind of "rough", but I DID
manage to get my code working. So, thanks a lot.
I was wrong thinking that looking for a period would be my
solution just because I couldn't figure out the -d and -f
switches.
Also my English isn't at it's best so that's probably why I
mixed up 'colon' with 'period'.
Anyway, this is my new code:
#!C:\perl\bin\
use warnings;
print "Enter a full directory path to examine: ";
chomp($dir = <STDIN>);
$dir .= "\\" unless $dir =~ /\\+$/;
opendir(HANDLE, $dir) || die "Unable to open directory for
analysis: $!";
foreach (readdir(HANDLE)) {
$path = $dir . $_;
if (-d $path) {
push(@dirs, $path);
} elsif (-f $path) {
push(@files, $path);
}
}
sort(@files);
sort(@dirs);
print "\n\nDirectories:\n------------\n";
foreach (@dirs) {
print "$_\n";
}
print "\n\nFiles:\n------\n";
foreach (@files) {
print "$_\n";
}
#End of program.
I'm glad I got it working, and if anyone still has any comments
on this code, please let me know.
What is annoying, is that the arrays are empty at program load,
and Perl returns an error saying it cannot sort empty void.
Ofcourse, the arrays will be filled later, but I was wondering
if there was any way of preventing this "error".
Thanks in advance,
Mitch.
----------------------------------------------
Posted with NewsLeecher v2.0 RC2
* Binary Usenet Leeching Made Easy
* http://www.newsleecher.com/?usenet
----------------------------------------------
------------------------------
Date: Thu, 09 Dec 2004 19:41:06 GMT
From: "Paul Lalli" <mritty@gmail.com>
Subject: Re: Recognize directories and files.
Message-Id: <mT1ud.687$ag6.142@trndny07>
"Mitchell Hulscher" <unacceptable@gmail.com> wrote in message
news:41b8a84e$0$1257$ba620dc5@nova.planet.nl...
> I just took a look at the replies to my post, and I was glad
> there were people that could help me to find an answer.
> I must say I found the first reply kind of "rough"
Have you read the posting guidelines for this group yet? You're far
less likely to receive rough replies when you follow those guidelines.
>, but I DID
> manage to get my code working. So, thanks a lot.
You're welcome.
> I was wrong thinking that looking for a period would be my
> solution just because I couldn't figure out the -d and -f
> switches.
Yes.
> Anyway, this is my new code:
>
>
> #!C:\perl\bin\
>
you're still missing
use strict;
> use warnings;
>
> print "Enter a full directory path to examine: ";
>
> chomp($dir = <STDIN>);
>
> $dir .= "\\" unless $dir =~ /\\+$/;
>
> opendir(HANDLE, $dir) || die "Unable to open directory for
> analysis: $!";
>
> foreach (readdir(HANDLE)) {
> $path = $dir . $_;
> if (-d $path) {
> push(@dirs, $path);
> } elsif (-f $path) {
> push(@files, $path);
> }
All well and good, but I'd probably rewrite it like so:
push (-d $path ? @dirs : @files), $path));
> }
>
> sort(@files);
> sort(@dirs);
Once again, what do you think this is doing? @files and @dirs remain
completely unchanged by this operation. sort() returns the sorted list,
it does not modify a given list.
> print "\n\nDirectories:\n------------\n";
>
> foreach (@dirs) {
> print "$_\n";
> }
>
> print "\n\nFiles:\n------\n";
>
> foreach (@files) {
> print "$_\n";
> }
>
> #End of program.
>
> I'm glad I got it working, and if anyone still has any comments
> on this code, please let me know.
> What is annoying, is that the arrays are empty at program load,
> and Perl returns an error saying it cannot sort empty void.
No it doesn't. First, it returns a warning, not an error. Second, that
warning reads:
Useless use of sort in void context
This has nothing at all to do with arrays being empty. Try adding
use diagnostics;
to the top of your code to have perl explain why it's giving you this
warning. (I have already told you why, of course).
> Ofcourse, the arrays will be filled later, but I was wondering
> if there was any way of preventing this "error".
The arrays are already non-empty by the time you call sort. You've
misdiagnosed the problem.
Paul Lalli
------------------------------
Date: 09 Dec 2004 19:58:43 GMT
From: unacceptable@gmail.com (Mitchell Hulscher)
Subject: Re: Recognize directories and files.
Message-Id: <41b8ae73$0$1247$ba620dc5@nova.planet.nl>
I've removed
sort(@files);
sort(@dirs);
and replaced it with
@files = sort(@files);
@dirs = sort(@dirs);
This removes the warning and seems to work, still I have my
doubts there isn't an easier way, Perl seems to have many
shortcuts compared to other languages.
The reason I didn't remove sort(@files) after the first reply,
was because even though I received the warning, my directories
were sorted.
I was mislead by this because my directories seem to be sorted
alphabatically anyway.
But I didn't remove the new code because if I'm going to use
this on a different machine, that might not be the case.
Also have I not added
push (-d $path ? @dirs : @files), $path));
simply because it's too high a level for me.
In other words I'm still a beginner, like you've most probably
noticed.
I do quite understand how it works, but it'll take me some more
reading to fully understand it.
Thanks again,
Mitch.
----------------------------------------------
Posted with NewsLeecher v2.0 RC2
* Binary Usenet Leeching Made Easy
* http://www.newsleecher.com/?usenet
----------------------------------------------
------------------------------
Date: Thu, 09 Dec 2004 20:21:39 GMT
From: "Paul Lalli" <mritty@gmail.com>
Subject: Re: Recognize directories and files.
Message-Id: <nt2ud.401$P14.175@trndny05>
"Mitchell Hulscher" <unacceptable@gmail.com> wrote in message
news:41b8ae73$0$1247$ba620dc5@nova.planet.nl...
> I've removed
>
> sort(@files);
> sort(@dirs);
>
> and replaced it with
>
> @files = sort(@files);
> @dirs = sort(@dirs);
That was the correct way to handle this. Very good.
> This removes the warning and seems to work, still I have my
> doubts there isn't an easier way, Perl seems to have many
> shortcuts compared to other languages.
well, you could write your own wrapper subroutine that calls sort and
modify its rguments directly. But I'm not convinced that's easier.
> The reason I didn't remove sort(@files) after the first reply,
> was because even though I received the warning, my directories
> were sorted.
> I was mislead by this because my directories seem to be sorted
> alphabatically anyway.
readdir() returns the files/directories in whatever order your operating
system returns them. It's system-dependent, not perl-dependent.
Therefore, yes, you might wind up with the lists in your preferred
sorted order already.
One quick detail - by default, sort() does not sort Alphabetically, as
you stated here. Instead, it sorts "ASCIIbetically". Effectively this
means that sort will place elements starting with a capital letter
before those with a lowercase letter. If this is not what you want,
read up on the documentation for sort():
perldoc -f sort
> But I didn't remove the new code because if I'm going to use
> this on a different machine, that might not be the case.
Very good plan.
> Also have I not added
>
> push (-d $path ? @dirs : @files), $path));
>
> simply because it's too high a level for me.
> In other words I'm still a beginner, like you've most probably
> noticed.
That's fine. I was just offering it as what I would do instead. The
Perl motto is "There's More Than One Way To Do It".
> I do quite understand how it works, but it'll take me some more
> reading to fully understand it.
briefly, the ? : operator behaves like an if-else statement:
$x == 1 ? $a = 'yes' : $a = 'no';
is equivalent to:
if ($x == 1){
$a = 'yes';
} else {
$b = 'no';
}
In addition, the operator returns whichever 'clause' it executed. So I
could have written it like so:
$a = ($x == 1 ? 'yes' : 'no');
This return value is also what we call an "l-value". That means it can
be assigned to:
($x == 1 ? $a : $b) = 'foo';
will assign 'foo' to either $a or $b.
That's the property I used above:
push ((-d $path ? @dirs : @files), $path); #my parens typo corrected
Here, I am pushing $path onto the return value of the ? : operator.
That return value will be either @dirs or @files, depending on the truth
of -d $path.
Hope this helps,
Paul Lalli
------------------------------
Date: 9 Dec 2004 21:18:16 GMT
From: "A. Sinan Unur" <1usa@llenroc.ude.invalid>
Subject: Re: Recognize directories and files.
Message-Id: <Xns95BAA5DBF10FBasu1cornelledu@132.236.56.8>
unacceptable@gmail.com (Mitchell Hulscher) wrote in news:41b8ae73$0$1247
$ba620dc5@nova.planet.nl:
Please read the posting guidelines before you go any further. Also, re-read
Paul's response. he has already answered your questions below.
One important comment based on one of your earlier posts in this thread:
#!C:\perl\bin\
This is a meaningless shebang line. It should containt the path to the Perl
executable, not the directory in which it lives. So:
#! C:\Perl\bin\perl.exe
Now, you might have noticed that things ran fine on Windows even though the
line is wrong because of file associations that are set up by AS Perl
installation, but this is an important point.
> I've removed
>
> sort(@files);
> sort(@dirs);
>
> and replaced it with
>
> @files = sort(@files);
> @dirs = sort(@dirs);
...
> push (-d $path ? @dirs : @files), $path));
>
> simply because it's too high a level for me.
Well, there is one problem with it in that not everything that is not a
directory is a file.
See perldoc -f -X
So, just as a matter of defensive programming, I would explicitly carry out
both the -f and the -d tests.
Now, one question is: How many entries in the directory? Depending on size,
you might better off processing each file individually or using grep.
#! /usr/bin/perl
# grep version
use strict;
use warnings;
use File::Spec::Functions 'catfile';
my $path = $ENV{HOME};
opendir my $DIR, $path
or die "Cannot open directory $path: $!";
my @all = map { catfile $path, $_ } readdir $DIR
or die "Cannot read directory $path: $!";
closedir $DIR
or die "Cannot close directory $path: $!";
my @dirs = sort grep { -d } @all;
my @files = sort grep { -f } @all;
use Data::Dumper;
print Dumper \@files, \@dirs;
__END__
#! /usr/bin/perl
# process entries one-by-ne
use strict;
use warnings;
use File::Spec::Functions 'catfile';
my $path = $ENV{HOME};
opendir my $DIR, $path
or die "Cannot open directory $path: $!";
my (@dirs, @files);
while(my $entry = readdir $DIR) {
my $full_path = catfile $path, $entry;
if( -d $full_path ) {
push @dirs, $full_path;
} elsif ( -f $full_path ) {
push @files, $full_path;
} else {
warn "Ignored: $full_path\n";
}
}
@dirs = sort @dirs;
@files = sort @files;
use Data::Dumper;
print Dumper \@files, \@dirs;
__END__
--
A. Sinan Unur
1usa@llenroc.ude.invalid
(remove '.invalid' and reverse each component for email address)
------------------------------
Date: Thu, 09 Dec 2004 19:10:12 GMT
From: "Paul Lalli" <mritty@gmail.com>
Subject: Re: Reg Hash of Hash
Message-Id: <oq1ud.1617$sU4.1311@trndny01>
"Shashank Khanvilkar" <shashank@mia.ece.uic.edu> wrote in message
news:cpa79v$594$1@newsx.cc.uic.edu...
> I have a program as shown below, which should print out all keys which
> have a degree of one.
What do you mean by "degree"?
> For example the below program should print
> (e, c) = 10
> since "e" has a a degree of one. But it does not work//
"does not work" is a red flag. What - exactly - should happen, what -
exactly - *does* happen, and how do the two differ?
> $Hoh{"e"}{"c"} = 10;
> $Hoh{"c"}{"f"} = 1;
> $Hoh{"c"}{"d"} = 1;
>
> foreach $n1 (keys %Hoh) {
> my $deg = keys(%{$Hoh{$n1}});
> # print "deg[$n1] = $deg\n";
>
> if ($deg eq 1){
You almost certainly want == instead of eq
If you don't know why, read:
perldoc perlop
> $n2 = %{$aa{$n1}};
What exactly do you think this is doing? I'm about 98% sure it's not
doing what you think it is.
> print "($n1, $n2) = $aa{$n1}{$n2}\n";
> }
> }
>
>
> However if i use the below program it works.
You have an odd definition of "works":
Name "main::aa" used only once: possible typo at - line 11.
Use of uninitialized value in concatenation (.) or string at - line
11.
(e, c) =
> $Hoh{"e"}{"c"} = 10;
> $Hoh{"c"}{"f"} = 1;
> $Hoh{"c"}{"d"} = 1;
>
> foreach $n1 (keys %Hoh) {
> my $deg = keys(%{$Hoh{$n1}});
> # print "deg[$n1] = $deg\n";
>
> if ($deg eq 1){
> foreach $n2 (sort keys %{$Hoh{$n1}}) {
> print "($n1, $n2) = $aa{$n1}{$n2}\n";
> }
> }
> }
> I will appreciate if someone can correct my first program. This way, I
> will avoid using an extra for loop.
Correct the ambiguity in your stated goal.
Correct your description of the problem statement.
Ask perl for help, by using strict and warnings.
Figure out what you think each line of your code is doing.
Once you've fixed those four problems, feel free to ask for more help.
Paul Lalli
>
> Thanks
> Shashank
------------------------------
Date: Thu, 09 Dec 2004 20:52:12 +0000
From: Henry Law <lawshouse.public@btconnect.com>
Subject: Re: Retrieving web pages
Message-Id: <fvdhr0l6o38jrbqsljk9a7vobhp9ru7ac4@4ax.com>
On 9 Dec 2004 11:00:28 -0800, "Dackle" <simon.dukes@gmail.com> wrote:
>OK, I'll give it a try. I think I used http:// in the URL and it didn't
>work, but I'll try use strict; and use warnings;.
It's not a matter of "trying" ... putting them in makes it easier to
find some kinds of problem and since nobody writes perfect code first
time you should always use them.
Sorry to sound like a school teacher here but I'm trying to help ...
Saying that something "doesn't work" doesn't help people to help you.
Much better to say what you expected it to do and what it actually
did. Anyway, unless there's a bug in perl itself then the code you
write always "works", in the sense that it does what it does. The
problem comes when what it does is not what you thought it would do.
>> On 9 Dec 2004 10:30:22 -0800, simon.dukes@gmail.com (Dackle) wrote:
>> > But I keep getting back a type 2 error saying File "internet"
>does
>> >not exist.
I meant to advise you earlier: it's much better to copy and paste
error messages, rather than giving a general description of them as
you have done above. The exact text is sometimes important.
Lastly, please don't top post; it's against the agreed guidelines for
this group. In addition many people hate it with a passion and most
of them are the ones you need to help you.
--
Henry Law <>< Manchester, England
------------------------------
Date: Thu, 09 Dec 2004 17:08:00 -0500
From: Sherm Pendley <spamtrap@dot-app.org>
Subject: Re: Retrieving web pages
Message-Id: <ua-dnSLvGptcUSXcRVn-hw@adelphia.com>
Dackle wrote:
> fact that I've never used Perl modules before. I downloaded
> libwww-perl and copied LWP::Simple into the Perl lib directory
That's the first problem. Read and follow the instructions in 'perldoc
perlmodinstall' - don't just copy files around.
> I'm still having trouble grabbing web pages. I tried something like
> this:
Post the code you tried, not "something like" it. Copy and paste it,
don't try to re-type it.
Have you read the posting guidelines that appear here frequently?
sherm--
--
Cocoa programming in Perl: http://camelbones.sourceforge.net
Hire me! My resume: http://www.dot-app.org
------------------------------
Date: Fri, 10 Dec 2004 08:23:35 +1300
From: "Tintin" <tintin@invalid.invalid>
Subject: Re: Using MIME::Lite for multipart message - trouble with string manipulation
Message-Id: <31rmuqF3dam32U1@individual.net>
<alamukutty@gmail.com> wrote in message
news:1102606298.518074.181700@f14g2000cwb.googlegroups.com...
> Hi,
>
> I am pretty new to cgi-perl and I'm trying to process a form and
> send the email using sendmail. I figured how to send attachments using
> MIME::Lite and also figured how to process a form and send a plain
> text mail like
>
> for each param()
> ParamName = Param vAlue
>
> When I try to put the two together, I am stuck. I don't know how to
> process strings with perl and any help will be appreciated.
> For now, this is what I am trying and I get a server error.
>
> ----------------------
>
> #! / usr/bin/perl -w
That's a might strange path to perl on your system.
> use lib '/usr/lib/perl5/site_perl/5.8.0/MIME';
Why? Do you have different versions of perl installed?
------------------------------
Date: Thu, 09 Dec 2004 16:51:50 -0500
From: Sherm Pendley <spamtrap@dot-app.org>
Subject: Re: why the following HereDoc print don't work?
Message-Id: <56SdnRRBjfFqVSXcRVn-sg@adelphia.com>
Anno Siegel wrote:
> I cannot reproduce this with v5.8.1
My Perl:
Sherm-Pendleys-Computer:~ sherm$ perl -v
This is perl, v5.8.1-RC3 built for darwin-thread-multi-2level
(with 1 registered patch, see perl -V for more detail)
Standard factory-supplied Perl for Mac OS X "Panther".
Your editor might be adding a trailing newline to text files
automatically - quite a few can be configured to do that.
> but if it is the reason then
> it *is* arguably a bug in (some version of) Perl. The final line
> feed shouldn't matter.
Agreed. Anyone using 5.8.6 care to comment here?
sherm--
--
Cocoa programming in Perl: http://camelbones.sourceforge.net
Hire me! My resume: http://www.dot-app.org
------------------------------
Date: 6 Apr 2001 21:33:47 GMT (Last modified)
From: Perl-Users-Request@ruby.oce.orst.edu (Perl-Users-Digest Admin)
Subject: Digest Administrivia (Last modified: 6 Apr 01)
Message-Id: <null>
Administrivia:
#The Perl-Users Digest is a retransmission of the USENET newsgroup
#comp.lang.perl.misc. For subscription or unsubscription requests, send
#the single line:
#
# subscribe perl-users
#or:
# unsubscribe perl-users
#
#to almanac@ruby.oce.orst.edu.
NOTE: due to the current flood of worm email banging on ruby, the smtp
server on ruby has been shut off until further notice.
To submit articles to comp.lang.perl.announce, send your article to
clpa@perl.com.
#To request back copies (available for a week or so), send your request
#to almanac@ruby.oce.orst.edu with the command "send perl-users x.y",
#where x is the volume number and y is the issue number.
#For other requests pertaining to the digest, send mail to
#perl-users-request@ruby.oce.orst.edu. Do not waste your time or mine
#sending perl questions to the -request address, I don't have time to
#answer them even if I did know the answer.
------------------------------
End of Perl-Users Digest V10 Issue 7502
***************************************