[7334] in Perl-Users-Digest
Perl-Users Digest, Issue: 959 Volume: 8
???@ATHENA.MIT.EDU (Perl-Users Digest)
Tue Sep 2 05:34:17 1997
Date: Tue, 2 Sep 97 02:00:28 -0700
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)
Perl-Users Digest Tue, 2 Sep 1997 Volume: 8 Number: 959
Today's topics:
Re: "U.S." =~ m/\bU\.S\.\b/ fails <jjwahl@eznet.net>
Cataloging the contents of an Array <spr@sysconfig.com>
Re: Cataloging the contents of an Array (Jeremy D. Zawodny)
character substitutions in msqlperl ..again <ptrainor@aura.title14.com>
debugger segmentation fault (Mick Ghazey)
formatnames, filehandles and strict denis@mathi.uni-heidelberg.de
Re: FTP with perl (Scott Houck)
Re: Help with Perl hooks on INN 1.5.1, please <srogge@telsarpc.harmonic.com>
Modules With oldperl 5.001 (LWP specifically) serstad@acc.jc.edu
Re: Modules With oldperl 5.001 (LWP specifically) <aas@bergen.sn.no>
Re: NIST Identifier Collaboration Service <aas@bergen.sn.no>
Re: pattern matching HELP! (Jeremy D. Zawodny)
Re: Perl (kind of) math question. <ajohnson@gpu.srv.ualberta.ca>
Re: Perl goofs up search/replace - *sometimes* <rootbeer@teleport.com>
Re: PERL/HTML Question (Max Rogovy)
Programming question <wolverin@is.usmo.com>
Re: Programming question (Jeremy D. Zawodny)
Q: Sorting a hash of emails, based on domain (Andrew Pollock)
Re: Q: Sorting a hash of emails, based on domain <friedman@uci.edu>
Re: Q: Sorting a hash of emails, based on domain (Jeremy D. Zawodny)
Re: Q: Sorting a hash of emails, based on domain (Jeremy D. Zawodny)
Re: Reading a data file <rootbeer@teleport.com>
Re: Reserved words (Scott Houck)
Re: Reserved words <lehors@w3.org>
Where can I get perl and how do I install it? (Steve Silberberg)
Digest Administrivia (Last modified: 8 Mar 97) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: Mon, 1 Sep 1997 21:45:03 -0400
From: "Jon Wahl" <jjwahl@eznet.net>
Subject: Re: "U.S." =~ m/\bU\.S\.\b/ fails
Message-Id: <917cd$152638.2a6@news.eznet.net>
I tried it too and it seems that Perl has a problem with the second \b word
boundary. According to the Camel Book,
'The special character string \b matches at a word boundary, which is
defined as the "nothing" between a word character (\w) and a non-word
character (\W), in either order. (The characters that don't exist off the
beginning and end of your string are considered to be non-word characters.)'
Which, as I read it means that your pattern should match.
Scratching my head too,
Jon Wahl
jjwahl@eznet.net
James H. Thompson wrote in article <5ufgc8$ccn@nuhou.aloha.net>...
>if ("U.S." =~ m/\bU\.S\.\b/) {
> print "match\n";
> }
>else {
> print "no match\n";
> }
>
>prints "no match"
------------------------------
Date: 2 Sep 1997 01:30:41 GMT
From: "Sean P. Robertson" <spr@sysconfig.com>
Subject: Cataloging the contents of an Array
Message-Id: <01bcb740$1be03640$42618cd0@colorbook>
I am working on a program that an am stuck.
Given:
@sorted_list = (0,0,0,1,2,3,3);
I want to find out that 0 occurs the most, 3 occurs the second most, and
that the other two occur the least number of times. These are keys for a
database thing that I am working on in which I want to return the documents
in order of probability that they are what the user is looking for. It
would be useful, after determining their order based on the frequency of
their occurance, to strip out the duplicates and then put them in order
from most frequent to least.
The result:
@new_list = (0,3,1,2)
I can then loop through @new_list and tell the database to return the Title
of the documents in order of frequency.
Thanks for any help that may come of this.
Sean P. Robertson
spr@sysconfig.com
------------------------------
Date: Tue, 02 Sep 1997 02:20:27 GMT
From: jzawodn@wcnet.org (Jeremy D. Zawodny)
Subject: Re: Cataloging the contents of an Array
Message-Id: <340b776e.36287989@news.bgsu.edu>
[original author automagically cc'd via e-mail]
On 2 Sep 1997 01:30:41 GMT, "Sean P. Robertson" <spr@sysconfig.com>
wrote:
>
>I am working on a program that an am stuck.
>
>Given:
>
>@sorted_list = (0,0,0,1,2,3,3);
>
>
>
>I want to find out that 0 occurs the most, 3 occurs the second most, and
>that the other two occur the least number of times. These are keys for a
>database thing that I am working on in which I want to return the documents
>in order of probability that they are what the user is looking for. It
>would be useful, after determining their order based on the frequency of
>their occurance, to strip out the duplicates and then put them in order
>from most frequent to least.
>
>
>The result:
>
>@new_list = (0,3,1,2)
>
>I can then loop through @new_list and tell the database to return the Title
>of the documents in order of frequency.
>
>Thanks for any help that may come of this.
You want a hash.
Something like:
my %hitcount = ();
my $key;
foreach $key (@sorted_list) { $hitcount{$key}++; }
That will count them up for you. Then all you need to do is sort by
the counts in the hash to get the array you want.
Of course, there's more than one way to do it.. :-)
Jeremy
---
Jeremy D. Zawodny
WCNet Technical Geek & Web Stuff
<URL:http://www.wcnet.org/~jzawodn/>
"That's an example of how Perl can bring school yard cruelty to new heights."
-- Jon Orwant at the 1st Annual Perl Conference
------------------------------
Date: Tue, 2 Sep 1997 00:18:58 -0400
From: Pat Trainor <ptrainor@aura.title14.com>
Subject: character substitutions in msqlperl ..again
Message-Id: <Pine.LNX.3.95.970902000825.26099A-100000@aura>
as an update, I can break it every time with entering the backspace
character \ into any field given to the database.
I can also enter the \ in as long as I have it 'delimited' like \\,
and it will pass in and out of the database no problem after that.
The big question is how to s/ or tr/ or anything the \ character
(and all the other perl-esque chars) into 'delimited' versions for
inclusion/extraction in db queries such as the one below.
Any help appreciated, I'm feeling I need to either re-do my
queries, or the solution has never been on the net for me to find! :)
==========================================================================
After looking through all my reference material and the msql faq,
I'm now asking a simple question of the newsgroup:
How can I treat a variable's contents so that perl/msql do not
treat the contents of the string as commands?
For example:
$sql_statement = " UPDATE tablename SET column_name = '$variable' WHERE
column_name = '$other_variable' ";
This all works great AS LONG AS no characters that can be construed
as commands are in the variable $variable. If I try to insert any
non-alpha-numeric characters, the char string is read as a command, and
perl parses it with (obvious) errors.
Now I tried a few things to no avail with approximations of:
$string =~ s/ .. / .. /gi;
But I'm just plain missing it. Any filter substitution string I
could pass these variable through that would allow them to be
impoted/exported to/from perl would be a ppreciated.
In case it matters, the contents of these variables are not
binary/high ascii.
TIA!!!!
------------------------------
Date: Tue, 02 Sep 1997 03:23:29 GMT
From: mick@lowdown.com (Mick Ghazey)
Subject: debugger segmentation fault
Message-Id: <340b81fc.52096529@news.lowdown.com>
I'm using perl5.004_1, recently installed. The debugger is failing as
shown below.
-r--r--r-- 1 root root 63403 Jun 18 16:31
/usr/lib/perl5/perl5db.pl
(23:04:16) root:/var/backup> perl -d /usr/bin/myprogs/pmscan
Loading DB routines from perl5db.pl version 1
Emacs support available.
Enter h or `h h' for help.
Segmentation fault
------------------------------
Date: Tue, 02 Sep 1997 09:54:38 +0200
From: denis@mathi.uni-heidelberg.de
Subject: formatnames, filehandles and strict
Message-Id: <340BC63E.41C6@mathi.uni-heidelberg.de>
hi,
how can i use formatnames and filehandles with strict...
i got a errormessage:
Bareword "PROBLEM" not allowed while "strict subs"
for the formatfiles and
Global symbol "OUT_FILE" requires explicit package name
for the filehandles?
thanks
denis
------------------------------
Date: Tue, 02 Sep 1997 03:10:39 GMT
From: scott@radix.net (Scott Houck)
Subject: Re: FTP with perl
Message-Id: <340c839c.31911005@news1.radix.net>
mweber@vt.edu (Matt Weber) wrote:
>Is there an easy perl script or module for FTPing something? It needs to be
>able to run on its own....log itslef in....transfer files and close the socket.
>The running on its own part will be done with crontabs. Any suggestions?
Maybe you should check out Expect.
------------------------------
Date: 2 Sep 1997 04:00:55 GMT
From: "Stan A. Rogge" <srogge@telsarpc.harmonic.com>
Subject: Re: Help with Perl hooks on INN 1.5.1, please
Message-Id: <01bcb753$2df794a0$fc01fd0a@telsarlt.harmonic.com>
Perl 5 does not use dbmopen and dbmclose. It uses tie and untie. Also,
you must define the type dbm you are using. Here is an example:
use SDBM_File;
tie(%SITES, SDBM_File, $config_file, O_RDWR | O_CREAT, 0660);
untie %SITES;
$config_file is the base name of the dbm filename.
%SITES is the associative array name
Get thee a perl5 book. Xref: news.mr.net tw.bbs.rec.model:6740 s Analyst) srogge@telsarpc.harmonic.com
Harmonic System Incorporated, 701 Fourth Avenue South, Suite 320,
Minneapolis MN 55415
Telephone: 612-321-4060 Fax- 612-672-3549
Web: http://www.telsarpc.harmonic.com FTP: ftp://telsarpc.harmonic.com
------------------------------
Date: Mon, 01 Sep 1997 23:11:25 -0600
From: serstad@acc.jc.edu
Subject: Modules With oldperl 5.001 (LWP specifically)
Message-Id: <873173053.31427@dejanews.com>
I'm trying to read an HTML file from another server and have found (thanks
to this group) that it's a 2-liner with LWP.
However, Perl on my system doesn't have LWP. Fine. D/L it? Ok -- so
then I find that LWP needs Perl 5.004. Hmmm... Perl -v yields that Perl
on my system is a lowly 5.001 or so....
What are my best options here? I would rather not download and install
Perl 5.004 on my local account (space restrictions, etc.) and my sysadmin
is a very busy man and has better things to do than upgrade Perl just for
me. (I know, that's heretical in this group!)
Is there an older version of LWP that I should use? Is there another
alternative for me to get a remote HTML file? Go ahead and install Perl
on my personal shell account?
Thanks a lot!
.sped.
-------------------==== Posted via Deja News ====-----------------------
http://www.dejanews.com/ Search, Read, Post to Usenet
------------------------------
Date: 02 Sep 1997 10:38:28 +0200
From: Gisle Aas <aas@bergen.sn.no>
Subject: Re: Modules With oldperl 5.001 (LWP specifically)
Message-Id: <hiuwkjekb.fsf@bergen.sn.no>
serstad@acc.jc.edu writes:
> However, Perl on my system doesn't have LWP. Fine. D/L it? Ok -- so
> then I find that LWP needs Perl 5.004. Hmmm... Perl -v yields that Perl
> on my system is a lowly 5.001 or so....
libwww-perl-5.11 require perl 5.004 or better
libwww-perl-5.10 require perl 5.002 or better
libwww-perl-5b6 require perl5.001m or better
Both 5.11 and 5.10 should be available on CPAN. 5b6 (it's almost 2
years old) is available from me on request.
> What are my best options here? I would rather not download and install
> Perl 5.004 on my local account (space restrictions, etc.) and my sysadmin
> is a very busy man and has better things to do than upgrade Perl just for
> me. (I know, that's heretical in this group!)
I would still try to make him upgrade perl.
--
Gisle Aas <aas@sn.no>
------------------------------
Date: 02 Sep 1997 10:50:13 +0200
From: Gisle Aas <aas@bergen.sn.no>
Subject: Re: NIST Identifier Collaboration Service
Message-Id: <hhgc4je0q.fsf@bergen.sn.no>
Tom Grydeland <tom@mitra.phys.uit.no> writes:
> http://pitch.nist.gov/nics/
>
> There is no domain for Perl modules. Seems it could very well be.
We have the module list to coordinate our name space. It seems to work
well.
--
Gisle Aas <aas@sn.no>
------------------------------
Date: Tue, 02 Sep 1997 00:30:51 GMT
From: jzawodn@wcnet.org (Jeremy D. Zawodny)
Subject: Re: pattern matching HELP!
Message-Id: <340b5e1e.29807681@news.bgsu.edu>
[original author automagically cc'd via e-mail]
On Fri, 29 Aug 1997 15:53:46 GMT, mguz@sol.co.uk (Mark Guz) wrote:
>
>You guys have been pretty helpfull so far, so I hav another question.
>
>I am trying to check for illegal characters in a string.
>
>the allowable set is [a-z0-9_&.-] and I am trying to write code
>something like -
>
>
> if($string is not [a-z0-9_&.-]){
>
> die "Not allowed!!!!"
>
> }
Look up the 'tr' function.
Jeremy
---
Jeremy D. Zawodny
WCNet Technical Geek & Web Stuff
<URL:http://www.wcnet.org/~jzawodn/>
"That's an example of how Perl can bring school yard cruelty to new heights."
-- Jon Orwant at the 1st Annual Perl Conference
------------------------------
Date: Mon, 01 Sep 1997 21:51:30 -0500
From: Andrew Johnson <ajohnson@gpu.srv.ualberta.ca>
Subject: Re: Perl (kind of) math question.
Message-Id: <340B7F32.6779A623@gpu.srv.ualberta.ca>
Scott Houck wrote:
>
> gbacon@adtran.com (Greg Bacon) wrote:
>
> >as hex or hexadecimal is another way of saying base sixteen. Most
> >humans are used to dealing with either base ten or base six.
>
> Who are these humans that are used to dealing with base six? Are they
> mutants that ran out of fingers? :-)
indeed, I've heard of base twenty (vigesimal) with the Mayans, and
base sixty (sexagesimal) with the Babylonians (still in use into
the 15th century, at least in astronomy)---but a base six system
doesn't ring any bells...
andrew
------------------------------
Date: Mon, 1 Sep 1997 16:59:33 -0700
From: Tom Phoenix <rootbeer@teleport.com>
To: "Filip M. Gieszczykiewicz" <fmgst+@pitt.edu>
Subject: Re: Perl goofs up search/replace - *sometimes*
Message-Id: <Pine.GSO.3.96.970901163624.10428L-100000@julie.teleport.com>
On 1 Sep 1997, Filip M. Gieszczykiewicz wrote:
> #!/usr/bin/perl
Where's -w? Where's 'use strict'? :-) Those can be a big help.
> sub Search_n_Replace {
> local (@tmp) = @_;
Why local instead of my? Using my() is more efficient, among other things.
> while (@tmp) {
> # FILO
> $replace = pop (@tmp);
> $search = pop (@tmp);
> if (m|$search|is) {
I don't like seeing $_ used as an implicit parameter to a subroutine. It's
better to pass it explicitly.
> # leave the section names/titles themselves ALONE!
> if (!m|<a name=| && !m|<a href=\"\#|) {
> s|$search|$replace|sxg;
Now, you know that that /x modifier does nothing here, right? And you're
only doing this replacement if $_ has both of those two strings '<a name='
and '<a href="#' in it - so if you're not getting all of the replacements
you want, that's the lead suspect. (For example, what happens if any
capitalization or spacing is changed?)
> s@/@\/@gx;
Again, the useless /x modifier. But that's okay, because the whole
statement is useless. :-)
> sub Load_Dictionary {
> if (! -f "$default_dict") { die ("ERROR: Can not find '$default_dict'!\n"); }
> open (DICT, "$default_dict") || die ("ERROR: can't open '$default_dict'");
(Those double quotes around the filename are merely misleading.) Why do
you do the extra check? If the open fails, it fails; if it succeeds, the
file exists. :-)
> # for now ignore "-->" (change to '@' and split on it)
> $_ =~ s/(\ *)-->(\ *)/@/;
> #
> # Stuff values on line into array
> ($search,$replace) = split (/@/);
Why don't you just split on / *--> */ ? Or, if you want to split on
at-signs as well, that's easy to add. That would be more efficient than
the substitution followed by the split.
> # Don't know how to do this 'nicer' but it
> # DOES work and everything is as desired...
Why do you say that it DOES work? Aren't you posting because it DOESN'T?
:-)
> $orig_search = $search;
> $orig_search =~ s/"//g;
> $search =~ s|\?|\\?|g;
> $search =~ s/"//g;
> # TODO: add search for unmatched ()
> $search =~ s|\.|\\.|g;
> $search =~ s|\"\ |\"|g;
> $search =~ s|\"|\\"|g;
> $search =~ s|\ |\.|g;
If I understood what you were trying to do here, I'd show you a better way
to do it. :-)
> $repl = "<a HreF=\"" . $replace . "\">" . $orig_search . "</a>";
> $replace =~ s/$replace/$repl/;
That's a good way to get confused. At least one of us doesn't understand
what that is doing. :-)
Hope this helps!
--
Tom Phoenix http://www.teleport.com/~rootbeer/
rootbeer@teleport.com PGP Skribu al mi per Esperanto!
Randal Schwartz Case: http://www.rahul.net/jeffrey/ovs/
------------------------------
Date: Mon, 01 Sep 1997 23:23:37 -0700
From: maxrNOSPAM@halcyon.com (Max Rogovy)
Subject: Re: PERL/HTML Question
Message-Id: <maxrNOSPAM-0109972323370001@blv-pm103-ip8.halcyon.com>
> How do I pass arguements from a hyperlink to a perl script?
http://www.server.com/script.pl?name=value&name=value
------------------------------
Date: Mon, 01 Sep 1997 19:27:46 -0700
From: Timothy Nolen <wolverin@is.usmo.com>
Subject: Programming question
Message-Id: <340B79A2.75B76B51@is.usmo.com>
I would like to make a script that, when I add a user to the database,
it puts it in a table and makes the table a certain color, but when I
add another user it puts in a table but makes that table a different
color. And when I add person 3 its sets up three like one. And when I
add person 4 it sets it up like 2.
I also would like to make a script that, when I delete a person, the
script will redo all the table colors so that they go color one, color
two, color one, color two, and so forth.
Please e-mail me at wolverin@is.usmo.com if you know the answer.
Thanks
Tim
------------------------------
Date: Tue, 02 Sep 1997 02:44:15 GMT
From: jzawodn@wcnet.org (Jeremy D. Zawodny)
Subject: Re: Programming question
Message-Id: <340e7c0d.37470049@news.bgsu.edu>
[original author automagically cc'd via e-mail]
On Mon, 01 Sep 1997 19:27:46 -0700, Timothy Nolen
<wolverin@is.usmo.com> wrote:
Even before answering your question, allow me to suggest that you more
carefully target your news postings. According my newsreader, you
posed to:
comp.lang.perl, comp.lang.perl.misc, comp.lang.perl.modules,
comp.lang.perl.tk, comp.lang.misc,alt.linux
comp.lang.perl hasn't existed for quite some time. Contact your news
server administrator, and suggest that s/he update his/her group list.
Based on the content of your question, I'm not sure why you asked the
linux group, perl.tk group, or the comp.lang.misc group. If it's
really a perl scripting question, they probably won't care.
I've taken those groups out of this follow-up.
I've also removed comp.lang.perl.modules, since this question doesn't
pertain to a module (that I can tell).
Enough of my ranting... :-)
>I would like to make a script that, when I add a user to the database,
>it puts it in a table and makes the table a certain color, but when I
>add another user it puts in a table but makes that table a different
>color. And when I add person 3 its sets up three like one. And when I
>add person 4 it sets it up like 2.
Hm. Some questions pop into mind.
(1) What database?
(2) What operating system are you using?
(3) What 'table'? A database table? A flat-file database?
(4) What language/system currently handles the user-management tasks
you've described?
The answers to those questions will help us formulate a specific
answer for you.
>I also would like to make a script that, when I delete a person, the
>script will redo all the table colors so that they go color one, color
>two, color one, color two, and so forth.
In the meantime, have you tried any of this yet, or are you just
collecting ideas?
The more details you provide us, the better we can point you in a good
direction.
Jeremy
---
Jeremy D. Zawodny
WCNet Technical Geek & Web Stuff
<URL:http://www.wcnet.org/~jzawodn/>
"That's an example of how Perl can bring school yard cruelty to new heights."
-- Jon Orwant at the 1st Annual Perl Conference
------------------------------
Date: 2 Sep 1997 01:46:44 GMT
From: apollock@bit.net.au (Andrew Pollock)
Subject: Q: Sorting a hash of emails, based on domain
Message-Id: <5ufr64$36q$1@hermes.bit.net.au>
Hi, I hope I'm not asking an FAQ here...
I've got a hash of email addresses, and I'd like to sort the keys
alphabetically, based on the domain. Does anyone know how I would
go about doing this?
Thanks in advance.
Andrew
----
Andrew Pollock Programmer/System Administrator
apollock@bit.net.au http://staff.bit.net.au/apollock
Brisbane Internet Technology Pty Ltd.
------------------------------
Date: 2 Sep 1997 02:35:48 GMT
From: "Eric D. Friedman" <friedman@uci.edu>
Subject: Re: Q: Sorting a hash of emails, based on domain
Message-Id: <5ufu24$88s@news.service.uci.edu>
[mailed, posted]
In article <5ufr64$36q$1@hermes.bit.net.au>,
Andrew Pollock <apollock@bit.net.au> wrote:
<I've got a hash of email addresses, and I'd like to sort the keys
<alphabetically, based on the domain. Does anyone know how I would
<go about doing this?
Assuming that the addresses are in the keys and that the domain
is always in the same place in the addresses (that is, the penultimate
substring when the address is split by dots: somebody@FOO.com,
another@machine.blah.FOO.edu, more@machine-blah.blah-blah.FOO.org),
you can do this with a Schwartzian transform:
(Read this from the bottom up)
sub getDomain
{
my $add = shift;
my @fields = split /\./, $add;
return $fields[$#fields - 1]; # Return the penultimate substring
}
my @sorted_keys =
map { $_->[0] } # return the real keys (sorted) to the list
sort { $a->[1] cmp $b->[1] } # sort on the domains, alphabetically
map { [$_, getDomain($_) } # make an anon array out of keys and domains
keys %hash;
I'd be curious to see a version of this which didn't need the
additional function (getDomain) to get the next to last key....
-edf
--
Eric D. Friedman
friedman@uci.edu
------------------------------
Date: Tue, 02 Sep 1997 02:37:50 GMT
From: jzawodn@wcnet.org (Jeremy D. Zawodny)
Subject: Re: Q: Sorting a hash of emails, based on domain
Message-Id: <340d7bb6.37383464@news.bgsu.edu>
[original author automagically cc'd via e-mail]
On Tue, 02 Sep 1997 02:34:09 GMT, jzawodn@wcnet.org (Jeremy D.
Zawodny) wrote:
Yikes... My proofreading leave something to be desired...
Ignore the first few comments in my code, and it'll make more sense.
:-)
># assuming that @addrs contains ("foo@bar.com", "foo2@blah.org", ...)
>#
Yes, those. The rest is okay.
># You can build a hash in which the key is the domain name, and the
># value is a comma separated list containing all the 'usernames'
># or 'mailbox names' you've seen.
[...]
*sigh* bed time, I guess.
Jeremy
---
Jeremy D. Zawodny
WCNet Technical Geek & Web Stuff
<URL:http://www.wcnet.org/~jzawodn/>
"That's an example of how Perl can bring school yard cruelty to new heights."
-- Jon Orwant at the 1st Annual Perl Conference
------------------------------
Date: Tue, 02 Sep 1997 02:34:09 GMT
From: jzawodn@wcnet.org (Jeremy D. Zawodny)
Subject: Re: Q: Sorting a hash of emails, based on domain
Message-Id: <340c77fc.36429342@news.bgsu.edu>
[original author automagically cc'd via e-mail]
On 2 Sep 1997 01:46:44 GMT, apollock@bit.net.au (Andrew Pollock)
wrote:
>Hi, I hope I'm not asking an FAQ here...
>
>I've got a hash of email addresses, and I'd like to sort the keys
>alphabetically, based on the domain. Does anyone know how I would
>go about doing this?
Do you have a hash (%something) or a list (@something)? I'll assume
that you have a list, because I can't guess whether you'd have the
e-mail address as the key or the value in a hash, and why you'd do
either.
In any case:
---snip---
# assuming that @addrs contains ("foo@bar.com", "foo2@blah.org", ...)
#
# You can build a hash in which the key is the domain name, and the
# value is a comma separated list containing all the 'usernames'
# or 'mailbox names' you've seen.
# If I was more creative, I'd make it a reference to a list
# of those names, but it's getting close to my bed time.
# get e-mail addresses (from STDIN). You can skip this part
# if the list already exists.
my %names;
my $val;
while(<>) {
chomp;
$_ =~ m/(.*)@(.*)/;
my($name,$domain) = ($1, $2);
print "Name: $name\n";
print "Domain: $domain\n";
# you can do better than this, probably...
if ($names{$domain}) {
$names{$domain} = join(',', $names{$domain}, $name);
} else {
$names{$domain} = $name;
} # end else
} # end while
foreach $val (sort keys(%names)) {
print "Names seen at $val are $names{$val}\n";
}
exit;
---snip---
Is that the sort of thing you were looking for? Maybe it'll get you
pointed in the right direction.
Jeremy
---
Jeremy D. Zawodny
WCNet Technical Geek & Web Stuff
<URL:http://www.wcnet.org/~jzawodn/>
"That's an example of how Perl can bring school yard cruelty to new heights."
-- Jon Orwant at the 1st Annual Perl Conference
------------------------------
Date: Mon, 1 Sep 1997 17:11:42 -0700
From: Tom Phoenix <rootbeer@teleport.com>
To: Jesse Markham <jjmarkha@mailhost.ecn.ou.edu>
Subject: Re: Reading a data file
Message-Id: <Pine.GSO.3.96.970901170106.10428M-100000@julie.teleport.com>
On Sun, 31 Aug 1997, Jesse Markham wrote:
> $file = data.txt; #gives variable $file the value data.txt
No, it doesn't.
> open(dummy,$file); #opens data.txt and associates dummy
That's a bad way to do that, for reasons any regular reader of this
newsgroup could tell you. And, in fact, for reasons that -w will tell you
as well.
> @lines = <dummy>; #dumps the contents of the file into an array of lines
This is an application which might be better suited to processing a line
at a time, which is better when the number of lines might be large.
> close(dummy); #closes dummy or data.txt
I don't know why your indentation is so ragged. Does your cat help you
type? :-)
> for($i==0;$i<@lines;$i++)
> {
(Let's pass on the obvious error here.) The more Perl-ish way to iterate
over a list is with the other kind of for loop, foreach.
> if($lines[$i] =~ /24\.95/g)
> { print "24.95 is located in line $i";}
I don't think that the /g is really what you want here...
> if($lines[$i] =~ /1102/g)
> { print "1102 is located in line $i";}
...especially since you've also got it here.
I applaud your effort to try to help a stranger, and I encourage you to
answer more questions sometime when you're more experienced with Perl so
that you have some good advice to give. Thanks!
--
Tom Phoenix http://www.teleport.com/~rootbeer/
rootbeer@teleport.com PGP Skribu al mi per Esperanto!
Randal Schwartz Case: http://www.rahul.net/jeffrey/ovs/
------------------------------
Date: Tue, 02 Sep 1997 05:28:18 GMT
From: scott@radix.net (Scott Houck)
Subject: Re: Reserved words
Message-Id: <340ea19e.39592671@news1.radix.net>
aml@world.std.com (Andrew M. Langmead) wrote:
>I'm glad someone else pointed out keywords.pl and keywords.h, I didn't
>know they existed. Perl is a little odd, though, in regard to reserved
>words. In most languages, knowing the keywords is important because
>every programmer at every level of expertise needs to learn all of the
>keywords, so as to avoid using them as variable (and subroutine)
>names.
>
>Since perl prefixes its variables with "$", "@", and "%", variable
>names never conflict with reserved words. If you want to name
>variables "$if", "@not", or "%foreach", you are perfectly welcome to.
I'm glad to learn of this too. Now it'll be much easier to update my
CodeWright Perl DLL!
------------------------------
Date: Tue, 02 Sep 1997 09:53:21 +0200
From: Arnaud Le Hors <lehors@w3.org>
Subject: Re: Reserved words
Message-Id: <340BC5F1.AD2B9ECE@w3.org>
Mike Guy wrote:
> That's why it *is* in the standard distribution. See the file keywords.pl
> (or keywords.h).
Thanks for the pointer, I was expecting it in the documentation.
Andrew M. Langmead wrote:
>
> I'm glad someone else pointed out keywords.pl and keywords.h, I didn't
> know they existed. Perl is a little odd, though, in regard to reserved
> words. In most languages, knowing the keywords is important because
> every programmer at every level of expertise needs to learn all of the
> keywords, so as to avoid using them as variable (and subroutine)
> names.
>
> Since perl prefixes its variables with "$", "@", and "%", variable
> names never conflict with reserved words. If you want to name
> variables "$if", "@not", or "%foreach", you are perfectly welcome to.
This is true. But there are still cases where you may have a conflict
though.
For instance if you define a function named "if", you can only call it
explicitly using "&". (I agree, it would be really stupid to call your
function if ;)
--
Arnaud
------------------------------
Date: Tue, 02 Sep 97 06:37:15 GMT
From: stevebo@onramp.net (Steve Silberberg)
Subject: Where can I get perl and how do I install it?
Message-Id: <5ugc2i$r70@news.onramp.net>
I have an old version of Perl that I downloaded and couldn't figure out how to
install or "make".
Can anyone point me to a Perl for Unix - Sun OS 4.1.2?
Thanks
Steve
----------------
Steve Silberberg
mailto:stevebo@onramp.net
Visit the Air Sickness Bag Museum at:
http://rampages.onramp.net/~stevebo/airsick.html
------------------------------
Date: 8 Mar 97 21:33:47 GMT (Last modified)
From: Perl-Request@ruby.oce.orst.edu (Perl-Users-Digest Admin)
Subject: Digest Administrivia (Last modified: 8 Mar 97)
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.
To submit articles to comp.lang.perl.misc (and this Digest), send your
article to perl-users@ruby.oce.orst.edu.
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.
The Meta-FAQ, an article containing information about the FAQ, is
available by requesting "send perl-users meta-faq". The real FAQ, as it
appeared last in the newsgroup, can be retrieved with the request "send
perl-users FAQ". Due to their sizes, neither the Meta-FAQ nor the FAQ
are included in the digest.
The "mini-FAQ", which is an updated version of the Meta-FAQ, is
available by requesting "send perl-users mini-faq". It appears twice
weekly in the group, but is not distributed in the digest.
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 V8 Issue 959
*************************************