[15577] in Perl-Users-Digest
Perl-Users Digest, Issue: 2990 Volume: 9
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Tue May 9 11:15:49 2000
Date: Tue, 9 May 2000 08:15:27 -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: <957885327-v9-i2990@ruby.oce.orst.edu>
Content-Type: text
Perl-Users Digest Tue, 9 May 2000 Volume: 9 Number: 2990
Today's topics:
Re: looking for Parse::Yapp simple example <ter@my-deja.com>
Masking script name in browser <bjorn@xfertipro.com>
Re: Masking script name in browser <rootbeer@redcat.com>
Re: Masking script name in browser (Bart Lateur)
Re: methods reading in external file <billy@arnis-bsl.com>
Re: methods reading in external file (Eric Bohlman)
Re: methods reading in external file (Bart Lateur)
Re: methods reading in external file <iltzu@sci.invalid>
Net::SMTP module question <skpurcell@hotmail.com>
ODBC for Fox Pro or Dbase III files <bGhassemlou@yahoo.com>
Re: ODBC for Fox Pro or Dbase III files <jeff@vpservices.com>
Re: ODBC for Fox Pro or Dbase III files (Bart Lateur)
Re: Perl code to check for broken links <erick.jensen@unisys.com>
Re: Perl code to check for broken links <jeff@vpservices.com>
Re: Perl code to check for broken links <rootbeer@redcat.com>
Re: perl in NT .BAT files Question <DNess@Home.Com>
Re: Perl on SGI Question <rootbeer@redcat.com>
Re: Perl on SGI Question markhunnibell@my-deja.com
Re: perlex install error -51 <rootbeer@redcat.com>
Re: Printing Arrays <billy@arnis-bsl.com>
Re: Proper use of resources (was Re: more regexp madnes (Bart Lateur)
Re: Proper use of resources (was Re: more regexp madnes <uri@sysarch.com>
Re: Reading MS-Word Doc via PERL <sigvald.refsum@siemens.no>
Re: signal trapper <rootbeer@redcat.com>
Re: Socket Question- <rootbeer@redcat.com>
Re: Socket Question- <adams1015@worldnet.att.net>
Sorting MLDBM records dstutz@clip.de
Using IRIX 6.5 Perl 5.00502 to Access MS SQL 6.5 markhunnibell@my-deja.com
Re: using Perl's RE to do basic manipulation of a flex <rootbeer@redcat.com>
vec and bitwise or ? <gerdmeier@lucent.com>
Re: vec and bitwise or ? <andkaha@my-deja.com>
Re: vec and bitwise or ? <aqumsieh@hyperchip.com>
Digest Administrivia (Last modified: 16 Sep 99) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: Tue, 09 May 2000 08:00:54 GMT
From: Tim Richardson <ter@my-deja.com>
To: francois@fdesar.net
Subject: Re: looking for Parse::Yapp simple example
Message-Id: <8f8gjg$da2$1@nnrp1.deja.com>
In article <391537B2.90C3D146@fdesar.net>,
=?iso-8859-1?Q?Fran=E7ois=20D=E9sarm=E9nien?= <francois@fdesar.net>
wrote:
> > anyone has a simple, complete example of a Perl script that parses
> > something simple using Parse::Yapp.
> >
>
> Well, sorry to be late for this answer, but the clpm volume is so high
> I simply cannot follow it :-(
>
> Well, I wrote the Parse::Yapp module, so maybe I can help ;-)
>
> You're right, writing a grammar is not *that* difficult, but there are
> some pitfalls you should be aware, mostly when using rules which can
> be empty. The bison tutorial is a *very* good starting point to
understand
> those pitfalls.
>
> To put everything together, you've got with Parse-Yapp tarball two
examples:
>
> the first one is the (simple) Calc.yp, and the other one is the
YappParse.yp
> which is Parse::Yapp parser source.
>
>
These example files are not included in the ActiveState package for this
module (which is at version 1.01 in case it's a version problem).
However, I have now downloaded the CPAN module, which does include the
sample files.
Thanks,
Tim
--
Tim Richardson
(search string: qweeblebeast)
Sent via Deja.com http://www.deja.com/
Before you buy.
------------------------------
Date: Tue, 9 May 2000 11:49:42 +0200
From: "Björn Comhaire" <bjorn@xfertipro.com>
Subject: Masking script name in browser
Message-Id: <8f8mtk$oac$1@news1.skynet.be>
Hi,
I have a small Perl cgi script which returns the certificate of analysis for
some of our products. This is simply done by searching a delimited Ascii
file for the corresponding batch number and inserting the data found, into
an html template.
Everything works fine there, but my question is more of a cosmetic nature. I
would like to hide the name of the script (in this case ReadFile.cgi) from
the user. And either show no page name or something like COA.html as the
name of the returned page in the browser navigation window.
Is this possible ?
Thanks for the help !
Björn
--
________________________________
Björn Comhaire
FertiPro N.V. - Your partner in IVF and ART
www.fertipro.com
------------------------------
Date: Tue, 9 May 2000 04:26:01 -0700
From: Tom Phoenix <rootbeer@redcat.com>
Subject: Re: Masking script name in browser
Message-Id: <Pine.GSO.4.10.10005090424530.3921-100000@user2.teleport.com>
On Tue, 9 May 2000, Björn Comhaire wrote:
> I would like to hide the name of the script (in this case
> ReadFile.cgi) from the user. And either show no page name or something
> like COA.html as the name of the returned page in the browser
> navigation window.
It sounds as if you want to search for the docs, FAQs, and newsgroups
about browsers and how CGI programs can interact with them. Reading
comp.infosystems.www.authoring.cgi might be a good place to start. Cheers!
--
Tom Phoenix Perl Training and Hacking Esperanto
Randal Schwartz Case: http://www.rahul.net/jeffrey/ovs/
------------------------------
Date: Tue, 09 May 2000 12:57:51 GMT
From: bart.lateur@skynet.be (Bart Lateur)
Subject: Re: Masking script name in browser
Message-Id: <391b09db.14584564@news.skynet.be>
Björn Comhaire wrote:
>Everything works fine there, but my question is more of a cosmetic nature. I
>would like to hide the name of the script (in this case ReadFile.cgi) from
>the user. And either show no page name or something like COA.html as the
>name of the returned page in the browser navigation window.
>
>Is this possible ?
It depends on the server configuration. If you script can work in any
directory, without .pl or .cgi suffix, then it's easy. Just name your
script as if it was a folder, like "coa", and append a fake file name to
it. The URL becomes
http://www.yourserver.duh/path/to/script/coa/coa.html
Again: the script name is "coa", and it's in directory
"/path/to/script". The "/coa.html" is also passed to you CGI script,
through the environment variable $ENV{PATH_INFO}.
If your server doesn't allow just any name or any location, you can
still do it, but the name of your script will give it away, at least, a
bit.
http://www.yourserver.duh/cgi-bin/coa.cgi/coa.html
--
Bart.
------------------------------
Date: Tue, 09 May 2000 09:54:49 GMT
From: Ilja <billy@arnis-bsl.com>
Subject: Re: methods reading in external file
Message-Id: <8f8n94$kfd$1@nnrp1.deja.com>
In article <8f8b0b$72c$1@nnrp1.deja.com>,
bluesrift@aol.com wrote:
> In article <8f645t$n8i$1@nnrp1.deja.com>,
> Ilja <billy@arnis-bsl.com> wrote:
> > I guess you simply need to read the whole content of file into
> $content.
> >
> > IMHO the simpliest (and most efficient way) is:
> >
> > undef $/;
> > my $content = <FILE>;
> >
> > Please consult 'perldoc perlvar', section about $/ variable.
>
> Thanks for the info! After having read the perldoc discussion of $/ I
> can see how efficient it is to use the technique above. However, I
> remain uncertain exactly how to set $/ back to the default newline
> afterwards. Is it as simple as $/ = "\n";
>
Yes, you may simply assign to $/.
But I'd suggest to use 'local $/ = undef' in a block,
so the old value will be restored automatically.
See 'perldoc perlsub' for local details.
Ilja.
Sent via Deja.com http://www.deja.com/
Before you buy.
------------------------------
Date: 9 May 2000 10:45:01 GMT
From: ebohlman@netcom.com (Eric Bohlman)
Subject: Re: methods reading in external file
Message-Id: <8f8q7d$ha4$4@slb0.atl.mindspring.net>
bluesrift@aol.com wrote:
: In article <8f645t$n8i$1@nnrp1.deja.com>,
: Ilja <billy@arnis-bsl.com> wrote:
: > undef $/;
: > my $content = <FILE>;
: >
: > Please consult 'perldoc perlvar', section about $/ variable.
:
: Thanks for the info! After having read the perldoc discussion of $/ I
: can see how efficient it is to use the technique above. However, I
: remain uncertain exactly how to set $/ back to the default newline
: afterwards. Is it as simple as $/ = "\n";
You could do it that way, but I'd suggest doing:
my $content=do {local $/;<FILE>};
This confines the change to $/ to the enclosing block; upon exit from the
block the old value is automatically restored. The localization
automagically sets $/ to undef after saving the old value.
------------------------------
Date: Tue, 09 May 2000 12:42:09 GMT
From: bart.lateur@skynet.be (Bart Lateur)
Subject: Re: methods reading in external file
Message-Id: <3919070a.13863289@news.skynet.be>
Ilja wrote:
>But I'd suggest to use 'local $/ = undef' in a block,
>so the old value will be restored automatically.
You don't need to assign anything to $/ when localizing it. undef is the
default value if you don't assign anything.
{
local $/;
$content = <FILE>;
}
I propose localizing *FILE too, or possibly use a Filehandle (?) object
to prevent stepping on it's use in other, outer, places.
local *FILE;
--
Bart.
------------------------------
Date: 9 May 2000 13:38:05 GMT
From: Ilmari Karonen <iltzu@sci.invalid>
Subject: Re: methods reading in external file
Message-Id: <957878907.7742@itz.pp.sci.fi>
In article <8f8b0b$72c$1@nnrp1.deja.com>, bluesrift@aol.com wrote:
>Thanks for the info! After having read the perldoc discussion of $/ I
>can see how efficient it is to use the technique above. However, I
>remain uncertain exactly how to set $/ back to the default newline
>afterwards. Is it as simple as $/ = "\n";
A common idiom for this is:
my $file = do {local $/; <FILE>};
The "local" limits the scope of the change to the surrounding block.
Since we give no explicit local value for $/, it defaults to undef.
If the filehandle is known to be a regular file, the following idiom
has been found to be even more efficient:
read FILE, my $file, -s FILE;
In practice, both ways are very fast, and while the second approach
IMHO looks more readable, the first does have the advantage of working
even for streams of unknown length.
--
Ilmari Karonen - http://www.sci.fi/~iltzu/
Please ignore Godzilla and its pseudonyms - do not feed the troll.
------------------------------
Date: Tue, 9 May 2000 07:55:20 -0500
From: "spurcell" <skpurcell@hotmail.com>
Subject: Net::SMTP module question
Message-Id: <39180aa1$0$25107@wodc7nh1.news.uu.net>
Hello,
I am new to modules, and have a couple of questions.
1. Does Net::SMTP allow for file attachments?
2. And if it does, where do I find the documentation for doing it?
Thanks
Scott
------------------------------
Date: Tue, 09 May 2000 08:52:10 GMT
From: "bjg" <bGhassemlou@yahoo.com>
Subject: ODBC for Fox Pro or Dbase III files
Message-Id: <_kQR4.8410$55.145032@news2.rdc1.on.home.com>
I am trying to Open a Fox Pro Table and its Index Files, Search, Add
Records, Modify or Delete records.
So far all examples I have seen are for connecting to SQL tables. Is there
any way for using ODBC Fox Pro?
Any suggestions are appreciated.
Thanks
Behzad
bGhassemlou@home.com
------------------------------
Date: Tue, 09 May 2000 04:53:34 -0700
From: Jeff Zucker <jeff@vpservices.com>
Subject: Re: ODBC for Fox Pro or Dbase III files
Message-Id: <3917FC3E.96C70726@vpservices.com>
bjg wrote:
>
> I am trying to Open a Fox Pro Table and its Index Files, Search, Add
> Records, Modify or Delete records.
>
> So far all examples I have seen are for connecting to SQL tables. Is there
> any way for using ODBC Fox Pro?
> Any suggestions are appreciated.
DBD::xbase works with FoxPro files, AFAIK.
--
Jeff
------------------------------
Date: Tue, 09 May 2000 12:50:30 GMT
From: bart.lateur@skynet.be (Bart Lateur)
Subject: Re: ODBC for Fox Pro or Dbase III files
Message-Id: <391a07d1.14062502@news.skynet.be>
bjg wrote:
>I am trying to Open a Fox Pro Table and its Index Files, Search, Add
>Records, Modify or Delete records.
>
>So far all examples I have seen are for connecting to SQL tables. Is there
>any way for using ODBC Fox Pro?
I'm pretty sure there is a DBD driver for dBase files, but I don't know
which. See CPAN (<http://search.cpan.org/>). I think it's XBase.
Also on CPAN, I found modules "CodeBase" and "XBase", which look
promising.
--
Bart.
------------------------------
Date: Tue, 9 May 2000 09:35:38 -0400
From: "Erick Jensen" <erick.jensen@unisys.com>
Subject: Re: Perl code to check for broken links
Message-Id: <8f947b$fqt$1@mail.pl.unisys.com>
Too complicated. I found something a lot easier: LWP::Simple's get()
function. Here's what I mean:
use LWP::Simple;
sub TestLink {
my $psLink = $_[0];
if (get($psLink) ne undef) {
return "Good";
}
else {
return "Bad";
}
}
This sub will try to fetch the link and return whether it could fetch it or
not.
-Erick Jensen
"Tom Phoenix" <rootbeer@redcat.com> wrote in message
news:Pine.GSO.4.10.10005081913530.3921-100000@user2.teleport.com...
> On Mon, 8 May 2000, Erick Jensen wrote:
>
> > I am looking for some simple code to check whether a link is broken or
not
>
> Randal has several, a few with some amazing features.
>
> http://www.stonehenge.com/merlyn/WebTechniques/
>
> Enjoy!
>
> --
> Tom Phoenix Perl Training and Hacking Esperanto
> Randal Schwartz Case: http://www.rahul.net/jeffrey/ovs/
>
------------------------------
Date: Tue, 09 May 2000 07:49:00 -0700
From: Jeff Zucker <jeff@vpservices.com>
Subject: Re: Perl code to check for broken links
Message-Id: <3918255C.316D8FC4@vpservices.com>
Erick Jensen wrote:
> "Tom Phoenix" <rootbeer@redcat.com> wrote in message
> news:Pine.GSO.4.10.10005081913530.3921-100000@user2.teleport.com...
> >
> > Randal has several, a few with some amazing features.
> >
> > http://www.stonehenge.com/merlyn/WebTechniques/
> >
>
> Too complicated. I found something a lot easier:
Good idea. Ignore what the author of three of the top books on Perl has
said is the proper way to go about it and invent something of your own
without thinking about the consequences because thinking about the
consequences is "too complicated". You will go far, my boy.
--
Jeff
------------------------------
Date: Tue, 9 May 2000 08:04:20 -0700
From: Tom Phoenix <rootbeer@redcat.com>
Subject: Re: Perl code to check for broken links
Message-Id: <Pine.GSO.4.10.10005090754310.3921-100000@user2.teleport.com>
On Tue, 9 May 2000, Erick Jensen wrote:
> if (get($psLink) ne undef) {
You want the defined() function instead. And why not just ask for head(),
rather than get(), if you're only checking whether the URL does something
at the given moment? Cheers!
--
Tom Phoenix Perl Training and Hacking Esperanto
Randal Schwartz Case: http://www.rahul.net/jeffrey/ovs/
------------------------------
Date: Tue, 09 May 2000 14:51:11 GMT
From: David Ness <DNess@Home.Com>
Subject: Re: perl in NT .BAT files Question
Message-Id: <391825E3.7C27E258@Home.Com>
This message contained a typo (two colons in the http). The proper URL
appears to be:
http://www.oceanes.fr/~database/isampm.htm
philippe_cyk@my-deja.com wrote:
>
> Hi,
>
> I have just uploaded a C-ISAM module on my website
> Follow the link :
>
> http:://www.oceanes.fr/~database/isampm.htm
>
> Please mail me a bug report at philippe.cyk@wanadoo.fr
>
> Hope this helps
>
------------------------------
Date: Tue, 9 May 2000 03:47:39 -0700
From: Tom Phoenix <rootbeer@redcat.com>
Subject: Re: Perl on SGI Question
Message-Id: <Pine.GSO.4.10.10005090347120.3921-100000@user2.teleport.com>
On Mon, 8 May 2000, spurcell wrote:
> So anyway, my mission is to get the Perl running on the SGI running
> Irix 6.5.
Does this get you started?
http://www.cpan.org/ports/index.html#irix
--
Tom Phoenix Perl Training and Hacking Esperanto
Randal Schwartz Case: http://www.rahul.net/jeffrey/ovs/
------------------------------
Date: Tue, 09 May 2000 13:02:54 GMT
From: markhunnibell@my-deja.com
Subject: Re: Perl on SGI Question
Message-Id: <8f929k$voq$1@nnrp1.deja.com>
In article <3916e0ed$0$21854@wodc7nh1.news.uu.net>,
"spurcell" <skpurcell@hotmail.com> wrote:
> So anyway, my mission is to get the Perl running on the SGI running
Irix
> 6.5.
You can get all the info on Perl on SGI here:
http://reality.sgi.com/scotth/info/perl5.html
There is something important you need to know, though:
1. IRIX 6.5 contains a built in version of perl that is used by
the operating system, /usr/sbin/perl5.00404
2. The Freeware Perl you get from the above page is to be installed
in a DIFFERENT location, /usr/freeware/bin/perl5.00502-n32
Once you get the /usr/freeware/bin/perl installed, you can then apply
modules to it but you must use the full perl path to install them
so they get in the right place. Then, you also have to use this at the
top of your perl scripts to ensure the right perl is running:
#!/usr/freeware/bin/perl
Mark Hunnibell
Sent via Deja.com http://www.deja.com/
Before you buy.
------------------------------
Date: Tue, 9 May 2000 04:00:08 -0700
From: Tom Phoenix <rootbeer@redcat.com>
Subject: Re: perlex install error -51
Message-Id: <Pine.GSO.4.10.10005090358270.3921-100000@user2.teleport.com>
On Mon, 8 May 2000 embern@my-deja.com wrote:
> We are trying to install PerlEx and we keep getting Error -51 when it
> tries to install the files.
You'll probably have to contact the distributor and ask why they didn't
put an explanation of Error -51 into the README. (I somehow expect
that the documentation of that message is found in Area -51. :-)
Cheers!
--
Tom Phoenix Perl Training and Hacking Esperanto
Randal Schwartz Case: http://www.rahul.net/jeffrey/ovs/
------------------------------
Date: Tue, 09 May 2000 09:21:30 GMT
From: Ilja <billy@arnis-bsl.com>
Subject: Re: Printing Arrays
Message-Id: <8f8lag$i4a$1@nnrp1.deja.com>
In article <8f7hlj$gac$2@216.155.32.145>,
The WebDragon <nospam@devnull.com> wrote:
> In article <fDFR4.38997$x4.1283757@newsread1.prod.itd.earthlink.net>,
> "Jason Malone" <jamalone@earthlink.net> wrote:
>
> <snip copious included "so and so said:" headers>
> | > >> I am trying to print individual elements of an array
> | > >> using a loop structure as follows:
> | > >>
> | > >> for ($i = $num_modules; $i >= 1; $i--) {
> | > >>
> | > >> print $block[$i],"\n";
> | > >>
> | > >> }
> | > >>
> | > > You could also try
> | >
> | > > foreach (@block) { print $_; }
> | >
> | > Now, why over-elaborate things? :-)
> | >
> | > print "$_\n" for @block;
> | >
> | > hth
> | > t
> | >
> |
> | Just a style issue :)
> | Jason
>
> heh.
>
> saving this in my growing library of 'neat ways to do things'
>
> That's a nice trick :)
>
Hm-m, why you need loop to print an array ?
$, = "\n";
print @block;
Ilja.
Sent via Deja.com http://www.deja.com/
Before you buy.
------------------------------
Date: Tue, 09 May 2000 10:21:52 GMT
From: bart.lateur@skynet.be (Bart Lateur)
Subject: Re: Proper use of resources (was Re: more regexp madness extracting data from files.)
Message-Id: <391ae69a.5559288@news.skynet.be>
Uri Guttman wrote:
> print OUT "$_\n" for @dataList;
>
>or
> print OUT map "$_\n", @dataList;
>
>i like the map version since you can insert leader/trailer text in the
>print statement like:
>
> print OUT "datalist:\n", map( "$_\n", @dataList ), "end of list\n" ;
I prefer to set $, and/or $\ . No need for any map at all.
--
Bart.
------------------------------
Date: Tue, 09 May 2000 13:22:44 GMT
From: Uri Guttman <uri@sysarch.com>
Subject: Re: Proper use of resources (was Re: more regexp madness extracting data from files.)
Message-Id: <x7g0rrvows.fsf@home.sysarch.com>
>>>>> "BL" == Bart Lateur <bart.lateur@skynet.be> writes:
BL> Uri Guttman wrote:
>> print OUT "$_\n" for @dataList;
>>
>> or
>> print OUT map "$_\n", @dataList;
>>
>> i like the map version since you can insert leader/trailer text in the
>> print statement like:
>>
>> print OUT "datalist:\n", map( "$_\n", @dataList ), "end of list\n" ;
BL> I prefer to set $, and/or $\ . No need for any map at all.
but the map idea is a good idiom for when you want to mung each element
and not just what is between them. and no need for local or funn
vars. to each their own.
uri
--
Uri Guttman --------- uri@sysarch.com ---------- http://www.sysarch.com
SYStems ARCHitecture, Software Engineering, Perl, Internet, UNIX Consulting
The Perl Books Page ----------- http://www.sysarch.com/cgi-bin/perl_books
The Best Search Engine on the Net ---------- http://www.northernlight.com
------------------------------
Date: Tue, 09 May 2000 10:59:24 +0200
From: Sigvald Refsum <sigvald.refsum@siemens.no>
To: Karim Wall <mirak63@yahoo.com>
Subject: Re: Reading MS-Word Doc via PERL
Message-Id: <3917D36C.DE193FE0@siemens.no>
Hi Karim
This is an example I use to start from when I need to access the
text of Word documents.
The script is far from perfect and is only ment to demonstrate
functionallity, any syntaxt can be wrong.
Hope this helps
Sigvald Refsum
Scrip for Word follows:
###########################################
use File::Basename;
use Win32::OLE qw(in with);
use Win32::OLE::Const 'Microsoft Word';
use Win32::Clipboard;
use strict;
my ($Arg,$Doc,$CurrentFile);
my $Word = Win32::OLE->new('Word.Application', 'Quit')
or die "Couldn't run Word";
foreach $Arg (@ARGV)
{
$CurrentFile = basename($Arg,"\.doc");
# Watch what happens
# $Word->{Visible} = 1;
# Open file ----
# Beware of escape characters
my $Doc = $Word->Documents->Open('C:\\'."$Arg");
#Turn of revision marks
with ($Doc, ShowRevisions => 0);
#Do your access .....
# Navigate using bookmarks
# $Doc->GoTo({What =>wdGoToBookmark, Name =>
'BookmarkName1'});
# $Doc->Bookmarks('BookmarkName1')->Select();
# my $Range = $Word->Selection();
# with ($Range, ExtendMode => 1);
# $Range->GoTo({What => wdGoToBookmark, Name =>
'BookmarkName2'});
#Just select the complete document
$Doc->Select();
my $Range = $Word->Selection();
with ($Range, ExtendMode => 1);
$Range->SelectAll();
# Copy selection to clipboard
$Range->Copy();
# Close file without saving
$Doc->Close({SaveChanges => wdDoNotSaveChanges});
# Create temp file
open(TextFile,">$CurrentFile.txt");
printf TextFile ("%s\n", Win32::Clipboard::Get());
close TextFile;
# Close file without saving
$Doc->Close({SaveChanges => wdDoNotSaveChanges});
}
# Disconnect OLE
undef $Word;
------------------------------
Date: Tue, 9 May 2000 05:49:13 -0700
From: Tom Phoenix <rootbeer@redcat.com>
Subject: Re: signal trapper
Message-Id: <Pine.GSO.4.10.10005090548341.3921-100000@user2.teleport.com>
On Sun, 7 May 2000, Andy Chantrill wrote:
> Below is a very crude mock-up of a couple of sub-routines that I'm trying to
> get working. It should basically trap INT and TSTP signals, and display a
> status error to the user.
Is this anything like what you want?
#!/usr/bin/perl -w
use strict;
$SIG{INT} = \&signal_trapper;
$SIG{TSTP} = \&signal_trapper;
sub signal_trapper {
my($type) = $_[0];
print "A signal was caught ($type).\n";
}
while (1) {
print "Command: ";
chomp(my $command = <STDIN>);
last if $command =~ /stop|quit|exit/i;
print "Sorry, Dave, I can't do that.\n";
}
Cheers!
--
Tom Phoenix Perl Training and Hacking Esperanto
Randal Schwartz Case: http://www.rahul.net/jeffrey/ovs/
------------------------------
Date: Tue, 9 May 2000 04:06:43 -0700
From: Tom Phoenix <rootbeer@redcat.com>
Subject: Re: Socket Question-
Message-Id: <Pine.GSO.4.10.10005090402090.3921-100000@user2.teleport.com>
On Tue, 9 May 2000, Veronica Adams wrote:
> The code (both client and server) runs fine while in debug. But, when
> the apps are fired normally the server will not send the client's
> input back to the client. Or the client just won't display it. I can't
> tell.
So, what changed when they aren't "in debug"? Can you hack one or the
other to print to a log file while they're running so that you can at
least tell whether the server is sending?
> I'm runing windows 98 se and active perl build 5.6
Windows, you say? Hmmmm. :-)
> if (($child = fork()) == 0) {
This should probably be fixed to check for a failed fork. I suspect that
the original was simply quick-and-dirty code as a sample.
> $SIG{'Int'} = 'dokill';
> sub dokill {
> kill 9, $child if $child;
> }
Does this work on Windows?
> chop($hostname = `hostname`);
Oh, my. :-)
--
Tom Phoenix Perl Training and Hacking Esperanto
Randal Schwartz Case: http://www.rahul.net/jeffrey/ovs/
------------------------------
Date: Tue, 09 May 2000 11:46:05 GMT
From: "Veronica Adams" <adams1015@worldnet.att.net>
Subject: Re: Socket Question-
Message-Id: <1USR4.56228$WF.3102186@bgtnsc04-news.ops.worldnet.att.net>
Tom Phoenix <rootbeer@redcat.com> wrote in message
>
> So, what changed when they aren't "in debug"? Can you hack one or the
> other to print to a log file while they're running so that you can at
> least tell whether the server is sending?
Thats a good idea, thanks!
> > I'm runing windows 98 se and active perl build 5.6
>
> Windows, you say? Hmmmm. :-)
I know, I know...
>
> > $SIG{'Int'} = 'dokill';
> > sub dokill {
> > kill 9, $child if $child;
> > }
No, but I cou;nd't find anything onn signals in active perl. Can you point
me soomewhere?
Thanks Tom
------------------------------
Date: Tue, 09 May 2000 09:25:36 GMT
From: dstutz@clip.de
Subject: Sorting MLDBM records
Message-Id: <8f8li5$iku$1@nnrp1.deja.com>
I'm using MLDBM to store HASHes of HASHes to disk.
Can anybody tell me how to sort the second level HASHes by their values?
My code returns an empty list:
sub numeric
{
my $FIELD = $_[0];
die if(! exists %$a{"$FIELD"});
die if(! exists %$b{"$FIELD"});
%$a{"$FIELD"} <=> %$b{"$FIELD"};
}
sub print_records
{
my (@hrefs,@values,$aref,@sorted_ids);
my (@return,$i);
$i = 0;
@hrefs = keys %HASH;
$aref = sort_by_field("ID",\@hrefs);
@sorted_ids = @$aref;
foreach my $record (@sorted_ids){
next if ($record eq "HIGHEST_ID");
next if ($record eq "FREE_IDs");
next if ($record eq "CATEGORIES");
my $hash_ref = $HASH{$record};
my %ENTRY = %$hash_ref;
$return[$i] = \%ENTRY;
$i++;
#print "I: $i\n";
#my ($key,$value);
#print "######### ID: $record #########\n";
#while(($key,$value) = each %ENTRY){
# print "$key => $value\n";
#}
}
return \@return;
}
Sent via Deja.com http://www.deja.com/
Before you buy.
------------------------------
Date: Tue, 09 May 2000 13:22:52 GMT
From: markhunnibell@my-deja.com
Subject: Using IRIX 6.5 Perl 5.00502 to Access MS SQL 6.5
Message-Id: <8f93er$14a$1@nnrp1.deja.com>
Hello:
I am trying to assist our IT folks in establishing a working database
link between our SGI box (Origin 200 running IRIX 6.5 with the
freeware perl5.00502-n32) and an NT Running MS SQL 6.5. The problem I
have is that I am not an SQL person and really only have a narrow
knowledge of perl (though I have a good deal of experience using
DB_File, tie, etc).
I seek to know if anyone has successfully made the above connection
(IRIX perl <-> MS SQL). I am not interested in hearing about success
with other platforms. If you have specific information or instruction
about how to make such a connection, please let me know as soon as
possible.
Thank you.
Mark Hunnibell
Sent via Deja.com http://www.deja.com/
Before you buy.
------------------------------
Date: Tue, 9 May 2000 03:57:43 -0700
From: Tom Phoenix <rootbeer@redcat.com>
Subject: Re: using Perl's RE to do basic manipulation of a flex file
Message-Id: <Pine.GSO.4.10.10005090352400.3921-100000@user2.teleport.com>
On Mon, 8 May 2000, Ron Grabowski wrote:
> $flex_file =~ s#{.*return\s+(\w+).*}#{ printf("[$1] %s", yytext); }#gs;
>
> My RE does not come out as expected because of the optional {DIGIT} ( or
I'm having trouble following your description, in part because of the
extra information about yytext and printf, which (I think) don't really
have anything to do with where you're having trouble.
Is it simply that you want to match substring-foo in string-bar, but your
pattern matches more or less than you wish? Can you cut the problem down
to just two or three possible source strings, a description of what you
want to match in each, and your attempt at making a pattern to do the job?
Alternatively, have you tried zero-width assertions following your
pattern? That may be what you need.
Good luck with it!
--
Tom Phoenix Perl Training and Hacking Esperanto
Randal Schwartz Case: http://www.rahul.net/jeffrey/ovs/
------------------------------
Date: Tue, 09 May 2000 16:01:11 +0200
From: Gerd Meier <gerdmeier@lucent.com>
Subject: vec and bitwise or ?
Message-Id: <39181A27.67D945FA@lucent.com>
Hi,
the following program
#!/usr/local/gnu/bin/perl -w
$rin = $win = $ein = 0;
vec($rin,0,1) = 1;
vec($win,1,1) = 1;
$ein = $rin | $win;
print "$rin $win $ein\n";
prints the output
1 2 0
Why is $ein equal zero?
regards,
Gerd
------------------------------
Date: Tue, 09 May 2000 14:43:03 GMT
From: Andreas Kahari <andkaha@my-deja.com>
Subject: Re: vec and bitwise or ?
Message-Id: <8f985i$6ma$1@nnrp1.deja.com>
In article <39181A27.67D945FA@lucent.com>,
Gerd Meier <gerdmeier@lucent.com> wrote:
> Hi,
>
> the following program
>
> #!/usr/local/gnu/bin/perl -w
>
> $rin = $win = $ein = 0;
> vec($rin,0,1) = 1;
> vec($win,1,1) = 1;
> $ein = $rin | $win;
> print "$rin $win $ein\n";
>
> prints the output
> 1 2 0
>
> Why is $ein equal zero?
>
> regards,
>
> Gerd
>
$ein = "$rin" | "$win"; # works, $ein is 3
From "perldoc -f vec":
Vectors created with C<vec()> can also be manipulated with the logical
operators C<|>, C<&>, and C<^>, which will assume a bit vector operation
is desired when both operands are strings.
(Notice that last word.)
/A
--
# Andreas Kähäri, <URL:http://hello.to/andkaha/>.
# All junk email is reported to the appropriate authorities.
Sent via Deja.com http://www.deja.com/
Before you buy.
------------------------------
Date: Tue, 09 May 2000 14:50:50 GMT
From: Ala Qumsieh <aqumsieh@hyperchip.com>
Subject: Re: vec and bitwise or ?
Message-Id: <7an1lz93qs.fsf@Merlin.i-did-not-set--mail-host-address--so-shoot-me>
Gerd Meier <gerdmeier@lucent.com> writes:
> Hi,
>
> the following program
>
> #!/usr/local/gnu/bin/perl -w
>
> $rin = $win = $ein = 0;
> vec($rin,0,1) = 1;
> vec($win,1,1) = 1;
> $ein = $rin | $win;
> print "$rin $win $ein\n";
>
> prints the output
> 1 2 0
>
> Why is $ein equal zero?
I think it's a bug. I can reproduce it with 5.005_03.
If you manually set $rin to 1 and $win to 2, then $ein will be 3, as
expected.
Anybody have a better explanation?
--Ala
------------------------------
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 2990
**************************************