[11133] in Perl-Users-Digest
Perl-Users Digest, Issue: 4733 Volume: 8
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Sat Jan 23 19:07:05 1999
Date: Sat, 23 Jan 99 16:00:17 -0800
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)
Perl-Users Digest Sat, 23 Jan 1999 Volume: 8 Number: 4733
Today's topics:
2nd Repost?: Win32 globbing always checks floppy (Martin Packer)
@INC and "use lib" <joe@laffeycomputer.com>
Re: Data Files without using text files. <joe@laffeycomputer.com>
Easy way to grep all combinations of array subscripts? (Clay Shirky)
Re: Easy way to grep all combinations of array subscrip (brian d foy)
Re: easy way to query other boxes <carvdawg@patriot.net>
encryption question (quickie) <pbuckley@tiac.net>
Re: Getting the last number in an IP addr with a regex. <allan@due.net>
Re: Getting the last number in an IP addr with a regex. <kims@tip.net.au>
Re: Getting the last number in an IP addr with a regex. <mds-resource@mediaone.net>
Re: language support (M.J.T. Guy)
Missing lines. <om@republica.freeserve.co.uk>
Re: Missing lines. <joe@laffeycomputer.com>
Re: Missing lines. <abey@hill.ucr.edu>
Re: need Fcntl.pm and SDBM_File. Where to get it? (M.J.T. Guy)
Re: perl bug with substitution via subroutine? <rick.delaney@home.com>
Re: Perl Criticism <staffan@ngb.se>
Re: Perl problem :(Offline mode... <andrewf@beausys.demon.co.uk>
Re: Perl problem :(Offline mode... (brian d foy)
PostgreSQL - query attribute types? (Richard Kilgore)
Regular expression to parse RealAudio logs? <mrgigabyte@hotmail.com>
Re: Regular expression to parse RealAudio logs? <rick.delaney@home.com>
Where can I find text parsing samples (Ron)
Re: Where can I find text parsing samples (Alastair)
Re: Where can I find text parsing samples (Ron)
Special: Digest Administrivia (Last modified: 12 Dec 98 (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: Sat, 23 Jan 1999 16:29:34 -0500
From: mpacker@concentric.net (Martin Packer)
Subject: 2nd Repost?: Win32 globbing always checks floppy
Message-Id: <36ae3ece.2973413@news.mindspring.com>
My apologizes if this post is showing up thrice. I twice tried
cross-posting to c.l.p.misc and c.l.p.moderate and the post does not seem
to take. So now I am posting to both groups individually.
I am running perl, version 5.004_02 on a Window 95 machine. I am running
the following script to calculate the bytes used in each directory (on the
c: drive for now):
sizedir("c:/*");
sub sizedir {
my($startdir) = @_;
my($dirsize) = 0;
# ****** glob is here
foreach $file (glob($startdir)) { # floppy accessed here
# ****** glob is here
if (-f $file) {
$dirsize += -s $file;
}
else {
sizedir($file."/*");
}
} # end of loop through this directory!
# we would actually look at $dirsize's size here and act on it
print "directory $startdir: $dirsize bytes\n";
}
=========== end of script
Each time the glob is called, the floppy drive is accessed for a second or
two, even though the a: drive isn't the one being looked at by the glob. Is
there a way to suppress this behavior? Am I going at it all wrong? If I
need to wait out a floppy check on each glob, this won't fly!
TIA,
Marty Packer
Elbow Technologies
"Reason with them, it drives them crazy"
------------------------------
Date: Sat, 23 Jan 1999 16:00:16 -0600
From: Joe Laffey <joe@laffeycomputer.com>
Subject: @INC and "use lib"
Message-Id: <Pine.LNX.4.05.9901231556420.11598-100000@tripe.laffeycomputer.com>
Is it normal to have to add a "use lib" for EVERY subdirectory that
contains a *.pm file? When I simply use lib for the main parent lib
directory (my own lib dir) perl cannot find my modules because they are in
subdirs like "5.00502_02" and "sun4-solaris", etc.
Thanks,
Joe Laffey
LAFFEY Computer Imaging
St. Louis, MO
http://www.laffeycomputer.com/
------------------------------
------------------------------
Date: Sat, 23 Jan 1999 16:06:39 -0600
From: Joe Laffey <joe@laffeycomputer.com>
Subject: Re: Data Files without using text files.
Message-Id: <Pine.LNX.4.05.9901231602210.11618-100000@tripe.laffeycomputer.com>
On Fri, 22 Jan 1999, Rob Hill wrote:
> I am attempting to write a perl program that manipulates a
> fair amount of data. Right now, all of my data is stored in ascii text
> files that I read in one line at a time, but I am wanting to use
> something a little for versatile. dbm will not work for me because I
> am looking for more that key/value pairs.
>
> I come from a C programming background and in the past I would merely
> make a struct.
>
> For those C programmers:
>
> struct data1 {
> char val1[20];
> char val2[20];
> char val3[100];
> long val4;
> } mydata1;
>
> When I would save this to a file I would make the length sizeof(struct
> data1) and if I needed to pull the 52nd record out of the file, I did
> a seek for sizeof(struct data1) * 52 and read sizeof(struct data1)
> bytes into my struct var (mydata1)...
>
> Can anyone give any insight into how I would do this with Perl?
You might check out MLDBM from www.cpan.org. This module will let you
create the equivalent of a C struct and write it out to a Db file. You
essentially get to make a struct with anydata you want (including members
that are arrays or hashes). You then add this "struct" to a hash as the
value protion. You can key off of whtever you want (in your example above
you would key off the record number "52"). MLDBM takes care of writing and
reading all of this data for you. It is very fast (esp if you use
Storable.pm and DB_File--both available from cpan).
For more info see O'Relly's "Perl Cookbook" p.504. If you don't have the
"Perl Cookbook" get it! This thing is the greatest reference I have ever
seen...
Joe Laffey
LAFFEY Computer Imaging
St. Louis, MO
http://www.laffeycomputer.com/
------------------------------
------------------------------
Date: 23 Jan 1999 17:48:46 -0500
From: clays@panix.com (Clay Shirky)
Subject: Easy way to grep all combinations of array subscripts?
Message-Id: <78djke$fv6$1@panix7.panix.com>
I am trying to figure out what percentage of 4 letter english words
potential mispellings are _also_ valid words. I have a dictionary list
of these words, and I
foreach $word (@four) {
@word = split (//, $word);
...
}
what I would like to do where those 3 little dots are is like
if (grep /$word[0]$word[2]$word[3]$word[1]/, @four) {
print "Type 1 $word - $word[0]$word[2]$word[3]$word[1]";
}
if (grep /$word[0]$word[3]$word[1]$word[2]/, @four) {
print "Type 2 $word - $word[0]$word[3]$word[1]$word[2]";
}
for all combinations of letters (there are 4 factorial -1 possible
misspellings, i.e. 23 possible mispellings.)
Is there an easier way to do this than 23 'if' tests?
TIA
-clay
------------------------------
Date: Sat, 23 Jan 1999 18:43:32 -0500
From: comdog@computerdog.com (brian d foy)
Subject: Re: Easy way to grep all combinations of array subscripts?
Message-Id: <comdog-ya02408000R2301991843320001@news.panix.com>
In article <78djke$fv6$1@panix7.panix.com>, clays@panix.com (Clay Shirky) posted:
> I am trying to figure out what percentage of 4 letter english words
> potential mispellings are _also_ valid words. I have a dictionary list
> of these words, and I
>
> foreach $word (@four) {
>
> @word = split (//, $word);
> ...
> }
>
> what I would like to do where those 3 little dots are is like
>
> if (grep /$word[0]$word[2]$word[3]$word[1]/, @four) {
>
> print "Type 1 $word - $word[0]$word[2]$word[3]$word[1]";
> }
> for all combinations of letters (there are 4 factorial -1 possible
> misspellings, i.e. 23 possible mispellings.)
>
> Is there an easier way to do this than 23 'if' tests?
wouldn't it be much easier to put these things into a hash and then
check for existence of the key? (perhaps a DBM file for a data set
this large.)
i recently implemented a system like this to catch misspellings in
URLs for one of our products. i store (in a relational db) the
correct spelling as the key, along with various representations
of the key (e.g. soundex, and others). one of these representations
is designed to catch juxtaposition errors. i store the letters of the
key in alphabetic order:
perl elpr
java aajv
...
so i can quickly find all the things that have the same letters.
you could also store this internal representation as the key
of a hash, and then have as the value a delimited list of
all the properly spelled words with those letters. if you
don't care what the words are, you could simply increment
the value so after scanning the entire list once, you have
the count of words that contain those letters. should
should be significantly faster than 23 greps with a regular
expression!
here's some pseudocode:
foreach $word
get a list of characters
sort that list then join it in $temp
$count{$temp}++
$words{$temp} .= "$word\0"
now you just have to take these numbers and do the math :)
[as a side note, your original approach can be improved in
several ways. first, if you start off with a sorted list,
you can save a lot of time traversing the list. a hash
would even be better. second, a regular expression doesn't
have any advantage over a string comparison operator in this
case. two books that go into this sort of stuff in great
detail are Programming Pearls by Jon Bentley (notice a
similarity to another title? :) and, of course, Knuth's
Sorting and Searching]
--
brian d foy
CGI Meta FAQ <URL:http://www.smithrenaud.com/public/CGI_MetaFAQ.html>
------------------------------
Date: Sat, 23 Jan 1999 17:37:57 +0000
From: Marquis de Carvdawg <carvdawg@patriot.net>
Subject: Re: easy way to query other boxes
Message-Id: <36AA08F5.14FFB76F@patriot.net>
> So i have 20 machines on a subnet. I want to know what each machine (NT,
> UNIX, ROUTER...) is running. any ideas?
I have a couple actually...
1. SNMP...the Net::SNMP module is great!
2. Write an agent for each system...bind it to a high port. Load the
agent on each system. If system responds to a ping, but doesn't
have an agent...router. Otherwise, have the agent respond with the
platform (I know, this is poor-man's SNMP).
------------------------------
Date: Sat, 23 Jan 1999 16:13:00 -0500
From: Phil Buckley <pbuckley@tiac.net>
Subject: encryption question (quickie)
Message-Id: <36AA3B5C.B2894202@tiac.net>
My ISP lets me password protect directories and add/delete users through
a simple CI form. Which is fine when you're only adding a few users. My
problem is I have about 3000 users to add! <big sigh>
I was hacking a little at their script, and not having much success, so
here I am, throwing myself on the mercy of this newsgroup.
this is how the current script (well the main part of it anyway) is
encrypting the passwords:
sub encrypt_password {
($unencrypted_password) = @_;
(@salt_chars) = ('a'..'z','A'..'Z','0'..'9','.','/') ;
($salt) = $salt_chars[rand(63)].$salt_chars[rand(63)];
return crypt($unencrypted_password, $salt);
}
I have text files in a form like this to encrypt: (first is user id,
second is unencrypted password)
6930164,6690966
4652639,4972881
9583870,5473254
8325551,5144819
4746034,8202826
1738640,4350132
I know this is about a six line hack, but for some reason, I'm brain
dead. My ultimate goal is to read the text file, encrypt the passwords
(the user id's actually will remain UNencrypted), and spit out the user
id and the new encrypted password into the .htpasswd file as
user_id:encrypted_password
Any help is greatly appreciated,
Phil Buckley
"Asking the world to be fair because you are a good person is like
asking a bull not to charge because you are a vegetarian."
------------------------------
Date: Sat, 23 Jan 1999 16:06:41 -0500
From: "Allan M. Due" <allan@due.net>
Subject: Re: Getting the last number in an IP addr with a regex.
Message-Id: <mSqq2.182$WR1.2821@nntp1.nac.net>
Kim Saunders wrote in message <917082514.915608@draal.apex.net.au>...
:Hiya all,
:could someone please help me with a regex to give me the last number in an
:IP address with a regex???
:That is, I have an IP w.x.y.z where w,x,y and z are numbers between 1 and
:255 or so (the actual details of an IP are not important at the moment!)
:I just want a regex to give me z, something that will work regardless of the
:number of digits of each section.
:I really need this ASAP, so please email me if you can, and I will try and
:do it myself in the meantime.
Well I still don't know what the actual permissable IP range is so I have two
assumptions.
1) you can't have multiple 0s between dots by themseleves. Thus
112.000.000.12 is not permissable. Then we might piggyback on Mikes near miss
and use
$octet = '(?:[1-9]?\d|1\d\d|2[01234]\d|25[012345])';
2) sequences like 112.000.00.2 are permissable and then we could use:
$octet = '(?:[01]?\d\d?|2[01234]\d|25[012345])';
with
#!/usr/local/bin/perl -w
use strict;
my @IPs = qw(000.000.000.12 0.0.123.221 0199.0123.0199.0178 1.2.3.4
123.456.789.225 1.23.456.78 1.23.213.87 1.2.3 1.2 1 1234.23.56.1234
1.2.3.999);
push @IPs,' 111.22.33.222 ';
my $octet = '(?:[1-9]?\d|1\d\d|2[01234]\d|25[012345])';
foreach (@IPs) {
print "The last octet is $1\n" if
/(?:^|\D)$octet\.$octet\.$octet\.($octet)(?:$|\D)/;
}
AmD
------------------------------
Date: Sun, 24 Jan 1999 09:01:18 +1100
From: "Kim Saunders" <kims@tip.net.au>
Subject: Re: Getting the last number in an IP addr with a regex.
Message-Id: <917128885.836942@draal.apex.net.au>
>Kim> That is, I have an IP w.x.y.z where w,x,y and z
>Kim> are numbers between 1 and 255 or so (the actual
>
>What's wrong with 0?
Whatever, not important..... Actually, it is as I am testing on a subnet
with a 0 in it...
KimS
------------------------------
Date: Sat, 23 Jan 1999 17:40:16 -0600
From: "Michael D. Schleif" <mds-resource@mediaone.net>
Subject: Re: Getting the last number in an IP addr with a regex.
Message-Id: <36AA5DE0.A648C531@mediaone.net>
What about this?
my @ip = qw(123.45.6.7 1.2.3.4 123.456.789.225 1.23.456.78 1.23.213.87
1.2.3.1.2 1 1234.23.56.1234 1.2.3.999);
for (@ip) {
print /([^.]*)$/, "\n";
}
Obviously, this has weaknesses. It depends on whether or not the input
IP address is known to be proper, because this method does *no* error
checking.
Kim Saunders wrote:
>
> could someone please help me with a regex to give me the last number in an
> IP address with a regex???
>
> That is, I have an IP w.x.y.z where w,x,y and z are numbers between 1 and
> 255 or so (the actual details of an IP are not important at the moment!)
>
> I just want a regex to give me z, something that will work regardless of the
> number of digits of each section.
For those who will fault me for the flaws in this method, I've keyed on
the requirements as specified in the original poster's sentence above ;)
--
Best Regards,
mds
mds resource
888.250.3987
"Dare to fix things before they break . . . "
"Our capacity for understanding is inversely proportional to how much we
think we know. The more I know, the more I know I don't know . . . "
------------------------------
Date: 23 Jan 1999 23:56:18 GMT
From: mjtg@cus.cam.ac.uk (M.J.T. Guy)
Subject: Re: language support
Message-Id: <78dnj2$6cc$1@pegasus.csx.cam.ac.uk>
In article <36AA21D9.F89D6E7C@usa.net>, n8twatch <n8twatch@usa.net> wrote:
>i'm a newbee on perl.
>
>is there any language support for example for german 'cause i have some
>problems with the characters like v V | \ d D and some problems with the
>french characters like i h ` g.
>
>the problems are for example:
>by capitalising (uc) or uncapitalising (lc) or matching with option i.
perldoc perllocale
Mike Guy
------------------------------
Date: Sat, 23 Jan 1999 21:23:23 -0000
From: "OM" <om@republica.freeserve.co.uk>
Subject: Missing lines.
Message-Id: <78df52$5v2$1@news6.svr.pol.co.uk>
I want to read in a file, but want to discard the first few lines.
I thought the following code would do it.
while(<DATA>)
{
for($t = 0; $t < $numberoflinestomiss; $t++) {next;}
............ now work on the part I want ............
}
Can someone tell me what I'm doing wrong?
Thanks.
------------------------------
Date: Sat, 23 Jan 1999 15:56:21 -0600
From: Joe Laffey <joe@laffeycomputer.com>
Subject: Re: Missing lines.
Message-Id: <Pine.LNX.4.05.9901231550530.11598-100000@tripe.laffeycomputer.com>
On Sat, 23 Jan 1999, OM wrote:
> I want to read in a file, but want to discard the first few lines.
>
> I thought the following code would do it.
>
> while(<DATA>)
> {
> for($t = 0; $t < $numberoflinestomiss; $t++) {next;}
> ............ now work on the part I want ............
> }
>
> Can someone tell me what I'm doing wrong?
>
Your loop is being executed for EACH line in the file. The
while(<FILEHANDLE>) construct reads one line at a time into $_.
There are a number of ways to do what you want... One of the easiest ways,
and faster (if your file has a lot of lines) is to skip the lines outside
of your main loop. This avoids the if test each time through the loop.
$lines_to_skip = 7;
for( my $i=0; $i < $lines_to_skip; $i ++ )
{
<FILEHANDLE>;
}
while(<FILEHANDLE>)
{
#Do your stuff with other lines here.
}
You could also use something like this:
while(<FILEHANDLE>)
{
next if( $. < $lines_to_skip );
#Do your stuff with other lines here.
}
The variable $. contains the current line number of the filehandle you are
reading.
Joe Laffey
LAFFEY Computer Imaging
St. Louis, MO
http://www.laffeycomputer.com/
------------------------------
------------------------------
Date: Sat, 23 Jan 1999 13:56:23 -0800
From: Abraham Grief <abey@hill.ucr.edu>
To: OM <om@republica.freeserve.co.uk>
Subject: Re: Missing lines.
Message-Id: <Pine.LNX.4.05.9901231352510.17239-100000@hill.ucr.edu>
What you're doing wrong is nesting loops for no reason. Try putting
that for loop before the while loop and using the for loop to read in
the lines you don't need.
> for($t = 0; $t < $numberoflinestomiss; $t++) {<DATA>;}
> while(<DATA>)
> {
> ............ now work on the part I want ............
> }
On Sat, 23 Jan 1999, OM wrote:
> I want to read in a file, but want to discard the first few lines.
>
> I thought the following code would do it.
>
> while(<DATA>)
> {
> for($t = 0; $t < $numberoflinestomiss; $t++) {next;}
> ............ now work on the part I want ............
> }
>
> Can someone tell me what I'm doing wrong?
>
> Thanks.
>
>
>
>
>
------------------------------
Date: 23 Jan 1999 23:54:37 GMT
From: mjtg@cus.cam.ac.uk (M.J.T. Guy)
Subject: Re: need Fcntl.pm and SDBM_File. Where to get it?
Message-Id: <78dnft$69v$1@pegasus.csx.cam.ac.uk>
Karl <karl@nospamaddYproline.at> wrote:
>I got a script with an application witch needs:
>
>use Fvntl qw(:flock);
>use SDBM_File;
>
>or alternativly Fcntl.
>
>Tried on CPAN, but only found directories and no moduls inside. any ideas
>are greatly appreziated.
Both Fcntl.pm and SDBM_File.pm are part of the standard distribution.
I deduce that your Perl is either out-of-date or incorrectly installed.
But since you provide no version information, I'm only guessing.
Mike Guy
------------------------------
Date: Sat, 23 Jan 1999 21:30:22 GMT
From: Rick Delaney <rick.delaney@home.com>
Subject: Re: perl bug with substitution via subroutine?
Message-Id: <36AA413F.BAED5C37@home.com>
[posted & mailed]
Michael Hvrmann wrote:
>
> When I call the function from outside a substituion (&handler("bar");
> instead of s/foo(bar)/&handler($1)/e;) $_[0] everything works fine.
When you call a subroutine the elements of @_ are aliases for the passed
scalars. So when you call handler($1), $_[0] is an alias for $1 and any
changes to $1 affect $_[0].
> $_ = "foobar";
> s/foo(bar)/&handler($1)/e;
$1 = 'bar';
> sub handler {
> my $bar = $_[0];
$_[0] = $1 = 'bar';
>
> print "here's a bar: $_[0]\n";
prints "here's a bar: bar\n"
> $bar =~ s/bar/foo/g;
$1 = undef
> print "wish there was a bar: $_[0]\n";
$_[0] = $1 = undef;
prints "wish there was a bar: \n" and an uninitialized variable warning.
>
> return $bar;
> }
>
> What's up? Is there a bug in perl? Or is there some point that I missed
> about $1 and friends on the one hand and @_ on the other?
The latter.
perldoc perlsub
To fix:
s/foo(bar)/&handler("$1")/e;
--
Rick Delaney
rick.delaney@shaw.wave.ca
------------------------------
Date: Sat, 23 Jan 1999 22:03:33 +0100
From: Staffan Liljas <staffan@ngb.se>
Subject: Re: Perl Criticism
Message-Id: <36AA3925.79DCD8BF@ngb.se>
Uri Guttman wrote:
> t> Lump all things you hate together. Typical of humans.
> and you are above being human?
I can't believe I missed this one, and we spoke about Turing in this
thread already. Stop posting everybody, topmind is someones new AI
project. AS would maybe be a better desciption, but IMHO it's doing
better than ELIZA. My compliments to whoever wrote the code, but you
didn't pass the T-Test. Sorry.
Staffan
------------------------------
Date: Sat, 23 Jan 1999 22:05:37 +0000
From: Andrew Fry <andrewf@beausys.demon.co.uk>
Subject: Re: Perl problem :(Offline mode...
Message-Id: <ySpTxGAxekq2Ew2x@beausys.demon.co.uk>
In article <1dm0coc.rvp0jx189rs0vN@bay3-116.quincy.ziplink.net>, Ronald
J Kimball <rjk@linguist.dartmouth.edu> writes
>Andrew Fry <andrewf@beausys.demon.co.uk> wrote:
>
>> I was talking about how it is important for me, as company director,
>> to use my time wisely ... and how I have only a limited amount of
>> time to plough through Perl on-line docs.
>
>So you expected to use our time instead, because as company director
>your time is more important than ours? Maybe that's wise... It's
>certainly not very polite.
I was not trying to imply that my time is more important than anyone
else's, nor that I expect others to do work for me. Both are absurd
suggestions ... and I am sure that you know this only too well.
If my comments have appeared to you as being impolite, then it is
you fault for misinterpreting them as you have chosen to do.
I have already said that...
* I do read a lot of technical documentation - it's a part of my job
* I have read numerous Perl books (pretty much all the way through)
* I dont know my way around the Perl on-line documentation, but would
try to explore it when I had time
It's just that I had a problem that I needed an answer to quickly, and
it seemed to me a reasonable thing to do to make use of the appropriate
newsgroup to seek help.
>Right now it's CGI.pm. Will you have time to read the documentation for
>the next module you want to use, or will you be back with more basic
>questions that you expect us to answer?
Lets try to tone down the sarcasm, shall we ?
This newsgroup, according to the initial auto-answer e-mail, is for
"questions on the Perl language". So I posted a question.
It isnt about making unhelpful, patronising, condescending or sarcastic
remarks (...I've had all those so far!).
I am puzzled though ... why do you bother answering *ANY* questions
at all, if this is your attitude ?
>Of course, if we answer your questions, we'll be expected to answer the
>trivial questions of everyone who 'doesn't have time to read the
>documentation'. No thanks.
I do apologize for putting you to so much trouble by asking such a
trivial question. I realize that you must have better things to do
than help others.
The fact is that there is no obligation on your part to answer anything.
Nor is there an obligation on your part to make the singularily
unhelpful remark of "Read the documentation!".
>> What is interesting to one person (eg a newbie) isnt necessarily
>> interesting to another (eg an expert). Who are you (or I) to dictate
>> what constitutes "interesting" ?
>
>Basic Usenet netiquette: questions that are answered in the FAQ are not
>interesting; questions that are answered in the documentation are not
>interesting; questions that are answered in the newsgroup archives are
>not interesting.
Well, that doesnt leave very much then, does it ?
You are basically suggesting that all newbies have no right to make
use of the newsgroup.
>
>> > Because we don't want you driving away the knowledgeable folks,
>> > we may need them someday?
>>
>> Why would I need somebody whose only response was "Go away and
>> read the manuals!" ?
>
>Because maybe someday you'll actually have an interesting question that
>you need answered by a knowledgable person. Sure, it seems like a
>stretch, but you never know.
Please explain what "interesting" means ... in the general sense, not
just as it concerns you and your personal interests.
I have been accused of being "lazy" by posting a question that is
(or may be) answered in documentation that I could not be bothered to
read (...these are other people'w words, not mine).
It seems to me that this is no more lazy that issuing a response
which says only "Read the documentation".
---
Andrew Fry
"Time flies like an arrow. Fruit flies like a banana". (Groucho Marx).
------------------------------
Date: Sat, 23 Jan 1999 18:58:23 -0500
From: comdog@computerdog.com (brian d foy)
Subject: Re: Perl problem :(Offline mode...
Message-Id: <comdog-ya02408000R2301991858230001@news.panix.com>
In article <ySpTxGAxekq2Ew2x@beausys.demon.co.uk>, Andrew Fry <andrewf@beausys.demon.co.uk> posted:
> In article <1dm0coc.rvp0jx189rs0vN@bay3-116.quincy.ziplink.net>, Ronald
> J Kimball <rjk@linguist.dartmouth.edu> writes
> >Andrew Fry <andrewf@beausys.demon.co.uk> wrote:
> >
> >> I was talking about how it is important for me, as company director,
> >> to use my time wisely ... and how I have only a limited amount of
> >> time to plough through Perl on-line docs.
give me a break. using time wisely in not a function of position.
do you let your entry level employees use their time less
efficiently?
> >So you expected to use our time instead, because as company director
> >your time is more important than ours?
> If my comments have appeared to you as being impolite, then it is
> you fault for misinterpreting them as you have chosen to do.
> I have already said that...
well, you didn't go out of your way to not appear like a
condescending jerk who doesn't have enough time to interact with
the peasants. communication involves two parties, so you can't
completely absolve yourself of blame. you might try to fit in a bit
more so you don't end up in too many killfiles. it would waste a
lot more of your time to have to find all of your answers yourself
rather than have knowledgable persons like chipmunk lead you
towards a solution.
> * I do read a lot of technical documentation - it's a part of my job
> * I have read numerous Perl books (pretty much all the way through)
yeah, whatever. doesn't quite jive with the next statement:
> * I dont know my way around the Perl on-line documentation, but would
> try to explore it when I had time
`man perl` goes a long way in explaining that. you might also like
to try the perldoc command, as in
perldoc CGI
you could also see the CGI.pm documentation on the web, as referenced
through the CGI Meta FAQ.
perhaps, in the interest of time efficiency, you should read the
documentation for a tool before you start using it. it saves
quite a bit of thrashing about. you may feel like you are wasting
your time at first, but you should discover that you save time later.
indeed, this is a suggestion of many time management gurus you might
peruse the next time you are in Barnes & Noble - "Read instructions
first.'
*plonk*
--
brian d foy
CGI Meta FAQ <URL:http://www.smithrenaud.com/public/CGI_MetaFAQ.html>
------------------------------
Date: 23 Jan 1999 21:36:44 GMT
From: rkilgore@sidney.kilgore.com (Richard Kilgore)
Subject: PostgreSQL - query attribute types?
Message-Id: <slrn7akg82.5fd.rkilgore@sidney.kilgore.com>
Does anyone know how to query PostgreSQL (preferably in perl) for
the _types_ of the columns (i.e., attributes) in a given table
(i.e., class)? There is a perl function called ftype(), which you
call on a result object, but it returns some damn "oid", whatever
the heck that is, and I can't make any sense out of it. For a
simple table (i.e., class) I created with a varchar(80), two
int4's, a float8, and a date field, ftype() returns:
varchar(80) -> 1043
int4 -> 23
int4 -> 23
float8 -> 701
date -> 1082
What are these values? Where do they come from?
Also, does anyone know a way to query the length limit for a
varchar()? The fsize() function returns -1 to indicate that it's
variable, but I can't seem to find anything that will give me a
limit on it's length.
thanks,
- rick
--
Richard Kilgore | rkilgore@ece.utexas.edu
Electrical & Computer Engineering | http://lore.ece.utexas.edu/~rkilgore/
The University of Texas at Austin | (512) 471-8011
------------------------------
Date: Sat, 23 Jan 1999 21:30:43 GMT
From: <mrgigabyte@hotmail.com>
Subject: Regular expression to parse RealAudio logs?
Message-Id: <mrgigabyte-230119991324092322@cr955118-a.nvcr1.bc.wave.home.com>
I am just starting to grasp the usage of regular expressions. I am
reading and trying to comprehend what I can as quickly as I can.
Unfortunately, I have come across a problem that is far beyond my
current ability.
I am trying to parse a RealAudio log file from which I will perform
some rudimentary stats. My problem is extracting the required fields
from the log. (Assume the entire log has been read in, and I am
looping through each entry in that array. I come to the point where I
must extract specific data from that entry)
The syntax of a RealAudio log entry has the following syntax:
IP_address - - [timestamp] "GET filename protocol" return_code
bytes_sent [client_ID_string] [stat1] [stat2] file_size file_time
sent_time resends failed_resends
A typical RA log entry would look like this...
210.201.65.104 - - [22/Jan/1999:18:19:06 -0800] "GET live/radio.ra
PNA/10" 200 6243360 [Win95_4.0_6.0.3.128_play32_PN01_en-US_486] [Stat1:
12910 44 0 0 1
20_Kbps_Stereo_Music][Stat2: 20000 19996 1496 1
546 44 44 1 0 0 4293
20_Kbps_Stereo_Music] 0 0 2497 44 0
The data I must extract is:
* The timestamp info between the first set of brackets
* Filename between the spaces and after the GET
* The bytes_sent which is between the space after return_code and the
space before the next left bracket
* The sent_time which is 3rd piece of data from the end.
In this example the extracted data would be:
22/Jan/1999:18:19:06, live/radio.ra, 6243360, 2497
Any suggestions regarding the regular expression involved in parsing
this data would be greatly appreciated.
------------------------------
Date: Sat, 23 Jan 1999 22:15:51 GMT
From: Rick Delaney <rick.delaney@home.com>
Subject: Re: Regular expression to parse RealAudio logs?
Message-Id: <36AA4BF1.57588438@home.com>
[posted & mailed]
mrgigabyte@hotmail.com wrote:
>
> The syntax of a RealAudio log entry has the following syntax:
>
> IP_address - - [timestamp] "GET filename protocol" return_code
> bytes_sent [client_ID_string] [stat1] [stat2] file_size file_time
> sent_time resends failed_resends
I'm going to assume this is all one line.
>snip<
>
> The data I must extract is:
>
> * The timestamp info between the first set of brackets
> * Filename between the spaces and after the GET
> * The bytes_sent which is between the space after return_code and the
> space before the next left bracket
> * The sent_time which is 3rd piece of data from the end.
>snip<
>
> Any suggestions regarding the regular expression involved in parsing
> this data would be greatly appreciated.
I suggest a thorough reading of perlre, and possibly buying the book,
"Mastering Regular Expressions".
I have constructed a regex that will work, but since you didn't show
anything that you tried, I have only left in the comments. After each
comment in brackets is the number of characters used for that portion of
the regex.
Your challenge is to fill in the blanks. It will be easy to test if
your solution is correct simply by running the program. If you have
trouble, please come back with what you've tried.
I have given you the first two lines for free to get you started.
Assume the data is in the scalar, $record.
($timestamp, $filename, $bytes_sent, $send_time) = $record =~
/\[ # open brace (2)
( # begin grouping for $timestamp (1)
# one or more anychars, not greedy (3)
# end grouping for $timestamp (1)
# close brace (2)
# one or more whitespace chars (3)
# a double-quote character (1)
# the string 'GET' (3)
# one or more whitespace chars (3)
# begin grouping for $filename (1)
# one or more non-whitespace chars (3)
# end grouping for $filename (1)
# one or more anychars (2)
# a double-quote character (1)
# one or more whitespace chars (3)
# one or more non-whitespace chars (3)
# one or more whitespace chars (3)
# begin grouping for $bytes_sent (1)
# one or more non-whitespace chars (3)
# end grouping for $bytes_sent (1)
# one or more anychars (2)
# one or more whitespace chars (3)
# begin grouping for $send_time (1)
# one or more non-whitespace chars (3)
# end grouping for $send_time (1)
# one or more whitespace chars (3)
# one or more non-whitespace chars (3)
# one or more whitespace chars (3)
# one or more non-whitespace chars (3)
# ZERO or more whitespace chars (3)
# end of string (1)
/x;
print "$timestamp, $filename, $bytes_sent, $send_time\n";
--
Rick Delaney
rick.delaney@shaw.wave.ca
------------------------------
Date: Sat, 23 Jan 1999 20:10:37 GMT
From: e_ron.no.spam@netvision.net.il (Ron)
Subject: Where can I find text parsing samples
Message-Id: <36ab2c78.18247532@news.netvision.net.il>
I am looking for scripts which can help in parsing long text files.
i.e. break line into array of words, etc.
------------------------------
Date: Sat, 23 Jan 1999 21:38:22 GMT
From: alastair@calliope.demon.co.uk (Alastair)
Subject: Re: Where can I find text parsing samples
Message-Id: <slrn7akgbs.4i4.alastair@calliope.demon.co.uk>
Ron <e_ron.no.spam@netvision.net.il> wrote:
>I am looking for scripts which can help in parsing long text files.
>i.e. break line into array of words, etc.
Why not try writing one? The split function does this.
--
Alastair
work : alastair@psoft.co.uk
home : alastair@calliope.demon.co.uk
------------------------------
Date: Sat, 23 Jan 1999 22:41:52 GMT
From: e_ron.no.spam@netvision.net.il (Ron)
Subject: Re: Where can I find text parsing samples
Message-Id: <36ae4f72.27202883@news.netvision.net.il>
Well, I'm new to Perl, first time I touched it was yesterday.
It looks like it can help me a lot as I am trying to parse long text
log files.
I am familiar with VB and C so the code looks familiar and easy to
use.
I will have to avoid thorough learning as I am under pressure to
finish a project so I just started playing.
I looked for split and yes, it does the job, thanks.
Any other built in function which can help in parsing text? And can I
detect special characters while splitting such as \t tab?
alastair@calliope.demon.co.uk (Alastair) wrote:
>Ron <e_ron.no.spam@netvision.net.il> wrote:
>>I am looking for scripts which can help in parsing long text files.
>>i.e. break line into array of words, etc.
>
>Why not try writing one? The split function does this.
------------------------------
Date: 12 Dec 98 21:33:47 GMT (Last modified)
From: Perl-Request@ruby.oce.orst.edu (Perl-Users-Digest Admin)
Subject: Special: Digest Administrivia (Last modified: 12 Dec 98)
Message-Id: <null>
Administrivia:
Well, after 6 months, here's the answer to the quiz: what do we do about
comp.lang.perl.moderated. Answer: nothing.
]From: Russ Allbery <rra@stanford.edu>
]Date: 21 Sep 1998 19:53:43 -0700
]Subject: comp.lang.perl.moderated available via e-mail
]
]It is possible to subscribe to comp.lang.perl.moderated as a mailing list.
]To do so, send mail to majordomo@eyrie.org with "subscribe clpm" in the
]body. Majordomo will then send you instructions on how to confirm your
]subscription. This is provided as a general service for those people who
]cannot receive the newsgroup for whatever reason or who just prefer to
]receive messages via e-mail.
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 4733
**************************************