[10714] in Perl-Users-Digest
Perl-Users Digest, Issue: 4313 Volume: 8
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Sat Nov 28 13:07:17 1998
Date: Sat, 28 Nov 98 10:00:24 -0800
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)
Perl-Users Digest Sat, 28 Nov 1998 Volume: 8 Number: 4313
Today's topics:
Re: Access Database (Stuart Summerville)
Re: Accessing script in cgi-bin <gellyfish@btinternet.com>
Basic form handler for dropdown boxes? (Rob)
Re: Basic form handler for dropdown boxes? (brian d foy)
Re: Begging a simple perl script for my study.. <gellyfish@btinternet.com>
Re: Crontab and "require" <gellyfish@btinternet.com>
Re: Globbing don't work (Larry Rosler)
Re: How could I "EXPORT" Variables from one script to a <rick.delaney@shaw.wave.ca>
how do i set up a ras entry? <pip@mijnkeldertje.com>
Re: How to generate Perl executable for UNIX? <tchrist@mox.perl.com>
Re: How to use relatives directory in MacPerl vx Unix? <gellyfish@btinternet.com>
Re: html vs. cgi via perl <gellyfish@btinternet.com>
Re: I have a question about Perl and CgI? <gellyfish@btinternet.com>
Re: Language Translation Module (Larry Rosler)
Re: Language Translation Module <newspost@morlock.net>
Re: Language Translation Module <gellyfish@btinternet.com>
Re: localtime () - perl's bug ? <stmintz@yahoo.com>
Re: mod_perl + perl 5.005_02 <gellyfish@btinternet.com>
Re: Newbie: Need to split comma-delimited data into sca <gellyfish@btinternet.com>
Re: Password Protected Sites ? <philip.class@popcorn-studio.ch>
Re: perl mods <gellyfish@btinternet.com>
Re: read from a program ? <gellyfish@btinternet.com>
rename() on NT <mats@webhandel.nu>
Re: Running Perl scripts as NT services <gellyfish@btinternet.com>
Security: Overwriting directory file when removing dire <nobody@replay.com>
sorry, wrong newsgroup <pip@mijnkeldertje.com>
Re: Training wheels for Perl <gellyfish@btinternet.com>
Re: Training wheels for Perl <newspost@morlock.net>
Website Automation internet.specialist@shaw.wave.ca
Re: What to do when printf() doesn't apply (M.J.T. Guy)
Re: Win32::API programming <perin@panix7.panix.com>
Re: Win32::API programming <gellyfish@btinternet.com>
Special: Digest Administrivia (Last modified: 12 Mar 98 (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: Sat, 28 Nov 1998 16:20:33 GMT
From: stus@netspace.net.au (Stuart Summerville)
Subject: Re: Access Database
Message-Id: <3660216f.623476@news.netspace.net.au>
On Wed, 18 Nov 1998 20:09:29 +0800, "Ho Seng Yip"
<hsengyip@(nospam)singnet.com.sg> wrote:
>I am wondering if Perl can actually read and write data into / from a
>Microsoft Access database.
You can talk to Access databases using OLE. I'm currently trying to
figure out how to do so. The examples directory in the ActiveState
Perl distribution has some sample Excel perl scripts. MSAccess OLE is
accessed in samee manner, just different method (??).
Not sure what (if any) support the standard Perl5 has for OLE.
I had a look through the DBC:: section of CPAN & didn't find much.
As for myself - I'm relatively new to Perl, OLE, & Access - might as
well jump in at (near??) the deep end. Any help appreciated.
Stu.
------------------------------
Date: 28 Nov 1998 16:20:00 -0000
From: Jonathan Stowe <gellyfish@btinternet.com>
Subject: Re: Accessing script in cgi-bin
Message-Id: <73p7rg$rt$1@gellyfish.btinternet.com>
On Thu, 26 Nov 1998 22:28:18 -0500 Evan Panagiotopoulos <evanp@technologist.com> wrote:
> This is a multi-part message in MIME format.
> --------------21A0F92AA1D881765FEA851F
> Content-Type: text/plain; charset=us-ascii
> Content-Transfer-Encoding: 7bit
>
Please dont allow your browser to insert this vCard stuff into newsgroup posts
at best it is completely pointless and at worst it is extremely annoying and
likely to ensure that the only replies you get are flames about it.
> Hello to all,
> I'm processing a form and the perl script resides in cgi-bin directory
> of the server. I have the following line:
> <form action="http://10.3.3.2/cgi-bin/form.cgi" method="POST">
> which doesn't workbecause the script's path is not found. How do I
> access it? The script is in the cgi-bin directory.
>
This is not a Perl problem. This almost certainly to do with the server's
configuration. Perhaps you should ask in a group appropriate for your
server. (You might find it also more helpful if gave them a little more
detail about what your server software is and what steps you have taken
to configure it previously).
/J\
--
Jonathan Stowe <jns@btinternet.com>
Some of your questions answered:
<URL:http://www.btinternet.com/~gellyfish/resources/wwwfaq.htm>
------------------------------
Date: Sat, 28 Nov 1998 15:41:21 GMT
From: rob@teleprise.com (Rob)
Subject: Basic form handler for dropdown boxes?
Message-Id: <36601833.7621776@news.direcpc.com>
I'm looking for a basic form handler that will simply allow me to use
dropdown boxes on a Web page to direct visitors to other pages on my
site and elsewhere. It's a pretty common script: The user sees the
names of the other pages, and by dropping down the list and pressing a
submit button, goes off to the selected siteI don't want to use a Java
applet, as I want to keep things simple and easy.
This seems pretty straightforward, but I haven't found a script that
does it. Any help would be appreciated. Thanks. -- Rob
------------------------------
Date: Sat, 28 Nov 1998 11:57:28 -0500
From: comdog@computerdog.com (brian d foy)
Subject: Re: Basic form handler for dropdown boxes?
Message-Id: <comdog-ya02408000R2811981157280001@news.panix.com>
In article <36601833.7621776@news.direcpc.com>, rob@teleprise.com posted:
> I'm looking for a basic form handler that will simply allow me to use
> dropdown boxes on a Web page to direct visitors to other pages on my
> site and elsewhere.
use CGI;
or
use CGI::Request;
good luck :)
--
brian d foy <comdog@computerdog.com>
CGI Meta FAQ <URL:http://computerdog.com/CGI_MetaFAQ.html>
------------------------------
Date: 28 Nov 1998 15:15:41 -0000
From: Jonathan Stowe <gellyfish@btinternet.com>
Subject: Re: Begging a simple perl script for my study..
Message-Id: <73p42t$o4$1@gellyfish.btinternet.com>
On Sat, 28 Nov 1998 05:11:28 GMT wjeon@chollian.net wrote:
> I'm a real beginner and trying to write simple script. What I wanner write is
> a script which can make a text file on the server and the content of the text
> file will be the parameter of the script. For example.. If I type
> 'http://www.myserver.com/cgi-bin/myscript.pl?par=ABCD' on any web browsers, a
> text file should be made by the script and the content of the text file
> should be 'ABCD'. It's really simple, huh? But it is difficult to me. It
> would be very much appreciated if anyone write the script for my study..
> Thanks.
Dont take this wrong but this kind of thing gets posted all the time and
sometimes people even post the code (I recall having done so in the past).
I think the best advice is to get hold of the CGI.pm module from CPAN
(http://www.perl.com/CPAN) and study its most excellent and comprehensive
documentation. You will certainly also find examples if you search this
group on DejaNews.
The only bit of your question that is not covered in the CGI.pm documentation
is regarding writing to a file - this is covered in the perlfunc documentation
that comes with Perl. Check out
open
print
The major reason I am evading giving the code is down to that old fishing
adage which seems to apply increasingly often in this newsgroup. If I
supply you with the specific answer the chances are you will be back with
another question which wasnt specifically dealt with - however if you are
pointed to the places where you can find this out for yourself then you
will also have the ability (hopefully) to answer any supplementary
questions you might have yourself.
Good Luck
/J\
--
Jonathan Stowe <jns@btinternet.com>
Some of your questions answered:
<URL:http://www.btinternet.com/~gellyfish/resources/wwwfaq.htm>
------------------------------
Date: 28 Nov 1998 15:23:57 -0000
From: Jonathan Stowe <gellyfish@btinternet.com>
Subject: Re: Crontab and "require"
Message-Id: <73p4id$pq$1@gellyfish.btinternet.com>
On Sat, 28 Nov 1998 00:40:40 -0500 David Coppit
<dwc3q@mamba.cs.virginia.edu> wrote:
>
> What's the best way to let a script know that it can find a "require"'d
> file in the directory in which the script is run?
>
You will probably want to use the FindBin.pm module that comes with recent
distributions of Perl - there are examples in the documentation that deal
specifically with this kind of thing.
>
> From what I understand, $0 doesn't always give the full directory.
>
>
Right, depending on a variety of factors it may well contain a relative
path to the CWD e.g.:
./scriptname.pl
/J\
--
Jonathan Stowe <jns@btinternet.com>
Some of your questions answered:
<URL:http://www.btinternet.com/~gellyfish/resources/wwwfaq.htm>
------------------------------
Date: Sat, 28 Nov 1998 07:28:21 -0800
From: lr@hpl.hp.com (Larry Rosler)
Subject: Re: Globbing don't work
Message-Id: <MPG.10c9b66bab18698498992e@nntp.hpl.hp.com>
[Posted to comp.lang.perl.misc and copy mailed.]
In article <73o843$978$1@power42t.hkbu.edu.hk> on 28 Nov 1998 07:18:27
GMT, CHOU KEI HONG <kelvinee@net1.hkbu.edu.hk> says...
> I have tried writing a script to count the no. of files with extension .pic
> with a directory.
> It works fine when invoke locally from a dos prompt (perl test.pl).
> But when I invoke this script as a CGI, it was found that the script can't
> report the no. of files and always is zero.
>
> Does anybody has any idea ? Below is the code I write.
>
> print "Content-Type: text/html\n\n";
>
> @list = <d:/pic/*.pic>;
> $list_len = $#list +1;
Or just
$list_len = @list;
> foreach $element (@list) {
> print "$element<br>";
> }
> print #list_len<br>";
Typo here.
print "$list_len<br>";
> Or I guess there may have a better way to do this.
The 'better way' works without spawning a subshell. (I have never seen
a reason to use globbing instead.)
opendir DIR, 'd:/pic' or die "Couldn't open 'd:/pic'. $!\n";
@list = sort grep /\.pic$/i, readdir DIR;
foreach $element (@list) {
print "$element<br>\n";
}
print scalar @list, "<br>\n";
Untested, but... I made the search case-independent because that's how
the DOS filesystem is. I also threw "\n" onto each of your '<br>s' out
of mercy to anyone who has to look at the output source.
--
(Just Another Larry) Rosler
Hewlett-Packard Laboratories
http://www.hpl.hp.com/personal/Larry_Rosler/
lr@hpl.hp.com
------------------------------
Date: Sat, 28 Nov 1998 17:00:17 GMT
From: Rick Delaney <rick.delaney@shaw.wave.ca>
Subject: Re: How could I "EXPORT" Variables from one script to another?
Message-Id: <36602DD4.E7183404@shaw.wave.ca>
Guillaume Dupuis wrote:
>
> This is my problem:
> We have one main script that calls 'child' scripts (All PERL
> scripts...), that themselves call 'child' scripts. Under Korn shell,
> this is not a problem, when you declare variables x,y,z in the
> 'parent'-most script, you can call those variables anywhere in the two
> other 'child' scripts.
Are you talking about environment variables? I'll assume you are since
you use the term 'export' in the subject.
In Perl you can access environment variables as $ENV{VAR_NAME}.
> My problem being that I don't know how to execute that under perl. I
> have tried unsuccessfully to execute those 'child' scripts, by
> calling them with:
> ...
> $scr_1 = system("perl script1.pl");
system() is probably what you want to execute your child scripts from
the parent, but not if you want to capture their output. To do that use
backticks, same as ksh:
$scr_1 = `perl script1.pl`;
Look up %ENV in perlvar and system() in perlfunc.
--
Rick Delaney
rick.delaney@shaw.wave.ca
------------------------------
Date: 28 Nov 1998 15:34:01 GMT
From: P vd Geer <pip@mijnkeldertje.com>
Subject: how do i set up a ras entry?
Message-Id: <366016C8.13A5BC1D@mijnkeldertje.com>
Can somebody explain me how to set up a ras entry, with all the needed
info like tel. nr. and DNS nr. network protocols etc.
I haven't found anything about this on the web so far.
(Please mail me too, cause I cannot access news all the time.)
TIA
P vd Geer
pip@mijnkeldertje.com
------------------------------
Date: 28 Nov 1998 16:56:21 GMT
From: Tom Christiansen <tchrist@mox.perl.com>
Subject: Re: How to generate Perl executable for UNIX?
Message-Id: <73p9vl$7ci$1@csnews.cs.colorado.edu>
[courtesy cc of this posting sent to cited author via email]
In comp.lang.perl.misc, "Z. Morley Mao" <zmao@eecs.berkeley.edu> writes:
: Could someone please tell me how to compile a Perl script into a
:UNIX executable a.out? We need this to make it run faster.
Doing so will not satisfy your goal. The fault, my dear Morley,
lies not within Perl but within your own code. Sorry 'bout that.
--tom
--
The only way to get rid of a temptation is to yield to it.
-- Oscar Wilde
------------------------------
Date: 28 Nov 1998 17:04:00 -0000
From: Jonathan Stowe <gellyfish@btinternet.com>
Subject: Re: How to use relatives directory in MacPerl vx Unix?
Message-Id: <73pae0$t0$1@gellyfish.btinternet.com>
On Sat, 21 Nov 1998 09:59:02 -0500 Jean-Marc Piuze <jmp@mlink.net> wrote:
> I want to relative directory like "../" in Unix. I want my perl script run
> on Unix platform as well as a Mac platform.
>
>
I am not familiar with the MacOS filesystem but you might take a look at the
File::Spec module that comes with recent distributions of Perl to see if that
does what you want.
/J\
--
Jonathan Stowe <jns@btinternet.com>
Some of your questions answered:
<URL:http://www.btinternet.com/~gellyfish/resources/wwwfaq.htm>
------------------------------
Date: 28 Nov 1998 15:33:01 -0000
From: Jonathan Stowe <gellyfish@btinternet.com>
Subject: Re: html vs. cgi via perl
Message-Id: <73p53d$pu$1@gellyfish.btinternet.com>
On Sat, 28 Nov 1998 03:28:02 +0100 Mike <mike@lovetalk.de> wrote:
> Does anyone have any idea on how to ping a cgi-script ?? (not just the
> ip)
>
As has already been pointed out you will need to write a script that is
effectively an HTTP User Agent ( you will probably want to use the LWP
suite to do this).
> I would like to write a script that compares html vs. cgi response times
> on a server.....
>
Of course this not a reasonable comparison in most cases because of the
different nature of the two things - intuition (in the presence of no other
guidance) would suggest that simply retrieving an HTML page is going to be
faster than a CGI program that would generate an identical page.
However this part is not a Perl issue at all really.
/J\
--
Jonathan Stowe <jns@btinternet.com>
Some of your questions answered:
<URL:http://www.btinternet.com/~gellyfish/resources/wwwfaq.htm>
------------------------------
Date: 28 Nov 1998 16:14:17 -0000
From: Jonathan Stowe <gellyfish@btinternet.com>
Subject: Re: I have a question about Perl and CgI?
Message-Id: <73p7gp$rq$1@gellyfish.btinternet.com>
On 27 Nov 1998 00:38:08 +0500 Rollo Lawson <rollo@enter.net> wrote:
> I am a newbie to cgi-bin. I have been studying perl5 for the last week or
> so. I have a network installed in my house and I have a question. I was
> wondering if I could put the script in the perl directory on one machine.
> And on the other machine if I access an html file with a form in it that is
> submitted right to the computer with the script on it if it. Would it
> process the script and show the results. Or do you need web server
> software or something like that to test scripts.
If you are using the CGI.pm module then you will be able to test your
programs off-line at the command-prompt - see the documentation for CGI.pm
for more on that. However to view the output in a browser you will need to
be running a web server of some description.
To find out more about web servers appropriate for your platform you should
probably ask in one of the comp.infosystems.www.servers.* groups (or even
better refer to the FAQ for that group).
> And also is the only way
> to interact with cgi scripts via the <form> tag or can it be with other
> html elements.
This is not a Perl question. You would probably be better put asking this
question in a group that has HTML or CGI in its name - or better still
looking at the documentation concerning forms.
> Please Help
> rollo@enter.net
>
/J\
--
Jonathan Stowe <jns@btinternet.com>
Some of your questions answered:
<URL:http://www.btinternet.com/~gellyfish/resources/wwwfaq.htm>
------------------------------
Date: Sat, 28 Nov 1998 07:12:54 -0800
From: lr@hpl.hp.com (Larry Rosler)
Subject: Re: Language Translation Module
Message-Id: <MPG.10c9b2d050a4f2b398992d@nntp.hpl.hp.com>
[Posted to comp.lang.perl.misc and copy mailed.]
In article <HwM72.1773$_g.9281110@news.rdc1.sfba.home.com> on Sat, 28
Nov 1998 06:13:59 GMT, jbharvey@home.net <jbharvey@home.net> says...
> Following instructions to submit a new module, I'm throwing this out.
> I've built a module that uses LWP to translate strings into Italian,
> German, French, Italian and Portugeuse and back to English using Alta
> Vista's Translation service. Should I release this? It works pretty
> well...
Does 'It works pretty well...' refer to your interface or to Babelfish?
Many of us have found the latter to be 'a source of innocent merriment.'
What CPAN category would you put it in -- Humor:: ?
--
(Just Another Larry) Rosler
Hewlett-Packard Laboratories
http://www.hpl.hp.com/personal/Larry_Rosler/
lr@hpl.hp.com
------------------------------
Date: Sat, 28 Nov 1998 11:00:55 -0500
From: "Steven Morlock" <newspost@morlock.net>
Subject: Re: Language Translation Module
Message-Id: <W8V72.18$Hw.198183@lwnws01.ne.mediaone.net>
Maybe you have already covered this bit of merriment
courtesy of Alta Vista, maybe not:
>From English: Just another Perl Hacker
To French: juste un autre intrus de Perl
To English: just another intruder of Perl
>From English: Just another Perl Hacker
To Italian: Appena un altro hacker del Perl
To English: As soon as an other hacker of the Perl
>From English: Just another Perl Hacker
To Spanish: Apenas otro hacker del Perl
To Engligh: Hardly other hacker of the Perl
>From English: Just another Perl Hacker
To Portuguese: Apenas um outro hacker do Perl
To English: But one other hacker of the Perl
>From English: Just another Perl Hacker
To German: Gerade ein anderer Perl-Hacker
To English: Even another Perl hacker
Steve
--
Foliage Software Systems
aka The Nerd Farm
http://www.foliage.com
Larry Rosler wrote in message ...
>[Posted to comp.lang.perl.misc and copy mailed.]
>
>In article <HwM72.1773$_g.9281110@news.rdc1.sfba.home.com> on Sat, 28
>Nov 1998 06:13:59 GMT, jbharvey@home.net <jbharvey@home.net> says...
>> Following instructions to submit a new module, I'm throwing this out.
>> I've built a module that uses LWP to translate strings into Italian,
>> German, French, Italian and Portugeuse and back to English using Alta
>> Vista's Translation service. Should I release this? It works pretty
>> well...
>
>Does 'It works pretty well...' refer to your interface or to Babelfish?
>Many of us have found the latter to be 'a source of innocent merriment.'
>What CPAN category would you put it in -- Humor:: ?
>
>--
>(Just Another Larry) Rosler
>Hewlett-Packard Laboratories
>http://www.hpl.hp.com/personal/Larry_Rosler/
>lr@hpl.hp.com
------------------------------
Date: 28 Nov 1998 14:56:07 -0000
From: Jonathan Stowe <gellyfish@btinternet.com>
Subject: Re: Language Translation Module
Message-Id: <73p2u7$nv$1@gellyfish.btinternet.com>
On Sat, 28 Nov 1998 06:13:59 GMT jbharvey@home.net wrote:
> Hi,
>
> Following instructions to submit a new module, I'm throwing this out.
> I've built a module that uses LWP to translate strings into Italian,
> German, French, Italian and Portugeuse and back to English using Alta
> Vista's Translation service. Should I release this? It works pretty
> well...
>
I think someone posted something like that here about a year ago - I seem to
recall that the subject was something like "Fun with babelfish" - you might
try and search DejaNews for this to see if it is similar to your work.
Having said that it would be an amusement to see anyhow. Yeah go on put it on
CPAN.
/J\
--
Jonathan Stowe <jns@btinternet.com>
Some of your questions answered:
<URL:http://www.btinternet.com/~gellyfish/resources/wwwfaq.htm>
------------------------------
Date: Sat, 28 Nov 1998 09:50:03 -0600
From: "Sean Mintz" <stmintz@yahoo.com>
Subject: Re: localtime () - perl's bug ?
Message-Id: <73p5pq$vud$1@Masala.CC.UH.EDU>
Roberto Slepetys Ferreira wrote in message
<365F3834.34B838F6@homeworks.com.br>...
>Hi,
>
>I wrote a script in Perl that make's use of the localtime() command to
>get the time and day as is wroten below:
>
>
>#
>($sec,$min,$hour,$day,$month,$year)=localtime ();
>$data = "$day/$month/$year";
>$horario = "$hour:$min:$sec";
>#
>
>But for my surprise the command works properly, but the month extracted
>was ever one below the current. I tried it on my machine (INTEL), in a
>DEC (alpha 500) and in the webserver (O2) and all reported the same
>error.
>
>Is it a perl's bug ?
>
>[]s
>SLepetys
>
hey !
heres some code to use:
$timestamp = time();
sub get_date_string
{
local ($timestamp) = @_;
($sec,$min,$hour,$mday,$mon,$year,$wday,$yday,$isdst) =
localtime($timestamp);
$mon++;
$mon = do date_pad($mon);
$mday = do date_pad($mday);
$hour = do date_pad($hour);
$min = do date_pad($min);
$sec = do date_pad($sec);
("${year}.${mon}.${mday}", "${hour}:${min}:${sec}");
}
sub date_pad
{
local ($n) = @_;
if ($n < 10) {
return "0$n";
}
else {
return "$n";
}
}
if this doesnt work, email me. it works on my machine.... but if you want to
print the local time its even easier:
print scalar localtime, "\n"; # thats also my favorite one line prog hehe
Sean Mintz <stmintz@yahoo.com>
------------------------------
Date: 28 Nov 1998 15:35:48 -0000
From: Jonathan Stowe <gellyfish@btinternet.com>
Subject: Re: mod_perl + perl 5.005_02
Message-Id: <73p58k$q2$1@gellyfish.btinternet.com>
On Sat, 28 Nov 1998 00:16:53 +0000 Balazs Rauznitz <prauz@sprynet.com> wrote:
> Hello.
>
> I am running an Apache server with mod_perl on my Linux box and just
> compiled perl 5.005_02, but experience strange things when using the new
> perl with mod_perl:
>
> The same script that worked before has syntax error reported about 50%
> of the time it's run. The line is:
> $tpl = new CGI::FastTemplate ("somedirectoryname");
>
> The error log says:
> [Fri Nov 27 17:55:12 1998] [error] syntax error at /www/perl-bin/mailrep
> line 20, near "new CGI::FastTemplate "
>
> Bareword found where operator expected at /www/perl-bin/bbthread line
> 12, near "new CGI::FastTemplate"
> (Do you need to predeclare new?)
>
>
> The really odd thing is that if I hit reload on the browser, then it
> usually loads the page fine, but I get this kind of error randomly
> through the site.
> After switching back to perl 5.004 the problem disapperers.
>
> Am I missing something (like is it a problem to run mod_perl with a
> different compiler it was compiled with) or is this a
> bug/incompatability ?
>
You will almost have to recompile mod_perl as well as Perl because it is
linked with the Perl libraries.
/J\
--
Jonathan Stowe <jns@btinternet.com>
Some of your questions answered:
<URL:http://www.btinternet.com/~gellyfish/resources/wwwfaq.htm>
------------------------------
Date: 28 Nov 1998 15:47:01 -0000
From: Jonathan Stowe <gellyfish@btinternet.com>
Subject: Re: Newbie: Need to split comma-delimited data into scalars or an array.
Message-Id: <73p5tl$qk$1@gellyfish.btinternet.com>
On Fri, 27 Nov 1998 16:53:12 GMT tcpeter@iname.com wrote:
> Ok, if my script doesn't give it away, I'm still something of a newbie, but
> I've checked the docs and the archives and this one is still giving me fits.
> My question is this: as part of my job, I receive e-mails with data in a
> number of comma-delimited fields. I've written a script to strip out the
> lines containing the data and put it into a new file. What I'd really like
> to do is plug the individual fields onto individual lines (or better yet,
> into scalars or an array, for further manipulation). Can anyone point me in
> the right direction, (and hopefully something more explicit or easier for a
> newbie than the Perl docs)?
>
<snip>
If your data is simply comma-delimited then you will be able to use
@array =split /,/,$data;
However if you're data is quoted (i.e fields that might contain spaces or
commas have double quotes round them) then you will need to look at the
example given in perlfaq4 - search for Comma-separated. You might also
consider looking at the Text::CSV module to see if that could achieve what
you want.
/J\
--
Jonathan Stowe <jns@btinternet.com>
Some of your questions answered:
<URL:http://www.btinternet.com/~gellyfish/resources/wwwfaq.htm>
------------------------------
Date: Sat, 28 Nov 1998 16:48:12 +0100
From: "Philip Class" <philip.class@popcorn-studio.ch>
Subject: Re: Password Protected Sites ?
Message-Id: <73p5ss$543$1@bw107zhb.bluewin.ch>
Unfortunately it is a NT-Server (with IIS)
Does your method work nevertheless ?
I've just implemented an Authentication example (from a tutorial on
http://www.activeserverpages.com/learn/security.asp ) that's based on ASP.
But I'm not sure about possible SECURITY HOLES and disadvantages of this
way.
At least one ristriction is that the visitor's browser must have enabled
cookies, otherwise the ASP's Session Variables don't work.
Can anyone recommend my above mentioned asp-authentication system ?
Philip
>Apache web server is doing this quite well without any Perl script. Try
this in
>your httpd.conf (Apache 1.3.3 compliant)
>
><directory /home/your.site/any.dir>
>AuthType Basic
>AuthName "Restricted Area"
>AuthUserFile /home/restricted.authfile
><Limit GET POST>
>require valid-user
></Limit>
></directory>
>
>Combine this with htpasswd to create your restricted.authfile. Works great.
>
>Hope this helps!
>
>DVD DREAM
>http://www.dvd-dream.com
>
------------------------------
Date: 28 Nov 1998 14:40:36 -0000
From: Jonathan Stowe <gellyfish@btinternet.com>
Subject: Re: perl mods
Message-Id: <73p214$nr$1@gellyfish.btinternet.com>
On Wed, 25 Nov 1998 11:09:24 GMT dave@mag-sol.com wrote:
> In article <73cpln$j1$1@gellyfish.btinternet.com>,
> Jonathan Stowe <gellyfish@btinternet.com> wrote:
>> On Sun, 22 Nov 1998 05:14:28 -0800 Frank <fdm@internethomeschool.com> wrote:
>> > what is a perl mod? I thought they only came from oysters?
>> >
>>
>> Someone who wears Tonic Suits, Chelsea boots, Parkas and rides to work on a
>> Lambretta. As opposed to the more usual Perl hacker who would probably
>> wear a bin bag if it was the first thing to hand when they got up in the
>> afternoon ;-b And then you have the London Perl M[ou]ngers...
>
> Ere! I saw that! What you saying?
>
Difficult to categorize bunch is all ;-}
/J\
--
Jonathan Stowe <jns@btinternet.com>
Some of your questions answered:
<URL:http://www.btinternet.com/~gellyfish/resources/wwwfaq.htm>
------------------------------
Date: 28 Nov 1998 16:02:49 -0000
From: Jonathan Stowe <gellyfish@btinternet.com>
Subject: Re: read from a program ?
Message-Id: <73p6r9$rh$1@gellyfish.btinternet.com>
In comp.lang.perl.misc Tim Schelfhout <tim.schelfhout@telenet.be> wrote:
> Me again,
>
comp.lang.perl is no longer a valid news group.
> I'm trying to write a perl script which reads output from a program and
> then formats some of its data. So far I've come up with the following but
> I don't seem to get any data
> back from the program although I know it's connected to it.
>
> ($phone,$rest)=@ARGV;
> $cli="/opt/cli/bin/cli";
> open (CLI,"|$cli") || die "Can't connect to $cli\n";
> print CLI,"searchdn $phone\n";
> close (CLI);
>
> This normally should print out something like:
>
> "connected to Server : l1mech1 echo report cauline
> MECH1,CCF-1,CCU-4,SA20001,CAU0022 { .... }"
>
> I guess it's normal that I'm not getting anything back since I'm printing
> to the pipe but don't get anything out of it. Is there any way
> to do this in native perl rather than doing it with the 'system
> (/opt/bin/cli .... )' solution ?
>
You will need to use the IPC::Open2 module if you wish to write to *and* read
from an external program i.e. your example should become something like
this (untested) :
use IPC::Open2;
use Symbol;
my ($phone,$rest) = @ARGV;
$WRITEHANDLE = gensym();
$READHANDLE = gensym();
$procid = open2($READHANDLE,$WRITEHANDLE,'/opt/cli/bin/cli');
if (defined($procid))
{
print $WRITEHANDLE "searchdn $phone\n";
while(<$READHANDLE>)
{
print $_ ; # or otherwise do something with data
}
close ($READHANDLE) || die 'Error in child - $!\n";
close ($WRITEHANDLE) || die 'Error in child - $!\n";
}
else
{
print "Couldnt open - $!\n";
}
/J\
--
Jonathan Stowe <jns@btinternet.com>
Some of your questions answered:
<URL:http://www.btinternet.com/~gellyfish/resources/wwwfaq.htm>
------------------------------
Date: Sat, 28 Nov 1998 17:47:58 +0100
From: Mats Westholm <mats@webhandel.nu>
Subject: rename() on NT
Message-Id: <3660293D.62686C43@webhandel.nu>
This is a multi-part message in MIME format.
--------------292E1E5EE1A74CD76AFB5531
Content-Type: text/plain; charset=us-ascii
Content-Transfer-Encoding: 7bit
I have moved a fully functioning perl-program from UNIX to
NT and the
rename() funktion is not working. It gives the error-code
"File exists" (in
$!). I'm renaming the new file to an existing filename.
1. Anyone knows how to handle rename() in NT?
2. Where can I read about the file commands in NT? (for
example how to
delete a file, rename or move it)
Thankfully hoping for help.
--
Mats Westholm
mats@webhandel.nu
http://webhandel.nu
--------------292E1E5EE1A74CD76AFB5531
Content-Type: text/x-vcard; charset=us-ascii;
name="mats.vcf"
Content-Transfer-Encoding: 7bit
Content-Description: Card for Mats Westholm
Content-Disposition: attachment;
filename="mats.vcf"
begin:vcard
n:Westholm;Mats
tel;home:08-644 54 02
x-mozilla-html:FALSE
url:http://webhandel.nu
org:webhandel.nu
adr:;;Bondegatan 28;Stockholm;;116 33;Sweden
version:2.1
email;internet:mats@webhandel.nu
x-mozilla-cpt:;22800
fn:Mats Westholm
end:vcard
--------------292E1E5EE1A74CD76AFB5531--
------------------------------
Date: 28 Nov 1998 16:05:41 -0000
From: Jonathan Stowe <gellyfish@btinternet.com>
Subject: Re: Running Perl scripts as NT services
Message-Id: <73p70l$rk$1@gellyfish.btinternet.com>
In comp.lang.perl.misc Marquis de Carvdawg <carvdawg@patriot.net> wrote:
> Could someone point me to a FAQ that tells me how
> to run my scripts as NT services?
>
This has been comprehensively answered a number of times in the last
few month - I would suggest a search of DejaNews may well throw up the
answer (But David is right you do need to have the NT Resource kit).
/J\
--
Jonathan Stowe <jns@btinternet.com>
Some of your questions answered:
<URL:http://www.btinternet.com/~gellyfish/resources/wwwfaq.htm>
------------------------------
Date: 28 Nov 1998 16:24:43 +0100
From: Anonymous <nobody@replay.com>
Subject: Security: Overwriting directory file when removing directory?
Message-Id: <199811281524.QAA06544@replay.com>
I would like to overwrite the contents of a file before removing
them (for instance when they contain privacy sensitive data). I
can do that easily, by opening them and overwriting them full of
junk and closing them again.
But I cannot find a way to do the same with the directory files
(I'm on a unix system) and I'd like every trace of my files
removed(even the names which may contain privacy sensitive info).
I tried opening the directory as a file, the removing the directory
and then overwriting the directory file and closing it. But I seem
to be unable to open the directory file as normal file to do this.
I'll include my script (not it is a dangerous script, you might
easily lose data - this after all is its goal :-):
#!/usr/local/bin/perl
use IO::File;
my $chunksize = 1024;
my $chunk;
my $minichunk = " "; #32 bytes
for (my $count = 0; $count < $chunksize/(length $minichunk); $count++) {
$chunk = $chunk . $minichunk;
}
foreach my $file (@ARGV) {
&clean( $file);
}
exit 0;
sub clean {
my $file = shift;
my ($size) = (stat( $file))[7];
warn "Cleaning $file (size $size)\n";
if (-d $file) {
if (opendir DIR, $file) {
my @files = grep( !/^\.\.?$/, readdir DIR);
closedir DIR;
foreach my $subfile (@files) {
&clean( "$file/$subfile");
}
# Here does the attempt to overwrite the directory file start
my $fh = new IO::File $file, O_RDWR;
if (defined $fh) {
rmdir $file; # remove links from directory tree
# then write spaces to it
for (my $offset = 0;
$offset + $chunksize < $size;
$offset += $chunksize) {
$fh->syswrite( $chunk, $chunksize);
}
$fh->syswrite( $chunk, $size - $offset);
$fh->close();
}
else {
warn "Cannot open directory $file as file for cleaning";
rmdir $file;
}
}
}
elsif (-r $file) {
my $fh = new IO::File $file, "r+";
if (defined $fh) {
for (my $offset = 0;
$offset + $chunksize < $size;
$offset += $chunksize) {
$fh->syswrite( $chunk, $chunksize);
}
$fh->syswrite( $chunk, $size - $offset);
$fh->close();
unlink $file;
}
else {
warn "Cannot open $file";
}
}
}
------------------------------
Date: 28 Nov 1998 15:34:53 GMT
From: P vd Geer <pip@mijnkeldertje.com>
Subject: sorry, wrong newsgroup
Message-Id: <366016FD.DF15B395@mijnkeldertje.com>
sorry 'bout my last msg.
------------------------------
Date: 28 Nov 1998 17:19:41 -0000
From: Jonathan Stowe <gellyfish@btinternet.com>
Subject: Re: Training wheels for Perl
Message-Id: <73pbbd$u3$1@gellyfish.btinternet.com>
On 25 Nov 1998 22:48:27 GMT Zenin <zenin@bawdycaste.org> wrote:
> Tom Phoenix <rootbeer@teleport.com> wrote:
> >snip<
> : My cat can write better Perl just by walking across the keyboard!
>
> And it would be more readable then most Perl code. :-) :-)
In the spirit of enquiry I thought I would put this assertion to the test.
Not having a cat I simulated the feline footsteps by rolling a grapefruit
around on the keyboard producing the following:
[p;-=klnm 7/@:
][#
~'][p;oyhtgrzx\c vhgbjnbvc zx\erdzxc vnbm, bnbm[p-=
215 nbcvx\zyt[p;-=
410
32][;pi6547895 7~@
542
=-?
(This looks more like APL than Perl right )
Giving :
Unquoted string "p" may clash with future reserved word at crap.pl line 1.
syntax error at crap.pl line 1, near "p;"
Unquoted string "klnm" may clash with future reserved word at crap.pl line 1.
Unrecognized character \267 at crap.pl line 1.
Maybe if I get five-thousand grapefruit and a similar number of keyboards I
might be able to come up with the Shell to Perl Converter.
:-P
/J\
--
Jonathan Stowe <jns@btinternet.com>
Some of your questions answered:
<URL:http://www.btinternet.com/~gellyfish/resources/wwwfaq.htm>
------------------------------
Date: Sat, 28 Nov 1998 12:45:19 -0500
From: "Steven Morlock" <newspost@morlock.net>
Subject: Re: Training wheels for Perl
Message-Id: <qHW72.32$Hw.238307@lwnws01.ne.mediaone.net>
After doing a comprehensive analysis, taking into account different
keyboard layouts and modifier keys, in an effort to map out the flight
path of the grapefruit, I have to conclude that it was a very oddly
shaped example of the citrus fruit family.
Steve
--
Foliage Software Systems
aka The Nerd Farm
http://www.foliage.com
Jonathan Stowe wrote in message <73pbbd$u3$1@gellyfish.btinternet.com>...
>On 25 Nov 1998 22:48:27 GMT Zenin <zenin@bawdycaste.org> wrote:
>> Tom Phoenix <rootbeer@teleport.com> wrote:
>> >snip<
>> : My cat can write better Perl just by walking across the keyboard!
>>
>> And it would be more readable then most Perl code. :-) :-)
>
>In the spirit of enquiry I thought I would put this assertion to the test.
>Not having a cat I simulated the feline footsteps by rolling a grapefruit
>around on the keyboard producing the following:
>
>
>[p;-=klnm 7/@:
>][#
>~'][p;oyhtgrzx\c vhgbjnbvc zx\erdzxc vnbm, bnbm[p-=
>215 nbcvx\zyt[p;-=
>410
>32][;pi6547895 7~@
>542
>=-?
>
>
>(This looks more like APL than Perl right )
>
>Giving :
>
>
>Unquoted string "p" may clash with future reserved word at crap.pl line 1.
>syntax error at crap.pl line 1, near "p;"
>Unquoted string "klnm" may clash with future reserved word at crap.pl line 1.
>Unrecognized character \267 at crap.pl line 1.
>
>
>Maybe if I get five-thousand grapefruit and a similar number of keyboards I
>might be able to come up with the Shell to Perl Converter.
>
>:-P
>
>/J\
>--
>Jonathan Stowe <jns@btinternet.com>
>Some of your questions answered:
><URL:http://www.btinternet.com/~gellyfish/resources/wwwfaq.htm>
------------------------------
Date: Sat, 28 Nov 1998 16:24:01 GMT
From: internet.specialist@shaw.wave.ca
Subject: Website Automation
Message-Id: <366023fc.750524532@news.cal.shaw.wave.ca>
Hi;
Ted Holmes here from the Canadian Email Business
Network.
I would very much like to speak with any one about Website
Automation.
I am looking for people who would be interested in helping build a
system that would allow a client to build their own web site on line,
install and configure their own discussion board, guestbook,
form handler, and minor database etc.
Once complete, the Web Site would be easily updated using online forms
which would create changes globally.
It is important that this system does not require the
client to know about perl or cgi or even html.
The Web Sites would be very utilitarian, and not provide much in the
way of graphics (if anything at all), but would provide a very
powerful tool that a client could construct and maintain in a
self-directed manner.
I would like to participate as the marketing director of such a
program, as I already have a database of hundreds of clients that
receive my daily editorial by email.
Is this something you would be interested in discussing or pursuing?
Contact me by Email
iot.help@shaw.wave.ca
If you know of anyone at all that has actually done this or come
close, I would appreciate your pointing me in their direction.
Warm regards,
Ted Holmes
President
http://www.cebn.com
How to Start and Promote Virtually Any Business, Product or Service On
the Internet
------------------------------
Date: 28 Nov 1998 15:07:43 GMT
From: mjtg@cus.cam.ac.uk (M.J.T. Guy)
Subject: Re: What to do when printf() doesn't apply
Message-Id: <73p3jv$kfm$1@pegasus.csx.cam.ac.uk>
In article <365B79CE.CDFA49E9@zerolimits.com>,
doug <doug@zerolimits.com> wrote:
>I'm writing a form input page in Perl, and I
>have the products-prices as key value pairs in a hash.
>I print these out with all the rest of the page
>in a series of print <<"EOF" statements. The problem
>I'm having is that 25.00 gets printed as 25
>and 25.50 gets printed as 25.5
>The way it's done would make it very difficult to use printf.
>Is there some other way to tell perl not to truncate
>trailing zeros?
Why is it difficult to combine printf with <<"EOF" ?
Would something like this do what you want?
printf <<"EOF", $val1, $val2;
The first arg is %8.2f
Here is an inserted $string
The second arg is %8.2f
EOF
Mike Guy
------------------------------
Date: 28 Nov 1998 10:24:27 -0500
From: Lewis Perin <perin@panix7.panix.com>
Subject: Re: Win32::API programming
Message-Id: <pc74srjvo0k.fsf@panix7.panix.com>
Marquis de Carvdawg <carvdawg@patriot.net> writes:
> Can someone point me to a resource that shows me what
> APIs are available to me using Win32::API? I have the PRK,
> but I want to know more...
You can use Win32::API for any function exported by a 32-bit DLL whose
calling sequence is known to you (typically via a C[++] language
header file.) The DLL needn't be a part of any Microsoft
distribution. You just have to read the Win32::API documentation
*very* carefully and code up a little bit of Perl for each external
function you want to use.
Cheers, Lew
------------------------------
Date: 28 Nov 1998 15:38:41 -0000
From: Jonathan Stowe <gellyfish@btinternet.com>
Subject: Re: Win32::API programming
Message-Id: <73p5e1$q6$1@gellyfish.btinternet.com>
In comp.lang.perl.misc Marquis de Carvdawg <carvdawg@patriot.net> wrote:
> Can someone point me to a resource that shows me what
> APIs are available to me using Win32::API? I have the PRK,
> but I want to know more...
>
Probably the best think to do is to get hold of the Win32 SDK from
microsofts web site - all of the API's are documented there in helpfiles.
/J\
--
Jonathan Stowe <jns@btinternet.com>
Some of your questions answered:
<URL:http://www.btinternet.com/~gellyfish/resources/wwwfaq.htm>
------------------------------
Date: 12 Jul 98 21:33:47 GMT (Last modified)
From: Perl-Request@ruby.oce.orst.edu (Perl-Users-Digest Admin)
Subject: Special: Digest Administrivia (Last modified: 12 Mar 98)
Message-Id: <null>
Administrivia:
Special notice: in a few days, the new group comp.lang.perl.moderated
should be formed. I would rather not support two different groups, and I
know of no other plans to create a digested moderated group. This leaves
me with two options: 1) keep on with this group 2) change to the
moderated one.
If you have opinions on this, send them to
perl-users-request@ruby.oce.orst.edu.
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 4313
**************************************