[22050] in Perl-Users-Digest
Perl-Users Digest, Issue: 4272 Volume: 10
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Mon Dec 16 18:10:44 2002
Date: Mon, 16 Dec 2002 15:10:12 -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 Mon, 16 Dec 2002 Volume: 10 Number: 4272
Today's topics:
OK, I give up - merge different fields from 2 files int (qanda)
Re: OK, I give up - merge different fields from 2 files <perl-dvd@ldschat.com>
Re: OK, I give up - merge different fields from 2 files (Tad McClellan)
Re: OT: Re: Get current date / time? (Helgi Briem)
Re: OT: Re: Get current date / time? <flavell@mail.cern.ch>
Re: PErl and CSS <bart.lateur@pandora.be>
Re: PErl and CSS <mgjv@tradingpost.com.au>
Re: Perl IDE suggestion for Win32 environment <bobx@linuxmail.org>
Re: security breach attempt ? web crawling ? <flavell@mail.cern.ch>
Re: security breach attempt ? web crawling ? <bart.lateur@pandora.be>
simple, simple regex Q <penny1482@attbi.com>
Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: 16 Dec 2002 08:22:46 -0800
From: fumail@freeuk.com (qanda)
Subject: OK, I give up - merge different fields from 2 files into 1.
Message-Id: <62b4710f.0212160822.3a5db374@posting.google.com>
Hello again, I've just spent 4 hours checking the newsgroup and docs;
I've seen lots of ideas but not enough to make sense of it all.
I have the following files.
filea:
a1,a2,A,a4,data_2,a6,1a
a1,a2,A,a4,data_1,a6,1a
a1,a2,A,a4,data_3,a6,1a
a1,a2,A,a4,data_3,a6,2a
a1,a2,A,a4,data_5,a6,1a
fileb:
b1,b2,B,b4,data_3,b6,1b
b1,b2,B,b4,data_1,b6,1b
b1,b2,B,b4,data_2,b6,1b
b1,b2,B,b4,data_6,b6,1b
b1,b2,B,b4,data_4,b6,1b
b1,b2,B,b4,data_7,b6,1b
b1,b2,B,b4,data_7,b6,2b
b1,b2,B,b4,data_7,b6,3b
In reality the two files will each contain a different number of
records, between 50 and 500,000 records in each, with 200 to 500
fields per record. Both files will have a fixed number of fields per
record, however the number of fields will differ between files.
I want to end up with something like this:
matched file:
a1,b2,a4,data_2,a6
a1,b2,a4,data_1,a6
a1,b2,a4,data_3,a6
a1,b2,a4,data_5,a6
Matched on the 4th field (for this example, in reality I match on
several fields) consisting of fields 1,3 and 6 from filea, and 2,5
from fileb, don't mind where field4 comes from.
unmatched file:
a1,a2,A,a4,data_3,a6,2a
a1,a2,A,a4,data_5,a6,1a
b1,b2,B,b4,data_7,b6,1b
b1,b2,B,b4,data_7,b6,2b
b1,b2,B,b4,data_7,b6,3b
Any pointers would help greatly, as I said I have been looking at this
but need more help, I should sort the files first (using perl or unix
sort?), how to open and access multiple files at the same time. After
this I need to consider things like, field 9 (for example) in the
matched file is a derived value from field x in filea and field y in
fileb.
I don't expect a working example as an answer (although I tend to
learn more that way by seeing how it should be done perlisticly - I
like that word!) I am more than happy to look into this but just need
more pointers - I'm only just getting a feel for how the docs can be
used.
Thanks.
------------------------------
Date: Mon, 16 Dec 2002 09:42:30 -0700
From: "David" <perl-dvd@ldschat.com>
Subject: Re: OK, I give up - merge different fields from 2 files into 1.
Message-Id: <JgnL9.16676$K5.1851@fe01>
"qanda" <fumail@freeuk.com> wrote in message
news:62b4710f.0212160822.3a5db374@posting.google.com...
> Hello again, I've just spent 4 hours checking the newsgroup and docs;
> I've seen lots of ideas but not enough to make sense of it all.
>
> I have the following files.
> filea:
> a1,a2,A,a4,data_2,a6,1a
> a1,a2,A,a4,data_1,a6,1a
> a1,a2,A,a4,data_3,a6,1a
> a1,a2,A,a4,data_3,a6,2a
> a1,a2,A,a4,data_5,a6,1a
>
> fileb:
> b1,b2,B,b4,data_3,b6,1b
> b1,b2,B,b4,data_1,b6,1b
> b1,b2,B,b4,data_2,b6,1b
> b1,b2,B,b4,data_6,b6,1b
> b1,b2,B,b4,data_4,b6,1b
> b1,b2,B,b4,data_7,b6,1b
> b1,b2,B,b4,data_7,b6,2b
> b1,b2,B,b4,data_7,b6,3b
>
> In reality the two files will each contain a different number of
> records, between 50 and 500,000 records in each, with 200 to 500
> fields per record. Both files will have a fixed number of fields per
> record, however the number of fields will differ between files.
>
> I want to end up with something like this:
> matched file:
> a1,b2,a4,data_2,a6
> a1,b2,a4,data_1,a6
> a1,b2,a4,data_3,a6
> a1,b2,a4,data_5,a6
>
> Matched on the 4th field (for this example, in reality I match on
> several fields) consisting of fields 1,3 and 6 from filea, and 2,5
> from fileb, don't mind where field4 comes from.
>
> unmatched file:
> a1,a2,A,a4,data_3,a6,2a
> a1,a2,A,a4,data_5,a6,1a
> b1,b2,B,b4,data_7,b6,1b
> b1,b2,B,b4,data_7,b6,2b
> b1,b2,B,b4,data_7,b6,3b
>
> Any pointers would help greatly, as I said I have been looking at this
> but need more help, I should sort the files first (using perl or unix
> sort?), how to open and access multiple files at the same time. After
You can open multiple files at the same time by using different file
handles:
open(FILEA, "<$path/$filea");
open(FILEB, "<$path/$fileb");
# do your stuff in here.
close(FILEB);
close(FILEA);
> this I need to consider things like, field 9 (for example) in the
> matched file is a derived value from field x in filea and field y in
> fileb.
foreach my $line (<FILEA>){
my @line_vals = split(/\,/, $line);
# at this point $line_vals[0] is the 1st of the comma separated
values, and $line_vals[8] would be the 9th.
}
Note: I am foreaching through each line rather than assigning the whole
file to an array. This is to save you execution time and memory (if
your files are large like you say).
Good Luck,
David
------------------------------
Date: Mon, 16 Dec 2002 16:56:11 -0600
From: tadmc@augustmail.com (Tad McClellan)
Subject: Re: OK, I give up - merge different fields from 2 files into 1.
Message-Id: <slrnavsmgb.fst.tadmc@magna.augustmail.com>
qanda <fumail@freeuk.com> wrote:
> I've seen lots of ideas but not enough to make sense of it all.
I see lots of specification below, but not enough to make sense of it all.
> I have the following files.
> filea:
> a1,a2,A,a4,data_2,a6,1a
> a1,a2,A,a4,data_1,a6,1a
> a1,a2,A,a4,data_3,a6,1a
> a1,a2,A,a4,data_3,a6,2a
> a1,a2,A,a4,data_5,a6,1a
>
> fileb:
> b1,b2,B,b4,data_3,b6,1b
> b1,b2,B,b4,data_1,b6,1b
> b1,b2,B,b4,data_2,b6,1b
> b1,b2,B,b4,data_6,b6,1b
> b1,b2,B,b4,data_4,b6,1b
> b1,b2,B,b4,data_7,b6,1b
> b1,b2,B,b4,data_7,b6,2b
> b1,b2,B,b4,data_7,b6,3b
> I want to end up with something like this:
> matched file:
> a1,b2,a4,data_2,a6
> a1,b2,a4,data_1,a6
> a1,b2,a4,data_3,a6
> a1,b2,a4,data_5,a6
How did data_5 end up matching?
> Matched on the 4th field
Matched on the _5th_ field in filea/fileb, but put into the
4th field in matched?
> (for this example, in reality I match on
> several fields) consisting of fields 1,3
field 3 in filea has "A"s in it but they are not in your "matched"
data, you must have meant field 4 there...
> and 6 from filea, and 2,5
> from fileb, don't mind where field4 comes from.
3 fields from filea, 2 fields from fileb, plus the "matched" field.
That adds up to 6 fields, your "matched" data has 5 fields...
> unmatched file:
> a1,a2,A,a4,data_3,a6,2a
> a1,a2,A,a4,data_5,a6,1a
data_5 both matched and didn't match?
How come data_6 didn't make it into either list?
> b1,b2,B,b4,data_7,b6,1b
> b1,b2,B,b4,data_7,b6,2b
> b1,b2,B,b4,data_7,b6,3b
> I don't expect a working example as an answer
Surprise!
But you'll have to adjust it once you repair your messed up spec...
Merry Christmas :-)
----------------------------------------
#!/usr/bin/perl
use strict;
use warnings;
open UNMATCH, '>unmatched.csv' or die "could not open 'unmatched.csv' $!";
open MATCH, '>matched.csv' or die "could not open 'matched.csv' $!";
my %a;
open FILEA, 'filea' or die "could not open 'filea' $!";
while ( <FILEA> ) {
my @f = split /,/;
my $key = $f[4];
if ( exists $a{$key} )
{ print UNMATCH } # only match the first occurence
else
{ $a{$key} = \@f }
}
close FILEA;
open FILEB, 'fileb' or die "could not open 'fileb' $!";
while ( <FILEB> ) {
my @b = split /,/;
my $key = $b[4];
if ( exists $a{$key} ) {
my $m = join ',', $a{$key}[0],
$b[1],
$a{$key}[3],
$key,
$a{$key}[5];
print MATCH "$m\n";
delete $a{$key};
}
else
{ print UNMATCH }
}
close FILEB;
print UNMATCH join ',', @{$a{$_}} for keys %a;
close MATCH;
close UNMATCH;
----------------------------------------
$ head *.csv
==> matched.csv <==
a1,b2,a4,data_3,a6
a1,b2,a4,data_1,a6
a1,b2,a4,data_2,a6
==> unmatched.csv <==
a1,a2,A,a4,data_3,a6,2a
b1,b2,B,b4,data_6,b6,1b
b1,b2,B,b4,data_4,b6,1b
b1,b2,B,b4,data_7,b6,1b
b1,b2,B,b4,data_7,b6,2b
b1,b2,B,b4,data_7,b6,3b
a1,a2,A,a4,data_5,a6,1a
--
Tad McClellan SGML consulting
tadmc@augustmail.com Perl programming
Fort Worth, Texas
------------------------------
Date: Mon, 16 Dec 2002 16:22:20 GMT
From: helgi@decode.is (Helgi Briem)
Subject: Re: OT: Re: Get current date / time?
Message-Id: <3dfdfc0e.1022817073@news.cis.dfn.de>
On 16 Dec 2002 16:03:41 +0100, mru@users.sourceforge.net
(=?iso-8859-1?q?M=E5ns_Rullg=E5rd?=) wrote:
>> Americans made a mistake when they defined a billion,
>> but there's a lot of them, and they're influential, so
>> eventually the rest of the world had to copy their
>> dumb way and not the other way around.
>
>IMHO, the American number system is more logical.
No, the US system is not logical!
European system:
Bi = 2. Tri = 3 Quadra = 4 Simple latin prefixes.
Billion = million to the power 2 = 10^12
Trillion = million to the power 3 = 10^18
Quadrillion = million to the power 4 = 10^24
Pentillion = 10^30
And so forth. In Europe we also have a supplementary
system to account for the numbers in between, which
unfortunately is not as well known as it should be.
As far as I know, we Icelanders are the only ones
who use it routinely.
Milliard = 10^9
Billiarrd = 10^15
Trilliard = 10^21
American system:
Billion = 10^9 Huh?
You try and explain it, I certainly can't.
>It also has the benefit of avoiding confusion with a fun
>game involving little balls on a green table.
I don't know which green table ball game involves
billions and trillions.
--
Regards, Helgi Briem
helgi AT decode DOT is
A: Top posting
Q: What is the most irritating thing on Usenet?
- "Gordon" on apihna
------------------------------
Date: Mon, 16 Dec 2002 22:44:51 +0100
From: "Alan J. Flavell" <flavell@mail.cern.ch>
Subject: Re: OT: Re: Get current date / time?
Message-Id: <Pine.LNX.4.40.0212162231500.16967-100000@lxplus073.cern.ch>
On Dec 16, Helgi Briem inscribed on the eternal scroll:
> And so forth. In Europe we also have a supplementary
> system to account for the numbers in between, which
> unfortunately is not as well known as it should be.
>
> As far as I know, we Icelanders are the only ones
> who use it routinely.
> Milliard = 10^9
Huh?
Still much used in Germany, I assure you. Google finds 759,000
references to "Milliarden" (the German plural) - on casual inspection
almost all those hits are German.
"Milliards" (the French plural, among other languages) 663,000 hits.
> Billiarrd = 10^15
(Quite what specific use Icelanders would have for 10^15 and upwards
shall remain a mystery ;-)
Amongst colleagues, we tend to shift to ISO prefixes (Giga- Tera-
Peta- ...) when the numbers get too big.
> I don't know which green table ball game involves
> billions and trillions.
I know which one invoves billiards, though.
------------------------------
Date: Mon, 16 Dec 2002 16:19:36 GMT
From: Bart Lateur <bart.lateur@pandora.be>
Subject: Re: PErl and CSS
Message-Id: <43vrvuco73meeln532u9erqgjojjb2ie04@4ax.com>
ToxicFungi wrote:
>How can I modify the perl script to format any html code it spits out
>to use CSS?
Create a .css page on your website, and make perl include a
<link rel="stylesheet" href="stylesheet.css" type="text/css">
tag in the HTML it spits out, somewhere in the head section.
--
Bart.
------------------------------
Date: Mon, 16 Dec 2002 21:57:17 GMT
From: Martien Verbruggen <mgjv@tradingpost.com.au>
Subject: Re: PErl and CSS
Message-Id: <slrnavsj5j.865.mgjv@verbruggen.comdyn.com.au>
On 16 Dec 2002 07:40:18 -0800,
ToxicFungi <toxicfungi@yahoo.com> wrote:
> Hi group,
>
> I am trying to setup a message board for a website. This uses a perl
> script. It is basically Matt's WWWBoard.
Have a look at http://nms-cgi.sourceforge.net/ for a much better
alternative (Matt says so himself).
> How can I modify the perl script to format any html code it spits out
> to use CSS?
Include the stylesheet somewhere at the top of the HTML.
What's your Perl question?
Martien
--
|
Martien Verbruggen | For heaven's sake, don't TRY to be cynical.
Trading Post Australia | It's perfectly easy to be cynical.
|
------------------------------
Date: Mon, 16 Dec 2002 23:04:41 GMT
From: "Bob X" <bobx@linuxmail.org>
Subject: Re: Perl IDE suggestion for Win32 environment
Message-Id: <d_sL9.3255$uV4.2287557@news2.news.adelphia.net>
"Rod" <palladium@spinn.net> wrote in message
news:uvioa73m21ttf2@corp.supernews.com...
> "Saul Spatz" <sspatz@kcnet.com> wrote in message
> news:3DF924D4.2030200@kcnet.com...
> > http://open-perl-ide.sourceforge.net/
> >
> > Kasp wrote:
> > > Hi,
> > > I would like your suggestion for a good IDE for developing and
debugging
> > > Perl for windows environment.
> > > I heard about Komodo from ActiveState, but they have a 21 day trial
> version.
> > > I am a student and can not spend $s for software. So a freeware would
be
> > > great.
> > > Thanks.
>
> My personal free favorite is SciTE editor downloadable from
> http://www.scintilla.org/wscite149.zip
> at only (390K) download, not to bad for a windblows editor.
> It supports 15 Languages with code highlighting output in the same window,
> and full customization of colors, languages, etc.
> and best of all..FREE.
> (I do not work with the guys that write this) I am just an avid fan of the
> editor.
>
> Rodney
>
I concur...I have modified the perl.properties file a little to allow
profiling and syntax checking as well. A nice little editor.
------------------------------
Date: Mon, 16 Dec 2002 17:00:17 +0100
From: "Alan J. Flavell" <flavell@mail.cern.ch>
Subject: Re: security breach attempt ? web crawling ?
Message-Id: <Pine.LNX.4.40.0212161643410.16967-100000@lxplus073.cern.ch>
On Dec 16, Eric Osman inscribed on the eternal scroll:
> (the following message I originally sent to
> comp.infosystems.www.authoring.cgi but that newsgroup
> doesn't show ANY messages beyond last Thurs.
Your question doesn't seem to be appropriate to either group, though.
> Any of you know what gives ???)
It's a long story. c.i.w.a.cgi was made "auto moderated", years ago;
it means it needs an auto-moderator bot to be running. The general
feeling, a while back, was that the guy who had been running the bot
wasn't taking enough care of it, and someone else stepped in to offer
assistance. However, even this isn't perfect, and sometimes a backlog
develops. http://www.thinkspot.net/ciwac/howtopost.html
But your question would be more appropriate for a network security
newsgroup. comp.security.firewalls or .misc, I guess.
> Are there other useful commands I can use to get more info ?
Yes, and a network security FAQ would help you find them. But they're
a fact of life if you're connected to the public internet. Unless
you're going to take the topic up seriously, you'd be better just
disregarding them - you've done the right think and blocked them,
after all - as you could do more harm than good if you reacted to them
on the basis of casual knowledge.
> I find it curious that ANYONE is calling.
They scan address-ranges - they don't concern themselves with who you
are, specifically.
> What are the most likely reasons ?
Either script kiddies, or viruses.
[f'ups set, please adjust to a suitable usenet group to taste.]
--
Jede Statistik ist gefälscht - daher auch der Grundsatz, nur
derjenigen Statistik zu glauben, die man selbst gefälscht hat.
- Lars Trebing
------------------------------
Date: Mon, 16 Dec 2002 16:14:37 GMT
From: Bart Lateur <bart.lateur@pandora.be>
Subject: Re: security breach attempt ? web crawling ?
Message-Id: <gkurvu43j16nfe3frt9524guaslkl0i6pu@4ax.com>
Eric Osman wrote:
>What's interesting is that several times a day
>my tiny firewall reports that such-and-such an
>ip address is trying to open port 80 on my
>web server .
Could be a virus, like Code Red. On *their* system, not yours.
<http://www.cert.org/advisories/CA-2001-19.html>
--
Bart.
------------------------------
Date: Mon, 16 Dec 2002 22:53:26 GMT
From: "Dick Penny" <penny1482@attbi.com>
Subject: simple, simple regex Q
Message-Id: <GPsL9.251355$GR5.85568@rwcrnsc51.ops.asp.att.net>
I thought I had conquered simple regexs. I guess I'm simple cause I can't
figure out why the following snippet matches on data line 1.
-------- regex
/\d+\D*(\d+)/
---------data line 1
>>SPH nb 83
---------data line 2
>>SPH:: 113400 115490 113200 115200 33709 23919
---------end snippet
This matches on data line 1 and returns the digit 3 which I do NOT expect. I
expect no match. It also matches data line 2 and returns 115490 which I do
expect.
Thank you.
--
Dick Penny
------------------------------
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 4272
***************************************