[11060] in Perl-Users-Digest
Perl-Users Digest, Issue: 4660 Volume: 8
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Fri Jan 15 14:17:27 1999
Date: Fri, 15 Jan 99 11:00:21 -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 Fri, 15 Jan 1999 Volume: 8 Number: 4660
Today's topics:
Re: *.pl Files ? And now ? <outline@p3.net>
Re: A newbie who needs some help (Abigail)
Accelerated Perl Programming Workshop <info@itte.org>
Re: Another newbie problem. Help (Abigail)
Re: BUG in perl 5.00502? (Larry Rosler)
Re: BUG in perl 5.00502? (Brian Wheeler)
Re: coredump & other weirdness with eval(require) (M.J.T. Guy)
DBI to MSAccess DB - truncates memo fields <nyoung@silcom.com>
Re: Different Results With Different Browsers (Abigail)
Re: Finding the last URL that was accessed (Abigail)
Re: FORM to two different CGI? <vpatricio@abrantina.pt>
Re: glob error <not@giving.it.out>
Re: Help needed with locking (Randal L. Schwartz)
Re: Help needed with locking (M.J.T. Guy)
Re: Help needed with locking (M.J.T. Guy)
HTML Form --> PERL "print" ?? (help!) <dstern@aschwebhosting.comnospam>
Re: HTML Form --> PERL "print" ?? (help!) <dstern@aschwebhosting.comnospam>
Is perl the right choise for the following job? <progressdll@angelfire.com>
Re: Is perl the right choise for the following job? (Clay Irving)
Re: kwlii: Formatting Numbers (Clay Irving)
open path problems colin@hpj.co.uk
Re: Perl + odbc.pm <nyoung@silcom.com>
Re: Perl and Cybercash <nyoung@silcom.com>
Re: perl cgi jhall@idiglobal.com
Re: Perl Criticism <vpatricio@abrantina.pt>
Persistent eval in xsub (Thomas Rock)
Problem with legacy Perl script (Brian Capouch)
Re: problem with use strict and use FileCache (M.J.T. Guy)
Re: Regex challenge <blainn@worldnet.att.net>
Re: Regex challenge (Tad McClellan)
Re: Regex challenge (Abigail)
Re: script produced no output jhall@idiglobal.com
Re: Searching a string, with a headache (Larry Rosler)
Re: Which Perl reference book? jhall@idiglobal.com
Special: Digest Administrivia (Last modified: 12 Dec 98 (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: Fri, 15 Jan 1999 12:01:44 -0500
From: "Paul Murphy" <outline@p3.net>
Subject: Re: *.pl Files ? And now ?
Message-Id: <77ns6a$i8a$1@newsreader.jvnc.net>
I think a better response might be, that in the perl script (.pl file) you
need to make sure it points to the location of perl on the server. there's
no reason to change it to .cgi unless your server has .cgi registered to
handle perl, in which case you wouldn't need to even point the file to the
interpreter.
------------------------------
Date: 15 Jan 1999 16:52:28 GMT
From: abigail@fnx.com (Abigail)
Subject: Re: A newbie who needs some help
Message-Id: <77nroc$76b$1@client2.news.psi.net>
Danny Downs (ddowns1@telusplanet.net) wrote on MCMLXIII September
MCMXCIII in <URL:news:rtCn2.7882$Kg6.57670@news2.telusplanet.net>:
== I am writing a perl script that would ask you to enter a username and
== password then telnet to a mail server and take the value of the username and
== the password and enter them once you connect to the mail server.
== For example you would enter the username "bob" and the password "bob1". once
== a connection to the mail server is made the script would initatate the
== 'user' command and the 'pass' command using the value that you entered
== above. What my problem is is that I can't get the 'user' and the 'pass'
== command to type out once I connect to the mail server. Can anyone help me
Perhaps you need one of the Net:: modules.
Abigail
------------------------------
Date: Fri, 15 Jan 1999 17:58:58 GMT
From: "ITTE" <info@itte.org>
Subject: Accelerated Perl Programming Workshop
Message-Id: <01be40b0$b9eb4d20$af7de8d0@debhome>
Accelerated Perl Programming Workshop
January 28-29, 1999
San Jose, CA
For more information
email: info@itte.org
visit: http://www.itte.org/INFO/ptrain.html
------------------------------
Date: 15 Jan 1999 18:35:27 GMT
From: abigail@fnx.com (Abigail)
Subject: Re: Another newbie problem. Help
Message-Id: <77o1pf$899$1@client2.news.psi.net>
Murphy (frball9@mail.idt.net) wrote on MCMLXIII September MCMXCIII in
<URL:news:36a1498f.14063919@news.idt.net>:
()
() 1- what convention do I use to call this from the HTML??? I am
() testing this script on a local OmniHTTP server. What is the
() convention for calling this script.?..
That's not a Perl question.
() 2- Perhaps this should've been part of question 1, but anyway.
() When calling this script, I want to pass a parameter to it, that being
() the filename I want the info on. I would obviously have to change the
() Perl script to do this, but how? All the examples I've seen currently
() are forms, and that's not really what I'm looking for.
That's not a Perl question either.
Abigail
------------------------------
Date: Fri, 15 Jan 1999 09:50:44 -0800
From: lr@hpl.hp.com (Larry Rosler)
Subject: Re: BUG in perl 5.00502?
Message-Id: <MPG.11091fd3d9b9bfde989994@nntp.hpl.hp.com>
[Posted to comp.lang.perl.misc and a copy mailed.]
In article <77nos6$7q8$1@jetsam.uits.indiana.edu> on 15 Jan 1999
16:03:18 GMT, Brian Wheeler <bdwheele@educ.indiana.edu> says...
>
> This works in 5.00404, but fails under 5.00502. I wrap a phrase with 'z's and
> change spaces to underlines. after I do some processing, I remove the z's and
> underlines to get back the original text.
...
> $data=~s/z($uname)\z/&uuline($1)/gie;
^
The problem is that backslash. In 5.005, '\z' has acquired its own
semantics.
>From perldelta:
New regular expression constructs
The following new syntax elements are supported:
...
\z
>From perlre:
\z Match only at end of string
In 5.004 or before, '\z' simply meant 'z' by default. So if you take
out the superfluous backslash, all should be well.
--
(Just Another Larry) Rosler
Hewlett-Packard Company
http://www.hpl.hp.com/personal/Larry_Rosler/
lr@hpl.hp.com
------------------------------
Date: 15 Jan 1999 18:40:04 GMT
From: bdwheele@educ.indiana.edu (Brian Wheeler)
Subject: Re: BUG in perl 5.00502?
Message-Id: <77o224$8lk$1@jetsam.uits.indiana.edu>
In article <MPG.11091fd3d9b9bfde989994@nntp.hpl.hp.com>,
lr@hpl.hp.com (Larry Rosler) writes:
> [Posted to comp.lang.perl.misc and a copy mailed.]
>
> In article <77nos6$7q8$1@jetsam.uits.indiana.edu> on 15 Jan 1999
> 16:03:18 GMT, Brian Wheeler <bdwheele@educ.indiana.edu> says...
>>
>> This works in 5.00404, but fails under 5.00502. I wrap a phrase with 'z's and
>> change spaces to underlines. after I do some processing, I remove the z's and
>> underlines to get back the original text.
> ...
>> $data=~s/z($uname)\z/&uuline($1)/gie;
> ^
> The problem is that backslash. In 5.005, '\z' has acquired its own
> semantics.
>
> From perldelta:
>
> New regular expression constructs
>
> The following new syntax elements are supported:
>
> ...
> \z
>
> From perlre:
>
> \z Match only at end of string
>
> In 5.004 or before, '\z' simply meant 'z' by default. So if you take
> out the superfluous backslash, all should be well.
>
That's cool. I just upgraded the other day and had not read the
new documentation yet.
thanks!
Brian
------------------------------
Date: 15 Jan 1999 17:03:14 GMT
From: mjtg@cus.cam.ac.uk (M.J.T. Guy)
Subject: Re: coredump & other weirdness with eval(require)
Message-Id: <77nsci$iq6$1@pegasus.csx.cam.ac.uk>
Steve Leibel <stevel@coastside.net> wrote:
>
>This is on BSD/OS 4.0, with perl 5.004_02.
That's a version of Perl that was never publicly released. Try again
with a newer, released Perl version.
Mike Guy
------------------------------
Date: Fri, 15 Jan 1999 10:43:53 -0800
From: Nathan Young <nyoung@silcom.com>
Subject: DBI to MSAccess DB - truncates memo fields
Message-Id: <369F8C69.98226D55@silcom.com>
Hi.
I have some scripts that were written to use a msql database on linux
and I'm trying to run them against access in windows. My problem is
that access "memo" type fields get truncated at around 80 characters. I
threw together an ASP to test the same thing, and it gets the full
contents of the fields. Is this a know problem with DBD::ODBC or does
the problem lie elsewhere?
---------------->Nathan
--
$:0`0:$x,88,x$:0`0:$x$:0`0:$x,88,x$:0
Nathan Young
nathan@ncyoung.com
(805) 686-2830
------------------------------
Date: 15 Jan 1999 18:40:46 GMT
From: abigail@fnx.com (Abigail)
Subject: Re: Different Results With Different Browsers
Message-Id: <77o23e$899$2@client2.news.psi.net>
info@gadnet.com (info@gadnet.com) wrote on MCMLXIII September MCMXCIII in
<URL:news:369f212b.9218694@news.newsguy.com>:
%% I have written a script which works fine under Netscape. You fill in a
%% form, click on the button and another page comes up. If you do the
%% same thing with MSIE a blank page comes up. Why are different browsers
%% treating my script differently?
Who cares? Different results on different browsers is what makes the
web the web. Your question isn't a Perl one.
Abigail
------------------------------
Date: 15 Jan 1999 18:44:32 GMT
From: abigail@fnx.com (Abigail)
Subject: Re: Finding the last URL that was accessed
Message-Id: <77o2ag$899$3@client2.news.psi.net>
vulcan_savik@my-dejanews.com (vulcan_savik@my-dejanews.com) wrote on
MCMLXIII September MCMXCIII in <URL:news:77n61v$tlo$1@nnrp1.dejanews.com>:
**
**
** Im other words I'm looking for a way to do a javascript:history.go(-1) type
** operation but implement it in PERL instead ... and return the URL.
1) That's not a Perl question.
2) That information isn't always available.
3) It's not a Perl question.
4) The information isn't reliable either.
5) It's not a Perl question.
6) Every browser has a back button already.
7) It's not a Perl question.
** any help is gratefully accepted.
Did I mention it isn't a Perl question?
Abigail
------------------------------
Date: 15 Jan 1999 18:16:11 GMT
From: "Vasco Patrmcio" <vpatricio@abrantina.pt>
Subject: Re: FORM to two different CGI?
Message-Id: <01be40b3$50c89980$3f0a0a0a@vpatricio2>
I'm new in Perl, so my suggestion might be of no use, but here it goes: why
don't you create a third script that does the logical routing of the
requests and put a single URL in the FORM statement?
------------------------------
Date: Fri, 15 Jan 1999 17:49:04 +0000
From: Etienne Pollard <not@giving.it.out>
Subject: Re: glob error
Message-Id: <369F7F8F.FA0647A1@giving.it.out>
Tad McClellan wrote:
> Are you _certain_ that that is the same exact code?
>
> You cut/pasted it into this article, or you typed it in?
>
I've tried just the following code:
!#/usr/bin/perl
@another = </home/webroot/*>;
And it still gives me the scalar assignment error!
However, running it on Win32 Perl 5.004 doesn't give me an error, but it
also doesn't give me any output either.
The Win32 code is:
#!c:/perl/bin/perl.exe
@another = <c:\perl\*.*>;
foreach (@another) {
print "file $_\n";
}
Perhaps someone could try the above code and the code from the previous
post and then let us know what you get?
Thanks,
Etienne
------------------------------
Date: 15 Jan 1999 08:53:01 -0800
From: merlyn@stonehenge.com (Randal L. Schwartz)
Subject: Re: Help needed with locking
Message-Id: <m14spszdea.fsf@halfdome.holdit.com>
>>>>> "info" == info <info@gadnet.com> writes:
info> Well that raises a question in itself. Why should one close a file
info> instead of unlocking it? Makes no sense to me.
close does the following things:
1) flush the buffer
2) close the fd
... system then releases the lock
flock(UN) does the following things:
1) release the lock
... later, buffer is flushed, and fd is closed
You NEVER want to release a flock when you haven't finished updating
it. The proper response is to let the system release the flock, long
after you're done updating it.
So, with very few exceptions, close is good, flock(UN) is bad.
print "Just another Perl flocker,"
--
Name: Randal L. Schwartz / Stonehenge Consulting Services (503)777-0095
Keywords: Perl training, UNIX[tm] consulting, video production, skiing, flying
Email: <merlyn@stonehenge.com> Snail: (Call) PGP-Key: (finger merlyn@teleport.com)
Web: <A HREF="http://www.stonehenge.com/merlyn/">My Home Page!</A>
Quote: "I'm telling you, if I could have five lines in my .sig, I would!" -- me
------------------------------
Date: 15 Jan 1999 17:48:53 GMT
From: mjtg@cus.cam.ac.uk (M.J.T. Guy)
Subject: Re: Help needed with locking
Message-Id: <77nv25$ln6$1@pegasus.csx.cam.ac.uk>
Randal L. Schwartz <merlyn@stonehenge.com> wrote:
>flock(UN) does the following things:
>
> 1) release the lock
> ... later, buffer is flushed, and fd is closed
Not in modern Perls. Nowadays, flock(UN) does
1) flush the filehandle
2) release the lock
... so there's no stuff in the buffer to be flushed.
>You NEVER want to release a flock when you haven't finished updating
>it. The proper response is to let the system release the flock, long
>after you're done updating it.
>
>So, with very few exceptions, close is good, flock(UN) is bad.
Despite the above, that's still good advice, if only for compatibility
with older Perls.
Mike Guy
------------------------------
Date: 15 Jan 1999 17:57:15 GMT
From: mjtg@cus.cam.ac.uk (M.J.T. Guy)
Subject: Re: Help needed with locking
Message-Id: <77nvhr$m8t$1@pegasus.csx.cam.ac.uk>
In article <369f2ea6.12664351@news.newsguy.com>, <info@gadnet.com> wrote:
>My real question concerns the open itself. From what I've seen, using
>flock goes something like this:
>
>Open file
>lock file
>manipulate file
>close file
>
>In other words you open a file and then lock it. Two separate steps.
>Now if process 1 successfully opens a file in write mode and then
>locks it, what happens when process 2 opens the file (in read mode).
>We don't need to worry about what happens when Process 2 actually
>tries to read, it's the Open that I'm worried about. Does the open
>work? Maybe this is just a stupid question, and the answer is: of
>course. But the idea of successfully opening locked files worries me.
You're quite right to be worried. It all depends on the type of
open() you do. If you go
open FH, ">$file"
you'll wipe the contents of the file before obtaining the lock. BAD.
But if you use
open FH, "+<$file"
no harm will be done.
Similarly, an open for append is basically safe:
open FH, ">>$file"
BUT (depending on platform) you may not be able to rely on the file
position, so you'll need to do a
seek FH, 0, 2;
AFTER the flock to ensure you are writing where you think.
Mike Guy
------------------------------
Date: Fri, 15 Jan 1999 17:22:24 -0500
From: "Danny" <dstern@aschwebhosting.comnospam>
Subject: HTML Form --> PERL "print" ?? (help!)
Message-Id: <77o0uk$jee$1@winter.news.rcn.net>
I have a HTML form which accesses a PERL script to verify a credit card. I
want to output the credit card information (which was typed in the HTML
form) in the new page that the PERL script creates. I've tried
print $FORM{'cardnumber');
But, it doesn't seem to work correctly.
My entire printing code is:
print "Your credit card has been approved. Please print the following
form: \n";
print "<table border=0 cellspacing=0 cellpadding=0><tr><font face=\"ms
sans serif\" color=black size=5> \n";
print "Order Form</font></tr></table><table border=0 cellspacing=0
cellpadding=0><tr><td width=150>Card Number</td><td width=100>Item</td><td
width=250>Decsription</td><td width=100>Price</td></tr> \n";
print "<tr><td width=150> \n";
print $FORM('cardholder');
print "<BR> \n";
print $FORM{'cardnumber');
print "<BR> \n";
print $FORM('cardexp');
print "</td><td width=100> \n";
print $FORM('item');
print "</td><td width=250> \n";
print $FORM('des');
print "</td><td width=100> \n";
print $FORM('price');
print "</td></tr></table> \n";
print "Thank you for your order\!\n";
I'm fairly new to PERL, so there could be some other stupid mistake above.
Let me know, thanks.
Danny
------------------------------
Date: Fri, 15 Jan 1999 17:50:23 -0500
From: "Danny" <dstern@aschwebhosting.comnospam>
Subject: Re: HTML Form --> PERL "print" ?? (help!)
Message-Id: <77o2iv$r9i$1@winter.news.rcn.net>
Yes, I fixed the two "{" that should be "(", but it still does not work.
Danny wrote in message <77o0uk$jee$1@winter.news.rcn.net>...
>I have a HTML form which accesses a PERL script to verify a credit card. I
>want to output the credit card information (which was typed in the HTML
>form) in the new page that the PERL script creates. I've tried
> print $FORM{'cardnumber');
>But, it doesn't seem to work correctly.
>My entire printing code is:
> print "Your credit card has been approved. Please print the following
>form: \n";
> print "<table border=0 cellspacing=0 cellpadding=0><tr><font face=\"ms
>sans serif\" color=black size=5> \n";
> print "Order Form</font></tr></table><table border=0 cellspacing=0
>cellpadding=0><tr><td width=150>Card Number</td><td width=100>Item</td><td
>width=250>Decsription</td><td width=100>Price</td></tr> \n";
> print "<tr><td width=150> \n";
> print $FORM('cardholder');
> print "<BR> \n";
> print $FORM{'cardnumber');
> print "<BR> \n";
> print $FORM('cardexp');
> print "</td><td width=100> \n";
> print $FORM('item');
> print "</td><td width=250> \n";
> print $FORM('des');
> print "</td><td width=100> \n";
> print $FORM('price');
> print "</td></tr></table> \n";
> print "Thank you for your order\!\n";
>I'm fairly new to PERL, so there could be some other stupid mistake above.
>Let me know, thanks.
>
>Danny
>
>
------------------------------
Date: Thu, 14 Jan 1999 18:28:47 +0100
From: "Joeri Belis" <progressdll@angelfire.com>
Subject: Is perl the right choise for the following job?
Message-Id: <77nv75$ejs$1@nickel.uunet.be>
Is perl the right choise for the following job?
I want to connect to a certain site (asp pages)
and need the extract some info from that page.
reformat it and right it to an ascii file.
Can perl do that easy?
--
******************************************************
http://www.experts-exchange.com
******************************************************
------------------------------
Date: 15 Jan 1999 13:20:03 -0500
From: clay@panix.com (Clay Irving)
Subject: Re: Is perl the right choise for the following job?
Message-Id: <77o0sj$5o7$1@panix.com>
In <77nv75$ejs$1@nickel.uunet.be> "Joeri Belis" <progressdll@angelfire.com> writes:
>Is perl the right choise for the following job?
>I want to connect to a certain site (asp pages)
>and need the extract some info from that page.
>reformat it and right it to an ascii file.
>Can perl do that easy?
Yes.
--
Clay Irving
clay@panix.com
------------------------------
Date: 15 Jan 1999 12:00:17 -0500
From: clay@panix.com (Clay Irving)
Subject: Re: kwlii: Formatting Numbers
Message-Id: <77ns71$qar$1@panix.com>
In <77nk8p$k59@bgtnsc02.worldnet.att.net> "Kenneth LaRue" <kwlii@worldnet.att.net> writes:
>I have done a search on the CPAN sites for Number::Format. For some
>reason the search engine changes the capital letters to lower case
>and I cannot seem to find anything on the topic. Would anyone
>happen to have a URL or site name that could point me to the
>documentation.
http://www.perl.com/CPAN/authors/William_R_Ward/
--
Clay Irving
clay@panix.com
------------------------------
Date: Fri, 15 Jan 1999 17:38:51 GMT
From: colin@hpj.co.uk
Subject: open path problems
Message-Id: <77nufa$j90$1@nnrp1.dejanews.com>
I have a directory off the web root called cgi-bin. This is set as a virtual
directory (IIS 4). In the cgi-bin there is a perl script that attempts to
open a file in the root. It always failes. Everybody (IUSER_xxx included) has
god rights to everywhere (just to rule out permission problems). If I open a
file in cgi-bin it's fine. What's up? Any help appreciated.
Colin.
-----------== Posted via Deja News, The Discussion Network ==----------
http://www.dejanews.com/ Search, Read, Discuss, or Start Your Own
------------------------------
Date: Fri, 15 Jan 1999 10:40:38 -0800
From: Nathan Young <nyoung@silcom.com>
Subject: Re: Perl + odbc.pm
Message-Id: <369F8BA6.8524610D@silcom.com>
Hi.
May I suggest using DBI and DBD::ODBC instead? This gives you access to
any ODBC database server, and provides a perl interface that can also be
used to get data from other (non ODBC and/or non-windows) database
servers. It also comes with sample scripts.
--------->Nathan
Bruce Davidson wrote:
>
> I'm looking for some practical examples of perl using w32 odbc sql commands.
> Any pointers welcome.
> Thanks
--
$:0`0:$x,88,x$:0`0:$x$:0`0:$x,88,x$:0
Nathan Young
nathan@ncyoung.com
(805) 686-2830
------------------------------
Date: Fri, 15 Jan 1999 10:37:40 -0800
From: Nathan Young <nyoung@silcom.com>
Subject: Re: Perl and Cybercash
Message-Id: <369F8AF4.B05CCABB@silcom.com>
Hi.
The cybercash website has some understandable example scripts. They're
a little hard to find, but keep at it, they're there somewhere. You'd
think as an internet commerce "pioneer" cybercash would have a well
organized web site, but no...
-------->Nathan
bshaffer932@my-dejanews.com wrote:
>
> I am faced with writing a perl script that integrates with cybercash... I
> have no idea where to start, does anyone know of any places with some good
> examples, advice, or whatnot?
>
> Thanks
> Brian
>
> -----------== Posted via Deja News, The Discussion Network ==----------
> http://www.dejanews.com/ Search, Read, Discuss, or Start Your Own
--
$:0`0:$x,88,x$:0`0:$x$:0`0:$x,88,x$:0
Nathan Young
nathan@ncyoung.com
(805) 686-2830
------------------------------
Date: Fri, 15 Jan 1999 16:51:25 GMT
From: jhall@idiglobal.com
Subject: Re: perl cgi
Message-Id: <77nrm7$gjc$1@nnrp1.dejanews.com>
Learning Perl 2nd e.;
Programming Perl 2nd e.;
Perl Cookbook;
those are the best I've seen and have used... (THat come to mind right now)
Jayce^
In article <369E2393.93442C03@rational.com>,
Alan Rogers <arogers@rational.com> wrote:
> Hi,
>
> I am just getting started with the web and perl cgi can anybody
> recommend any books on the subject.
>
> Kinds Regards
> Alan Rogers
>
> arogers@rational.com
>
>
-----------== Posted via Deja News, The Discussion Network ==----------
http://www.dejanews.com/ Search, Read, Discuss, or Start Your Own
------------------------------
Date: 15 Jan 1999 18:20:00 GMT
From: "Vasco Patrmcio" <vpatricio@abrantina.pt>
Subject: Re: Perl Criticism
Message-Id: <01be40b3$d7a9b6a0$3f0a0a0a@vpatricio2>
> Wrong. Everyone enjoys abigail's posts. Except perhaps some of the
hapless
> newbies.
Wrong again. The newbies aren't the only ones that do not enjoy abigail's
posts.
------------------------------
Date: Fri, 15 Jan 1999 10:50:14 -0600
From: thomas@x-tekcorp.com (Thomas Rock)
Subject: Persistent eval in xsub
Message-Id: <MPG.11092dc04e5c9d8898969b@news.anet-chi.com>
I have an application that needs to execute a line
of perl code from within an xsub. However, this line
of code will be contained within a loop structure and
be executed over and over.
I know I can use perl_eval_pv to eval the code and
execute it, but I don't want to take the eval hit
each time through the loop. I also thought about
putting the line of code into a perl sub and
perl_eval_pv that, but I don't want the sub-call
overhead either.
Is there a way to eval a line of code once and
execute it over and over? Or, any other ideas
out there on how to accomplish this?
Thanks.
--
Thomas Rock
thomas@x-tekcorp.com
------------------------------
Date: Fri, 15 Jan 1999 11:27:20 -0500
From: brianc@palaver.net (Brian Capouch)
Subject: Problem with legacy Perl script
Message-Id: <369F6C68.7D69C3@palaver.net>
I just got the task of upgrading some scripts that have been running
under Perl 4 SunOS to Perl 5 Linux.
Things have gone smoothly except for this one little niggle, but I can't
(so far) get past it, and a couple of Perl programmers I've shown it to
haven't known either.
It's an unpack, using the template in the following string:
$headformat = "A2, A9, A21, A10, A7, A3, A7, A6, A6, A6";
Here's the unpack:
($junk, $courseid, $title, $teacher, $credits, $bldg, $room, $start,
$stop, $days, $junk) = unpack ($headformat, $nextline);
Here's the line of text it's trying to process:
0 10102B PRIN OF ACCT II AMES J 3.00 C 111 09:00 09:50 M
W F
And here's the error I get under Perl 5. (It works flawlessly in Perl
4):
Invalid type in unpack: ',' at ./roster.pl line 75, <ROSTERS> chunk 4.
"Line 75" is the line that does the unpacking. . . .
Any pointers would be tremendously appreciated.
Thanks.
Brian Capouch
brianc@palaver.net
brianc@saintjoe.edu
------------------------------
Date: 15 Jan 1999 18:29:10 GMT
From: mjtg@cus.cam.ac.uk (M.J.T. Guy)
Subject: Re: problem with use strict and use FileCache
Message-Id: <77o1dm$nt3$1@pegasus.csx.cam.ac.uk>
Ramanujam Parthasarathi <rpsarathi@usa.net> wrote:
>
>Always use the directive 'use strict' after importing (literally) all other
>packages. So, your use strict should be usually the last one. This way you
>need not care if other package modules have 'use(d ) strict' or not.
That's rubbish. "use strict" is lexically scoped, so has no effect on
other modules you "use". A module is compiled with 'strict' iff it
does a "use strict" itself.
But you can be forgiven for not knowing this, since "perldoc strict"
is entirely silent on the matter. :-(
Mike Guy
------------------------------
Date: 15 Jan 1999 16:50:57 GMT
From: Blain Nelson <blainn@worldnet.att.net>
Subject: Re: Regex challenge
Message-Id: <369F7134.E4D24F6A@worldnet.att.net>
Eric Smith wrote:
>
> Hi perl
>
> Double barrelled s/gun/question/ ;)
>
> 1) I want to match a word, say `table' but the character \& or ampersand
> can appear anywhere in table so all these are legal:
> \&table
> t\&able
> ta\&ble
> ... [snip] ...
> table\&
>
> any elegant solutions for my regex?
>
Assuming the word is fixed, what's wrong with good old
/\&?t\&?a\&?b\&?l\&?e\&?/ && (tr/\&/\&/==1);
aside from a little LTS?
> 2) I want to march a lower case, upper case or mixed word and _replace_ it
> with the same case layout in the new word
>
> so
> Table becomes Chair
> TABLE becomes CHAIR
> table becomes chair
>
Beats me.
> thanx guys.
>
> this list is so big, so please cc me in case I miss a gem.
>
Doubt this qualifies as a gem.
> --
> Eric Smith
Take care,
Blain
--
Celebrate Ideological Diversity
Tolerate Conservatism
http://www.blainn.cc/
blain@blainn.cc ICQ:19857966 anon-20630@anon.twwells.com
------------------------------
Date: Fri, 15 Jan 1999 11:28:15 -0600
From: tadmc@metronet.com (Tad McClellan)
Subject: Re: Regex challenge
Message-Id: <frtn77.cnh.ln@magna.metronet.com>
Eric Smith (eric@nafex.comi) wrote:
: 1) I want to match a word, say `table' but the character \& or ampersand
: can appear anywhere in table so all these are legal:
: \&table
: t\&able
: ta\&ble
: table\&
: any elegant solutions for my regex?
I cannot think of one.
Would an inelegant solution do?
----------------------
#!/usr/bin/perl -w
use strict;
while (<DATA>) {
my $pattern = pattern('table');
while ( /($pattern)/g ) {
print "matched '$1'\n";
}
}
sub pattern {
my($word) = @_;
my $pattern;
### construct length($word)+1 alternatives
foreach my $i ( 0 .. length($word) ) {
my $subpat = $word;
substr($subpat, $i, 0) = '\\\\&';
$pattern .= "$subpat|";
}
chop $pattern; # remove extra trailing vertical bar
return $pattern;
}
__DATA__
a \&table and a t\&able on this line
a ta\&ble and a tab\&le on this line
a tabl\&e and a table\& on this line
----------------------
: 2) I want to march a lower case, upper case or mixed word and _replace_ it
: with the same case layout in the new word
: so
: Table becomes Chair
: TABLE becomes CHAIR
: table becomes chair
----------------------
#!/usr/bin/perl -w
use strict;
while (<DATA>) {
s/(table)/ template($1, 'chair') /gie;
print;
}
sub template {
my($template, $replace) = @_;
my $case_matched; # return value
die "'$template' and '$replace' are not the same length\n"
unless length($template) == length($replace);
foreach my $i ( 0 .. length($template)-1 ) {
if ( substr($template, $i, 1) =~ /[A-Z]/ )
{ $case_matched .= uc(substr($replace, $i, 1)) }
else
{ $case_matched .= lc(substr($replace, $i, 1)) }
}
return $case_matched;
}
__DATA__
a table and a Table on this line
a Table and a TABLE on this line
a TABLE and a TablE on this line
a TablE and a table on this line
----------------------
: thanx guys.
You're welcome.
: this list is so big, so please cc me in case I miss a gem.
Sorry.
Ask it here, get the answer here ('cause you may not be the
only person here that wants to see the answer).
[real newsreaders allow you to autoselect interesting things.
tell it that your thread is interesting ;-)
]
[ www.dejanews.com has a searchable archive of newsgroups.
search there to make sure you don't miss a gem
]
--
Tad McClellan SGML Consulting
tadmc@metronet.com Perl programming
Fort Worth, Texas
------------------------------
Date: 15 Jan 1999 18:52:40 GMT
From: abigail@fnx.com (Abigail)
Subject: Re: Regex challenge
Message-Id: <77o2po$899$4@client2.news.psi.net>
Eric Smith (eric@nafex.comi) wrote on MCMLXIII September MCMXCIII in
<URL:news:slrn79ueln.2m2.eric@eric.nafex.com>:
$$
$$ 1) I want to match a word, say `table' but the character \& or ampersand
$$ can appear anywhere in table so all these are legal:
$$ \&table
$$ t\&able
$$ ta\&ble
$$ ... [snip] ...
$$ table\&
$$
$$ any elegant solutions for my regex?
What do you mean? The single character '&', or the two characters '\&'?
Can the '&' appear more than once? More than once on the same place?
Assuming you mean the character '&', allowed to appear more than once,
but at most once on the same place:
m {${\('&?' . (join '&?' => split // => 'table') . '&?')}};
Abigail
------------------------------
Date: Fri, 15 Jan 1999 16:52:54 GMT
From: jhall@idiglobal.com
Subject: Re: script produced no output
Message-Id: <77nrp1$gkb$1@nnrp1.dejanews.com>
Did you remember the header? Content-type: text/html\n\n ?
In article <01be3fba$a69fa5a0$7c48a8c0@PC124.alb.se>,
"mikael j" <mj@alb.se> wrote:
> I get the message "script produced no output " when my gustbook script are
> going to write to the guestbook HTML-page. It seems like the information
> disappear from the webserver. Can anyone help me with this?
>
> I use a perl script on a IIS 3.0 server.
>
> Mikael Johansson
> mj@alb.se
>
-----------== Posted via Deja News, The Discussion Network ==----------
http://www.dejanews.com/ Search, Read, Discuss, or Start Your Own
------------------------------
Date: Fri, 15 Jan 1999 08:53:57 -0800
From: lr@hpl.hp.com (Larry Rosler)
Subject: Re: Searching a string, with a headache
Message-Id: <MPG.1109128097b7d896989993@nntp.hpl.hp.com>
In article <369F4BE4.5B934ACA@link-maker.com>, webmaster@link-maker.com
says...
> all I can say is
> @stuff=split('|',$line);
> @more=split('*',$stuff[0])
I think you have overlooked that despite those misleading single-quotes,
the argument to 'split' is a regex. I prefer to make it explicit:
@stuff=split(/\|/, $line);
@more=split(/\*/, $stuff[0])
--
(Just Another Larry) Rosler
Hewlett-Packard Company
http://www.hpl.hp.com/personal/Larry_Rosler/
lr@hpl.hp.com
------------------------------
Date: Fri, 15 Jan 1999 16:48:34 GMT
From: jhall@idiglobal.com
Subject: Re: Which Perl reference book?
Message-Id: <77nrgt$gfm$1@nnrp1.dejanews.com>
Both are good books. The cookbook is more examples and the Programming perl
I believe is a better "Reference". The cookbook has great examples and
ideas, but to search for answers I find the programming perl book easier and
a little better.
Jayce^
In article <77k5qr$cer$1@nnrp1.dejanews.com>,
bnelissen@hotmail.com wrote:
> Hi,
>
> I recently started learning Perl, and bought "Learning Perl (2nd edition).
> However, I'd like to buy also a reference book and would like to know which
> one is best:
>
> Programming Perl (2nd Edition)
> The Perl Cookbook
>
> Has anybody compared these two?
>
> Thanks in advance.
>
> Bart
>
> -----------== Posted via Deja News, The Discussion Network ==----------
> http://www.dejanews.com/ Search, Read, Discuss, or Start Your Own
>
-----------== Posted via Deja News, The Discussion Network ==----------
http://www.dejanews.com/ Search, Read, Discuss, or Start Your Own
------------------------------
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 4660
**************************************