[17288] in Perl-Users-Digest

home help back first fref pref prev next nref lref last post

Perl-Users Digest, Issue: 4710 Volume: 9

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Tue Oct 24 11:10:29 2000

Date: Tue, 24 Oct 2000 08:10:16 -0700 (PDT)
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)
Message-Id: <972400215-v9-i4710@ruby.oce.orst.edu>
Content-Type: text

Perl-Users Digest           Tue, 24 Oct 2000     Volume: 9 Number: 4710

Today's topics:
        Paragraph slurping for reading records from config file <bruce_phipps@my-deja.com>
    Re: Paragraph slurping for reading records from config  (Bernard El-Hagin)
    Re: Paragraph slurping for reading records from config  <bruce_phipps@my-deja.com>
    Re: Paragraph slurping for reading records from config  xerxes_2k@my-deja.com
    Re: parse url <mauldin@netstorm.net>
    Re: Perl debugger ? <ehansen@rbg.informatik.tu-darmstadt.de>
        Ping via PERL? wuselwesen@my-deja.com
    Re: Ping via PERL? (Clay Irving)
    Re: please help me! Installing DBI and DBD on WIN98 <anders@wall.alweb.dk>
    Re: please help me! Installing DBI and DBD on WIN98 <tward10@jaguar.com>
    Re: Processing an Email (sendmail) attachment with Perl <gary@dkstat.com>
    Re: Regular expression help <jeff@vpservices.com>
    Re: Regular expression help <jeff@vpservices.com>
    Re: Regular expression help <james@NOSPAM.demon.co.uk>
    Re: regular expression (Philip Lees)
        replacing known lines <w.berg@samsom.nl>
    Re: What will the code look like? <russ_jones@rac.ray.com>
    Re: why core dump ? <ronr@my-deja.com>
        Digest Administrivia (Last modified: 16 Sep 99) (Perl-Users-Digest Admin)

----------------------------------------------------------------------

Date: Tue, 24 Oct 2000 11:25:42 +0100
From: "Bruce Phipps" <bruce_phipps@my-deja.com>
Subject: Paragraph slurping for reading records from config files
Message-Id: <8t3o88$hmv$1@sshuraab-i-1.production.compuserve.com>

I am working from an example in the Perl Cookbook (recipe 11.10) that:

* Uses paragraph slurping to read in records from a text file
* Uses hash references

Data records are separated by a new line in the format:
Name: Michael
Age: 25
Occupation: Journalist

Name: Amy
Age: 34
Occupation: Soldier

etc..

Here's the code:
--------------------
#!/usr/bin/perl -w

open(FH,'datafile') or die "Could not open data file: $!\n";
$/ = "";

while (<FH>) {
     my @fields = { split (/^([^:]+):\s*/m) };  #from Cookbook -- this is a
weird pattern match!
     shift @fields;         # for leading null field
     push(@Array_of_Records, { @fields });
 }

close(FH);

foreach $record (@Array_of_Records) {
     for $key (sort keys %$record) {
      print "$key is $record->{$key}\n";
   }
 }

----------error output-----------------
Odd number of elements in hash assignment at ./read.pl line 7, <FH> chunk 1.
Odd number of elements in hash assignment at ./read.pl line 7, <FH> chunk 2.
Odd number of elements in hash assignment at ./read.pl line 7, <FH> chunk 3.

Any tips welcomed on reading in such a text file.
TIA
Bruce.




------------------------------

Date: 24 Oct 2000 10:56:16 GMT
From: bernard.el-hagin@lido-tech.net (Bernard El-Hagin)
Subject: Re: Paragraph slurping for reading records from config files
Message-Id: <slrn8vaqpa.28m.bernard.el-hagin@gdndev25.lido-tech>

On Tue, 24 Oct 2000 11:25:42 +0100, Bruce Phipps
<bruce_phipps@my-deja.com> wrote:
>I am working from an example in the Perl Cookbook (recipe 11.10) that:
>
>* Uses paragraph slurping to read in records from a text file
>* Uses hash references
>
>Data records are separated by a new line in the format:
>Name: Michael
>Age: 25
>Occupation: Journalist
>
>Name: Amy
>Age: 34
>Occupation: Soldier
>
>etc..
>
>Here's the code:
>--------------------
>#!/usr/bin/perl -w
>
>open(FH,'datafile') or die "Could not open data file: $!\n";
>$/ = "";
>
>while (<FH>) {
>     my @fields = { split (/^([^:]+):\s*/m) };  #from Cookbook -- this is a

This line should read:

my @fields = split (/^([^:]+):\s*/m);  
	
With this change the script works fine.

Cheers,
Bernard
--
perl -le'
($B,$e,$r,$n,$a,$r,$d)=q=$B$e$r$n$a$r$d==~m;
\$(.);xg;print$B.$e.$r.$n.$a.$r.$d;'


------------------------------

Date: Tue, 24 Oct 2000 12:11:40 +0100
From: "Bruce Phipps" <bruce_phipps@my-deja.com>
Subject: Re: Paragraph slurping for reading records from config files
Message-Id: <8t3qql$j1r$1@sshuraab-i-1.production.compuserve.com>

Bernard,

Theres something in the Errata on the O'Reilly web site about this. In
future, it would be wise for me to check there first before posting...I'll
try a few changes.

Bruce




------------------------------

Date: Tue, 24 Oct 2000 11:16:30 GMT
From: xerxes_2k@my-deja.com
Subject: Re: Paragraph slurping for reading records from config files
Message-Id: <8t3r2c$s1t$1@nnrp1.deja.com>

not sure if this is the main problem but, u are pushing onto an array
from a split on :.  and then pushing a reference (i think) onto another
array.
then foreaching that array.
but, and heres the important but, u r then tying to use tha element of
the array as a hash not an array.
try this;

while(<fh>){
	($field, $value)=(split /whateverthat was/);
	$fileds{$field}=$value;
	push @array, \%fields;
}

and the rest should be ok.


Sent via Deja.com http://www.deja.com/
Before you buy.


------------------------------

Date: Tue, 24 Oct 2000 11:08:46 GMT
From: Jim Mauldin <mauldin@netstorm.net>
Subject: Re: parse url
Message-Id: <39F56D45.5F0F6706@netstorm.net>

jason wrote:
> 
> Peter Clarke wrote ..
> >Is there a more efficient way of doing this? I wont to separate the host,
> >path and query from a given url. It works but seems long winded.
> 
> 'working' is such a relative term .. your code demonstrates that you do
> not know how URLs are correctly formed .. 'http://www.foo.com/' is a
> correctly formed URL .. whereas 'www.foo.com/index.html' is not

IETF RFC 1738

A URL has the following form:

<scheme>:<scheme-specific-part>

Schemes currently in use include ftp, http, gopher, mailto, news, nntp,
telnet, wais, file, prospero

   "While the syntax for the rest of the URL may vary depending on the
   particular scheme selected, URL schemes that involve the direct use
   of an IP-based protocol to a specified host on the Internet use a
   common syntax for the scheme-specific data:"

    //<user>:<password>@<host>:<port>/<url-path>

[text omitted]

  An HTTP URL takes the form:

      http://<host>:<port>/<path>?<searchpart>


-- Jim


------------------------------

Date: Tue, 24 Oct 2000 14:09:07 +0200
From: Erik Hansen <ehansen@rbg.informatik.tu-darmstadt.de>
Subject: Re: Perl debugger ?
Message-Id: <39F57BE3.5BFD5BB6@rbg.informatik.tu-darmstadt.de>

<!doctype html public "-//w3c//dtd html 4.0 transitional//en">
<html>
"P.Eftevik" wrote:
<blockquote TYPE=CITE>Is there a debug kind of tool for perl ?
<br>I'd just like to step through parts of scripts,&nbsp; monitor variables
<br>etc.
<br>Thanx for any hint
<p>PEftie</blockquote>
ok&nbsp; shure you can use the integrated perl-debugger in the console
but this is not nice . Look at the activestate homepage
<br><A HREF="http://www.activestate.com/Products/Perl_Dev_Kit/index.html">http://www.activestate.com/Products/Perl_Dev_Kit/index.html</A>
<br>for the debugging-tool for windows. don"t know which os you're running.
<p>also look at
<br><A HREF="http://www.perl.com/reference/query.cgi?debug">http://www.perl.com/reference/query.cgi?debug</A>
<br>for an overview....perlbuilder is another nice application with integrated
debugger.
<br>greetings erik</html>



------------------------------

Date: Tue, 24 Oct 2000 14:10:53 GMT
From: wuselwesen@my-deja.com
Subject: Ping via PERL?
Message-Id: <8t4596$499$1@nnrp1.deja.com>

Hi!
My Question is: How can i ping someone using a Perl-script?


Sent via Deja.com http://www.deja.com/
Before you buy.


------------------------------

Date: 24 Oct 2000 14:53:22 GMT
From: clay@panix.com (Clay Irving)
Subject: Re: Ping via PERL?
Message-Id: <slrn8vb8j2.nh0.clay@panix2.panix.com>

On Tue, 24 Oct 2000 14:10:53 GMT, wuselwesen@my-deja.com 
<wuselwesen@my-deja.com> wrote:

>My Question is: How can i ping someone using a Perl-script?

Get the Net::Ping module.

-- 
Clay Irving <clay@panix.com>
There's nothing remarkable about it. All one has to do is hit the right
keys at the right time and the instrument plays itself. 
- J. S. Bach 


------------------------------

Date: Tue, 24 Oct 2000 13:28:26 +0200
From: Anders Lund <anders@wall.alweb.dk>
Subject: Re: please help me! Installing DBI and DBD on WIN98
Message-Id: <7oeJ5.419$z71.32495@news000.worldonline.dk>

jinlee wrote:

> I refered to README in DBI-1.14 but couldn't install that package.
> I tried on command line by "ppm install DBI.ppd" but i've got this message
> "Error installing package 'DBI.ppd': Could not locate a PPM binary of
> 'DBI.ppd' for this platform"
> 
> I don't understand this message.
> now, I'm trying to connect ORACLE with perl.
> please help me.
> thanks in advance.
> 

the message means that ppm couldn't find DBI.ppd for windows.

I installed DBI on windows once before I moved to a more friendly OS, using 
the standard package from CPAN, you could download that and try.. I 
remember no trouble.

-anders
-- 
[ the word wall - and the trailing dot - in my email address
is my _fire_wall - protecting me from the criminals abusing usenet]


------------------------------

Date: Tue, 24 Oct 2000 12:16:34 +0100
From: "Trevor Ward" <tward10@jaguar.com>
Subject: Re: please help me! Installing DBI and DBD on WIN98
Message-Id: <8t3r2j$agp2@eccws12.dearborn.ford.com>

Your using activestate perl I presume. on PC

Were you connected to the internet at the time, This is where the ppm
package loader looks for the dbi module.

If you were connected and it still failed look in the online documents for
ppm to find out how to list the available packages for installation. or at
the ppm prompt type search and this will give you a list of available
packages.

If all this fails look at the activestate web site for the faq's and one of
these will answer your problem.

jinlee <leej100@chollian.net> wrote in message
news:8t3j4o$aua$1@michelle.lgcit.com...
> I refered to README in DBI-1.14 but couldn't install that package.
> I tried on command line by "ppm install DBI.ppd" but i've got this message
> "Error installing package 'DBI.ppd': Could not locate a PPM binary of
> 'DBI.ppd' for this platform"
>
> I don't understand this message.
> now, I'm trying to connect ORACLE with perl.
> please help me.
> thanks in advance.
>
>
>
>




------------------------------

Date: Tue, 24 Oct 2000 07:56:25 -0700
From: Gary Artim <gary@dkstat.com>
Subject: Re: Processing an Email (sendmail) attachment with Perl
Message-Id: <39F5A319.54E83022@dkstat.com>

Martien Verbruggen wrote:

> On Mon, 23 Oct 2000 20:06:07 -0700,
>         Gary J. Artim <gartim@ix.netcom.com> wrote:
> > Question: Can you act as an email client using Perl and
> > read emails and process attached files as data? We have
>
> Me, personally? Nope :)
>
> > a Website where some of the clients refuse to use our
> > upload page, but will email us attached, tab-delimited
> > files. I'd like to get them thru Perl and auto upload them
> > to my mysql database. Has anyone done this.
>
> You should probably have a look at the many mail related modules on
> CPAN. Start at search.cpan.org.
>
> You probably might be interested in Graham Barr's MailTools to parse
> the mail, MIME::Base64 and/or the MIMETools package, and if you need
> to pull it from a POP server or IMAP server you may need
> Mail::POP3Client, Net::POP3, Mail::IMAPClient or Net::IMAP.
>
> Have a look around, and see what suits your needs best. You don't
> really give enough information to make a more sensible recommendation.
>
> Martien
> --
> Martien Verbruggen              | My friend has a baby. I'm writing
> Interactive Media Division      | down all the noises the baby makes so
> Commercial Dynamics Pty. Ltd.   | later I can ask him what he meant -
> NSW, Australia                  | Steven Wright

I'll have a look. We are running FreeBSD sendmail and an Apache web
server. We use PINE
as an email client, don't have any POP3 running, but I could set that up
and try the POP client.
This is just more food for thought. Anyone listening? Bravo and thanks for
your response MV!




------------------------------

Date: Tue, 24 Oct 2000 07:14:49 -0700
From: Jeff Zucker <jeff@vpservices.com>
Subject: Re: Regular expression help
Message-Id: <39F59959.38E84BA3@vpservices.com>


Craig Berry wrote:
> 
> Jeff Zucker (jeff@vpservices.com) wrote:
> : jsfinn@my-deja.com wrote:
> : > At least 6 alpha-numeric characters
> : > there must be at least 1 digit
> : > there must be at least 1 letter
> :
> : /\d/ && /\D/ && /^[a-zA-Z0-9]{6,}$/
> 
> "/\D/" isn't equivalent to "letter".

True, and I knew that when I wrote it.  If the string matches /\D/ and
the following regex also, then whatever was matched by /\D/ must be a
letter.  There's no need to check if it's a letter twice.

-- 
Jeff


------------------------------

Date: Tue, 24 Oct 2000 07:26:19 -0700
From: Jeff Zucker <jeff@vpservices.com>
Subject: Re: Regular expression help
Message-Id: <39F59C0B.DE9A09F6@vpservices.com>

Larry Rosler wrote:
> 
> In article <39F4BB8F.2510ADEC@vpservices.com> on Mon, 23 Oct 2000
> 15:28:31 -0700, Jeff Zucker <jeff@vpservices.com> says...
> > jsfinn@my-deja.com wrote:
> > >
> > > At least 6 alpha-numeric characters
> > > there must be at least 1 digit
> > > there must be at least 1 letter
> >
> > /\d/ && /\D/ && /^[a-zA-Z0-9]{6,}$/
> 
> He said at least 6 alphanumeric characters (which includes '_', but your
> character class doesn't), 

I guess I define alphanumeric literally as composed of alphabetic and
numeric characters.  If you look at perlre, it contains this definition:

  \w  Match a "word" character (alphanumeric plus "_")

If the underscore were included in the definition of "alphanumeric",
there would be no need for the "plus" in the definition.

> but didn't exclude other characters (as your regex does).

You're right there, I interpreted him to mean that it could only contain
what he specified and he didn't say that so I was wrong to exclude
them.  OTOH, he was asking for a password and I am not aware of a lot of
password programs that accept unlimited other characters.

> I'll stand by my already-posted response:

Which I have no argument with.  If your response had arrived at my
newsfeed before I sent mine, I wouldn't have sent mine.

-- 
Jeff


------------------------------

Date: Tue, 24 Oct 2000 15:53:21 +0100
From: James Taylor <james@NOSPAM.demon.co.uk>
Subject: Re: Regular expression help
Message-Id: <ant2414210b0fNdQ@oakseed.demon.co.uk>

In article <39F5305C.53EE16E8@stomp.stomp.tokyo>, Godzilla!
<URL:mailto:godzilla@stomp.stomp.tokyo> wrote:
> 
> Yes, Perl does need more symbology. There are two
> other matching 'bracket' like symbols I know of,
> 
> « » and ‹ ›   <-- those are not html brackets.

Not sure what you think you typed there, but I received
codes 171, 187, 139, 155 in that order. 171 and 187 appear
as the open and close French quotes or chevrons. 139 looks
like an upward pointing arrow, and 155 is the oe ligature.
The native character set on my OS is ISO Latin-1 which
explains why 171, 187 and 155 appear as they do, but 139
is undefined in Latin-1 so my OS has simply used it for
some other useful symbol.

Although I can see that the French quotes make a matching
pair, the other two characters certainly don't. I assume
you're seeing something quite different. 

I am surprised that the latter two characters you typed
are not in the Latin-1 set from your perspective because
your newsreader has added a Content-Type header indicating
charset=iso-8859-1 (which is Latin-1).

Of course none of those characters are 7bit safe so I am
astonished they made it through Usenet. Is Usenet an 8bit
system then?

-- 
James Taylor <james (at) oakseed demon co uk>
PGP key available ID: 3FBE1BF9
Fingerprint: F19D803624ED6FE8 370045159F66FD02



------------------------------

Date: Tue, 24 Oct 2000 06:38:15 GMT
From: pjlees@ics.forthcomingevents.gr (Philip Lees)
Subject: Re: regular expression
Message-Id: <39f52bf3.58205925@news.grnet.gr>

On Mon, 23 Oct 2000 11:55:23 GMT, joelyhughes@my-deja.com wrote:

>I need a regex (or more than one?) which can indentify all tags of a
>certain type in a HTML doc which have a certain parameter. I then want
>to be able to alter an additional parameter (inserting it if it does
>not previously exist) with a new value.
>
>I though I'd start off with somthing like
>/<INPUT.*TYPE='HIDDEN'.*>/gi
>Can I then pump these results into another regex which look for the
>attributes?

Your question is not entirely clear, but I assume you want to change
every instance of 'HIDDEN' to something else. If so, you can do it in
one go, without all the redundant punctuation:

my $line = "garbage<INPUT TYPE='HIDDEN'>more garbage";

$line =~ s/(<INPUT TYPE=')HIDDEN('>)/$1YourNewType$2/gi;

ObRef: Read perlre for more.

Phil

--
Philip Lees
ICS-FORTH, Heraklion, Crete, Greece
Ignore coming events if you wish to send me e-mail
'The aim of high technology should be to simplify, not complicate' - Hans Christian von Baeyer


------------------------------

Date: Tue, 24 Oct 2000 15:14:36 +0200
From: "walter" <w.berg@samsom.nl>
Subject: replacing known lines
Message-Id: <8t4222$bf7$1@zonnetje.nl.uu.net>

Hi group,

I've justed started with perl (here we go again), and I want to make a
script that reads files in a directory and puts them in a certain context,
like this:


opendir(HERE, '.');
open(OUT, '>plaatjes.def') or die "Couldn't make the file...\n";

@Allfiles = readdir(HERE);
 foreach $Name (@Allfiles) {

  print OUT '<OD:FO:"'."$Name".'",bitmap,"afbeeldingen/'."$Name".'">'."\n";
       }

And it works fine. Reason i use '.' is because it should be easy to work
with for people who are scared of commandlines, so it's just: drop the
script in the directory where the pictures are (we work with folioviews:
http://www.nextpage.com/foliostuff/index.asp ), doubleclick it and get a
file that's ready to use.

Now the script also puts the following lines in the file:

<OD:FO:".",bitmap,"afbeeldingen/.">
<OD:FO:"..",bitmap,"afbeeldingen/..">
<OD:FO:"fileReader.pl",bitmap,"afbeeldingen/fileReader.pl">

(fileReader.pl is the name of my script)

I know why these lines are in my file,  but now I want them out, and my best
guess was: use regular expressions. So I used:

$empty = "";  #empty variable that's used in the next replacement
 s/<OD:FO:"\.",bitmap,"afbeeldingen\/\.">/$leeg/;

And something similar for the other lines. But I can't find out how I put
these lines in my script. Yes, i'm an idiot.
But thanks anyway.

Walter.
--
http://vandenb.com




------------------------------

Date: Tue, 24 Oct 2000 09:18:06 -0500
From: Russ Jones <russ_jones@rac.ray.com>
Subject: Re: What will the code look like?
Message-Id: <39F59A1E.4F2588DF@rac.ray.com>

Gwyn Judd wrote:
> 
> I was shocked! How could Tad McClellan <tadmc@metronet.com>
> say such a terrible thing:
> 
> >Who is Spike Milligan, and what has he done with poor Ogden Nash?
> 
> Spike Milligan was one of the Goon Show members. Who the heck was Ogden
> Nash?
> 

Jeez Louise I've fallen amongst the Philistines.

-- 
Russ Jones - HP OpenView IT/Operatons support
Raytheon Aircraft Company, Wichita KS
russ_jones@rac.ray.com 316-676-0747

Quae narravi, nullo modo negabo. - Catullus


------------------------------

Date: Tue, 24 Oct 2000 11:31:21 GMT
From: Ronald J.H. Rood <ronr@my-deja.com>
Subject: Re: why core dump ?
Message-Id: <8t3rua$sib$1@nnrp1.deja.com>

In article <39F4F5C3.8EA51262@rochester.rr.com>,
  Bob Walton <bwalton@rochester.rr.com> wrote:
> "Ronald J.H. Rood" wrote:
> >
> > Hi,
> > I am relatively new to perl. This is a little excercise script:
> > perl 5.6.0 aix
> > dbi 1.14
> > dbd oracle 1.06

> > $sth->finish;
> > $dbh->disconnect;

> Question:  if your while loop never terminates, how does your program
> terminate?  When you type ctrl-C?  Normally, I wouldn't expect that
> killing a Perl program would dump core, but who knows?
> Hope the above helps.
> Bob Walton

Thanks Bob (again ...) it did help.
I think the problem is in DBI. And yes, I did use ctrl-C to stop. Now it
works the way I wanted. I think I just wanted to do to much in the while
expression.

--
Ronald
http://unix-dba.myweb.nl
The best way to accellerate a computer 'running' windows is by
gravitation


Sent via Deja.com http://www.deja.com/
Before you buy.


------------------------------

Date: 16 Sep 99 21:33:47 GMT (Last modified)
From: Perl-Users-Request@ruby.oce.orst.edu (Perl-Users-Digest Admin) 
Subject: Digest Administrivia (Last modified: 16 Sep 99)
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.  

| NOTE: The mail to news gateway, and thus the ability to submit articles
| through this service to the newsgroup, has been removed. I do not have
| time to individually vet each article to make sure that someone isn't
| abusing the service, and I no longer have any desire to waste my time
| dealing with the campus admins when some fool complains to them about an
| article that has come through the gateway instead of complaining
| to the source.

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 V9 Issue 4710
**************************************


home help back first fref pref prev next nref lref last post