[8133] in Perl-Users-Digest
Perl-Users Digest, Issue: 1750 Volume: 8
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Wed Jan 28 12:09:48 1998
Date: Wed, 28 Jan 98 09:00:30 -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 Wed, 28 Jan 1998 Volume: 8 Number: 1750
Today's topics:
Re: "Teach Yourself Perl in 21 days" (Was: Re: substitu (Dave Till)
[silliness] Camel and llama successfully cross-bred! (Brian Altheim)
Re: Check Variable type <real@earthling.net>
Re: crypt function ... help. (Gabor)
Re: Directory Listing... <plbF92@hampshire.edu>
Efficiently break a string of [a..z]+ into words using (Zachary Brown)
Re: email address <rets@meta3.com>
Re: exec, fork and CGI confusion <spt@cstr.ed.ac.uk>
Re: Freidl's book mystery <jdporter@min.net>
Re: Hello... another prob :( (Gabor)
Re: HELP HELP HELP!!! - with function call parameters <real@earthling.net>
Re: help please. [N,S,O]dbm weirdness <plbF92@hampshire.edu>
Help with Modules <moores@wantree.com.au>
Re: Help with Modules (Richard Bellavance)
Re: HELP!!!! Perl and IIS timeout problem.! (brian d foy)
Installation error for Perl15.004_03 <joerg-peter.lorch@siemens.ch>
Re: Installing a CPAN module on Windows NT (Gurusamy Sarathy)
Re: is "reverse <>" of a list type? (brian d foy)
Re: Is there a WebRing Script? (brian d foy)
multiple single line match peter@uhu.com
Re: newbie: need help with first script -- here it is (Terence Kearns)
Re: newbie: need help with first script -- here it is (Terence Kearns)
Re: Odd syntax problem <dj@reitz-adams.org.REMOVEME>
Re: Perl Source Obfuscator (brian d foy)
perl/Hyperwave DBI/DBD ODBC + Oracle questions <carola@music.gla.ac.uk>
Problem with self-installing script <kmiles@erols.com>
Digest Administrivia (Last modified: 8 Mar 97) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: 28 Jan 1998 11:24:14 -0500
From: davet@angel.uunet.ca (Dave Till)
Subject: Re: "Teach Yourself Perl in 21 days" (Was: Re: substitute...)
Message-Id: <6anm3e$dvu@angel.uunet.ca>
>>>> My reference book for Perl was initially "Teach Yourself
>>>> Perl in 21 days" by David Till.
>
>>>My experience with that book is somewhat less positive.
>>>I had heard Randal claim that he could start at any random page in that
>>>book and find a serious error of fact within four pages.
>>
>>Thanks Tom, for pointing this out. I too found many errors in the book,
>>but it was still more valuable to me as a beginner than the Camel books.
>>I should not have been so enthusiastic.
Regarding errors of fact and *Teach Yourself Perl 5 in 21 Days*: would
anyone finding errors in the book *please* be so kind as to report them to
me? That way, I can fix them in subsequent printings of the book
(if, as I hope, it continues to remain in print :-)).
Current known errors are listed on my Perl errata sheet web page,
located at http://www.net/~davet/errata52.html.
I'd much prefer it if people would light a candle rather than curse
the darkness, if you know what I mean! :-)
>I suppose that with no other background in programming such a book
>would be difficult to comprehend. But for someone who understands
>programming concepts, someone who understands flow control, logic
>operations, the concepts of variables, structures and arrays, and so
>forth, learning Perl at least in principal from the Camel book is a
>good approach.
I intended the TYP book to serve as an introduction to Perl for
people without a significant amount of programming experience.
I think the question "What is the right book for me?" can't be answered
without knowing the background of the person asking the question. I also
believe that it is not possible for one book to adequately serve the
needs of both advanced and beginning readers: you'll either bore the
former or confuse the latter.
>A student learning a foriegn language of communication for the first
>time does so painfully. However, subsequent languages may be acquired
>with more ease as the acquisition of the first foriegn language
>introduced and familiarized the student with the building blocks of
>language, the processes involved in learning, ...
In my experience, this is true when the subsequent foreign languages
(natural or programming) fit roughly into the same class.
Once you've learned enough imperative programming languages to be
familiar with the concepts of typing, flow control, pointers and
(for more recent languages) object-orientation, learning another
imperative programming language basically means just learning
another set of syntax rules.
However, if the programming language is based on a different paradigm
entirely (such as, say, LISP or Prolog), learning the new language is
somewhat more difficult, as you first have to wrap your head around a
new set of concepts.
The same holds true for natural languages: the Indo-European languages
are similar enough in structure that subsequent languages become easier
to learn. But I'm not sure how much benefit this provides when learning
a language that is not subject-object based, or whose roots are
not based in Indo-European. (I am no expert on languages, so I'm kind
of speculating without a whole lot of data here.)
>That previous statement is my wordy attempt at saying that I'm glad
>for books such as Camel that assume I'm *not* learning about computers
>for the first time.
And others are glad that books exist that do not assume such experience.
It all depends on the background of the reader.
Cheers,
--Dave Till
author of "Teach Yourself Perl 5 in 21 Days"
------------------------------
Date: 28 Jan 1998 14:01:02 GMT
From: altheim@agc.bio.ns.ca (Brian Altheim)
Subject: [silliness] Camel and llama successfully cross-bred!
Message-Id: <6andmu$4o91@sapphire.mtt.net>
It's true! See for yourself! I hate to contemplate what this
means for O'Reilly's perl books in the future.
The URL where I found this most un-newsworthy story is:
http://www.abcnews.aol.com/sections/scitech/cama0120/index.html
Sorry about this being off-topic...I just couldn't help myself.
Brian
------------------------------
Date: 28 Jan 1998 16:49:16 GMT
From: "Real" <real@earthling.net>
Subject: Re: Check Variable type
Message-Id: <01bd2c0c$aa326120$822c57c0@pc0130.pica.nl>
Daniel Balderman <Daniel.Balderman@digital.com> wrote in article
<34CC7D84.5B4@digital.com>...
> Hi,
>
> I'm writing a WEB application where the user has to enter an integer.
> How can I check the user input to see if the user has entered the
> correct type (in this case integer).
This is a Unix style of checking. There might be a shorter one but this
will work.
print "Number: "; $number = <STDIN>; chomp($number);
$chknum = $number; $chknum =~ s/[0-9]//g;
if ($chknum eq '') { print "Nummeric\n" } else { print "Alpha-nummeric\n";
}
Iow, replace all digits with nothing and find out if you've got anything
left.
> Thanks,
You're welcome.
Real
> Daniel Balderman
> Daniel.Balderman@digital.com
------------------------------
Date: 28 Jan 1998 16:06:15 GMT
From: gabor@vmunix.com (Gabor)
Subject: Re: crypt function ... help.
Message-Id: <slrn6culik.3pf.gabor@vnode.vmunix.com>
In comp.lang.perl.misc, Tom Phoenix <rootbeer@teleport.com> wrote :
# On 27 Jan 1998, Gabor wrote:
#
# > In comp.lang.perl.misc, chad <chad> wrote :
#
# > # How do I de-crypt a crypt'd string? I cryp'd it using the perl
# > # crypt function.
#
# > use crypt twice on the string while chanting some secret voodoo
# > rhymes. :-)
#
# I tried this, but on the second verse, I get a core dump. But only when
# using IE4.0; it runs fine under Netscape. BTW, do you know if the voodoo
# rhymes have been certified Y2K compliant? My boss wants me to find out
# before we upgrade to Mojo 3.0.
I am not too sure about the Y2K compliance but Mojo 3.0 is way out of
date. You need to upgrade to 3.28 if you're reading this today, but
probably 3.29 if you're reading this tomorrow. :-)
And, no, there won't be a patch released, you must buy the whole
product and cross your fingers and toes when installing. Failure to
do so could render your printer inoperable or set fire to your
monitor. :-)
gabor.
--
tmps_base = tmps_max; /* protect our mortal string */
-- Larry Wall in stab.c from the perl source code
------------------------------
Date: Mon, 26 Jan 1998 02:05:14 -0500
From: "Peter B." <plbF92@hampshire.edu>
To: David Reid <abb37@dial.pipex.com>
Subject: Re: Directory Listing...
Message-Id: <34CC357A.49E0@hampshire.edu>
> Hi. I need to capture a directory listing so I can mess with the files
> (move them after sorting and cataloguing them) and would like to do it with
> a perl script. So I can do all the sorting bits, but whats the best way of
> getting a directory listing. Ideally I'd like to build an array with every
> file in the directory, but thats the bit I can't do.
>
> Its an NT 4 server, with Perl 5.004. One thought I'd had was to use the
> 'DIR' command from a system command, then capture the output, but is that a
> stupid way of doing it??
>
> Any help, as always, gratefully recieved.
> (Spelling mistakes deliberate)
I'd start with the opendir function... although this is a heady
example.... this shows how Ulrich Pfeifer did it in TPJ 6, the article
about Information Retrieval...
opendir( BASE, $dir);
for $sub (grep -d "$dir/$_", grep /^man_/, readdir BASE ) {
my $path = "$dir/$sub/";
opendir SUBDIR, $path;
for $page (grep -f "$path/$_", readdir SUBDIR ) {
if ( my ( $number, $headline) = $agent->add_document("$path/$page")) {
printf("%4d %s\n", $number, $headline);
}
}
}
That goes through and indexes the man page, but the example might
beuseful in trying to search through any pages. Note I very well may
have mistyped something, as this little example wasn't posted on the tpj
website and i had to retype it.
-Evan
------------------------------
Date: 28 Jan 1998 11:44:18 -0500
From: zbrown@lynx01.dac.neu.edu (Zachary Brown)
Subject: Efficiently break a string of [a..z]+ into words using dictionary
Message-Id: <6ann92$gdl@lynx01.dac.neu.edu>
For a random text generation program I'm working on (actually a set of
programs whose tasks are to feed potential text to each other---it's
weird), I've been trying to time-optimize the following recursive
subroutine (which is heavily used by the program), whose task is to take a
string of letters such as "itryeat" and break it into all possible word
sequences (if its possible at all), using a dictionary stored as a hash
table. For the above example, &breakwords("itryeat") would output "i try
eat" and "it rye at", assuming the dictionary table had those words.
I realize that using a hash table won't be the best solution when using
large word lists.
As you can see from the code, I'm no great wizard. But I thought it might
be interesting enough to inspire some of the code crunchers around here.
Zack
p.s. this isn't for school.
------------------------------------------------------
#!/usr/bin/perl -w
%hash = ("at", "w", "eat", "w", "i", "w",
"it", "w", "rye", "w", "try", "w");
print join("\n", breakwords("itryeat")), "\n";
sub breakwords {
my($string, $sofar) = @_;
my($newstring, $newsofar, @total);
(exists $hash{$string} && $hash{$string} =~ /w/) &&
push(@total, ($sofar ? "$sofar $string" : $string));
while($string =~ s/(.)(.)$/$1/) {
$newstring = defined $newstring ? "$2$newstring" : $2;
if(exists $hash{$string} && $hash{$string} =~ /w/) {
$newsofar = $sofar ? "$sofar $string" : $string;
push(@total, &breakwords($newstring, $newsofar));
}
}
@total;
}
------------------------------
Date: Wed, 28 Jan 1998 08:10:04 -0600
From: Ken Holm <rets@meta3.com>
Subject: Re: email address
Message-Id: <34CF3C3C.41C6@meta3.com>
Following is a non-optimal function that returns true or false for an
email passed to it. This certainly is not fool proof but works well
enough to use:
################
sub emailCheck {
my $Item = shift;
$Item =~ s/^\s+|\s+$//g;
my @List;
return (0) unless $Item;
my ($user, $domain) = split(/\@/, $Item);
return (0) unless ($user && $domain);
return (0) if ($domain !~ /\./);
foreach $Section ($user, $domain) {
@List = split(/\./, $Section);
for (@List) {
return (0) if $_ =~ /\W/;
}
}
return(1);
}
--
Kennneth A Holm | META 3 - Webmaster |webmaster@meta3.com
PO Box 1508 |----------------------------------|(601)718.1030 phone
Jackson, MS 39215|PGP Key finger webmaster@meta3.com|(601)948.5999 (fax)
------------------------------
Date: 28 Jan 1998 16:47:42 +0000
From: Richard Caley <spt@cstr.ed.ac.uk>
Subject: Re: exec, fork and CGI confusion
Message-Id: <eyhyb004kb5.fsf@liddell.cstr.ed.ac.uk>
In article <34CD7518.E0288620@spam.me.com>, Robert Goheen (rg) writes:
rg> I've tried moving the close(STDOUT) statement up, to before one or both
rg> of the unless statements, but when I do that, cleanup.pl doesn't get
rg> executed.
It's possible that when you close STDOUT the program which is calling
this script (presumably an http server) decides that the script has
finished and kills it.
Try something other than the fork and exec after the close (say sleep
for 5 seconds (to make sure there is time for something to happen) then
creating an empty file) to see if it is reached.
--
Mail me as rjc not spt@cstr.ed.ac.uk _O_
|<
------------------------------
Date: Wed, 28 Jan 1998 09:36:45 -0500
From: John Porter <jdporter@min.net>
Subject: Re: Freidl's book mystery
Message-Id: <34CF427D.70FE@min.net>
Ilya Zakharevich wrote:
>
> [A complimentary Cc of this posting was sent to Joseph N. Hall
> <joseph@5sigma.com>],
> who wrote in article <34CDAA80.D94951B@5sigma.com>:
> > Ilya, and Tom, and company,
> >
> > There are some things that are indisputably faster written
> > in a other language than Perl, and lexers are one of them.
> > A lexer written in C, either hard-coded or machine-generated,
> > translates into extremely efficient byte-twiddling opcodes.
> > The limiting factor for a lexer written in C or other language
> > that compiles to machine code is I/O, and that is *not* the
> > case with a complex Perl regex lexer.
>
> This is definitely true for but-the-simplest lexers *with the current
> - pitiful - Perl's RE engine*. Nobody said that several well-aimed
> small modifications of the engine will not make this statement
> obsolete.
OTOH, it can be argued that *anything* written in C will faster than
the equivalent in Perl, by orders of magnitude >=0.
Clearly, there are other reasons for writing in Perl. A moderately
complex RE in Perl might be a god-awful nasty machine in C which
takes many times longer to write and is many times harder/costlier
to maintain.
Here's an idea for you p5p-ers: since RE is a language unto itself,
wouldn't it be nice to have separate compilation units for RE.
You could have a flex-like program which compiles Perl RE's into
native-code XSUBS.
On a related point, I think RE's (and pack/unpack) ought to have a
full-blown O-O interface. That is, the engine/interpreter ought
to be extensible via subclassing, overriding. In Perl, of course.
jat,
John Porter
------------------------------
Date: 28 Jan 1998 16:07:44 GMT
From: gabor@vmunix.com (Gabor)
Subject: Re: Hello... another prob :(
Message-Id: <slrn6culld.3pf.gabor@vnode.vmunix.com>
In comp.lang.perl.misc, diogo <np59re@mail.telepac.pt> wrote :
# Thanks for the people who replied to the last post of mine.
#
# But, nothing works. I downloaded perl for Win NT again. And nothing works.
# My www directory is in c:\inetpub\wwwroot.
#
# Who can tell me, step by step, how do I install it? In wich folder, wich
# path, wich registry key. Or give me the URL. Cause nothing seems to work...
#
# Please?
#
# A desperate perlerer (?),
# diogo
# Thank you.
#
On the first pass install FreeBSD or Linux. :-)
gabor.
--
The degree of civilization in a society can be judged by observing
its prisoners.
-- Dostoyevski
------------------------------
Date: 28 Jan 1998 16:36:37 GMT
From: "Real" <real@earthling.net>
Subject: Re: HELP HELP HELP!!! - with function call parameters
Message-Id: <01bd2c0a$e57e59c0$822c57c0@pc0130.pica.nl>
Bhanu P. Suravarapu <bhanu@usl.edu> wrote in article
<34CDC784.41C67EA6@usl.edu>...
I wonder how many responces you'll get on this one. It's a bit cryptic but
I'll try anyway.
> Hi,
>
> I am using perl5.003.
>
> In my perl script I have something like
>
> open(somefile1....);
I presume a $nodenumber = <SOMEFILE>;
> print somefile1 $nodenumber;
> $response = &travlink($node);
Variable $node was not used before.
> open(somefile....);
> print somefile2 $nodenumber;
> ...
>
> I have the above code in a loop where $nodenumber takes values 1..9
> My function is something like this:
> sub travlink
> {
> open(somefile....);
> print somefile3 $_[0];
>
> 1;
What's this ?
> }
>
>
> Now my problem is somefile1 and somefile2 have values 1..9
> BUT somefile3 has only few values 2,6,8 (say).
>
> So my function is not being called sometimes I donot know
> why this is happening.
>
> i have spent a lot of time to figure out the existance of this problem.
>
> PLEASE HELP ME.
>
> bhanu.
> bhanu@usl.edu
I'm sure any newsgroup reader would like to help you out but you have to be
a little bit more specific. How about adding a piece of _real_ Perl script
with your results ?
It also might help adding some debug messages at certain points in your
script. Write them to STDERR if you expect a lot of output.
Cheers,
Real.
------------------------------
Date: Mon, 26 Jan 1998 01:57:00 -0500
From: "Peter B." <plbF92@hampshire.edu>
Subject: Re: help please. [N,S,O]dbm weirdness
Message-Id: <34CC338C.3A60@hampshire.edu>
I'm not sure about this but I believe that your problem probally is due
to the incompatiblity of the various xDBM file formats. To transfer
things about tie the dbm file using the xDBM that created it and then
copy it over to the a new tied hash with whatever xDBM you want to use.
-Evan
------------------------------
Date: Wed, 28 Jan 1998 22:25:49 +0800
From: Steve Moore <moores@wantree.com.au>
Subject: Help with Modules
Message-Id: <34CF3FE9.ABEEECA0@wantree.com.au>
Hi,
I'm still coming up to speed with Perl, so please excuse the elementary
question.
I've trying to install a new module (the IO module) to Perl 5.003.
Is there away of installing the module WITHOUT having to
re-compile the Perl executable?
I need the IO module in place so that I can use the FTP module in
side LIBNET.
I'm using :-
# uname -X
System = SCO_SV
Node = trans07
Release = 3.2v5.0.0
KernelID = 95/08/08
Machine = Pentium
BusType = EISA
Serial = XXXXXXXXX
Users = 5-user
OEM# = 0
Origin# = 1
NumCPU = 1
TIA
Steve Moore
------------------------------
Date: 28 Jan 1998 10:13:29 -0500
From: charlot@CAM.ORG (Richard Bellavance)
Subject: Re: Help with Modules
Message-Id: <6anhup$9q2@ocean.CAM.ORG>
In article <34CF3FE9.ABEEECA0@wantree.com.au>,
Steve Moore <moores@wantree.com.au> wrote:
>Hi,
>
>I'm still coming up to speed with Perl, so please excuse the elementary
>question.
>
>I've trying to install a new module (the IO module) to Perl 5.003.
>Is there away of installing the module WITHOUT having to
>re-compile the Perl executable?
>
Of course. Installing a module does not involve recompiling the Perl
interpreter (well, not that I know of anyway).
The standard module installing procedure is:
perl Makefile.PL
make
make test
make install
>I need the IO module in place so that I can use the FTP module in
>side LIBNET.
>
Of course, depending on the version of the IO and libnet modules that you're
installing, you may need to upgrade your Perl to 5.004 first... Although there
might still be older versions of these modules on CPAN that will work with
5.003, I strongly recommend upgrading your Perl to 5.004; it fixes many bugs,
has a lot of interesting and powerful new features, and IO comes bundled with
it !
Good luck !
Richard.
--
Richard Bellavance -- charlot@cam.org -- http://www.cam.org/~charlot/
"All along this path I tread / My heart betrays my weary head
With nothing but my love to save / From the cradle to the grave"
(Eric Clapton, "From the cradle")
------------------------------
Date: Wed, 28 Jan 1998 09:15:47 -0500
From: comdog@computerdog.com (brian d foy)
Subject: Re: HELP!!!! Perl and IIS timeout problem.!
Message-Id: <comdog-2801980915470001@news.panix.com>
Keywords: just another new york perl hacker
[there is no need to post the same article under two different subject
lines. once is enough]
In article <34CE76FF.56F5182C@mastermind.net>, srudolph@mastermind.net posted:
> Perl time out on IIS? HELP!!!!
this is not a Perl issue.
> I have a Perl script that when runs updates a text file. The
> IIS server reports a timeout. If anyone else has this timeout
> problem with IIS send me email please.
see the people in comp.infosystems.www.authoring.cgi to find
out about returning some data to the client while doing your
task. you miht also want to provide them wth enough information
to actually provide a useful answer.
questions about your server product can go to the newsgroup
devoted to it.
good luck [and with a PoB you need it] :)
--
brian d foy <http://computerdog.com>
the solution is to upgrade
------------------------------
Date: Wed, 28 Jan 1998 15:35:16 +0100
From: Joerg-Peter Lorch <joerg-peter.lorch@siemens.ch>
To: lorch@es2.siemens.ch
Subject: Installation error for Perl15.004_03
Message-Id: <34CF4224.C6BB7B19@siemens.ch>
I tried several times to install Perl (V.5.004_3) on a sun with OS
Solaris 2.5.1
The used compiler is the cc (ucbcc: SC4.0 18 Oct 1995 C 4.0) not gcc.
According to the INSTALL procedure, I made :
a.) rm -f config.sh
b.) sh Configure
c.) make
d.) I can't go on because of toubles before
The first two procedure ran without problems.
The answers of b.) has been the default ones.
But during the run of make, I always get the error
------------------------------
Date: 28 Jan 1998 16:13:49 GMT
From: gsar@engin.umich.edu (Gurusamy Sarathy)
Subject: Re: Installing a CPAN module on Windows NT
Message-Id: <6anlft$763@srvr1.engin.umich.edu>
[ mailed and posted ]
In article <34CDFC52.3198@tietogroup.com>,
Kari Marttila <Kari.Marttila.@tietogroup.com> wrote:
>pm_to_blib: $(TO_INST_PM)
> @$(PERL) "-I$(INST_ARCHLIB)" "-I$(INST_LIB)" \
> "-I$(PERL_ARCHLIB)" "-I$(PERL_LIB)" -MExtUtils::Install \
> -e "pm_to_blib(qw[ <<pmfiles.dat ],'$(INST_LIB)\auto')"
>
>$(PM_TO_BLIB) # THIS IS LINE 726!!!!!!!!!!!!!!!!!!
><<
The install process ass_u_me_s that you'd use nmake (since you
said you had Visual C++). So, just use nmake. If you want to use
dmake anyway (no special reason to), s/nmake/dmake/ in your
Config.pm.
Sorry this is not documented clearly enough.
- Sarathy.
gsar@umich.edu
------------------------------
Date: Wed, 28 Jan 1998 09:08:34 -0500
From: comdog@computerdog.com (brian d foy)
Subject: Re: is "reverse <>" of a list type?
Message-Id: <comdog-2801980908340001@news.panix.com>
Keywords: just another new york perl hacker
In article <6amdv8$r9q$1@marina.cinenet.net>, cberry@cinenet.net (Craig Berry) posted:
> brian d foy (comdog@computerdog.com) wrote:
> : rather than all that reversing, why not:
> :
> : create the array of lines
> : find the index of the last element of that array
> : print out lines $#array - N to $array
>
> You needn't even 'find out the index of the last element; use negative
> indices as in my earlier post on this thread, essentially
>
> @lines = <>;
> print @lines[-N .. -1];
of course, on should ensure that there are that N lines to print
or things will get kinda wierd. this involves knowing how many
lines there are... :)
--
brian d foy <http://computerdog.com>
Comprehensive Perl Archive Network (CPAN) <URL:http://www.perl.com>
sometimes clever ways bite back
------------------------------
Date: Wed, 28 Jan 1998 09:32:06 -0500
From: comdog@computerdog.com (brian d foy)
Subject: Re: Is there a WebRing Script?
Message-Id: <comdog-2801980932060001@news.panix.com>
Keywords: just another new york perl hacker
[there is no need to post the same question twice]
In article <34CB53D5.4E8B6C50@att.net.hk>, Walter Archie <warchie@att.net.hk> posted:
> I am looking for a webring script out there. If someone has one or knows
> of one please help find it. I am looking for a site I am putting
> together. This is really appreciated if you can help me.
what does this have to do with Perl, other than it's possible
implementation?
why not just ask the people that already have such things what
they use?
--
brian d foy <http://computerdog.com>
Comprehensive Perl Archive Network (CPAN) <URL:http://www.perl.com>
------------------------------
Date: Wed, 28 Jan 1998 10:37:57 -0600
From: peter@uhu.com
Subject: multiple single line match
Message-Id: <886003288.1218052101@dejanews.com>
I have a comma delimeted text database. Each value in the "field" is
enclosed in '"' double quotes. There are a total of 31 "fields" in each
line. Each line is a record. The datastructure is as follows: "Company
Name","Platform","Status","Product","Platform","Status","Product","Platfo
rm" ,...","Product"
1.) I have to "fish" out all products, and their respective platforms
whose status is xyz. Each company can have more than one product with the
same status. So far I got the REGEX for gettting out the Company name and
the platform and product OK, but I don't know how to get the next one out
of the same line, if there are multiple occurrences.
So here is my code: (assuming string is in $_)
open file;
read in stuff;
blah,blah,blah;
&analyze_date;
sub analyze_data { while(m/$somestatus/g) { /^\"([^\"]+?)\",/;
$company = $1; /\"([^\"]+)\",\"$somestatus\",\"([^\"]+)\"/; $platform =
$1; $product = $2; print "<tr>\n"; print " <td><font face=\"Arial\"
size=\"1\"> $company <\/font><\/td>\n"; print " <td><font face=\"Arial\"
size=\"1\"> $platform <\/font><\/td>\n"; print " <td><font
face=\"Arial\" size=\"1\"> $product <\/font><\/td>\n"; print "<\/tr>\n";
$num_recs++ } ## end while } ## end sub
I tried to use \G, but did not find good examples of this assertion. My
code retrieves only the very first occurrence and repeats the same(first)
find as many times as many occurrences there are in the same line.
QUESTION: How do I step to the next match ? How do I get all matches out
of the same line?
Thanks for any help
peter@uhu.com
-------------------==== Posted via Deja News ====-----------------------
http://www.dejanews.com/ Search, Read, Post to Usenet
------------------------------
Date: Wed, 28 Jan 1998 16:05:25 GMT
From: terence[no_spam]@designer-web-pages.com (Terence Kearns)
Subject: Re: newbie: need help with first script -- here it is
Message-Id: <34d556fc.68008045@newshost.canberra.edu.au>
On Tue, 27 Jan 1998 10:49:11 -0800, Tom Phoenix
<rootbeer@teleport.com> wrote:
>On Mon, 26 Jan 1998, it was written:
>
>> I had a LOT of trouble trying to find anything that explained basic
>> things properly. ie. couldn't get a straight explanation of how to
>> write a file ...
>
>The books in the perlbook manpage are good. I'd recommend the Llama for
>this.
>
I realise this now. I was advised to get the Camel but I'm somewhat
frustrated at there being no tutorials (which is of course what the
Llama book is for).
>> took ages before I sussed out you had to 'select' a
>> file handle (which was opened for output). Why didn't any of the
>> documentation just say that.
>
>Because you don't _have_ to select a filehandle. It's primarily a
>convenience.
>
Ah yes, now I see that thanks to the helpful folks on usenet.
>> Anyway, I got this far without help but I'm stuck.
>
>In what way are you stuck? Perhaps your program isn't doing something you
>intended, or perhaps it's doing something you didn't intend. Did your
>attempt to run it give you any helpful error messages?
>
Yes I realise I wasn't very clear about what i need help with for
someone who needs it so much. I shall do some more work on "kerchop"
and post it in this thread. This time I will be more explicit in what
I have problems with. There is one thing though ...
... So far I've been trying to use the SPLIT funtion to break up a
large file at 'separators' that occur many lines apart. Does anyone
know if SPLIT can do this or is it restricted to breaking things apart
one line at a time where the separator occurs one or more times per
line ?
>> # kerchop is a program for splitting up large ascii files into bight
>> size
>> # segments (in this case, for the web).
>
>That sounds a bit like the unix split(1) program.
>
I just had a look at the man pages for 'split'. It works on a byte
basis rather than searching a file for flags. Thanks for the tip
anyway, I wasn't aware of it's existance. Maybe I should modify my
program description to say "using 'flags' which you specify".
>> $outputfile = join ('','>',$prefix,$ticker,$suffix) ;
>
>Generally, this would be written like this, although there's nothing
>really wrong with your method.
>
> $outputfile = ">$prefix$ticker$suffix";
>
Wow. That is so much more elegant. I didn't know you could do that
(man, I really need that Llama book - such a basic thing).
>> open ( PIECE , $outputfile ) ;
>
>Even when your script is "just an example" (and perhaps especially in that
>case!) you should _always_ check the return value after opening a file.
>
That sounds like a _very_ sensible thing to do. Thanks for that, I
will.
>Hope this helps!
Surly does ! --Thanks.
------------------------------
Date: Wed, 28 Jan 1998 16:03:29 GMT
From: terence[no_spam]@designer-web-pages.com (Terence Kearns)
Subject: Re: newbie: need help with first script -- here it is
Message-Id: <34d356c9.67957546@newshost.canberra.edu.au>
On Mon, 26 Jan 1998 10:54:08 -0600, tadmc@flash.net (Tad McClellan)
wrote:
>Terence Kearns (terence[no_spam]@designer-web-pages.com) wrote:
>: This is my first perl script. It's most probably a a pathetic mess But
>: I had a LOT of trouble trying to find anything that explained basic
>: things properly. ie. couldn't get a straight explanation of how to
>: write a file ... took ages before I sussed out you had to 'select' a
> ^^^^^^
>
>You don't _have to_ use select(). You can always specify the filehandle
>directly:
>
> print OUTFILE "some stuff\n";
>
>
>I've written hundreds of scripts. I've never used select()...
>
>
>: file handle (which was opened for output). Why didn't any of the
>: documentation just say that.
Thanks !
I will definately be using 'select' only when necessary.
------------------------------
Date: Wed, 28 Jan 1998 08:23:19 -0000
From: "DJ Adams" <dj@reitz-adams.org.REMOVEME>
Subject: Re: Odd syntax problem
Message-Id: <6annlu$577$1@alpha.ftech.net>
Chipmunk wrote in message <34CC260D.A07F712@coos.dartmouth.edu>...
>"foo/bar/baz/" =~ m{(/.*?$)} will set $1 to "/bar/baz", *not* "/baz",
Shouldn't $1 == "/bar/baz/" ?
dj
------------------------------
Date: Wed, 28 Jan 1998 09:36:23 -0500
From: comdog@computerdog.com (brian d foy)
Subject: Re: Perl Source Obfuscator
Message-Id: <comdog-2801980936230001@news.panix.com>
Keywords: just another new york perl hacker
In article <6ajfhv$ov3$1@ha2.rdc1.pa.home.com>, "Nick" <nmarino@home.com> posted:
> So you're against obfuscating on principle, then?
read the FAQ or the responses to the thousands of other people that
asked the same question.
--
brian d foy <http://computerdog.com>
Comprehensive Perl Archive Network (CPAN) <URL:http://www.perl.com>
------------------------------
Date: Wed, 28 Jan 1998 14:50:26 +0000
From: Carola Boehm <carola@music.gla.ac.uk>
Subject: perl/Hyperwave DBI/DBD ODBC + Oracle questions
Message-Id: <34CF45B2.31DF@music.gla.ac.uk>
Hi,
Can anybody help me out with more experience handling the perl DBI/BD
modules? I am lost in the installation process due to unsufficient
documentation.
Problem:
*********
I have a Hyperwave Information Server running on a Irix 6.3.
I also have ACCESS and/or additional future RDBMS running on WindowsNT
on a different machine(s). Hyperwave is supposed to have HGI gateways
capable of interfacing with RDBMS (via perl DBD/DBI) and my ACCESS
database can hook up with a MS SQL server.
According to my documentation, I can specify
( in hgi_config, accoding to docs, but do I just create one if it is not
existant?) gateways to RDBMS via the perlmodule DBD/DBI
I have perl 5.004_01 installed and also DBI 0.91. I have not yet
installed DBD-Oracle (as the HWI docs tellme) or DBD-ODBC ( which would
be more logical). To install these I must have either already a standing
Oracle source (DBD-Oracle docs) or a DSN source specified (DBD-ODBC
docs. The DBI module and perl is installed on Irix6.3, i.e. on the same
machine as the Hyperwave server.
Questions:
**********
(Using DBD-ODBC) What do I specify as DBI_DSN if the ACCESS datbase is
on a remote machine? DOes it have to be on a local network?
(Using DBD-Oracle) What do I specify when i am not running Oracle but
Access?
Where does the perl DBD/DBI actually have to be installed, on the same
machine as the RDBMS or can I access them remotely?
(Using DBD-ODBC) What is ODBCHOME? The directory where (in my case) my
dsn is?
The HWI documentation seem to say that one can access RDBMS of other
type than Oracle via Hyperwave and the DBD-Oracle. Is that true and if
yes, what do I do with the following step described in DBD-Oracle docs:
"Install enough Oracle software to enable
DBD::Oracle to build.
That includes Pro*C."
If the above is false, than do I use DBD-ODBC? How can I hook up
Hyperwave and ACcess via DBD-ODBC if they are on different machines?
I.e. what should the following env variables set at:
(quote from the installation docs:)
BUILDING:
set-up these environment variables:
DBI_DSN The dbi data source, e.g. 'dbi:ODBC:YOUR_DSN_HERE'
DBI_USER The username to use to connect to the database
DBI_PASS The username to use to connect to the database
ODBCHOME (Unix only) The dir your driver manager is installed in
Thanks. Please sent comments by email.
carola
--
------------------------------------------------------------------
"Is this just a clockwork of fabulous design,
or does it actually tell time"
(Virgil Thompson)
------------------------------------------------------------------
PADS
http://www.arts.gla.ac.uk/PADS/
------------------------------------------------------------------
Carola Boehm
Department of Music Tel: +44 (0) 141 330 6065
University of Glasgow Fax: +44 (0) 141 330 3518
14 University Gardens email: carola@music.gla.ac.uk
Glasgow G128QH
------------------------------
Date: Wed, 28 Jan 1998 10:17:53 -0500
From: Kevin Miles <kmiles@erols.com>
Subject: Problem with self-installing script
Message-Id: <34CF4C21.147E@erols.com>
I have an install.pl script which generates setup.pl using user input
for variables such as email address.
The file is being created ok and I can chmod it ok, but I can't seem to
get it to execute. If I exec it, it wipes the file to 0 bytes. I've also
tried eval and system and ``, none of them work.
The script works fine, however, once the original script exits and I
call it from the command line. Any suggestions?
print SETUP <<'EOF'; # use single quotes to keep \n intact
print STDOUT "This is the installation routine.\n";
print "\nAll Variable parameters passed from the server\n";
print " will be defined here.\n";
EOF
close SETUP;
chmod 0111, 'setup.pl';
#none of these work
#do "./setup.pl" or die "\nError running setup: $!\n";
#system('/home/kevin/m2000/setup.pl');
#eval ("`/home/kevin/m2000/setup.pl`");
------------------------------
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 1750
**************************************