[17936] in Perl-Users-Digest
Perl-Users Digest, Issue: 96 Volume: 10
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Fri Jan 19 06:05:31 2001
Date: Fri, 19 Jan 2001 03:05:09 -0800 (PST)
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)
Message-Id: <979902309-v10-i96@ruby.oce.orst.edu>
Content-Type: text
Perl-Users Digest Fri, 19 Jan 2001 Volume: 10 Number: 96
Today's topics:
Re: Call C function in XS from C function in the same X <time4tea@monmouth.com>
Re: Call C function in XS from C function in the same X <active_ingy@my-deja.com>
Can't locate URI/Escape.pm in @INC <jkuo@bellatlantic.net>
Re: Can't locate URI/Escape.pm in @INC <jamie.oshaughnessy@ntlworld.com>
Re: deleting all files in a directory (Eric Bohlman)
Re: deleting all files in a directory (BUCK NAKED1)
Re: deleting all files in a directory (Rafael Garcia-Suarez)
Re: email reply (David Efflandt)
Re: FAQ 9.15: How do I decode a CGI form? (Chris Fedde)
Re: FAQ 9.15: How do I decode a CGI form? <callgirl@la.znet.com>
Fork stability on ActivePerl <iain_hosking@hotmail.com>
Re: Hello. I'm back. (David H. Adler)
Re: How to search for a certain entity's value in a xml (Eric Bohlman)
Re: Is this the BEST way ? (Eric Bohlman)
Re: isInNet() function <Peter.Dintelmann@dresdner-bank.com>
Re: List Current Processes in Win32 jdf@pobox.com
Re: Mailing attachments? (Damian James)
Re: Mailing attachments? <noemail@nospam.org>
Re: Mailing attachments? (Abigail)
Re: Mailing attachments? <ron@savage.net.au>
opening file into filter bolero92@my-deja.com
Re: opening file into filter <ccx138@coventry.ac.uk>
overhead on filehandle opening/closing <ans@_nospam_x64.net>
Re: passing parameters from command line? (Helgi Briem)
Pattern Matching <kangsoon.toh@sg.origin-it.com>
Re: Pattern Matching Problem <cmon_209@hotmail.com>
Re: Pattern Matching Problem (Abigail)
Re: Pattern Matching (Bernard El-Hagin)
Re: Pattern Matching (Anno Siegel)
Re: Randy Kobes et al. <randy@theory.uwinnipeg.ca>
Re: Randy Kobes et al. <a565a87@my-deja.com>
Re: Redirect question (David Efflandt)
tie()ing STDOUT to a file being written to by anothe (c rereidy@my-deja.com
Re: tie()ing STDOUT to a file being written to by anoth (Anno Siegel)
Writing Unix-format files on NT <iain_hosking@hotmail.com>
Digest Administrivia (Last modified: 16 Sep 99) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: Fri, 19 Jan 2001 00:37:31 -0500
From: "James Richardson" <time4tea@monmouth.com>
Subject: Re: Call C function in XS from C function in the same XS file
Message-Id: <948jt4$6vj$1@slb7.atl.mindspring.net>
> In article <93tos9$ium@netnews.hinet.net>, "John" <john@imining.com.tw>
wrote:
> > Hi:
> >
> > I have a function ShowCounter() in WebGet.xs
> > When I call ShowCounter() from another function in WebGet.xs, I get the
> > following error.
> >
> > perl: error in loading shared libraries:
blib/arch/auto/WebGet/WebGet.so:
> > undefined symbol: ShowCounter
> >
> > But I can call ShowCounter() from my perl program that use module
WebGet.
> > I really have to call ShowCounter() in other C functions in WebGet.xs.
> > How should I do?
>
So you have
MODULE = WebGet PACKAGE = WebGet
void
ShowCounter ( SV *arg )
PPCODE:
{
/* ... */
somewhere here you want to call ShowCounter ( new sv )
}
OK, well, you can't really do this.
The reason is that your xs function is really called
XS_WebGet_ShowCounter()
and it has perl calling conventions, not C ones ( see perldoc perlcall for
how to use dSP, PUSHMARK, and SPAGAIN macros to successfully call perl from
C )
If you had a function defined above the MODULE line ( which is not parsed by
the xs preprocessor ) then you would be able to call it successfully.
e.g.
#include <perl.h>
#include <XSUB.h>
#include <stdio.h>
void plusone( int i, int times ) {
if ( times == 0 )
return
printf("%d",i);
plusone(++i, --times);
}
MODULE = Rubbish PACKAGE = Rubbish
void
PlusOne(SV *i, SV *times)
PPCODE:
{
plusone(SvIV(i), SvIV(times));
/* But you can't call PlusOne(i,times), because its name is
XS_Rubbish_PlusOne (check the output from nm) */
XPUSHs(&PL_sv_undef);
}
I'm not sure that i explained that very well.....(my code might be a little
off, but hopefully i've conveyed what I am trying to say )....
HTH
James
------------------------------
Date: Fri, 19 Jan 2001 06:16:52 GMT
From: Brian Ingerson <active_ingy@my-deja.com>
To: john@imining.com.tw
Subject: Re: Call C function in XS from C function in the same XS file
Message-Id: <948m4h$nk2$1@nnrp1.deja.com>
In article <948di0$eln@netnews.hinet.net>,
"John" <john@imining.com.tw> wrote:
> I followed your advice and it worked fine.
> Thank you very much.
>
> But I found another problem.
> Running C code with Inline module seems very slow.
> Maybe it has to take some time to parse the C code.
> The major reason that makes me use C to extend Perl is I have to some
system
> level actions in a very fast manner.
> When I use Inline module, it seems that I have to give up the speed.
John, hold on a second. You need to read the instructions :)
Inline.pm only runs slow once. That's because it's compiling your code
in the background. Inline is actually writing the XS for you. Try
running the program a second time and it will run as fast as XS.
Because, um, it *is* XS. (Inline only recompiles when you change the C
code.)
The idea behind Inline is to hide the messy XS implementation details so
that you can concentrate on what you really want to do. Use C with Perl.
Brian
--
perl -le 'use Inline C=>q{SV*JAxH(char*x){return newSVpvf
("Just Another %s Hacker",x);}};print JAxH+Perl'
Sent via Deja.com
http://www.deja.com/
------------------------------
Date: Fri, 19 Jan 2001 05:25:45 GMT
From: "Justin Kuo" <jkuo@bellatlantic.net>
Subject: Can't locate URI/Escape.pm in @INC
Message-Id: <tdQ96.511$CC.271908@typhoon2.ba-dsg.net>
I'm completely new to perl/CGI and need a little help getting my program to
work in my Apache server's cgi-bin.
I'm installed the "tree.pl" routine available at:
<http://www.ev-stift-gymn.guetersloh.de/server/tree_e.html>
When I attempt to run the program as a cgi in a browser, I got an Internal
Server error. The error log gave me this message:
Can't locate URI/Escape.pm in @INC (@INC contains:
/usr/lib/perl5/5.00503/i386-linux /usr/lib/perl5/5.00503
/usr/lib/perl5/site_perl/5.005/i386-linux /usr/lib/perl5/site_perl/5.005 .)
at /home/jkuo/www/cgi-bin/tools/tree.pl line 153.
BEGIN failed--compilation aborted at /home/jkuo/www/cgi-bin/tools/tree.pl
line 153.
[Thu Jan 18 21:57:53 2001] [error] [client 192.168.1.4] Premature end of
script headers: /home/jkuo/www/cgi-bin/tools/tree.pl
What can I do to correct the problem? Is my perl application on my Linux
machine missing a module? If so, how do I install the module? I appreciate
any help. Thank you. -- Justin
------------------------------
Date: Fri, 19 Jan 2001 08:25:29 +0000
From: Jamie O'Shaughnessy <jamie.oshaughnessy@ntlworld.com>
Subject: Re: Can't locate URI/Escape.pm in @INC
Message-Id: <c8uf6t02ijtmmnipsbeqors1gi1mchfhao@4ax.com>
Not sure if URI::Escape is part the libwww group of modules, so you
should have this (maybe not though).
Read up about the CPAN module. This is a module that will help you
download, build, test and install modules from CPAN. Run it doing
something like:
perl -MCPAN -e shell
It may then be as simple as "installl URI::Escape".
Jamie
On Fri, 19 Jan 2001 05:25:45 GMT, "Justin Kuo" <jkuo@bellatlantic.net>
wrote:
>I'm completely new to perl/CGI and need a little help getting my program to
>work in my Apache server's cgi-bin.
>
>I'm installed the "tree.pl" routine available at:
>
> <http://www.ev-stift-gymn.guetersloh.de/server/tree_e.html>
>
>When I attempt to run the program as a cgi in a browser, I got an Internal
>Server error. The error log gave me this message:
>
>Can't locate URI/Escape.pm in @INC (@INC contains:
>/usr/lib/perl5/5.00503/i386-linux /usr/lib/perl5/5.00503
>/usr/lib/perl5/site_perl/5.005/i386-linux /usr/lib/perl5/site_perl/5.005 .)
>at /home/jkuo/www/cgi-bin/tools/tree.pl line 153.
>BEGIN failed--compilation aborted at /home/jkuo/www/cgi-bin/tools/tree.pl
>line 153.
>[Thu Jan 18 21:57:53 2001] [error] [client 192.168.1.4] Premature end of
>script headers: /home/jkuo/www/cgi-bin/tools/tree.pl
>
>What can I do to correct the problem? Is my perl application on my Linux
>machine missing a module? If so, how do I install the module? I appreciate
>any help. Thank you. -- Justin
>
------------------------------
Date: 19 Jan 2001 05:28:35 GMT
From: ebohlman@omsdev.com (Eric Bohlman)
Subject: Re: deleting all files in a directory
Message-Id: <948ja3$3jg$2@bob.news.rcn.net>
rbfitzpa@my-deja.com wrote:
> You might want to break up your code, I'm not sure if the unlink command
> can handle an array, try:
[code that doesn't solve the OP's problem]
If you had taken the time to type 'perldoc -f unlink' you would have seen
an example that showed unlink being called with an array as its
argument. This isn't rocket science. Please don't post speculative
misinformation.
------------------------------
Date: Fri, 19 Jan 2001 01:16:11 -0600 (CST)
From: dennis100@webtv.net (BUCK NAKED1)
Subject: Re: deleting all files in a directory
Message-Id: <1977-3A67E9BB-245@storefull-242.iap.bryant.webtv.net>
Hmmm... I thought I read in the perldocs somewhere that "unlink" was
only for removing "files", and not recommended for removing directories.
What about just using the shell, such as `rmdir directoryname` ?
Regards,
Dennis
------------------------------
Date: Fri, 19 Jan 2001 08:53:24 GMT
From: rgarciasuarez@free.fr (Rafael Garcia-Suarez)
Subject: Re: deleting all files in a directory
Message-Id: <slrn96g04q.ned.rgarciasuarez@rafael.kazibao.net>
BUCK NAKED1 wrote in comp.lang.perl.misc:
> Hmmm... I thought I read in the perldocs somewhere that "unlink" was
> only for removing "files", and not recommended for removing directories.
> What about just using the shell, such as `rmdir directoryname` ?
perldoc -f rmdir
--
Rafael Garcia-Suarez / http://rgarciasuarez.free.fr/
------------------------------
Date: Fri, 19 Jan 2001 06:03:34 +0000 (UTC)
From: efflandt@xnet.com (David Efflandt)
Subject: Re: email reply
Message-Id: <slrn96fm52.1q4.efflandt@efflandt.xnet.com>
On Thu, 18 Jan 2001, neurofase@my-deja.com <neurofase@my-deja.com> wrote:
>I am perl to convert a form on the internet into an email but i was
>looking to make it that the email came from the email addy that was
>entered by the user so it was easier to reply. The bit that is getting
>me is i have to use the \ in the email. Can anyone help?
You don't need the \ in an e-mail address you get from a web form.
You may also want to include a Reply-To: header just in case your mail
server sets the From: header to who it thinks it really is from (you or
the webserver).
Assuming you are using CGI.pm function mode and the field is called
'email' you would simply:
$smtp->datasend("From: " . param('email') . "\n");
$smtp->datasend("Reply-To: " . param('email') . "\n");
> use Net::SMTP;
>
> $smtp = Net::SMTP->new('EXCHANGE'); # connect to an SMTP server
> $smtp->mail( 'website@ozarks.edu' ); # use the sender's
>address here
> $smtp->to('lgarriso@email.com', 'webmaster@email.com');
># recipient's address
> $smtp->data(); # Start the mail
>
> # Send the header.
> $smtp->datasend("To: lgarriso\@email.com,
>webmaster\@ozarks.edu\n");
> $smtp->datasend("From: website\@email.com\n");
> $smtp->datasend("Subject: Satisfaction Survey of Maintance
>Request (from Web Site)\n");
> $smtp->datasend("\n");
>
># Send the body.
>$smtp->datasend("Time Sent(Local) $now\n");
>$smtp->datasend("\n");
>$smtp->datasend("Survey on Work Requested\n");
>$smtp->datasend("E-mail: $input{'email'}\n");
>
>
>Sent via Deja.com
>http://www.deja.com/
--
David Efflandt efflandt@xnet.com http://www.de-srv.com/
http://www.autox.chicago.il.us/ http://www.berniesfloral.net/
http://cgi-help.virtualave.net/ http://hammer.prohosting.com/~cgi-wiz/
------------------------------
Date: Fri, 19 Jan 2001 06:31:45 GMT
From: cfedde@fedde.littleton.co.us (Chris Fedde)
Subject: Re: FAQ 9.15: How do I decode a CGI form?
Message-Id: <lbR96.1103$B9.192883712@news.frii.net>
In article <3A67A538.F9D4BE6C@la.znet.com>, Kira <callgirl@la.znet.com> wrote:
>PerlFAQ Server wrote:
>
>> How do I decode a CGI form?
>
>> You use a standard module, probably CGI.pm. Under no circumstances
>> should you attempt to do so by hand!
>
>> You'll see a lot of CGI programs that blindly read from STDIN the number
>> of bytes equal to CONTENT_LENGTH for POSTs, or grab QUERY_STRING for
>> decoding GETs. These programs are very poorly written. They only work
>> sometimes.
>
>(snipped)
>
>Total pile of Mule Manure. Posting this type of garbage
>is an affront to all decent programmers.
>
>Godzilla!
>--
greetings oh great salimander. It's good to see you back. Please
make yourself at home. BTW feel free to post repairs to the FAQ to
the posting address or to the address listed in perlfaq1.
--
This space intentionally left blank
------------------------------
Date: Thu, 18 Jan 2001 23:08:40 -0800
From: Kira <callgirl@la.znet.com>
Subject: Re: FAQ 9.15: How do I decode a CGI form?
Message-Id: <3A67E7F8.C751D825@la.znet.com>
Chris Fedde drooled:
> Kira, in her usual unique style, quipped:
> > PerlFAQ Server blathered:
> >> How do I decode a CGI form?
> >> You use a standard module, probably CGI.pm. Under no circumstances
> >> should you attempt to do so by hand!
> >(snipped)
> >Total pile of Mule Manure. Posting this type of garbage
> >is an affront to all decent programmers.
> >Godzilla!
> greetings oh great salimander.
I am not a salamander. I am a variant on a spit fire lizard.
^
> It's good to see you back.
This is doubtful.
> Please make yourself at home.
Do you mind? My personal life is private.
> BTW feel free to post repairs to the FAQ....
I already have.
> This space intentionally left blank
I doubt this space between your ears is intentional.
You still need to improve on your faking it. This
is too obvious, Sybil.
Godzilla!
--
Dr. Kiralynne Schilitubi ¦ Cooling Fan Specialist
UofD: University of Duh! ¦ ENIAC Hard Wiring Pro
BumScrew, South of Egypt ¦ HTML Programming Class
------------------------------
Date: Fri, 19 Jan 2001 21:25:06 +1100
From: "Iain Hosking" <iain_hosking@hotmail.com>
Subject: Fork stability on ActivePerl
Message-Id: <3a68157a_2@news01.one.net.au>
I'm writing a system which involves downloading weather reports,
distributing them amongst processing directories, then running processing
programs to parse the data and load it into a database. Currently the
queue-processor runs in a 1-minute loop to watch the incoming directory to
do the distribution. Separate processing programs are fired off every 15
minutes by NT's AT scheduler.
To reduce the latency in the system it would be nice to trigger the
processes whenever a file appears in the relevant processing directory. As I
see it, I can either (a) run all the processing programs constantly, each
one in a loop which checks the input directory or (b) run a 'watch' program
which fires off the appropriate program.
If I do (b) is it feasible on NT to use fork() to run the processes? I'm
running ActivePerl 5.6.0 build 623 on NT 4.0 SP5. The system runs round the
clock 365 days a year so must be stable.
(Down the track we may migrate the system to Linux or Solaris.)
Thanks
Iain
------------------------------
Date: 19 Jan 2001 07:00:00 GMT
From: dha@panix6.panix.com (David H. Adler)
Subject: Re: Hello. I'm back.
Message-Id: <slrn96fpfg.778.dha@panix6.panix.com>
On 19 Jan 2001 00:01:14 -0500, jdf@pobox.com <jdf@pobox.com> wrote:
>Hello. My name is Jonathan Feinberg. I used to be a frequent poster
>to this group and to c.l.p.moderated. I gave up in exhaustion some
>time ago--perhaps a year or so--but I'm back.
Welcome back Jonathan. Good to see you.
You coming back to irc too, or is that even more exhausting? :-)
dha
--
David H. Adler - <dha@panix.com> - http://www.panix.com/~dha/
"Your point being..." - Homer Simpson
------------------------------
Date: 19 Jan 2001 05:37:52 GMT
From: ebohlman@omsdev.com (Eric Bohlman)
Subject: Re: How to search for a certain entity's value in a xml file
Message-Id: <948jrg$3jg$3@bob.news.rcn.net>
Khuong H. Dinh <kdinh@commerce-tv.com> wrote:
> Hi,
> I'm pretty new with perl. I'm trying to find a way to search through an
> xml file and get out of that value of some entities. For example I have
> an xml file:
> <?xml version="1.0" encoding="UTF-8" ?>
> - <table>
> <name1>234</name1>
> <versionNumber>1.0</versionNumber>
> <errorName>0</errorName>
> </table>
> Is there a way that I can get out value of entity name1?
> I would appreciate any helps.
name1 isn't an "entity." It's an "element." And strictly speaking, 234
isn't its "value"; it's its "content." It's important to remember that in
XML, an element can have "mixed content" which can include both text *and*
sub-elements, potentially interspersed. Therefore you really shouldn't
conceive of an XML element as an object that has a text-type property
called its "value." I know I'm sounding pedantic here, but this
distinction trips up a lot of beginners to XML.
For this type of query, you're probably best off using XML::XPath.
------------------------------
Date: 19 Jan 2001 05:08:11 GMT
From: ebohlman@omsdev.com (Eric Bohlman)
Subject: Re: Is this the BEST way ?
Message-Id: <948i3r$3jg$1@bob.news.rcn.net>
hafateltec@hotmail.com wrote:
> #!/usr/bin/perl -w
> use strict;
> use DBI();
> #opens a database connection
> my $dbh = DBI->connect
> ("dbi:mysql:database=phone;host=localhost","root", "hafa") or die
> "Couldn't connect to database address: " .
> DBI::errstr;
> $dbh->{PrintError} = 0; # Do Not Print errors.
> $dbh->{RaiseError} = 1; # Die on errors, and display to
> browser.
Funny, this doesn't *look* like a CGI program.
> while (<>) {
> chomp;
> #regex checks for valid input xxx-xxxx phone number
> if ($_ =~ /^\d{3}-\d{4}$/) {
A little location-centric, aren't we? That pattern assumes that all your
phone numbers are A) in the North American Numbering Plan and B) come from
areas that have no overlay area codes (where numbers located in the same
region can have different area codes, so the last 7 digits don't uniquely
identify a number).
> my $sth = $dbh->prepare("SELECT * FROM phone where number = '$_'");
As Rafael mentioned, pull this out of the loop. Unless the 'print
"@row\n"' below is for more than debugging, you should really select only
the fields you're going to use rather than all of them.
> $sth->execute();
> while (my @row = $sth->fetchrow_array) {
> print "@row\n";
> my $number = shift @row;
> my $first = shift @row;
> my $last = shift @row;
> print "$number\n";
> print "$first\n";
> print "$last\n";
> }
> }
>
I'd use fetchrow_hashref and the actual field names here both to shorten
your code and remove the needless dependency on the order and position of
the fields. Assuming the field names are NUMBER, FIRST, and LAST, you'd
do something like:
while (my $row = $sth->fetchrow_hashref) {
print "$row->{NUMBER}\n$row->{FIRST}\n$row->{LAST}\n";
}
}
> $dbh->disconnect;
------------------------------
Date: Fri, 19 Jan 2001 09:12:14 +0100
From: "Dr. Peter Dintelmann" <Peter.Dintelmann@dresdner-bank.com>
Subject: Re: isInNet() function
Message-Id: <948sth$7qk7@intranews.bank.dresdner.net>
Hi,
"Garry Williams" <garry@zvolve.com> wrote in message
news:vfG96.323$032.11756@eagle.america.net...
[snip]
> > print isInNet( '0.0.0.0', '3.255.255.255', '3.2.3.4' );
> >
> > sub isInNet
> > { my ($start, $end, $ip) = @_;
> > return convert($start) < convert($ip) && convert($ip) <
> >convert($end);
> >
> > sub convert {unpack( "L", join '',map chr,reverse
> >split(/\./,$_[0]) )}
> > }
>
> I think the OP meant for the parameters to be:
>
> address to be tested
> network address
> network mask
I did not spot a valid netmask in his posting
> where all of these are expressed in a dotted decimal string. His
> example was flawed in that the network address didn't make sense with
> the given mask, but I think that's what he meant.
> You seem to be changing that profoundly.
yepp, my code is intended to test if a given address is
between a start and an end address.
> Furthermore, your code to
> convert a string form of an IP address into binary won't compile.
strange. It runs under 'use strict' without any problems on
my machine (perl, v5.6.0 built for MSWin32-x86-multi-thread).
The code was cut/paste directly from my editor.
> am confused about what you really intend.
convert() converts an IP address into a base10 value. These
values are compared.
Peter
------------------------------
Date: 19 Jan 2001 00:22:53 -0500
From: jdf@pobox.com
Subject: Re: List Current Processes in Win32
Message-Id: <itncdsk2.fsf@pobox.com>
"jg" <Jerry_Geist@infinium.com> writes:
> Can someone point me in the direction of how to get the entire list of
> processes which are showing in the Windows NT Task Manager into a list.
The least programmer-intensive way would be to visit the redoubtable
http://www.sysinternals.com
and download their free PsTools utility package. Capture the output
of pslist.exe and process it as you like.
my @ps = `d:/bin/pslist.exe`;
All Win32 programmers should pay a lingering visit to SysInternals.
--
Jonathan Feinberg jdf@pobox.com Sunny Brooklyn, NY
http://pobox.com/~jdf
------------------------------
Date: 19 Jan 2001 05:23:28 GMT
From: damian@puma.qimr.edu.au (Damian James)
Subject: Re: Mailing attachments?
Message-Id: <slrn96fjrt.ejl.damian@puma.qimr.edu.au>
Thus spake Rand Simberg on Fri, 19 Jan 2001 04:10:02 GMT:
>
>Well, my biggest problem will be, whatever module I find, to convince
>my ISP to put it into the library. Unfortunately, I am not the master
>of my domain...
>
Or to convince them to let you keep it in your home directory. You can,
after all, put the following near the beginning of your program:
use lib '/path/to/home/directory/my_perl5_lib';
HTH
Cheers,
Damian
------------------------------
Date: Fri, 19 Jan 2001 10:14:34 +0100
From: Craig Manley <noemail@nospam.org>
Subject: Re: Mailing attachments?
Message-Id: <3A68057A.80F38970@nospam.org>
These is a simple solution:
use Mime::Lite;
-Craig Manley.
Rand Simberg wrote:
>
> I'm doing a CGI script that (in theory) emails a data file
> automatically. I was going to use sendmail, but when I looked in the
> FAQ and asked how sendmail handles attachments, the simple answer
> was--it doesn't.
>
> It recommended something like pine, but when I looked in the pine
> manual it wasn't obvious how to run it from a script (I assume that I
> can probably play some games with pipes, but I don't have the time to
> climb a learning curve right now) and was wondering if there are any
> canned routines that do this anywhere.
>
> ************************************************************************
> simberg.interglobal.org * 310 372-7963 (CA) 307 739-1296 (Jackson Hole)
> interglobal space lines * 307 733-1715 (Fax) http://www.interglobal.org
>
> "Extraordinary launch vehicles require extraordinary markets..."
> Replace first . with @ and throw out the "@trash." to email me.
> Here's my email address for autospammers: postmaster@fbi.gov
------------------------------
Date: 19 Jan 2001 09:06:53 GMT
From: abigail@foad.org (Abigail)
Subject: Re: Mailing attachments?
Message-Id: <slrn96g0td.hhh.abigail@tsathoggua.rlyeh.net>
Rand Simberg (simberg.interglobal@trash.org) wrote on MMDCXCVIII
September MCMXCIII in <URL:news:3a6abde4.12415745@nntp.ix.netcom.com>:
@@
@@ Well, my biggest problem will be, whatever module I find, to convince
@@ my ISP to put it into the library. Unfortunately, I am not the master
@@ of my domain...
If you can install programs, you can install modules as well. It isn't
that you need to sacrifice a goat and a virgin while burning black
candles. Just read the FAQ.
Abigail
--
perl -le 's[$,][join$,,(split$,,($!=85))[(q[0006143730380126152532042307].
q[41342211132019313505])=~m[..]g]]e and y[yIbp][HJkP] and print'
------------------------------
Date: Fri, 19 Jan 2001 21:15:42 +1100
From: "Ron Savage" <ron@savage.net.au>
Subject: Re: Mailing attachments?
Message-Id: <tBT96.351$cF2.11598@ozemail.com.au>
And if all else fails, see: http://savage.net.au/Perl-tutorials.html#tut-2
--
Cheers
Ron Savage
ron@savage.net.au
http://savage.net.au/index.html
Craig Manley <noemail@nospam.org> wrote in message
news:3A68057A.80F38970@nospam.org...
> These is a simple solution:
>
> use Mime::Lite;
>
------------------------------
Date: Fri, 19 Jan 2001 08:39:36 GMT
From: bolero92@my-deja.com
Subject: opening file into filter
Message-Id: <948ug8$ui7$1@nnrp1.deja.com>
how can I open a file to a filter
so that the input to the filter contains
no more than 2 newline?
For example,
> cat readme.txt
I love Perl.
I love Perl again.
I love Perl again and again.
> cat test.pl
#!/usr/local/bin/perl
open (FILE, "what should I put here |");
while (<FILE>) {
print $_;
}
> test.pl
I love Perl.
I love Perl again.
I love Perl again and again.
Sent via Deja.com
http://www.deja.com/
------------------------------
Date: Fri, 19 Jan 2001 09:11:38 +0000
From: John Tutchings <ccx138@coventry.ac.uk>
Subject: Re: opening file into filter
Message-Id: <3A6804C9.D116B76A@coventry.ac.uk>
Unix I take it.
head -2
bolero92@my-deja.com wrote:
> how can I open a file to a filter
> so that the input to the filter contains
> no more than 2 newline?
>
> For example,
> > cat readme.txt
> I love Perl.
> I love Perl again.
>
> I love Perl again and again.
>
> > cat test.pl
> #!/usr/local/bin/perl
> open (FILE, "what should I put here |");
> while (<FILE>) {
> print $_;
> }
>
> > test.pl
> I love Perl.
> I love Perl again.
> I love Perl again and again.
>
> Sent via Deja.com
> http://www.deja.com/
------------------------------
Date: Fri, 19 Jan 2001 08:51:27 GMT
From: "Anson Parker" <ans@_nospam_x64.net>
Subject: overhead on filehandle opening/closing
Message-Id: <jeT96.70519$xW4.546038@news-server.bigpond.net.au>
A bit left of center - but can anyone tell me whether there's a significant
overhead on opening and closing a filehandle?
For example, in a Perl daemon I'm building there's an built-in logging
routine. Currently the daemon opens a filehandle to the log file on startup
and closes it on shutdown. Given that the daemon could have uptimes
into the years (hmmm don't think it's quite that robust yet) are there any
issues with keeping a filehandle open indefinitely?
If so, is it then better to open and close the filehandle for every logfile
write (this could sometimes be a good number of lines/second)? Or
would the overhead (if any) make this a bad idea.
regards,
Anson.
--
foreach (unpack 'C*','aonjixfghklceyrqtuwxvdbp') {
print substr 'jerk not the surreal chap',$_-97,1;}
------------------------------
Date: Fri, 19 Jan 2001 09:50:27 GMT
From: helgi@NOSPAMdecode.is (Helgi Briem)
Subject: Re: passing parameters from command line?
Message-Id: <3a680cec.850614138@news.itn.is>
On Thu, 18 Jan 2001 12:22:09 GMT, tedius@gmx.co.uk (Ted)
wrote:
>Hi!
>
>just a short question: how can I pass some string to my perl script from
>command line?
>
>I need something like this:
>
>script.pl STRING
>
>
>
>#!/usr/bin/perl
>
>$Foo=STRING
>.........
#!/usr/bin/perl -w
use strict;
if (not @ARGV) { die "Usage: $0 <string>\n"; }
my $Foo = shift;
# or my $Foo = $ARGV[0];
# or for (@ARGV) { my $Foo = $_; }
Regards,
Helgi Briem
------------------------------
Date: Fri, 19 Jan 2001 11:01:12 +0100
From: "Toh Kang Soon" <kangsoon.toh@sg.origin-it.com>
Subject: Pattern Matching
Message-Id: <0E16861EE7BCD111BE9400805FE6841F1400AF2C@c1s5x001.cor.srvfarm.origin-it.com>
Hi,
I need help! I have a file which log the ftp result and are listed below, I
am trying to extract the hostname and files that are not successfully ftped
(ie. /var/opt/CPfw1-41/log/fwlog.export.07.Jan is the missing) and output
into a file with the following format, Thank you!
desired output
----------------
ftp gwabc < ++
cd /var/opt/CPfw1-41/log/
bin
prompt off
get fwlog.export.07.Jan
bye
++
ftp gwhkg < ++
cd /var/opt/CPfw1-41/log/
bin
prompt off
get fwlog.07.Jan.alog
get fwlog.07.Jan.alogptr
get fwlog.07.Jan.log
get fwlog.07.Jan.logptr
get fwlog.export.07.Jan
bye
++
.
.
.
----------------
ftp result
-------------------
Server: gwabc
Interactive mode off.
/var/opt/CPfw1-41/log/fwlog.export.07.Jan: No such file or directory.
Server: gwsyd
Interactive mode off.
Server: gwtky
Interactive mode off.
Server: gwhkg
Interactive mode off.
/var/opt/CPfw1-41/log/fwlog.07.Jan.alog: No such file or directory.
/var/opt/CPfw1-41/log/fwlog.07.Jan.alogptr: No such file or directory.
/var/opt/CPfw1-41/log/fwlog.07.Jan.log: No such file or directory.
/var/opt/CPfw1-41/log/fwlog.07.Jan.logptr: No such file or directory.
/var/opt/CPfw1-41/log/fwlog.export.07.Jan: No such file or directory.
Server: gwsgp
Interactive mode off.
/var/opt/CPfw1-41/log/fwlog.07.Jan.alog: No such file or directory.
/var/opt/CPfw1-41/log/fwlog.07.Jan.alogptr: No such file or directory.
/var/opt/CPfw1-41/log/fwlog.07.Jan.log: No such file or directory.
/var/opt/CPfw1-41/log/fwlog.07.Jan.logptr: No such file or directory.
/var/opt/CPfw1-41/log/fwlog.export.07.Jan: No such file or directory.
-----------------
------------------------------
Date: Fri, 19 Jan 2001 09:09:16 GMT
From: CM <cmon_209@hotmail.com>
Subject: Re: Pattern Matching Problem
Message-Id: <94907q$vnu$1@nnrp1.deja.com>
In article <3A67C133.B9A65188@home.com>,
Rick Delaney <rick.delaney@home.com> wrote:
> [posted & mailed]
>
> CM wrote:
> >
> > My data file appears like this...
> >
> > <!--2-->
> > <data goes here>
> > <!--2-->
> > <!--5-->
> > <data goes here>
> > <!--5-->
> [snip]
> > Now a record is the data that appears between <!--n--> and <!--n-->.
>
> > My algorithm is like this.
> >
> > $buffer=Entire file contents
>
> Ugh, don't do that. Read in as little as you need to determine when
you
> have a full record.
>
Doesnt this involve mamy File Open Operations and wouldnt it make it
slow?
regards
CM
Sent via Deja.com
http://www.deja.com/
------------------------------
Date: 19 Jan 2001 09:19:11 GMT
From: abigail@foad.org (Abigail)
Subject: Re: Pattern Matching Problem
Message-Id: <slrn96g1kf.hhh.abigail@tsathoggua.rlyeh.net>
Rick Delaney (rick.delaney@home.com) wrote on MMDCXCVIII September
MCMXCIII in <URL:news:3A67C133.B9A65188@home.com>:
[] [posted & mailed]
[]
[] CM wrote:
[] >
[] > My data file appears like this...
[] >
[] > <!--2-->
[] > <data goes here>
[] > <!--2-->
[] > <!--5-->
[] > <data goes here>
[] > <!--5-->
[] [snip]
[] > Now a record is the data that appears between <!--n--> and <!--n-->.
[]
[] > My algorithm is like this.
[] >
[] > $buffer=Entire file contents
[]
[] Ugh, don't do that. Read in as little as you need to determine when you
[] have a full record.
[]
[] > The problem with this algorithm is that it goes thru the entire data
[] > whereas I need just 4 records .
[]
[] Right. Set $/ = "-->" and then just read one record at a time, stopping
[] when you get to the desired number. If "-->" can appear within a record
[] (and not only at the end) then keep reading chunks into your buffer
[] until the bracketing numbers match.
If the datafile consists of records, each started with and ended with
<--n-->, with the numbers in sequence and nothing else in the file,
you could do:
$/ = "<--1-->\n";
my $record = "";
while (<>) {
$record .= $_ . <>;
$record =~ s!$/!!g;
do_something_with $record;
}
continue {
$/ =~ s/(\d+)/$1 + 1/e;
$record = "";
}
Abigail
--
perl -wle 'print "Prime" if ("m" x shift) !~ m m^\m?$|^(\m\m+?)\1+$mm'
------------------------------
Date: Fri, 19 Jan 2001 10:31:08 +0000 (UTC)
From: bernard.el-hagin@lido-tech.net (Bernard El-Hagin)
Subject: Re: Pattern Matching
Message-Id: <slrn96g5rb.2q0.bernard.el-hagin@gdndev25.lido-tech>
On Fri, 19 Jan 2001 11:01:12 +0100, Toh Kang Soon
<kangsoon.toh@sg.origin-it.com> wrote:
>Hi,
>
>I need help! I have a file which log the ftp result and are listed below, I
>am trying to extract the hostname and files that are not successfully ftped
>(ie. /var/opt/CPfw1-41/log/fwlog.export.07.Jan is the missing) and output
>into a file with the following format, Thank you!
[snip]
>/var/opt/CPfw1-41/log/fwlog.export.07.Jan: No such file or directory.
I'm not going to write the whole thing for you, but I'll give you a
couple of hints to get you started. First, you need to go through your
log file line by line and weed out the lines which have the "No such
file or directory" error message:
open (IN, "/log/file") or die $!;
while (<IN>){
if (/No such file or directory/){
#got a line with an error
}
}
Next, you need to extract the information from each of these lines. To
get the filename you can use this regex:
my ($filename) = m!^.*/([^:]*):!;
And to get the directory:
my ($dir) = m!^(.*/)!;
And finally, you have to write this to an output file:
open (OUT, "> /output/file") or die $!;
print OUT $stuff;
Now all you have to do is use this information to come up with what should
be in $stuff.
Try to come up with a script using this info and if you still have
trouble post it and someone will help you.
Cheers,
Bernard
--
#requires 5.6.0
perl -le'* = =[[`JAPH`]=>[q[Just another Perl hacker,]]];print @ { @ = [$ ?] }'
------------------------------
Date: 19 Jan 2001 10:35:01 GMT
From: anno4000@lublin.zrz.tu-berlin.de (Anno Siegel)
Subject: Re: Pattern Matching
Message-Id: <94958l$nak$2@mamenchi.zrz.TU-Berlin.DE>
Toh Kang Soon <kangsoon.toh@sg.origin-it.com> wrote in comp.lang.perl.misc:
>Hi,
>
>I need help! I have a file which log the ftp result and are listed below, I
>am trying to extract the hostname and files that are not successfully ftped
>(ie. /var/opt/CPfw1-41/log/fwlog.export.07.Jan is the missing) and output
>into a file with the following format, Thank you!
[sample data snipped]
So what have you tried so far?
You see, you can't just throw a problem at the group and expect solutions
to be thrown back your way. If you have no idea where to begin, you
haven't reached a stage where a language-specific group can help you.
Anno
------------------------------
Date: Thu, 18 Jan 2001 23:30:17 -0600
From: "Randy Kobes" <randy@theory.uwinnipeg.ca>
Subject: Re: Randy Kobes et al.
Message-Id: <948jof$rlc$1@canopus.cc.umanitoba.ca>
"Rob" <a565a87@my-deja.com> wrote in
message news:947brk$ict$1@nnrp1.deja.com...
> Randy et al,
>
> I succeeded--I think--in building the perl/Perl environment from the
> latest source release last week.
[ ...]
> I say "I think" because I don't know perl. Yet. I also use Windows NT
> 4 Workstation while just about everyone else around here seems to be
> hacking UN*X. Fine. I'll eventually get around to installing
> FreeBSD. But the whole reason I wanted to immerse myself into learning
> Perl and Apache and mod_perl and Apache::ASP is that I wanted an
> alternative to IIS (which I also don't know). I also really like the
> Apache logo. Who knows--I may even eventually buy the books that I've
> been reading standing up in the bookstore.
>
> First things first though. The INSTALL.Win32 File reads like a
> treasure map. It's ambiguous at best.
[ ... ]
It isn't easy to build Perl and mod_perl on Win32 .... The
INSTALL.win32 mod_perl file assumes a basic knowledge
of building and installing modules - if you're just starting out,
building mod_perl isn't the place to learn ... I'd suggest getting
ActivePerl from http://www.activestate.com/ - that's a Perl
binary distribution that has the Perl Package Manager for
installing binary module packages. Read the very good html
documentation that comes with ActivePerl, especially the FAQs.
Then install an Apache binary, if you haven't done so, from
http://www.apache.org/. Get comfortable with setting up and
using Perl CGI scripts on Apache - the documentation for
the CGI.pm module (which comes with Perl) has examples,
as does the sources for CGI.pm - http://www.cpan.org/ suggests
several ways to find things on CPAN, and has a nice FAQ.
Next try mod_perl - http://perl.apache.org/distributions.html has
links of where to get mod_perl ppms for Win32 ActivePerl,
plus some other common Apache::* modules. In setting up
and using mod_perl, the guide at http://perl.apache.org/guide/
is invaluable, as is http://take23.org/.
best regards,
randy kobes
------------------------------
Date: Fri, 19 Jan 2001 07:58:51 GMT
From: Rob <a565a87@my-deja.com>
Subject: Re: Randy Kobes et al.
Message-Id: <948s3q$rue$1@nnrp1.deja.com>
Randy,
Thanks for replying. A lot has happened in the intervening couple of
hours since I sent that very frustrated-sounding post.
I've since gone back and re-read the INSTALL.Win32 File after browsing
a few books tonight and searching around Google for a good "Hello,
world" introduction to Perl.
I've since discovered how a .PL file behaves and have now seen it in
action on my console so that I can make heads and tails of the perl
environs. I know now that my perl build from the source worked out
successfully.
From that discovery, I proceeded to the "mod_perl Makefile.PL" and
the "nmake install" procedures and subsequently got terrific results
that produced all of the files that I had last wrote that I was
missing. (And you had predicted in a reply that the files should in
fact be created by some of the build process.)
Suffice it to say that I'm having a much better time of things now. I
went and downloaded the Apache source and a compile of that gave me the
ApacheCore.lib file that I had also lacked. Now the only thing that's
stopped up is a linker message that I got when finishing off the
mod_perl build. (But I've submitted a question about the link issue to
a separate NG and will await a reply.)
I want to thank you again, and Garry, and everyone else on the board
for your politesse and patience and generous acknowledgment of my
beginner's questions.
Things are looking up. Thanks again,
-Rob
Sent via Deja.com
http://www.deja.com/
------------------------------
Date: Fri, 19 Jan 2001 06:08:10 +0000 (UTC)
From: efflandt@xnet.com (David Efflandt)
Subject: Re: Redirect question
Message-Id: <slrn96fmdn.1q4.efflandt@efflandt.xnet.com>
On Thu, 18 Jan 2001 14:35:34 -0000, Jon <jons1@lineone.net> wrote:
>Hi,
>Running Windows 2000/ActivestatePerl/SQL Server 7
>This is probably a really simple question - I have a form which posts data
>to a Perl script the Perl script pulls messages from a POP3 mailbox and
>stores them in SQL Server, after the script has run i want to redirect to
>another page. I've tried the code below to redirect
>use CGI qw(:standard);
>print redirect('http://www.perl.com');
>and also
>$url = "http://www.perl.com/CPAN/";
>print "Location: $url\n\n";
>exit;
>neither works, the Perl script runs, messages stored in the database but the
>redirect doesnt happen, no error messages.
>
>Any clues? Thanks, Jon
Are you sure that you are NOT printing anything before this? If you print
header or anything else at all, it will NOT work.
--
David Efflandt efflandt@xnet.com http://www.de-srv.com/
http://www.autox.chicago.il.us/ http://www.berniesfloral.net/
http://cgi-help.virtualave.net/ http://hammer.prohosting.com/~cgi-wiz/
------------------------------
Date: Fri, 19 Jan 2001 09:10:00 GMT
From: rereidy@my-deja.com
Subject: tie()ing STDOUT to a file being written to by anothe (child) process
Message-Id: <949096$voa$1@nnrp1.deja.com>
Hi,
I have the dubious honor of solving a problem on a production WinNT
server involving report generation and zipping the resulting file from
this report process.
The process is set up to work as follows in the production and
development enviorments:
1. The report is started on the server via a HTTP call from another
server.
2. After the report is completed, a new HTTP call starts a (pk?)zip
process.
This all seems very inefficient to me. I asked the developers why they
can't pipe STDOUT of the report process into the zip process (a la
Unix). I was informed the report writer program (Oracle*Reports
runtime) does not write to STDOUT.
I then thought maybe I could make this happen with Perl. What I want
to do is invoke a Perl program that will tie() the STDOUT of the Perl
process to the output filename of the report process it will launch,
and pipe this result into a zip process. Or maybe, I can trick
Oracle*Reports into "thinking" STDOUT is a valid file to write to.
It sounds so easy, but...
I have found nothing in the perl docs, CPAN, nor any books (i.e. Perl
Cookbook, etc.) that is cluing me into any of this.
Does anyone have any experience with this type of scenario?
Any help or suggestions are very welcome.
Thanks for your time.
Ron Reidy
Oracle DBA
Sent via Deja.com
http://www.deja.com/
------------------------------
Date: 19 Jan 2001 09:59:29 GMT
From: anno4000@lublin.zrz.tu-berlin.de (Anno Siegel)
Subject: Re: tie()ing STDOUT to a file being written to by anothe (child) process
Message-Id: <949361$nak$1@mamenchi.zrz.TU-Berlin.DE>
<rereidy@my-deja.com> wrote in comp.lang.perl.misc:
>Hi,
>
>I have the dubious honor of solving a problem on a production WinNT
>server involving report generation and zipping the resulting file from
>this report process.
>
>The process is set up to work as follows in the production and
>development enviorments:
>
>1. The report is started on the server via a HTTP call from another
>server.
>2. After the report is completed, a new HTTP call starts a (pk?)zip
>process.
>
>This all seems very inefficient to me. I asked the developers why they
>can't pipe STDOUT of the report process into the zip process (a la
>Unix). I was informed the report writer program (Oracle*Reports
>runtime) does not write to STDOUT.
>
>I then thought maybe I could make this happen with Perl. What I want
>to do is invoke a Perl program that will tie() the STDOUT of the Perl
>process to the output filename of the report process it will launch,
>and pipe this result into a zip process. Or maybe, I can trick
>Oracle*Reports into "thinking" STDOUT is a valid file to write to.
>
>It sounds so easy, but...
It may be easy,if you are on a (Unix) system that supports named
pipes. Just create one and give it to the report process for
output. On the other end of the pipe have the zip process waiting
for data.
This has little to do with Perl, and I don't see how tie() could
help with it. You can't tie an (external) file to anything, just
a file handle. But the file handle in question belongs to the
report process; there's no way you could use Perl to tie that.
Anno
------------------------------
Date: Fri, 19 Jan 2001 21:08:44 +1100
From: "Iain Hosking" <iain_hosking@hotmail.com>
Subject: Writing Unix-format files on NT
Message-Id: <3a6811a0_4@news01.one.net.au>
I'm trying to write a text file which must be used on a Silicon Graphics
machine. If I set
$\ = "\n";
then the newline character is CR+LF, and the file can't be used. But the
strange thing is that if I set
$\ = "\012";
or
$\ = "\x0A";
then the newline is still CR+LF. How can I create a file with a line
delimiter of LF only?
Thanks in advance
Iain
------------------------------
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 V10 Issue 96
*************************************