[20014] in Perl-Users-Digest
Perl-Users Digest, Issue: 2209 Volume: 10
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Mon Nov 26 14:10:42 2001
Date: Mon, 26 Nov 2001 11:10:17 -0800 (PST)
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)
Message-Id: <1006801816-v10-i2209@ruby.oce.orst.edu>
Content-Type: text
Perl-Users Digest Mon, 26 Nov 2001 Volume: 10 Number: 2209
Today's topics:
Re: File position of of every word in a file <godzilla@stomp.stomp.tokyo>
Re: How to trap calls to undefined procedures at compil <cp@onsitetech.com>
ISO Country Code Lookup (Mike Norton)
Re: ISO Country Code Lookup <tony_curtis32@yahoo.com>
New posters to comp.lang.perl.misc <gbacon@cs.uah.edu>
Re: New posters to comp.lang.perl.misc <bart.lateur@pandora.be>
Re: Perl 6 (Cameron Laird)
Perl and Windows 2000 Service. <bubba_1947@lycos.com>
Re: Perl and Windows 2000 Service. <bubba_1947@lycos.com>
Re: Perl and Windows 2000 Service. <admin@asarian-host.net>
Re: Perl and Windows 2000 Service. <bubba_1947@lycos.com>
Re: Perl and Windows 2000 Service. <admin@asarian-host.net>
Re: Perl and Windows 2000 Service. <ellem@techie.net>
Posting style (Was: A Perl Bug?) (Jon Bell)
Re: question for array operation (Daniel Berger)
Re: question for array operation <godzilla@stomp.stomp.tokyo>
regexp <michDEL_THIS@bsd.fr.eu.org>
Re: regexp <holland@origo.ifa.au.dk>
Re: regexp (John J. Trammell)
Re: regexp <bart.lateur@pandora.be>
Re: regexp (Helgi Briem)
Re: regexp <peb@bms.umist.ac.uk>
Re: returning keys of a tree hashed array????? <no.th@ank.you>
RTFM (was Re: A Perl Bug?) <ellem@techie.net>
Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: Mon, 26 Nov 2001 06:06:57 -0800
From: "Godzilla!" <godzilla@stomp.stomp.tokyo>
Subject: Re: File position of of every word in a file
Message-Id: <3C024C81.46F3AD46@stomp.stomp.tokyo>
Rob van Strien wrote:
> How can I get the file position of each single word in a file?
> I can read the file line by line and chop it up in words, but
> the tell-function will always return the file position of the
> (end of the) line I'm on, not the words.
> Thanks to all of you who helped me with this problem.
> This is my solution (apart from the discussion of what
> a 'word' might be, which isn't solved yet in my case).
>
> while ($startOfLine = tell, $line = <INV>) {
> chomp($line);
> while ($line =~ m/\b([a-zA-Z]+)\b/g) {
> $match = $&;
> $position = $startOfLine+pos($line);
> print TEMP "$match:$position\n";
> }
> }
I am quite certain you are aware this code does
not work right as you state. It does not even
come close to finding the file position of
each word in a file.
Godzilla!
------------------------------
Date: 26 Nov 2001 17:38:11 GMT
From: "Curtis Poe" <cp@onsitetech.com>
Subject: Re: How to trap calls to undefined procedures at compile time
Message-Id: <9ttum3$jog@dispatch.concentric.net>
I know of no way to accomplish that and frankly, I don't think it's
possible. With ease of access to symbol tables, AUTOLOAD, and generating
code on the fly, it would be impossible for Perl to know at compile time if,
in fact, a given function exists.
The best I could suggest is to write some code that walks your symbol tables
and looks for coderefs, but then you're going to wind up with problems
trying to parse all of the different ways Perl can call functions and
methods. What follows is five different ways to call the same function (and
some of these can break, depending on the how the program is structured):
my $q = new CGI;
my $q = CGI::->new;
my $q = CGI->new;
my $q = CGI->new();
my $q = &CGI::new;
--
Cheers,
Curtis Poe
Senior Programmer
ONSITE! Technology
www.onsitetech.com
503.233.1418
"Peter Terpstra" <terpstra@REMOVEPLEASEsmr.nl> wrote in message
news:91659E6E7terpstrasmrnl@24.132.26.253...
>
> Well,
>
> the subject says it all.
> I'm working on a large program, written in perl. The program has a lot of
> modules.
> When I do a syntax check in a module, which calls an undefined procedure,
> the
> syntax checker still says that the syntax is "OK".
>
> I tried stuff like "use strict", but that does not seem to help.
> I know about the dynaloader, but this module only traps errors at runtime.
>
> Without an appropriate compile time check, I would need to have a test,
> which checks exhaustively all possible execution branches. This is not
very
> practical.
> Is there a better solution?
>
> Peter Terpstra
>
>
------------------------------
Date: 26 Nov 2001 08:22:23 -0800
From: mnorton2000@hotmail.com (Mike Norton)
Subject: ISO Country Code Lookup
Message-Id: <93b16924.0111260822.136577a6@posting.google.com>
I am trying to write a script in Perl Which allows me to enter an IP
address and it will lookup which country that IP address is located
within, however I do not want to use the tld which is e.g .com (us
commercial) as this is very innacurate. To find a more accurate way I
want to use the ISO country codes. When you go to the ripe whois
database and type in the ip you get the following information :-
inetnum: 194.192.224.0 - 194.192.239.255
netname: COLOPLAST
descr: Coloplast A/S
country: DK
admin-c: MC290-RIPE
tech-c: MC290-RIPE
status: ASSIGNED PA
mnt-by: DKNET-MNT
changed: sp@DK.net 19961125
source: RIPE
route: 194.192.0.0/16
descr: Tele Danmark
origin: AS3292
remarks: +---------------------------------------+
remarks: | For abuse and security issues contact |
remarks: | csirt@csirt.dk, http://www.csirt.dk |
remarks: +---------------------------------------+
mnt-by: AS3292-MNT
changed: auto-ripe@ip.tele.dk 20000207
changed: auto-ripe@ip.tele.dk 20010813
source: RIPE
person: Mogens Christensen
address: Coloplast A/S
address: Hoejvangen 2
address: DK-3060 Espergaerde
address: Denmark
phone: +45 49 11 15 07
fax-no: +45 49 11 15 10
nic-hdl: MC290-RIPE
mnt-by: DKNET-MNT
changed: blu@sas.dk 19960925
changed: sp@DK.net 19961125
source: RIPE
what I am looking to do is grab the country code on the whois record
for example on the record above is DK which will give me a better
indication of where the ip address is from if anyone has any ideas on
how I would go about doing this then let me know.
Thanks
Mike
------------------------------
Date: Mon, 26 Nov 2001 10:27:29 -0600
From: Tony Curtis <tony_curtis32@yahoo.com>
Subject: Re: ISO Country Code Lookup
Message-Id: <877ksdzedq.fsf@limey.hpcc.uh.edu>
>> On 26 Nov 2001 08:22:23 -0800,
>> mnorton2000@hotmail.com (Mike Norton) said:
> I am trying to write a script in Perl Which allows me to
> enter an IP address and it will lookup which country
> that IP address is located within, however I do not want
> to use the tld which is e.g .com (us commercial) as this
> is very innacurate. To find a more accurate way I want
> to use the ISO country codes. When you go to the ripe
> whois database and type in the ip you get the following
> information :-
Net::ParseWhois is probably what you want:
http://search.cpan.org/doc/ABEROHAM/Net-ParseWhois-0.62/lib/Net/ParseWhois.pm
or maybe just Net::Whois
http://search.cpan.org/doc/DHUDES/Net-Whois-1.9/Whois.pm
hth
t
--
Oh! I've said too much. Smithers, use the amnesia ray.
------------------------------
Date: Mon, 26 Nov 2001 17:39:01 -0000
From: Greg Bacon <gbacon@cs.uah.edu>
Subject: New posters to comp.lang.perl.misc
Message-Id: <u04vhljl05fsa4@corp.supernews.com>
Following is a summary of articles from new posters spanning a 7 day
period, beginning at 19 Nov 2001 17:40:50 GMT and ending at
26 Nov 2001 15:45:30 GMT.
Notes
=====
- A line in the body of a post is considered to be original if it
does *not* match the regular expression /^\s{0,3}(?:>|:|\S+>|\+\+)/.
- All text after the last cut line (/^-- $/) in the body is
considered to be the author's signature.
- The scanner prefers the Reply-To: header over the From: header
in determining the "real" email address and name.
- Original Content Rating (OCR) is the ratio of the original content
volume to the total body volume.
- Find the News-Scan distribution on the CPAN!
<URL:http://www.perl.com/CPAN/modules/by-module/News/>
- Please send all comments to Greg Bacon <gbacon@cs.uah.edu>.
- Copyright (c) 2001 Greg Bacon.
Verbatim copying and redistribution is permitted without royalty;
alteration is not permitted. Redistribution and/or use for any
commercial purpose is prohibited.
Totals
======
Posters: 93 (34.6% of all posters)
Articles: 196 (20.5% of all articles)
Volume generated: 467.6 kb (23.6% of total volume)
- headers: 164.4 kb (3,329 lines)
- bodies: 295.1 kb (9,745 lines)
- original: 234.7 kb (8,186 lines)
- signatures: 8.0 kb (289 lines)
Original Content Rating: 0.795
Averages
========
Posts per poster: 2.1
median: 1 post
mode: 1 post - 68 posters
s: 3.7 posts
Message size: 2443.1 bytes
- header: 858.6 bytes (17.0 lines)
- body: 1541.8 bytes (49.7 lines)
- original: 1226.4 bytes (41.8 lines)
- signature: 41.7 bytes (1.5 lines)
Top 10 Posters by Number of Posts
=================================
(kb) (kb) (kb) (kb)
Posts Volume ( hdr/ body/ orig) Address
----- -------------------------- -------
25 92.1 ( 26.7/ 65.3/ 58.9) "Steffen Müller" <5l259r001@sneakemail.com>
19 33.8 ( 18.0/ 15.6/ 9.1) Bart Lateur <bart.lateur@pandora.be>
10 23.9 ( 8.8/ 15.1/ 8.5) "Jake Fan" <jake@chaogic.com>
9 11.3 ( 6.7/ 4.6/ 2.7) helgi@decode.is
6 6.6 ( 3.8/ 2.8/ 2.8) "MisterSoftware" <moodie@fast.net>
5 8.6 ( 3.7/ 4.9/ 3.8) mike <mjc@drizzle.net>
5 9.4 ( 4.5/ 4.3/ 4.0) Dale Henderson <nilram@boisdarc.tamu-commerce.edu>
4 8.5 ( 3.6/ 4.5/ 3.9) Rafal Konopka <rafalk@home.com>
4 5.9 ( 3.8/ 2.1/ 2.1) john <jazz450@hotmail.com>
4 6.9 ( 3.8/ 3.0/ 2.3) "Louis" <louisdepointedulac@theatredesvampires.freeserve.co.uk>
These posters accounted for 9.5% of all articles.
Top 10 Posters by Volume
========================
(kb) (kb) (kb) (kb)
Volume ( hdr/ body/ orig) Posts Address
-------------------------- ----- -------
92.1 ( 26.7/ 65.3/ 58.9) 25 "Steffen Müller" <5l259r001@sneakemail.com>
71.5 ( 0.6/ 70.9/ 66.4) 1 Gary <healthrx@yahoo.com>
33.8 ( 18.0/ 15.6/ 9.1) 19 Bart Lateur <bart.lateur@pandora.be>
23.9 ( 8.8/ 15.1/ 8.5) 10 "Jake Fan" <jake@chaogic.com>
20.1 ( 0.8/ 19.3/ 9.6) 1 "Asayogure" <CGI_SPAM@BLOCKER_asayogure.com>
11.3 ( 6.7/ 4.6/ 2.7) 9 helgi@decode.is
9.4 ( 4.5/ 4.3/ 4.0) 5 Dale Henderson <nilram@boisdarc.tamu-commerce.edu>
8.6 ( 3.7/ 4.9/ 3.8) 5 mike <mjc@drizzle.net>
8.5 ( 3.6/ 4.5/ 3.9) 4 Rafal Konopka <rafalk@home.com>
8.0 ( 0.6/ 1.7/ 0.7) 1 gaius.petronius <rut@linuxmail.org>
These posters accounted for 14.5% of the total volume.
Top 10 Posters by OCR (minimum of three posts)
==============================================
(kb) (kb)
OCR orig / body Posts Address
----- -------------- ----- -------
0.999 ( 2.1 / 2.1) 4 john <jazz450@hotmail.com>
0.993 ( 2.8 / 2.8) 6 "MisterSoftware" <moodie@fast.net>
0.930 ( 4.0 / 4.3) 5 Dale Henderson <nilram@boisdarc.tamu-commerce.edu>
0.901 ( 58.9 / 65.3) 25 "Steffen Müller" <5l259r001@sneakemail.com>
0.859 ( 3.9 / 4.5) 4 Rafal Konopka <rafalk@home.com>
0.760 ( 2.3 / 3.0) 4 "Louis" <louisdepointedulac@theatredesvampires.freeserve.co.uk>
0.759 ( 3.8 / 4.9) 5 mike <mjc@drizzle.net>
0.598 ( 1.1 / 1.9) 3 "Jeff Klassen" <nospam!jklassen@biblesociety.ca>
0.587 ( 2.7 / 4.6) 9 helgi@decode.is
0.583 ( 9.1 / 15.6) 19 Bart Lateur <bart.lateur@pandora.be>
Bottom 10 Posters by OCR (minimum of three posts)
=================================================
(kb) (kb)
OCR orig / body Posts Address
----- -------------- ----- -------
0.759 ( 3.8 / 4.9) 5 mike <mjc@drizzle.net>
0.598 ( 1.1 / 1.9) 3 "Jeff Klassen" <nospam!jklassen@biblesociety.ca>
0.587 ( 2.7 / 4.6) 9 helgi@decode.is
0.583 ( 9.1 / 15.6) 19 Bart Lateur <bart.lateur@pandora.be>
0.561 ( 8.5 / 15.1) 10 "Jake Fan" <jake@chaogic.com>
0.510 ( 0.5 / 0.9) 3 e-mail
0.494 ( 0.6 / 1.2) 3 Ciaran McCreesh <keesh@users-dot-sf.net>
0.450 ( 1.2 / 2.8) 4 "brian norman" <brian.norman@gecm.com>
0.366 ( 0.7 / 1.8) 3 "Jonathan Rew" <jon_rew@nospam.learn-it.demon.co.uk>
0.289 ( 1.2 / 4.3) 3 owain@nospam.ofrm.demon.co.uk
16 posters (17%) had at least three posts.
Top 10 Targets for Crossposts
=============================
Articles Newsgroup
-------- ---------
18 comp.lang.perl.modules
10 alt.perl
5 nyc.food
5 comp.lang.java.programmer
5 comp.lang.basic.visual
5 comp.lang.ada
5 comp.object
5 comp.lang.c++
5 comp.lang.eiffel
3 comp.lang.perl
Top 10 Crossposters
===================
Articles Address
-------- -------
7 Gregor <gg@gg.net>
4 Brice Ruth <brice@webprojkt.com>
2 helgi@decode.is
2 "Steffen Müller" <5l259r001@sneakemail.com>
1 Derek Balling <dredd@megacity.org>
0 martin@unix-ag.org
0 "Travis Spencer" <t.s.spencer@n2.com>
0 "Adam Stein" <adam@scan.mc.xerox.com>
0 samer.forzley@alcatel.com
0 "LaVon Missell" <Lavon.Missell@sas.com>
------------------------------
Date: Mon, 26 Nov 2001 18:26:03 GMT
From: Bart Lateur <bart.lateur@pandora.be>
Subject: Re: New posters to comp.lang.perl.misc
Message-Id: <k9250u4j35qnssn8pkpbmesknd17dfv387@4ax.com>
Greg Bacon wrote:
>Top 10 Posters by Volume
>========================
> 33.8 ( 18.0/ 15.6/ 9.1) 19 Bart Lateur <bart.lateur@pandora.be>
Yeah I 'm new!
Just a change of address, folks.
--
Bart.
------------------------------
Date: 26 Nov 2001 12:23:17 -0600
From: claird@starbase.neosoft.com (Cameron Laird)
Subject: Re: Perl 6
Message-Id: <B1ABE7562AFF8241.BE4D4076B516D20A.3994F3DBD8FCAA0C@lp.airnews.net>
In article <comdog-F001F4.19552612112001@news.panix.com>,
brian d foy <comdog@panix.com> wrote:
>In article <a3db0d59.0111121247.27e1a95@posting.google.com>,
>raptnor@msn.com (john) wrote:
>
>> Hi, Im just another Perl hacker with a question to the Perl community.
>
>> Why do we need a complete redesign of our language?
.
.
.
>working on the core is getting tougher and tougher because it
>has been worked over so many times. to make it easy to work on
>Perl, even for things like bug fixes, the internals need to be
>made cleaner.
>
>along the way, they can fix nagging issues and add support for
>things that Perl will have to deal with in the future. the
.
.
.
>you can get a lot better answers by reading the previous
>discussions on the perl6 mailing lists if you have not done
>so already:
>
> http://dev.perl.org
.
.
.
While I can add nothing to brian's wise description,
<URL: http://www.unixreview.com/documents/s=1780/urm0111h/0111h.htm >
might be useful to those who want a very easy-going introduction to
Perl 6 for managers or other unPerled colleagues.
--
Cameron Laird <Cameron@Lairds.com>
Business: http://www.Phaseit.net
Personal: http://starbase.neosoft.com/~claird/home.html
------------------------------
Date: Mon, 26 Nov 2001 16:50:45 +0000 (UTC)
From: "Bubba Frank" <bubba_1947@lycos.com>
Subject: Perl and Windows 2000 Service.
Message-Id: <baf46d5161241ac34ac7d5e2984f751a.42091@mygate.mailgate.org>
Perl gurus,
I have a perl script which is watching a Oracle DB, waiting for a certain
column to change value; once done, it fires of an exe. I execute this script
from the command prompt, say : C:\watch.pl.
I needed to convert this script into a Service on the server. So, following the
steps as described in http://www.perlguy.com/article/nt_service.html, which I
found, everything is set up.
But now, I find an instance of perl.exe running in the process list instead of
seeing my script. What am i doing wrong? I am a newbie to perl. So please bear
with me...
Thanks in advance.
=Frank.
--
Posted from [65.115.221.98]
via Mailgate.ORG Server - http://www.Mailgate.ORG
------------------------------
Date: Mon, 26 Nov 2001 16:54:54 +0000 (UTC)
From: "Bubba Frank" <bubba_1947@lycos.com>
Subject: Re: Perl and Windows 2000 Service.
Message-Id: <509f18980cf4369fb14c71b95349e8a8.42091@mygate.mailgate.org>
The url should read : http://www.perlguy.com/articles/nt_service.html
=Frank
--
Posted from [65.115.221.98]
via Mailgate.ORG Server - http://www.Mailgate.ORG
------------------------------
Date: Mon, 26 Nov 2001 16:57:47 GMT
From: "Mark" <admin@asarian-host.net>
Subject: Re: Perl and Windows 2000 Service.
Message-Id: <fwuM7.46317$YD.3984283@news2.aus1.giganews.com>
"Bubba Frank" <bubba_1947@lycos.com> wrote in message
news:baf46d5161241ac34ac7d5e2984f751a.42091@mygate.mailgate.org...
> Perl gurus,
>
> But now, I find an instance of perl.exe running in the process list
> instead of seeing my script. What am i doing wrong? I am a newbie
> to perl. So please bear with me...
I am not really a Perl guru, but it appears to me that you should not be
overly surprised by finding an instance of perl running; for it is not your
script that runs perl, but perl which runs your script (perhaps as an
argument to perl?).
- Mark
------------------------------
Date: Mon, 26 Nov 2001 17:02:20 +0000 (UTC)
From: "Bubba Frank" <bubba_1947@lycos.com>
Subject: Re: Perl and Windows 2000 Service.
Message-Id: <91dfb51840991d26d7b7ac92d0c88cdd.42091@mygate.mailgate.org>
Mark,
Interesting. But perl.exe does not show up in the Task mgr list
when I run it from the command prompt. So the dilemma...
=Frank
"Mark" <admin@asarian-host.net> wrote in message
news:fwuM7.46317$YD.3984283@news2.aus1.giganews.com...
> I am not really a Perl guru, but it appears to me that you should not be
> overly surprised by finding an instance of perl running; for it is not your
> script that runs perl, but perl which runs your script (perhaps as an
> argument to perl?).
>
> - Mark
--
Posted from [65.115.221.98]
via Mailgate.ORG Server - http://www.Mailgate.ORG
------------------------------
Date: Mon, 26 Nov 2001 17:46:13 GMT
From: "Mark" <admin@asarian-host.net>
Subject: Re: Perl and Windows 2000 Service.
Message-Id: <FdvM7.58455$8q.9583172@bin2.nnrp.aus1.giganews.com>
"Bubba Frank" <bubba_1947@lycos.com> wrote in message
news:91dfb51840991d26d7b7ac92d0c88cdd.42091@mygate.mailgate.org...
> Mark,
>
> Interesting. But perl.exe does not show up in the Task mgr list
> when I run it from the command prompt. So the dilemma...
Hmm, the doc says that if you run:
INSTSRV NAME_OF_SERVICE C:\WINNT\SRVANY.EXE
You should see NAME_OF_SERVICE in your task manager, which could be the name
of your script, or a descriptive name. I guess, since SRVANY.EXE is said to
run perl.exe as an argument, you may never really see perl.exe in your task
manager.
Did you set the AppParameters of the perl executable too? (it should point
to your script). If so, you will have to provide us with a little more info
on the steps you took run to "daemonize" your script.
- Mark
------------------------------
Date: Mon, 26 Nov 2001 13:55:26 -0500
From: Lou Moran <ellem@techie.net>
Subject: Re: Perl and Windows 2000 Service.
Message-Id: <qv350ucps3ic1tpo4ugle2io40cqh7rigj@4ax.com>
On Mon, 26 Nov 2001 16:50:45 +0000 (UTC), "Bubba Frank"
<bubba_1947@lycos.com> wrote wonderful things about sparkplugs:
>I needed to convert this script into a Service on the server. So, following the
>steps as described in http://www.perlguy.com/article/nt_service.html, which I
>found, everything is set up.
SNIP
Try this:
http://www.roth.net/perl/scripts/scripts.asp?DirMon.pl
--
TMTOWTDI: My way tends to be wrong...
lmoran@wtsg.com
------------------------------
Date: Mon, 26 Nov 2001 15:12:49 GMT
From: jtbell@presby.edu (Jon Bell)
Subject: Posting style (Was: A Perl Bug?)
Message-Id: <GnEy9D.IC5@presby.edu>
In article <9ttekt$bf4$1@Masala.CC.UH.EDU>, Jake Fan <jake@chaogic.com> wrote:
>
> IMHO, the best way to write a post, is not to quote anything at
>all. When you reply to a letter in real life, do you pick the original
>letter apart, make verbatim copy of various sentences and paragraphs, and
>then make comments beneath each one of them? Probably you don't.
Well, with a paper letter, it's usually more convenient to paraphrase as
necessary in your own words as necessary, instead of bringing out the
scissors and paste. Or scanning the original letter, running it through
OCR, and doing a copy-and-paste in your word processor. :-)
With e-mail, I find it easier to quote directly, if there are any points
that need a direct response.
But apart from the technological factors, there's a fundamental difference
between a letter (or private e-mail) and a Usenet posting (or mailing-list
posting): the audience. When you respond to a private letter or e-mail,
you're responding only to the person who wrote the original message, and
who can be expected to remember something about what he/she wrote
originally (unless it was a very long time ago). When you post a response
in a newsgroup, your audience also includes the other people who are
participating in that particular thread, and the people who are invisibly
reading the discussion without posting. All these people are probably
following many different simultaneous discussions in the current newsgroup
alone (let alone all the other newsgroups that they're reading).
Effective quoting and context-setting is especially important for those
other people, to help them keep track of what's going on.
Exactly which styles of quoting and context-setting are most effective, is
of course open to discussion, and the consensus doesn't have to be the
same from one group to another. Different newsgroups have different
patterns of discussion (depth of threads, numbers of participants, numbers
of "lurkers", etc.) and other circumstances. Quoting style doesn't much
matter in some groups, but matters very much in some others (like this
one). When in Rome, and all that...
--
Jon Bell <jtbell@presby.edu> Presbyterian College
Dept. of Physics and Computer Science Clinton, South Carolina USA
------------------------------
Date: 26 Nov 2001 10:54:29 -0800
From: djberg96@hotmail.com (Daniel Berger)
Subject: Re: question for array operation
Message-Id: <6e613a32.0111261054.65608884@posting.google.com>
"nathan" <michealo@ozemail.com.au> wrote in message news:<D80M7.18557$li3.209238@ozemail.com.au>...
> isnt there some kind of pop function?
> Kit <hkyeung9@ie.cuhk.edu.hk> wrote in message
> news:9to2ph$kr9$1@eng-ser1.erg.cuhk.edu.hk...
> > Thx~ But is it apply to hash only?
> > "Laocoon" <Laocoon@eudoramail.com> wrote in message
> > news:Xns916384A54DC18Laocooneudoramailcom@62.153.159.134...
> > > perldoc -f delete
It seems to me the OP wanted to delete based on a string, not an
index, presumably because the index might not be known.
Take a look at 'grep', e.g.
my @array = qw(dog cat bird);
my $val = 'bird';
@array = grep $_ !~ /$val/, @array;
# @array now contains only 'dog' and 'cat'
Regards,
Mr. Sunblade
------------------------------
Date: Mon, 26 Nov 2001 11:05:17 -0800
From: "Godzilla!" <godzilla@stomp.stomp.tokyo>
Subject: Re: question for array operation
Message-Id: <3C02926D.F6591A39@stomp.stomp.tokyo>
Daniel Berger wrote:
> nathan wrote:
> > Kit wrote:
> > > Laocoon wrote:
(snipped - topic is how to remove an array element)
> It seems to me the OP wanted to delete based on a string, not an
> index, presumably because the index might not be known.
> Take a look at 'grep', e.g.
> my @array = qw(dog cat bird);
> my $val = 'bird';
> @array = grep $_ !~ /$val/, @array;
> # @array now contains only 'dog' and 'cat'
Be careful! This code does more than you may know.
#!perl
my @array = qw (dog cat bird catfish);
my $val = 'cat';
@array = grep $_ !~ /$val/, @array;
print "@array";
PRINTED RESULTS:
________________
dog bird
Godzilla!
------------------------------
Date: 26 Nov 2001 15:45:30 GMT
From: "Michael L. Hostbaek" <michDEL_THIS@bsd.fr.eu.org>
Subject: regexp
Message-Id: <slrna04osp.2pnj.michDEL_THIS@freebsdcluster.dk>
Hello,
A little problem.
I have a variable, called $svin = "100,00";
and I would like to replace all commas with dots.. Isn't it like this:
$svin = "100,00";
$svin =~ s/\./,/g
And $svin should be "100.00" however, it does not work. Can anyone
enlighten me ?
thx
--
Regards,
Michael L. Hostbaek
-= Thanks for all the fish.. =-
------------------------------
Date: 26 Nov 2001 17:03:42 +0100
From: Steve Holland <holland@origo.ifa.au.dk>
Subject: Re: regexp
Message-Id: <w47667xecyp.fsf@origo.ifa.au.dk>
"Michael L. Hostbaek" <michDEL_THIS@bsd.fr.eu.org> writes:
> I have a variable, called $svin = "100,00";
> and I would like to replace all commas with dots.. Isn't it like this:
>
> $svin = "100,00";
> $svin =~ s/\./,/g
>
> And $svin should be "100.00" however, it does not work. Can anyone
> enlighten me ?
It would help to see the error message, and even a short example program
that reproduces the error. I suspect that your problem is that you mistyped
the regexp. It should be
$svin =~ s/,/\./g;
to replace commas with periods.
#! /usr/local/bin/perl -w
use strict;
my $svin = "100,00";
print "$svin --> ";
$svin =~ s/,/\./g;
print "$svin\n";
=====================================================================
To find out who and where I am look at:
http://www.nd.edu/~sholland/index.html
Spammers: Please send spam to: abuse@aol.com and abuse@yahoo.com
=====================================================================
------------------------------
Date: Mon, 26 Nov 2001 10:11:13 -0600
From: trammell@haqq.hypersloth.invalid (John J. Trammell)
Subject: Re: regexp
Message-Id: <slrna04qia.uv8.trammell@haqq.el-swifto.com>
On 26 Nov 2001 17:03:42 +0100, Steve Holland <holland@origo.ifa.au.dk> wrote:
> "Michael L. Hostbaek" <michDEL_THIS@bsd.fr.eu.org> writes:
>
> > I have a variable, called $svin = "100,00";
> > and I would like to replace all commas with dots.. Isn't it like this:
> >
> > $svin = "100,00";
> > $svin =~ s/\./,/g
> >
> > And $svin should be "100.00" however, it does not work. Can anyone
> > enlighten me ?
>
> It would help to see the error message, and even a short example program
> that reproduces the error. I suspect that your problem is that you mistyped
> the regexp. It should be
>
> $svin =~ s/,/\./g;
>
> to replace commas with periods.
>
That backslash is not necessary:
$svin =~ s/,/./g;
or even
$svin =~ y/,/./;
------------------------------
Date: Mon, 26 Nov 2001 16:22:00 GMT
From: Bart Lateur <bart.lateur@pandora.be>
Subject: Re: regexp
Message-Id: <6oq40u8p8v5hc0eg2kbuophe8i23qcknm8@4ax.com>
Michael L. Hostbaek wrote:
>I have a variable, called $svin = "100,00";
>and I would like to replace all commas with dots.. Isn't it like this:
>
>$svin = "100,00";
>$svin =~ s/\./,/g
>
>And $svin should be "100.00" however, it does not work. Can anyone
>enlighten me ?
You've got it backwards. What you're *searching* for should be on the
left, what you're replacing it with, on the right.
$svin =~ s/,/./g;
There's also tr///, which serves to replace specific characters with
other specific characters
$svin =~ tr/,/./
The difference may not be apparent here, but in the latter, the LHS is a
character class, and you replace it with the character at the same
position of the RHS, for example
tr/abc/bca/;
will replace *every* "a" with "b", every "b" with "c", and every "c"
with "a", without interfering with the other subsitutions:
$_ = "foo abc ABC bca xyz";
tr/abc/bca/;
print;
-->
foo bca ABC cab xyz
--
Bart.
------------------------------
Date: Mon, 26 Nov 2001 16:22:46 GMT
From: helgi@decode.is (Helgi Briem)
Subject: Re: regexp
Message-Id: <3c026881.3394052229@News.CIS.DFN.DE>
On 26 Nov 2001 15:45:30 GMT, "Michael L. Hostbaek"
<michDEL_THIS@bsd.fr.eu.org> wrote:
>and I would like to replace all commas with dots.. Isn't it like this:
>
>$svin = "100,00";
>$svin =~ s/\./,/g
>
>And $svin should be "100.00" however, it does not work.
>Can anyone enlighten me ?
"Does not work" is uninformative. However,
since your original wish was to replace all commas
with dots, I guess you inverted your regex.
Use $svin =~ s/,/./g;
Regards,
Helgi Briem
------------------------------
Date: Mon, 26 Nov 2001 16:58:43 +0000
From: Paul Boardman <peb@bms.umist.ac.uk>
Subject: Re: regexp
Message-Id: <3C0274C3.A8A27CA2@bms.umist.ac.uk>
"Michael L. Hostbaek" wrote:
> I have a variable, called $svin = "100,00";
> and I would like to replace all commas with dots.. Isn't it like this:
>
> $svin = "100,00";
> $svin =~ s/\./,/g
>
> And $svin should be "100.00" however, it does not work. Can anyone
> enlighten me ?
you have the logic for the substitution the wrong way round.
$svin =~ s/,/./g;
should work fine for you.
HTH
Paul
------------------------------
Date: Mon, 26 Nov 2001 16:37:38 -0000
From: "Martin" <no.th@ank.you>
Subject: Re: returning keys of a tree hashed array?????
Message-Id: <3c0271f4$1_3@mk-nntp-1.news.uk.worldonline.com>
tried that...and have something like this:
foreach my $key1 (sort keys %t) {
foreach my $key2 (sort keys %{$t{$key1}}) {
print FILE "$key1,$key2,$t{$key1}{$key2}\n";
}
}
but get a "can't coerce array in hash" error...
Eric Bohlman <ebohlman@omsdev.com> wrote in message
news:9to4o3$dcj$1@bob.news.rcn.net...
> martin <no.th@nk.you> wrote:
> > the "keys" command will return all keys of a hashed array....but how can
i
> > find the keys of a branched/tree array, at a certain branch??
>
> > so if i had:
>
> > {dog}{brown}{fat}=1
> > {dog}{brown}{thin}=2
> > {dog}{white}{fat}=1
> > {dog}{blue}{thin}=3
> > {cat}....etc
>
> > and i want to return the keys within the {dog}{brown} branch...(the
answer
> > being [fat] and [thin]) how would i do that?
>
> Just remember that a "multi-dimensional" hash is actually a hash of
> references to hashes, so the value of $hash{dog}{brown} is a reference to
> a hash with keys like "fat" and "thin." You just grab that value,
> dereference it, and apply keys() to the result:
>
> my @keylist = keys %{$hash{dog}{brown}};
>
>
>
>
------------------------------
Date: Mon, 26 Nov 2001 09:33:28 -0500
From: Lou Moran <ellem@techie.net>
Subject: RTFM (was Re: A Perl Bug?)
Message-Id: <fsj40uss6bmnmdfm588du8m2phsrv347h1@4ax.com>
On Mon, 26 Nov 2001 06:02:06 GMT, Uri Guttman <uri@stemsystems.com>
wrote wonderful things about sparkplugs:
>>>>>> "XX" == <mcnuttj@dnps-linux1.telecom.missouri.edu> writes:
>
> XX> Uri Guttman <uri@stemsystems.com> wrote:
SNIP
>
>rtfm. this is not a helpdesk. it is a discussion group on perl. you are
>expected to have TRIED to understand your problem and research the
>abundant resources.
SNIP
The problem with RTFM in regards to the Perl perldocs is that they are
written by programmers for programmers. Which makes sense considering
the intended audience. However, not everyone who uses Perl is a
programmer. I mentioned this in y very first post here in 98 (or 99)
and everyone assured me that since I was programming I was in fact a
programmer. But I am not. I am a Sys Admin trying to make my life
easier by scripting and Perl seems to be the best choice for nearly
everything I do. Chances are there's something better out there for
some tasks but I have already invested a great deal of time into Perl
(and money in books) so I use it.
The point being that many times I can't find what I am looking for
simply b/c I don't know what a programmer calls it.
Auto-vivification? I seem to remember some girls in college
complaining loudly about vivification with signs and posters... I have
no idea what it means in the context of programming. (I'm not sure if
I remember what they were complaining about either... but they were
very cute... .)
There were problems I tried to solve with Perl only to find that there
was a module that did what I wanted but I didn't know the name of what
I wanted to do. Programmers called it X, I called it Y. I looked up
Y via perldoc but I would never find it.
So now I am getting into programming at a "deeper" level and find
myself "getting" the perldocs but it is 4 years later! Add to that
that the average "Newbie: How do I..." asker is going to use Perl
once in a while and won't make a huge effort to wade through perlops.
In conclusion:
NEWBIES -- For your One Off Questions, this may not always be the best
place. PerlMonks.org is A LOT more accomodating to your type of
question.
CLPM Folks -- PLease remember hardly any of us asking questions know
what you do... And chances are we don't even know another "real"
programming language.
Thanks.
--
TMTOWTDI: My way tends to be wrong...
lmoran@wtsg.com
------------------------------
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.
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 2209
***************************************