[7487] in Perl-Users-Digest
Perl-Users Digest, Issue: 1113 Volume: 8
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Thu Oct 2 05:17:25 1997
Date: Thu, 2 Oct 97 02:00:28 -0700
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)
Perl-Users Digest Thu, 2 Oct 1997 Volume: 8 Number: 1113
Today's topics:
accessing a printer's status via socket?... <scoler@earthlink.net>
Re: Building perl 5.004_01 (Martien Verbruggen)
Re: Building perl 5.004_01 <bholzman@mail.earthlink.net>
Re: Building perl 5.004_01 <lsheldon@creighton.edu>
Re: Can't debug a perl script. (Ilya Zakharevich)
Re: expect lib for perl? <ccr@jordan.uni-paderborn.de>
Re: Generating bit patterns "00000000" .. "11111111" (Bart Lateur)
MSQL interface <s1095261@frodo.student.gu.edu.au>
multipart forms <pat@progsoc.uts.edu.au>
multipart forms <pat@progsoc.uts.edu.au>
Re: Multiple Simultaneous prints??? (Wolfgang Viechtbauer)
Re: Multiple Simultaneous prints??? (Wolfgang Viechtbauer)
Re: Multiple Simultaneous prints??? (Wolfgang Viechtbauer)
Re: Mysql in Perl <bob.basques@stpaul.gov>
Re: Mysql in Perl (Martien Verbruggen)
Re: Newbie ques: How to concatenate two strings? (Joseph)
Newbie: absolute file path's <emil.granstrom@era.ericsson.se>
Re: NT 4 and PERL <jurlwin@access.digex.net>
oraperl <mari.mortell@Sun.COM>
Re: perl c-link indenter (Martien Verbruggen)
post-query form help! <sac31277@saclink.csus.edu>
Re: regex problem (brian d foy)
Re: regex problem (Martien Verbruggen)
Re: Wanted: Wall/Schwartz book (1st ed) <seay@absyss.fr>
Digest Administrivia (Last modified: 8 Mar 97) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: Thu, 02 Oct 1997 00:49:47 -0700
From: Stephen Cole <scoler@earthlink.net>
Subject: accessing a printer's status via socket?...
Message-Id: <3433521B.1B5C@earthlink.net>
I am having a devil of a time with this problem:
I'm trying to write a program that will continuously monitor
a certain plotter's status and if it finds that it's not
responding (i.e. it's off-line), it will send mail to the
appropriate people.
This would be *MUCH* easier if this plotter would
show up using "lpstat" or "lpq" or even "lpc" but it does
not. This plotter has it's own host & all the in que files
& out que files reside on it. Incidentally, the plotter is
listed as /dev/sy03.
Now, I do have a perl script (similiar to the many
client scripts out there) that can attempt to retrieve a
remote host's local time but this, of course, only reflects
that the host is operational, not that the plotter is still
running ok.
We currently can check the que of this plotter & it's
status using a C program that (I think) was developed by the
plotter's manufacturer. The plotter is an old Synergy electrostatic
plotter and the que program is sycom & sycom_d. I don't know
if anyone out there has any experience with this plotter.
If anyone has any similiar experiences or suggestions,
I'm all ears..
Thanks in advance-
Stephen Cole
------------------------------
Date: 2 Oct 1997 02:49:17 GMT
From: mgjv@comdyn.com.au (Martien Verbruggen)
Subject: Re: Building perl 5.004_01
Message-Id: <60v23d$d9o$1@comdyn.comdyn.com.au>
In article <Pine.HPP.3.95.971001193902.25276A-100000@bluejay.creighton.edu>,
"L. F. Sheldon, Jr." <lsheldon@creighton.edu> writes:
> Note (probably harmless): No library found for -lucb
Hi,
>From your crosspost to comp.sys.hp.hpux I gather that you're running
on HPUX. I don't know too much about the system specifically.
However, -lucb refers to libucb.a or libucb.so or libucb.whatever your
system likes to use as a dynamic library extension. It is a library
with BSD compatibility functions, and often is installed in
/usr/ucblib or /usr/ucb/lib. You can check your system to see if it is
installed somewhere, and if it is, adapt the path your linker searches
for the libraries. Otherwise you could consider moving it or copying
it to some place that your linker does search.
If you disable the build of ODBM_File, it just means that you won't be
able to use the ODBM database access functionality. if you are not
worried about that, just disable it :)
HTH,
Martien
--
Martien Verbruggen |
Webmaster www.tradingpost.com.au | For heaven's sake, don't TRY to be
Commercial Dynamics Pty. Ltd. | cynical. It's perfectly easy to be
NSW, Australia | cynical.
------------------------------
Date: Wed, 01 Oct 1997 23:01:55 -0400
From: Benjamin Holzman <bholzman@mail.earthlink.net>
To: "L. F. Sheldon, Jr." <lsheldon@creighton.edu>
Subject: Re: Building perl 5.004_01
Message-Id: <34330EA3.B7687657@mail.earthlink.net>
[posted & mailed]
> What breaks if I tell "Configure" to leave ODBM_File out of the build?
The ability to 'use ODBM_File'. Since ODBM_File is the last class which
AnyDBM_File (and therefore dbmopen) will inherit from, and SDBM_File is
_sure_ to be there, I don't think you have to worry. _If_ you had
existing code which 'use(d) ODBM_File', then you might care.
Benjamin Holzman
------------------------------
Date: Thu, 2 Oct 1997 01:38:21 -0500
From: "L. F. Sheldon, Jr." <lsheldon@creighton.edu>
Subject: Re: Building perl 5.004_01
Message-Id: <Pine.HPP.3.95.971002013417.29491B-100000@bluejay.creighton.edu>
On 2 Oct 1997, Martien Verbruggen wrote:
> In article <Pine.HPP.3.95.971001193902.25276A-100000@bluejay.creighton.edu>,
> "L. F. Sheldon, Jr." <lsheldon@creighton.edu> writes:
> > Note (probably harmless): No library found for -lucb
>
> From your crosspost to comp.sys.hp.hpux I gather that you're running
> on HPUX. I don't know too much about the system specifically.
Yup.
> However, -lucb refers to libucb.a or libucb.so or libucb.whatever your
> system likes to use as a dynamic library extension. It is a library
> with BSD compatibility functions, and often is installed in
> /usr/ucblib or /usr/ucb/lib. You can check your system to see if it is
> installed somewhere, and if it is, adapt the path your linker searches
> for the libraries. Otherwise you could consider moving it or copying
> it to some place that your linker does search.
"find" didn't find any files with the string "libucb" in their names in
/usr anywhere.
>From that I am going to infer that we can not possibly ber running
anything with "ODBM" in it--so I can safely (as "safely" as anything I do,
I guess) turn that code off in perl.
Thanks to the several folk who have offered help.
> If you disable the build of ODBM_File, it just means that you won't be
> able to use the ODBM database access functionality. if you are not
> worried about that, just disable it :)
What, _me_ worry?
Thanks.
--
-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
. .
- L. F. (Larry) Sheldon, Jr. -
. Unix Systems Administration .
- Creighton University Computer Center-Old Gym -
. 2500 California Plaza .
- Omaha, Nebraska, U.S.A. 68178 We are all faced with -
. lsheldon@creighton.edu great opportunities .
- 402 280-2254 (work) brilliantly disguised as -
. 402 681-4726 (cellular) impossible situations. .
- 402 332-4622 (residence) -
. Bits and Pieces .
-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
------------------------------
Date: 2 Oct 1997 02:40:08 GMT
From: ilya@math.ohio-state.edu (Ilya Zakharevich)
Subject: Re: Can't debug a perl script.
Message-Id: <60v1i8$9hc@agate.berkeley.edu>
In article <34322A19.41C6@ansf.alcatel.fr>,
Pierre BERGDOLT <Pierre.Bergdolt@ansf.alcatel.fr> wrote:
> Hi perl world!
>
> I have a problem with a perl script called "cc_upvw".
>
> If I run:
>
> "perl cc_upvw" or "perl -w cc_upvw"
>
> this works fine.
>
> But if I run:
>
> "perl -d cc_upvw"
>
> I get the following message:
>
> Stack dump during die enabled outside of evals.
>
> Loading DB routines from perl5db.pl patch level 0.94
> Emacs support available.
>
> Enter h or `h h' for help.
>
> Stack dump during die enabled outside of evals.
>
> Loading DB routines from perl5db.pl patch level 0.94
> Emacs support available.
>
> Enter h or `h h' for help.
>
> Got SEGV!
> Signal SEGV: No such file or directory
> Resources lost
I do not know about duplicated header, but a similar segfault was
reported by a guy who had T::ReadKey installed under 5.003, which
would fail with 5.004 (?!).
Try
env PERLDB_OPTS=R=0 perl -d cc_upvw
If this works, you need (at least) to reinstall TRL::Perl and TRK.
Ilya
------------------------------
Date: Thu, 2 Oct 1997 10:52:42 +0200
From: Christopher Creutzig <ccr@jordan.uni-paderborn.de>
Subject: Re: expect lib for perl?
Message-Id: <Pine.GSO.3.95.971002103632.21584D-100000@jordan.uni-paderborn.de>
On 29 Sep 1997, Danny R. Faught wrote:
> There are many esoteric features of expect that aren't likely to all
> be available from perl in the near future. For example, the send_human
> function which randomizes the inter-character arrival time.
A quick shot at that looks like
#!/usr/local/bin/perl -w
sub send_human {
my $save = $|;
$| = 1;
foreach ( split(//, shift(@_))) {
select(undef,undef,undef, rand()/2.0);
print;
}
$| = $save;
}
&send_human("nur ein kleiner Test.\n");
__END__
You would need to select() the filehandle to print to before calling
send_human. The speed of output is a bit beyond what I think to be usual
typing speed for most people, but that's easily adjustable.
> Not that it's difficult, there just hasn't been a volunteer to port
> all those features to perl.
Anyone collecting them?
regards,
Christopher Creutzig
------------------------------
Date: Thu, 02 Oct 1997 07:43:21 GMT
From: bart.mediamind@tornado.be (Bart Lateur)
Subject: Re: Generating bit patterns "00000000" .. "11111111"
Message-Id: <34344f82.2559450@news.tornado.be>
Ricky Roque <ricky.roque@bigfoot.com> wrote:
>I'm trying to generate pattern like the following
> "00000000"
> "00000001"
> "00000010"
> :
> :
> "11111110"
> "11111111"
I'd think about doin this using sprintf. But sprintf doesn't seem to be
able to format numbers as binary.
Why not?
Bart.
------------------------------
Date: Thu, 2 Oct 1997 13:04:50 +1000
From: "PRASHANTH N.R. RAGHAVENDRA RAO" <s1095261@frodo.student.gu.edu.au>
Subject: MSQL interface
Message-Id: <Pine.SOL.3.91.971002124924.6390A-100000@frodo.student.gu.edu.au>
Hello
I am a novice perl programmer trying to interface msql to www.
I am able to insert, search and display records. But I am not able to
delete or update the database. When I modify the name in the textfield,
nothing happens when I reload. I am putting the code I am using below
Thanks in advance for any help.
script is like this
#!/usr/local/bin/perl
use CGI;
use Msql;
BEGIN {
unshift(@INC,("/opt/lib/perl5/site_perl"));
}
$HOST="kurango.cit.gu.edu.au";
$DB="cit";
$p = new CGI;
print $p->header;
print $p->start_html;
$name = $p->param('name');
$password = $p->param('password');
if(!($dbh = Msql->Connect($HOST,$DB))){
print ("cannot connect to database:$Msql::db_errstr\n");
die;
}
if(!($dbh->Query("update authentication set
name='$name',password='$password' where name='$name'"))){
print("An error:$Msql::db_errstr\n");
} else {
print"modification done\n"
}
------------------------------
Date: Thu, 02 Oct 1997 14:57:26 +1000
From: Patrick Kennedy <pat@progsoc.uts.edu.au>
Subject: multipart forms
Message-Id: <343329B6.3F99@progsoc.uts.edu.au>
hello
i'm writing a for to allow uploading documentation files, and i have
decided to use CGI.pm. My script works fine, except when i have the
ENCTYPE="multipart/form-data" attribute in the FORM tag. The webserver
(Appache ) gives an internal server error when this attribute is
inserted.
any ideas? it sounds like a problem with the multipart CGI.pm modules
which have been installed on our server...can anyone confirm this?
thanks in advance
please reply via e-mail too
--
Pat Kennedy % http://www.progsoc.uts.edu.au/~pat/ %
pat@progsoc.uts.edu.au
Computer Systems Engineer % UTS, Sydney AU % pskenned@acs.itd.uts.edu.au
------------------------------
Date: Thu, 02 Oct 1997 15:02:50 +1000
From: Patrick Kennedy <pat@progsoc.uts.edu.au>
Subject: multipart forms
Message-Id: <34332AFA.41EE@progsoc.uts.edu.au>
hello
i'm writing a for to allow uploading documentation files, and i have
decided to use CGI.pm. My script works fine, except when i have the
ENCTYPE="multipart/form-data" attribute in the FORM tag. The webserver
(Appache - not sure which version) gives an internal server error when
this attribute is inserted.
any ideas? it sounds like a problem with the multipart CGI.pm modules
which have been installed on our server...can anyone confirm this?
thanks in advance
please reply via e-mail too
--
Pat Kennedy % http://www.progsoc.uts.edu.au/~pat/ %
pat@progsoc.uts.edu.au
Computer Systems Engineer % UTS, Sydney AU % pskenned@acs.itd.uts.edu.au
------------------------------
Date: Thu, 02 Oct 1997 05:04:20 GMT
From: wviecht@rs6000.cmp.ilstu.edu (Wolfgang Viechtbauer)
Subject: Re: Multiple Simultaneous prints???
Message-Id: <34332aa4.6831702@news.ilstu.edu>
>>What happens if two or more people at the same time submit their data
>>with a form, that has the following Perl script to write the data to a
>>text file?
>
>don't try to find out ;) lock the file in some fashion (see the
>Perl FAQs for more info).
I looked at the FAQ but did not find anything pertaining to the
problem. Could you help me out? Any direct suggestions for improving
the script?
open (DATA, ">>/data.txt")
|| die ("Couldn't write to data file.\n");
&ReadParse;
print DATA (($in{question1} eq "") ? "9" : $in{question1});
print DATA " ",(($in{question2} eq "") ? "9" : $in{question2});
print DATA " ",(($in{question3} eq "") ? "9" : $in{question3}),"\n";
close DATA;
How do I lock the file so that only one person at a time can write to
the data file???
Wolfgang
------------------------------
Date: Thu, 02 Oct 1997 05:44:40 GMT
From: wviecht@rs6000.cmp.ilstu.edu (Wolfgang Viechtbauer)
Subject: Re: Multiple Simultaneous prints???
Message-Id: <34333410.9243916@news.ilstu.edu>
>>>What happens if two or more people at the same time submit their data
>>>with a form, that has the following Perl script to write the data to a
>>>text file?
>>
>>don't try to find out ;) lock the file in some fashion (see the
>>Perl FAQs for more info).
>
>I looked at the FAQ but did not find anything pertaining to the
>problem. Could you help me out? Any direct suggestions for improving
>the script?
>
>open (DATA, ">>/data.txt")
> || die ("Couldn't write to data file.\n");
>&ReadParse;
>
>print DATA (($in{question1} eq "") ? "9" : $in{question1});
>print DATA " ",(($in{question2} eq "") ? "9" : $in{question2});
>print DATA " ",(($in{question3} eq "") ? "9" : $in{question3}),"\n";
>close DATA;
>
>
>
>How do I lock the file so that only one person at a time can write to
>the data file???
I think I found the answer to my question:
While (-f data.lock){
select (undef, undef, undef, 0.1);}
open (LOCKFILE, ">data.lock);
open (DATA, ">>/data.txt")
|| die ("Couldn't write to data file.\n");
&ReadParse;
print DATA (($in{question1} eq "") ? "9" : $in{question1});
print DATA " ",(($in{question2} eq "") ? "9" : $in{question2});
print DATA " ",(($in{question3} eq "") ? "9" : $in{question3}),"\n";
close DATA;
close (LOCKFILE);
unlink (data.lock);
That should do the trick, right?
Any suggestions or comments for improvement?
Wolfgang
------------------------------
Date: Thu, 02 Oct 1997 08:07:42 GMT
From: wviecht@rs6000.cmp.ilstu.edu (Wolfgang Viechtbauer)
Subject: Re: Multiple Simultaneous prints???
Message-Id: <3433562b.17976966@news.ilstu.edu>
On Thu, 02 Oct 1997 05:44:40 GMT, wviecht@rs6000.cmp.ilstu.edu
(Wolfgang Viechtbauer) wrote:
>While (-f data.lock){
> select (undef, undef, undef, 0.1);}
>open (LOCKFILE, ">data.lock);
>
>open (DATA, ">>/data.txt")
> || die ("Couldn't write to data file.\n");
>&ReadParse;
>print DATA (($in{question1} eq "") ? "9" : $in{question1});
>print DATA " ",(($in{question2} eq "") ? "9" : $in{question2});
>print DATA " ",(($in{question3} eq "") ? "9" : $in{question3}),"\n";
>close DATA;
>
>close (LOCKFILE);
>unlink (data.lock);
>
>
>That should do the trick, right?
>
>Any suggestions or comments for improvement?
I keep posting to myself :-) ... oh well ...
So I should use the flock() command. Okay, okay. But what if you are
not running your scripts on a UNIX system??? Won't that crash your
system?
So what about:
sysopen(FH, "file.lock", O_WRONLY|O_EXCL|O_CREAT, 0644)
or die "can't open file.lock: $!":
What the heck is going on in here?
In general then: What should you do if you cannot use the flock()
command, because you are running your scripts on Windows NT or Windows
95?
Wolfgang
------------------------------
Date: Wed, 01 Oct 1997 20:32:40 -0500
From: bob basques <bob.basques@stpaul.gov>
To: thomas@shurflo.com
Subject: Re: Mysql in Perl
Message-Id: <3432F9B8.24AB@stpaul.gov>
Thomas Beardshear wrote:
>
> Any one know how to get mysql to return data to a browser?
>
> I can't get the following to return the user list to the browser.
> It works fine from a shell.
>
> --------------------------------------------------------
> #!/bin/bash
>
> echo "Content-Type: text/html"
> echo ""
> echo "Hello"
> mysql -e 'select user from user' mysql
> echo "there"
> --------------------------------------------------------
> --
using PERL its something like this:
print "Content-type: text/html\n\n"
You may need two(2) newlines. Its a real stickler in PERL anyway.
bobb
--
Bob Basques
bob.basques@stpaul.gov - WORK
blammo@win.bright.net - HOME
www.stpaul.gov - 3rd of a bunch of (Volunteer) Webmasters
bridges.stpaul.gov - Webmaster
25 W. 4th St. PHONE (612)266-6188
900 C.H.A. Bridge Div. FAX (612)292-6315
St. Paul, Mn. 55102
------------------------------
Date: 2 Oct 1997 02:31:32 GMT
From: mgjv@comdyn.com.au (Martien Verbruggen)
Subject: Re: Mysql in Perl
Message-Id: <60v124$d4t$1@comdyn.comdyn.com.au>
In article <34313B5C.5091@shurflo.com>,
Thomas Beardshear <thomas@shurflo.com> writes:
> #!/bin/bash
>
> echo "Content-Type: text/html"
> echo ""
> echo "Hello"
> mysql -e 'select user from user' mysql
> echo "there"
This is not perl. It isn't even a question about shell scripting. It
seems to be a question about CGI.
The ever helpful perl community has a bunch of CGI FAQs answered in
http://www.perl.com/CPAN/doc/FAQs/cgi/idiots-guide.html
and
http://www.perl.com/CPAN/doc/FAQs/cgi/perl-cgi-faq.html
and
http://www.perl.com/CPAN/doc/manual/html/pod/perlfaq9.html
I suggest you read through those a bit.
HTH,
Martien
--
Martien Verbruggen |
Webmaster www.tradingpost.com.au | I'm just very selective about what I
Commercial Dynamics Pty. Ltd. | accept as reality - Calvin
NSW, Australia |
------------------------------
Date: Thu, 02 Oct 1997 05:26:23 GMT
From: jglosz@san.rr.com (Joseph)
Subject: Re: Newbie ques: How to concatenate two strings?
Message-Id: <34333060.14992601@news-server>
Thanks :)
I went with the dot operator, and it works perfectly. Thanks for
everyone's help...
------------------------------
Date: Thu, 02 Oct 1997 10:06:37 +0100
From: Emil Granstrom <emil.granstrom@era.ericsson.se>
Subject: Newbie: absolute file path's
Message-Id: <3433641D.6BCA5375@era.ericsson.se>
Hello.
I am pretty new to Perl and I have stumbled on to a problem.
I need to expand a relative pathname to a file to an absolute one.
An example:
current dir: ~/test
relative filename: ../IMAGES/myfile.eps
I need:
absolute filename /export/users/lzstm1/IMAGES/myfile.eps
Is there a function to expand the relative filename and get the absolute
one ?
The only thing I can think of is breaking the relative filename into a
path and filename, do a 'cd' to the path and print current working dir
and store that as the absolute path, is there an easier way ?
I need to do this for a lot of files when parsing an SGML document.
TIA.
Best Regards
Emil
------------------------------
Date: Wed, 1 Oct 1997 23:13:15 -0400
From: "Jeff Urlwin" <jurlwin@access.digex.net>
Subject: Re: NT 4 and PERL
Message-Id: <60v3ha$a7j$1@news2.digex.net>
Matt wrote in article <01bccecd$0cad6900$198345c6@nt1>...
>I need help with something.
>
>I have NT 4.0 running IIS 3.0 and PERL, the latest build. Everytime I try
>to execute a pl file in a html document, the browser tries to download the
>script. The registry is perfect, I think. I check all the settings that
>were in the FAQ.
Try checking your settings against what is on my home page.
http://www.access.digex.net/~jurlwin
Note, that it's helpful to say, for the NT platform, that you are using Perl
version 5.004_02 or send the output of perl -V, so that people know what you
mean by the latest perl...
Jeff
------------------------------
Date: Wed, 01 Oct 1997 21:19:34 -0700
From: MARI J MORTELL <mari.mortell@Sun.COM>
Subject: oraperl
Message-Id: <343320D6.2172@Sun.COM>
Hi,
I am interested in oraperl.
Can anyone point me to information on oraperl?
Thank you!
Mari Mortell
------------------------------
Date: 2 Oct 1997 02:37:05 GMT
From: mgjv@comdyn.com.au (Martien Verbruggen)
Subject: Re: perl c-link indenter
Message-Id: <60v1ch$d4t$2@comdyn.comdyn.com.au>
In article <60ul5l$8h1$1@vhoorl.rli-net.net>,
millerd@vhoorl.rli-net.net (root) writes:
> Does anyone know where I can find a c-linke indenter for perl?
If you mean something like indent, no I don't, but there is something
which is similar to cb (c beautifier), surprisingly called pb (perl
beautifier). It is fairly primitive, so you might need to adapt the
code to reflect your preferences.
Have a look at:
http://www.arachnoid.com/lutusp/ftp/cgi/pb.txt
Martien
--
Martien Verbruggen |
Webmaster www.tradingpost.com.au | In a world without fences, who needs
Commercial Dynamics Pty. Ltd. | Gates?
NSW, Australia |
------------------------------
Date: Mon, 29 Sep 1997 13:08:50 -0700
From: MT <sac31277@saclink.csus.edu>
Subject: post-query form help!
Message-Id: <34300AD2.1DBE@saclink.csus.edu>
Hi everyone.
I am in desperate need of help getting my script to work on my WinNT4.0
server. The script is a post-query.c program and will not work from
the web browser! I keep getting Server Error!...and it links with
misconfiguration. I am using the Netscape Enterprise server for my
cgi-bin directory. I also have tried using the script as .exe/.cgi
on my cgi directory with proper permissions. and still nothing.
I would appreciate any help you might have.
Thanks a bunch!
Marjan
------------------------------
Date: Wed, 01 Oct 1997 22:34:07 -0400
From: comdog@computerdog.com (brian d foy)
Subject: Re: regex problem
Message-Id: <comdog-ya02408000R0110972234070001@news.panix.com>
In article <3432F3E4.79A959BB@radyn.com>, Michael Veve <mav@radyn.com> wrote:
>Can somebody tell me why $11 in the following perl excerpt is "6" and
>not "+", "-", or ";"? I am running Perl 5.001, Unofficial patchlevel
>1m, Perl for Win32 Build 109, Built Jul 15 1996@17:36:29 on WinNT 4.0
>
>
> $gausscode =
>"(+o1-o4+u5+o6+o7-o8-o9-u10-o11+o12+u13+o14+u15-u9+u6+o5-o10-u11-u16+u1-u8+u7-u4-o16+u12+o15+u14+o13;;)";
>
> $r2_found = $gausscode =~
>s/([+-])([ou])(\d+)([+-])\2(\d+)([+-;].*)([+-][ou])(\3|\5)([+-][ou])
>(\3|\5)([+-;])/$6$11/;
^
|
+------- guess what comes between + and ; in ASCII! 6!
you need to either escape that hypen (see below) or put it at the
end of the character class. thank god i realized that. i wasn't
planning on taking the Owl book with me on the subway :)
btw, this looks rather interesting. are you playing with magnets?
(don't forward that answer to the newsgroup unless it has perl stuff!)
************
#!/usr/bin/perl
my $gausscode = '(+o1-o4+u5+o6+o7-o8-o9-u10-o11+o12+u13+o14+u15-' .
'u9+u6+o5-o10-u11-u16+u1-u8+u7-u4-o16+u12+o15+u14+o13;;)';
$gausscode =~ m/([+-]) # 1 +
([ou]) # 2 o
(\d+) # 3 1
([+-]) # 4 -
\2 # o
(\d+) # 5 4
([+-;].*) # 6 + here's where it gets tricky
([+-][ou]) # 7 -u
(\3|\5) # 8 4
([+-][ou]) # 9 -o
(\3|\5) #10 1
([+\-;]) #11 !!!! that hyphen is literal!
/x;
print <<"HERE";
1: $1
2: $2
3: $3
4: $4
5: $5
6: $6
7: $7
8: $8
9: $9
10: $10
11: $11
HERE
__END__
1: +
2: o
3: 7
4: -
5: 8
6: -o9-u10-o11+o12+u13+o14+u15-u9+u6+o5-o10-u11-u16+u1
7: -u
8: 8
9: +u
10: 7
11: -
--
brian d foy <comdog@computerdog.com>
NY.pm - New York Perl M((o|u)ngers|aniacs)* <URL:http://ny.pm.org/>
CGI Meta FAQ <URL:http://computerdog.com/CGI_MetaFAQ.html>
------------------------------
Date: 2 Oct 1997 03:21:11 GMT
From: mgjv@comdyn.com.au (Martien Verbruggen)
Subject: Re: regex problem
Message-Id: <60v3v7$dea$1@comdyn.comdyn.com.au>
In article <3432F3E4.79A959BB@radyn.com>,
Michael Veve <mav@radyn.com> writes:
> Can somebody tell me why $11 in the following perl excerpt is "6" and
> not "+", "-", or ";"? I am running Perl 5.001, Unofficial patchlevel
> $gausscode =
> "(+o1-o4+u5+o6+o7-o8-o9-u10-o11+o12+u13+o14+u15-u9+u6+o5-o10-u11-u16+u1-u8+u7-u4-o16+u12+o15+u14+o13;;)";
>
> $r2_found = $gausscode =~
> s/([+-])([ou])(\d+)([+-])\2(\d+)([+-;].*)([+-][ou])(\3|\5)([+-][ou])(\3|\5)([+-;])/$6$11/;
phew..
I took the liberty of rewriting this a bit, so it's a bit more legible:
(You will need 5.002 for this to work. The comments will break any
older version of perl. The whitespace should work on 5.000 and up, I
believe. I suggest you upgrade to 5.004_01 at least anyway :))
$gausscode =
"(+o1-o4+u5+o6+o7-o8-o9-u10-o11+o12+u13" .
"+o14+u15-u9+u6+o5-o10-u11-u16+u1-u8+u7" .
"-u4-o16+u12+o15+u14+o13;;)";
$r2_found = $gausscode =~
s{
([+-]) # $1 : a + or -
([ou]) # $2 : an o or u
(\d+) # $3 : all the digits you can find
([+-]) # $4 : a + or -
\2 # match what is in $2
(\d+) # $5 : all the digits
([+-;].*) # $6 : match any one of the characters between + and ;,
# followed by any number of characters (greedy)
#
([+-][ou]) # $7 : a + or - followed by either an o or u
(\3|\5) # $8 : match either $3 or $5
([+-][ou]) # $9 : a + or - followed by either an o or u
(\3|\5) # $10: match either $3 or $5
([+-;]) # $11: Match any one of the characters between + and ;
}{
$6$11 # Substitute the whole matched thing with $6$11
}x;
The error is very likely the pattern for $6 and $11. You are asking
for the whole character set between '+' and ';'. What you meant to do
(I suppose) is ask for either '+', '-' or ';'. You should use
something like:
[+;-]
to not use the special meaning of '-'. (besides, it looks like a funny
winking smily now :)). Alternatively, you can escape the - with a \,
but in my opinion, that is ugly and less readable.
HTH,
Martien
--
Martien Verbruggen | My friend has a baby. I'm writing down
Webmaster www.tradingpost.com.au | all the noises the baby makes so later
Commercial Dynamics Pty. Ltd. | I can ask him what he meant - Steven
NSW, Australia | Wright
------------------------------
Date: Thu, 02 Oct 1997 10:13:16 +0200
From: Doug Seay <seay@absyss.fr>
Subject: Re: Wanted: Wall/Schwartz book (1st ed)
Message-Id: <3433579C.1D9024AB@absyss.fr>
Gregory Glockner wrote:
>
> I am looking for a copy of the old version of the book "Programming perl"
> by Wall and Schwartz that covers Perl 4.0. I can only seem to find the
> newer version that covers Perl 5.0. If you have an extra copy of this
> book (ISBN 0-937175-64-1), please contact me by email. TIA.
Good luck. Ain't no way I'm gettin' rid of mine. It's a classic.
- doug
------------------------------
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 1113
**************************************