[11624] in Perl-Users-Digest
Perl-Users Digest, Issue: 5224 Volume: 8
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Thu Mar 25 11:07:29 1999
Date: Thu, 25 Mar 99 08:00:26 -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 Thu, 25 Mar 1999 Volume: 8 Number: 5224
Today's topics:
"seeding" the time function <dave@peon.oit.umass.edu>
Re: @INC Problem <hvermeulen@correctnl.com>
ANNOUNCE: UML Tool for PERL <microgold@pipeline.com>
Re: cgi directory listing (Tad McClellan)
Re: File Read Error: Step at / chunk error message <sguidos@nr.infi.net>
Re: Foreign Languages. (Tad McClellan)
Format page length (Thomas Wade Vaughan)
get `top` into a string? <newsgroups@kidkaboom.frogspace.net>
Re: get `top` into a string? <Antonius.Erdmann@mch6.siemens.de>
Re: get `top` into a string? <Tony.Curtis@vcpc.univie.ac.at>
Help a rookie please (Jeffery Jones)
Help a rookie please (Jeffery Jones)
Re: Help a rookie please (Larry Rosler)
Re: Help searching text file <seannln@bit-net.com>
Help: Displaying Database search results slamda@hotmail.com
Re: Help: Displaying Database search results (Jonathan Stowe)
html to text script needed 11jberke@my-dejanews.com
Is there a statement to activate a setenv command <oconnors@cs.ucc.ie>
Is this a perl problem or am I missing somehting... <j.jenkins@gu.edu.au>
Re: MS Access and Perl -- help! <woerdehoff@sdm.de>
Need Help with Simple Program <ophir@saifun.com>
Re: never mind... (Tad McClellan)
Re: New Bee Alert <rick.delaney@home.com>
Re: New Bee Alert <Philip.Newton@datenrevision.de>
Re: New Bee Alert <Wm.Blasius@ks.sel.alcatel.de>
Re: Odd/Even <droby@copyright.com>
Parsing text file <balanscott@earthlink.net>
Re: passing variables to script through SSI? <newsgroups@kidkaboom.frogspace.net>
Re: Perl, Oracle, and SQL <vince@oxxfordinfo.com>
Re: Perl, Oracle, and SQL <jwarner@tivoli.com>
Re: Premature end of script headers <hvermeulen@correctnl.com>
Re: print on win32? <vince@oxxfordinfo.com>
Quicksort won't work (Darren Smurthwaite)
STDOUT to HTML domat6905@my-dejanews.com
Too Late for -T error <cal@spacemoose.com>
WHY: open (HPIPE, "| notexistfile") or die "..."; DOES <ppa@itmasters.com>
Special: Digest Administrivia (Last modified: 12 Dec 98 (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: Thu, 25 Mar 1999 10:46:49 -0500
From: Dave Heaney <dave@peon.oit.umass.edu>
Subject: "seeding" the time function
Message-Id: <36FA5A69.9A19CFA2@peon.oit.umass.edu>
Is there a function in Perl that can take a month, day, year, time set
of arguments, and return the number of seconds from the epoch to that
time? Or am I off to write my own? If it's not actually part of Perl,
but someone else has it out there, it would be great if I could take a
look at it. My version's not very efficient, and it's off by 5 hrs...
Thanks,
-Dave
------------------------------
Date: 25 Mar 1999 13:09:21 GMT
From: Henry Vermeulen <hvermeulen@correctnl.com>
Subject: Re: @INC Problem
Message-Id: <36FA3573.26CF0829@correctnl.com>
> My guess is that something went wrong with the installation of your
> module.
> It's Perl that can't find it, not your script.
But, who am i...
Henry Vermeulen
Jens Engelbrecht wrote:
> Hello,
>
> I wrote a cgi script using the modul LWP::Simple.
> By running the script on the server I get the following error:
>
> "Can't locate LWP/simple.pm in @INC (@INC contains:
> /usr/lib/perl5/i586-linux/5.00404 /usr/lib/perl5
> /usr/lib/perl5/site_perl/i586-linux /usr/lib/perl5/site_perl .) at
> crawler.pl line 9.
> BEGIN failed--compilation aborted at crawler.pl line 9."
>
> The correct path to LWP::Simple is " /usr/lib/perl5/site_perl/LWP " .
> How do I get the script to look in this directory ?
> Thanks for helping.
>
> Jens Engelbrecht
------------------------------
Date: Thu, 25 Mar 1999 09:02:19 -0500
From: "Michael Gold" <microgold@pipeline.com>
Subject: ANNOUNCE: UML Tool for PERL
Message-Id: <7ddh7d$8m1$1@camel25.mindspring.com>
WithClass 99 announces it now supports PERL. We have included an
add-in for reverse engineering PERL into WithClass 99 a UML tool
that currently reverse engineers Java, Delphi, VB, C++, IDL, and Java
class files. What's new about the add-in feature of WithClass is that
it can be modified to customize the reverse engineering!
WithClass also allows you to draw UML diagrams, generate code and
more. We are also writing scripts to generate Perl code and we'll
make these available on our web site.
You can download a free trial version of WithClass 99 from our web
site at http://www.microgold.com. After downloading the demo you
can get the perl add-in at http://www.microgold.com/Stage/vba/addins.html
The add-in uses VBA to generate class models from perl class modules.
One good use of this is to document the existing CPAN modules. WithClass
has a feature that allows you to capture gif, and jpeg files so you can
document
the UML models in html. Also WithClass has the ability to create reports in
Word, Excel, and more.
WithClass runs under 95/98 and NT.
Mike Gold
MicroGOLD Software Inc.
Senior Software Developer
------------------------------
Date: Thu, 25 Mar 1999 03:27:16 -0500
From: tadmc@metronet.com (Tad McClellan)
Subject: Re: cgi directory listing
Message-Id: <41scd7.v44.ln@magna.metronet.com>
Edward Villalovoz (edwardv@jps.net) wrote:
: Can anyone tell me how to pass a variable to my perl script from my html
: page? Thanks in advance...
The same way that you would pass a variable to a C or
Visual Basic CGI program.
That is, it has nothing to do with Perl.
It is part of the Common Gateway Interface (CGI).
CGI things are discussed in the CGI newsgroup:
comp.infosystems.www.authoring.cgi
--
Tad McClellan SGML Consulting
tadmc@metronet.com Perl programming
Fort Worth, Texas
------------------------------
Date: Thu, 25 Mar 1999 09:01:40 -0500
From: "Steve Guidos" <sguidos@nr.infi.net>
Subject: Re: File Read Error: Step at / chunk error message
Message-Id: <7ddfm0$b5j$1@nw001t.infi.net>
Ronald J Kimball wrote:
>Steve Guidos <sguidos@nr.infi.net> wrote:
>> My perl script aborts and generates the following error message
>> PRODFILE Step at /u/web/artfo4/cgi-local/cron-RandHome.pl line 35,
>> <PRODFILE> chunk 454.
>
>I don't believe that is line 35 of your program.
>The line which is outputting that message should look more like:
>do { something } or die "PRODFILE Step";
> ^^^^^^^^^^^^^
>because that's the text that is appearing in the output.
>'<PRODFILE> chunk 454' means that this message was output after reading
>from the PRODFILE filehandle 454 times.
You are right, I mis-counted the lines in my program (next time I'll turn on
line numbering, mea culpa). The error was generated because I was
attempting to read past the eof. Thank you for your help.
Steve Guidos
------------------------------
Date: Wed, 24 Mar 1999 17:59:39 -0500
From: tadmc@metronet.com (Tad McClellan)
Subject: Re: Foreign Languages.
Message-Id: <roqbd7.qn3.ln@magna.metronet.com>
John Cokos (jcokos@ccs.net) wrote:
: How does perl handle / does it support foreign languages using non-standard
: character sets (like polish, chinese, etc)
perldoc perllocale
--
Tad McClellan SGML Consulting
tadmc@metronet.com Perl programming
Fort Worth, Texas
------------------------------
Date: 25 Mar 1999 13:52:43 GMT
From: vaughan@well.com (Thomas Wade Vaughan)
Subject: Format page length
Message-Id: <7ddf3b$9fh$1@its.hooked.net>
I am sorry if this question has already been answered, but I could not find it in
the FAQ. I am using the $= variable to set the page length in a formatted output
to the screen and the $= variable allows me to change the page length. When I
change the output to a file the variable seems to have no effect. Is there a
reason the the $= variable doesn't work the same way in file output as in screen
output and how might I change the page length to a file?
Thanks, Tom
------------------------------
Date: Thu, 25 Mar 1999 15:07:46 GMT
From: "Theodore" <newsgroups@kidkaboom.frogspace.net>
Subject: get `top` into a string?
Message-Id: <36fa510f.0@news3.escape.ca>
I've come accross a peculiar problem. I am writing a script to show how long
the server has been "up" and am going to display it on a web page. My
sysadmin told me about `top` and I think it would be the perfect way to get
this into the SSI (thats how I'm going to callit) the only thing is that top
never ends, it goes until you hit ctrl-c. How would I get just one second
or something into a string? using
$topresult = `top`;
doesn't work, neither does
open(TOP,"|top");
@topresult = <TOP>;
close(TOP);
I'm at a loss, I may have to do this by writing the date the the server
started up unti a text file, and then comparing and doing all kinds of
complicated math to get the hours/minutes its been up for.
>From Theodore
PS, if you could send the reply by email as well I would appreciate it..
------------------------------
Date: Thu, 25 Mar 1999 16:14:49 +0100
From: Toni Erdmann <Antonius.Erdmann@mch6.siemens.de>
Subject: Re: get `top` into a string?
Message-Id: <36FA52E9.4CF20A23@mch6.siemens.de>
Theodore wrote:
> I've come accross a peculiar problem. I am writing a script to show how long
> the server has been "up" and am going to display it on a web page. My
> sysadmin told me about `top` and I think it would be the perfect way to get
> this into the SSI (thats how I'm going to callit) the only thing is that top
> never ends, it goes until you hit ctrl-c. How would I get just one second
> or something into a string? using
> $topresult = `top`;
gives you the first line only, use
@topresult = `top`;
instead
>
> doesn't work, neither does
> open(TOP,"|top");
would be used to write to top, use
open( TOP, "top |" ); or open( TOP, "top 2>&1 |" );
instead, to read the results of top
>
> @topresult = <TOP>;
> close(TOP);
>
> I'm at a loss, I may have to do this by writing the date the the server
> started up unti a text file, and then comparing and doing all kinds of
> complicated math to get the hours/minutes its been up for.
>
> From Theodore
> PS, if you could send the reply by email as well I would appreciate it..
this is all true, if top is a program/script and not a plain file
Ciao
Toni
------------------------------
Date: 25 Mar 1999 16:46:36 +0100
From: Tony Curtis <Tony.Curtis@vcpc.univie.ac.at>
Subject: Re: get `top` into a string?
Message-Id: <83k8w5wp0j.fsf@vcpc.univie.ac.at>
Re: get `top` into a string?, Theodore
<newsgroups@kidkaboom.frogspace.net> said:
Theodore> I've come accross a peculiar problem. I am
Theodore> writing a script to show how long the
Theodore> server has been "up" and am going to
Theodore> display it on a web page. My sysadmin told
Theodore> me about `top` and I think it would be the
"top" is an interactive process viewer, it's not
really suitable for this kind of operation.
"uptime" is more what you want, the simplest way is
chomp($ut = `uptime`);
print "$ut\n";
hth
tony
--
Tony Curtis, Systems Manager, VCPC, | Tel +43 1 310 93 96 - 12; Fax - 13
Liechtensteinstrasse 22, A-1090 Wien. | <URI:http://www.vcpc.univie.ac.at/>
"You see? You see? Your stupid minds! | private email:
Stupid! Stupid!" ~ Eros, Plan9 fOS.| <URI:mailto:tony_curtis32@hotmail.com>
------------------------------
Date: Thu, 25 Mar 1999 14:05:04 GMT
From: jeffery_jones@mtlusa.com (Jeffery Jones)
Subject: Help a rookie please
Message-Id: <36fa4248.70640479@news.supernews.com>
I'm working on a perl script (my first) that summarizes a log file for
me. With
some pretty horrible code I've gotten it to do what I want except for
one
thing. I'd like the script to run as a cron job. But I don't want the
entire
log file analyzed every time...only what are new entries since the
last
analysis. I've thought of using DateManip to only examine entries by
time...but
that seemed like a clunky solution.
What I'd like to do is place a string like 'analyzed' in the log file
and only
read from the last instance on into an array for analysis. I've pored
over the
NGs and man pages and I know this has to be easy for a seasoned perl
coder. Any
help?
Regards,
Jeff
------------------------------
Date: Thu, 25 Mar 1999 14:05:44 GMT
From: jeffery_jones@mtlusa.com (Jeffery Jones)
Subject: Help a rookie please
Message-Id: <36fb42b5.70748978@news.supernews.com>
I'm working on a perl script (my first) that summarizes a log file for
me. With
some pretty horrible code I've gotten it to do what I want except for
one
thing. I'd like the script to run as a cron job. But I don't want the
entire
log file analyzed every time...only what are new entries since the
last
analysis. I've thought of using DateManip to only examine entries by
time...but
that seemed like a clunky solution.
What I'd like to do is place a string like 'analyzed' in the log file
and only
read from the last instance on into an array for analysis. I've pored
over the
NGs and man pages and I know this has to be easy for a seasoned perl
coder. Any
help?
Regards,
Jeff
------------------------------
Date: Thu, 25 Mar 1999 07:05:04 -0800
From: lr@hpl.hp.com (Larry Rosler)
Subject: Re: Help a rookie please
Message-Id: <MPG.1163f079c951cea99897c5@nntp.hpl.hp.com>
[Posted and a courtesy copy sent.]
In article <36fb42b5.70748978@news.supernews.com> on Thu, 25 Mar 1999
14:05:44 GMT, Jeffery Jones <jeffery_jones@mtlusa.com >says...
...
> What I'd like to do is place a string like 'analyzed' in the log file
> and only read from the last instance on into an array for analysis.
The cleanest solution (to me) involves using either the tell() function
or the -s (file-size) operator to compute the file size at the end of an
analysis, then store that result in a second file. On the next run, use
that value to seek() to where you left off the last time.
--
(Just Another Larry) Rosler
Hewlett-Packard Company
http://www.hpl.hp.com/personl/Larry_Rosler/
lr@hpl.hp.com
------------------------------
Date: Thu, 25 Mar 1999 08:27:45 -0500
From: Sean Phillips <seannln@bit-net.com>
To: John Fettig <jfettig@students.uiuc.edu>
Subject: Re: Help searching text file
Message-Id: <36FA39D1.6021F163@bit-net.com>
John -
Why are you going to an external program to do something that is so easy
to do in Perl?
> $found = `findstr /I $searcher thefile.txt`;
$searcher = quotemeta($searcher);
open SEARCH, "thefile.txt";
while (<SEARCH>) {
$found = $_ if(/$searcher/i);
}
close SEARCH;
This will probably be faster than whatever searchstr is, and much easier
to debug.
I do not know what searchstr is, but I am assuming the /I means
case-insensitive - if not use the line "$found = $_ if(/$searcher/);"
instead.
The line $searcher = quotemeta($searcher); is a good idea if the users
might enter characters such as "\" as part of the search string.
Admittingly, this script will return the last match in the file. If
you use the line:
push @results, $_ if(/$searcher/i); instead of $found = $_
if(/$searcher/i); the array @results will contain all of the lines
that matched the search string.
Good luck,
- Sean
John Fettig wrote:
> I'm a newbie to perl, but I'm not sure if Perl is my problem. I am
> trying
> to search a text file using an online form generated by a Perl script.
>
> The script basically calls the ms-dos command findstr on the string
> that
> the user enters in, and searches the file I have specified. Then I
> want
> it to print the results from the search on the screen. So far, I
> can't
> get anything to show up. Here's my code:
>
> BEGIN {
> unshift(@INC);
> }
>
> use CGI qw(:standard);
>
> print header;
> print start_html('Search the File'),
> h1('Search the File'),
> start_form,
> "Enter a string to search for: ",textfield('search'),
> submit,
> end_form,
> hr;
>
> if (param()) {
> $searcher = param('search');
> $found = `findstr /I $searcher thefile.txt`;
> print
> "Search Results for ",em($searcher),
> p,
> em($found),
> hr;
> }
>
> Now, I do get output from the "Search Results for ",em($searcher),
> line.
> That works fine. But I don't ever get any output from the $found. My
>
> best guess is that findstr doesn't return a string. I've tried
> putting in
> strings to search for, instead of $searcher, in my code but still no
> luck.
> I've also tried just printing the findstr line. Can anyone point out
> what
> I am doing wrong?
>
> John Fettig
> University of Illinois
------------------------------
Date: Thu, 25 Mar 1999 13:11:27 GMT
From: slamda@hotmail.com
Subject: Help: Displaying Database search results
Message-Id: <7ddclo$aq3$1@nnrp1.dejanews.com>
Hi,
I've successfully written some code to use a HTML form to query a SQL
database and return the results as an HTML page, however I would like to
display only a certain range of the result set each time (ie matches 1-10
on 1st page, 10-20 on the second etc, etc)
How can I do this?
Thanks in advance
Ian Dash
-----------== Posted via Deja News, The Discussion Network ==----------
http://www.dejanews.com/ Search, Read, Discuss, or Start Your Own
------------------------------
Date: Thu, 25 Mar 1999 15:18:48 GMT
From: gellyfish@gellyfish.com (Jonathan Stowe)
Subject: Re: Help: Displaying Database search results
Message-Id: <36fa5381.23060188@news.dircon.co.uk>
On Thu, 25 Mar 1999 13:11:27 GMT, slamda@hotmail.com wrote:
>Hi,
> I've successfully written some code to use a HTML form to query a SQL
>database and return the results as an HTML page, however I would like to
>display only a certain range of the result set each time (ie matches 1-10
>on 1st page, 10-20 on the second etc, etc)
>
>How can I do this?
>
>
I posted a suggestion how one might achieve this in :
<http://www.dejanews.com/[ST_rn=ps]/getdoc.xp?AN=451933628&fmt=raw>
Though it might not be so good for a larger result set ...
/J\
------------------------------
Date: Thu, 25 Mar 1999 14:57:18 GMT
From: 11jberke@my-dejanews.com
Subject: html to text script needed
Message-Id: <7ddis7$g8n$1@nnrp1.dejanews.com>
Seeking a script that will convert a large graphical web site with javascript
and include files to a text-only web site with hyperlinks intact and using
alternative text in place of graphics. Please email me privately as I do not
read this newsgroup.
-----------== Posted via Deja News, The Discussion Network ==----------
http://www.dejanews.com/ Search, Read, Discuss, or Start Your Own
------------------------------
Date: Thu, 25 Mar 1999 15:12:42 +0000
From: sean O'Connor <oconnors@cs.ucc.ie>
Subject: Is there a statement to activate a setenv command
Message-Id: <36FA526A.E49A5EC5@cs.ucc.ie>
I'm running a perl program to access an oracle database using oraperl.
To make the program run I have to type in the command
'setenv LD_LIBRARY_PATH ${ORACLE_HOME}/lib', before I run it. I now have
to run the program straight from the net using cgi so I can't type the
setenv command and I was wondering if there is any command in perl that
will run the setenv statement for me.
Eoghan Bourke
bourke@ocean.ucc.ie
------------------------------
Date: Thu, 25 Mar 1999 08:23:00 +1100
From: "Griffith" <j.jenkins@gu.edu.au>
Subject: Is this a perl problem or am I missing somehting...
Message-Id: <7dbkuf$pfb$1@kraken.itc.gu.edu.au>
Hi
I am new to perl, actually started a few days ago
with a CGI script to help with some web based
tutorial allocations for uni. However I have reached
a point where I am mystified.
I have a script which reads a csv database. This
part all works fine for lookups etc.
However being the adventurous sort I wrote
the script to add records to the database. let me
say first that this is a permissions problem
but a weird one.
In the perl script I open the file which is
rwxrwxrwx meown webgroup size date time database.csv
I can open the file for reading just fine. But opening
for writing/appending is the problem.
If I run this script (as me) from the command line
it works just fine. However when I run the script
from the webserver (as nobody) it crashes. In debugging
the scrip the last info dumped is (I open STDOUT ">dump");
open (FILE, ">>datbase.csv);
Ther perl script stops here with no error messages.
OK so I made the cgi script run in setgid mode, no change!!
Hmm lets get serious run it in setuid (as me). Huh
still wont open the file for appending ????
Change the file name to "xxx" and run again, no problem.
In setgid the created file is:
rwxrwxrwx nobody webgroup size date time xxx.csv
In setuid mode the created file is:
rwxrwxrwx meown webgroup size date time xxx.csv
So the script does actually run as me/group as required.
So why can't I open the original database.csv for writing ???
Any suggestions appreciate ??????
Regards and thanks
Jon
------------------------------
Date: Thu, 25 Mar 1999 15:12:39 +0100
From: Hendrik =?iso-8859-1?Q?W=F6rdehoff?= <woerdehoff@sdm.de>
Subject: Re: MS Access and Perl -- help!
Message-Id: <36FA4457.183183D6@sdm.de>
Hi Pete,
if you haven't figured it out in the meantime here are some
explanations:
1) DBD::ODBC needs an ODBC driver manager to work with (you got it right
and went for iODBC although your package does not seem to be complete).
2) An ODBC driver manager is just that: a program to manage ODBC
drivers. You need an ODBC driver as well.
And here the trouble starts: There is no ODBC driver for MS Access on
UNIX! Nobody ever ported the Jet Database Engine to UNIX so you will not
be able to use MS Access database files on UNIX.
You have three solutions:
a) Run your Perl scripts on Win32.
b) Use a UNIX database instead of MS Access (e.g. MySQL).
c) Get two computers (one UNIX for your Perl script, one Win32 for MS
Access) and use DBD::Proxy or some commercial middleware (e.g.
http://www.openlinksw.com/) to get them talking.
Yours
Hendrik
Pete wrote:
> I'm having trouble understanding all the steps necessary to get perl to
> 'talk' with a MS Access database. Here's what I've done so far:
>
> 1- I installed DBI ver 1.06
> 2- At this point, I tried installing DBD-ODBC-0.20
> 3- When I ran perl Makefile.pl it told me that I need an ODBC Driver
> Manager.
>
> I'm confused because I thought that DBD-ODBC *was* the driver. If it's
> not, what exactly is it? Anyhow, it said:
>
> If you do not have an ODBC Driver Manager you can try building
> the free iODBC Driver Manager in the iodbcsrc directory.
>
> OK. so i cd to iodbcsrc and follow the instructions to the letter. This
> is what I get:
>
> # ./build linux-elf
> autoconfig linux-elf
> make
> gcc -O -fPIC -ansi -I. -DDLDAPI_SVR4_DLFCN -DVERSION=\"2.12.0\" -c
> dlf.c -o dlf.o
> In file included from dlf.c:16:
> dlf.h:4: windows.h: No such file or directory
>
> I'm having a rough time here. Can some kind soul please help me get this
> running?
>
> Much thanks!
> Peter
>
> --
> ---------------------------------------------------------------
> http://landau.ucdavis.edu/psalzman
> psalzman@landau.ucdavis.edu
> One world, one web, one program. -- Microsoft Ad Campaign
> Ein Volk, ein Reich, ein Fuhrer. -- Nazi Ad Campaign
> Prevent world domination, Install Linux today!
> ---------------------------------------------------------------
> The best way to accelerate a win95 system is at 9.81 m/s^2
--
Nach Paragraph 28 Abs. 3 des Bundesdatenschutzgesetz widerspreche ich
der Nutzung oder Uebermittlung meiner Daten fuer Zwecke der Werbung
oder der Markt- oder Meinungsforschung.
Pursuant to US Code, Title 47, Chapter 5, Subchapter II, Sec. 227,
any and all unsolicited commercial E-mail sent to this address
is subject to a download and archival fee in the amount of $500
US (per infraction). E-mailing denotes acceptance of these terms.
--
Hendrik W"ordehoff |s |d &|m | software design & management
| | | | GmbH & Co. KG :
woerdehoff@sdm.de | | | | Thomas-Dehler-Str. 27 >B)
Tel/Fax (089) 63812-337/515 81737 M"unchen :
------------------------------
Date: Thu, 25 Mar 1999 16:12:04 +0200
From: Ophir Marko <ophir@saifun.com>
Subject: Need Help with Simple Program
Message-Id: <36FA4433.6B64728@saifun.com>
#! /local/perl/bin/perl -w
$index=0;
while(<>){
$i=0;
while ($i <= $#_){
++$i;
}
$index=$index+$#_+1;
}
$t=0;
$a=123;
open(FILE2, ">file");
if ($index eq $a){
print FILE2 $index, "\n";
++$t;
}
close(FILE2);
Please note that there are some relics of a previous script in here.
Disregard them
--
Ophir Marko e-mail: ophir@saifun.com
Saifun Semiconductors Tel: 972-9-885-0830
Toper Bldg. 65 Ha'Melacha St. Fax: 972-9-885-0831
Industrial Zone, Netanya South
------------------------------
Date: Thu, 25 Mar 1999 02:43:22 -0500
From: tadmc@metronet.com (Tad McClellan)
Subject: Re: never mind...
Message-Id: <qepcd7.c04.ln@magna.metronet.com>
Bob Trieger (sowmaster@juicepigs.com) wrote:
: kwoody@citytel.net wrote:
: >
: >as is the case just about every time I post to this group or some other
: >because after much fscking about trying to figure something out I figured
: >it out...
: >
: >if (not defined $var) {
: > do something
: >} else {
: > do someting else
: >}
: >is right, not
: >
: >if not (defined $var)
: $var?do something:do something else;
: will work but I am hoping somebody will tell me why it shouldn't be done this
: way.
In addition to the things already noted, there are two other
problems that I don't think anyone has mentioned.
1) the logic is backwards
2) it executes the "do something" if $var='' or $var=0,
which the original does not do.
--
Tad McClellan SGML Consulting
tadmc@metronet.com Perl programming
Fort Worth, Texas
------------------------------
Date: Thu, 25 Mar 1999 13:45:19 GMT
From: Rick Delaney <rick.delaney@home.com>
Subject: Re: New Bee Alert
Message-Id: <36FA3FE7.A19F37A2@home.com>
[posted & mailed]
Philip Newton wrote:
>
> William H. Asquith wrote:
> >
> > Also if($_ eq "\n") is a preferred idiom instead of if($_ eq \n)
>
> What do you mean by "preferred idiom"? Does the second variant work?
> It seems to take a reference to something called 'n' (a file handle
> maybe?);
Not a filehandle.
$ perl -le '$_=\n;print ref'
SCALAR
$ perl -le '$_=\*n;print ref'
GLOB
perldoc perldata
perldoc perlref
--
Rick Delaney
rick.delaney@home.com
------------------------------
Date: Thu, 25 Mar 1999 14:49:52 +0100
From: Philip Newton <Philip.Newton@datenrevision.de>
Subject: Re: New Bee Alert
Message-Id: <36FA3F00.33E3F915@datenrevision.de>
Rick Delaney wrote:
> Philip Newton wrote:
> > William H. Asquith wrote:
> > > Also if($_ eq "\n") is a preferred idiom instead of if($_ eq \n)
> >
> > What do you mean by "preferred idiom"? Does the second variant work?
> > It seems to take a reference to something called 'n' (a file handle
> > maybe?);
>
> Not a filehandle.
>
> $ perl -le '$_=\n;print ref'
> SCALAR
> $ perl -le '$_=\*n;print ref'
> GLOB
Ah, OK. A reference to a bareword then. ($$_ in your example is 'n').
Either way, \n is \"n" not "\n".
Cheers,
Philip
------------------------------
Date: Thu, 25 Mar 1999 15:35:05 +0100
From: William Blasius #42722 <Wm.Blasius@ks.sel.alcatel.de>
To: Gabriel Richards <grichard@uci.edu>
Subject: Re: New Bee Alert
Message-Id: <36FA4999.446B9B3D@ks.sel.alcatel.de>
Gabriel Richards wrote:
>
> > Why don't you post a cut-and-paste of your code, and we'll take a look...
>
> Ya know...I've never met a more prompt helpful group of computer folk...ya
> guys are all great...OK...I explained the wrong problem, but I still have a
> problem.
>
> while (<THREAD>) {
> #if...etc
> elsif ($_ eq "\n") { print "<br>"}
> else { print "$_ \n"}
> }
>
> Perl was in fact printing the blank lines, but I'm outputting HTML and I
> forgot that browsers ignore extra spaces and lines. So, I want to make up
> for that by printing the <br> tag where the originating text file has a
> blank line. For some reason this isn't working and I'm not chopping or
> chomping anything. The originating text file looks as follows:
>
> This is a line of text followed by a blank line then more text.
>
> This is the second line of text (paragraph).
>
> Gabe
This worked for me:
__CODE__
while (<DATA>) {
if ($_ eq "") { die "got a null string in DATA!" }
elsif ($_ eq "\n") { print "<br>"}
else { print "$_ \n"}
}
__END__
This is a line of text followed by a blank line then more text.
This is the second line of text (paragraph).
<EOF>
Produced:
This is a line of text followed by a blank line then more text.
<br>This is the second line of text (paragraph).
<EOF>
If this isn't your intention perhaps you want to forget adding
that newline (unless you *want* double spacing.
Regards,
Wm Blasius
Stuttgart
---
...now I'm <wm.blasius@ks.sel.alcatel.de> - no matter what my mail
server says!
------------------------------
Date: Thu, 25 Mar 1999 13:12:49 GMT
From: Don Roby <droby@copyright.com>
Subject: Re: Odd/Even
Message-Id: <7ddcob$aqi$1@nnrp1.dejanews.com>
In article <MPG.1162c325468f27289897b4@nntp.hpl.hp.com>,
lr@hpl.hp.com (Larry Rosler) wrote:
> In article <7db5bc$cl0$1@nnrp1.dejanews.com> on Wed, 24 Mar 1999
> 16:54:11 GMT, Don Roby <droby@copyright.com >says...
> ...
>
> > I mean, what if we want to port our code to
> > a ternary machine? ;-)
>
> One doesn't have to go that far. There *were* machines that used ones-
> complement binary representation for negative numbers. On such a
> machine, the number -1 (~1, not ~0) would be *even* using a bitwise
> operation on natively-represented integers.
>
I was of course joking, but had forgotten that machines actually used
ones-complement once upon a time. I think that might actually be before I
dealt with computers. ;-)
> I think that 32-bit twos-complement binary representation is so
> ingrained in Perl that the compiler would have to simulate that
> representation on any hardware, no matter what the native machine
> representation of an integer might be.
>
Doesn't it do 64-bit on 64-bit machines, at least in numeric context?
Dealing with things as odd as ternary machines or ones-complement machines
would just about have to wreak havoc on bitwise operators and pack/unpack, I
would think. We might have to simulate twos-complement for compatibility,
but also supply ways to get at the real representation.
But we have diverged from the topic of the thread (and perhaps the group).
We learn even/odd by being forced by our parents to share. This is also how I
first contacted the integers mod 6 and fractions.
--
Don Roby
-----------== Posted via Deja News, The Discussion Network ==----------
http://www.dejanews.com/ Search, Read, Discuss, or Start Your Own
------------------------------
Date: Thu, 25 Mar 1999 10:46:03 -0500
From: "Alan Scott" <balanscott@earthlink.net>
Subject: Parsing text file
Message-Id: <rXsK2.17$FP.735@newsfeed.slurp.net>
I need to read a test file into an array so I can then write it out as a
different file. How would I do this????
----------------------------------------------------------
Alan Scott
ascott@powersite.net
----------------------------------------------------------
------------------------------
Date: Thu, 25 Mar 1999 15:43:09 GMT
From: "Theodore" <newsgroups@kidkaboom.frogspace.net>
Subject: Re: passing variables to script through SSI?
Message-Id: <36fa59a6.0@news3.escape.ca>
To the best of my limited knowledge of Apache and SSI you can't pass a query
string in an SSI call, the script gets passed the one in the page that was
loaded.. so say you load up test.shtml?some+quesry+string
and you have <!--#exec cgi="cgi-bin/test.cgi" --> test.cgi will be passed
some+query+string.
>From Theodore
COUNSEL.NET wrote in message <36F9F450.7BE5D0C7@counsel.net>...
>Hi folks,
>What I'd like to do is format an SSI call to the banner program and pass
>a variable to the script so that it defaults to a control file specified
>in the variable passed to the script through the SSI. I've tried a few
>variations but all generate errors. I was thinking something like
>this...
>
> <!--#exec cgi="/cgi-bin/bannerscript.cgi?controlfileabc"-->
>
>...to pass a variable to the script which would tell the script to pull
>the banner from the control file "controlfileabc". Alas this syntax
>crashes my program.
------------------------------
Date: Thu, 25 Mar 1999 15:02:52 GMT
From: "Vincent P. Mautone" <vince@oxxfordinfo.com>
Subject: Re: Perl, Oracle, and SQL
Message-Id: <wesK2.11$YA1.30198@client.news.psi.net>
John,
Look up the 'LIKE' operator in your SQL docs. Also, you can may be able to
use the LEFT function or right function.
Vince
John Warner <jwarner@tivoli.com> wrote in message
news:36F95382.2345F36C@tivoli.com...
>I'm trying to write a Perl script to query an Oracle db. The Perl
>portion works fine but I seem to be having a problem with performing
>substring searches in SQL. (I know, I know it's a little off topic but
>please bear with me.) The SQL string Perl is building is:
>
>SELECT SOLUTION_ID,SOLUTION,DESCRIPTION FROM EXAV.SOLUTIONS WHERE
>DESCRIPTION = some_portion_of_text;
>
>_The SQL Guide to Oracle_ hasn't been much help in how I should be going
>about searching for, say *FAQ*. Where are there any decent on-line
>references for SQL that can help me?
>
>--
>
>John Warner Tivoli Systems Inc.
>Sales Support Engineer 9442 Capital Of Texas Hwy North
>Sales Infrastructure Group Austin, TX 78759
>john_warner@tivoli.com
>
>
------------------------------
Date: Thu, 25 Mar 1999 09:20:19 -0600
From: John Warner <jwarner@tivoli.com>
Subject: Re: Perl, Oracle, and SQL
Message-Id: <36FA5433.382FADBB@tivoli.com>
Thanks to all that responded and for those of you who didn't for not flaming
me. I've solved the SQL portion of my problem. Now all I need to do is get
the rest of it working. ;-)
--
John Warner Tivoli Systems Inc.
Sales Support Engineer 9442 Capital Of Texas Hwy North
Sales Infrastructure Group Austin, TX 78759
john_warner@tivoli.com
------------------------------
Date: 25 Mar 1999 13:16:42 GMT
From: Henry Vermeulen <hvermeulen@correctnl.com>
Subject: Re: Premature end of script headers
Message-Id: <36FA372B.B96B8960@correctnl.com>
mmm, looks quite easy.
In your server config files there a directory mentioned from where youre scripts
are running. Mostly CGI-BIN. You simply can't start a script from somewhere else.
Its rejected by the server.
Read all about it at
http://language.perl.com/CPAN/doc/FAQs/cgi/idiots-guide.html
Good luck.
Henry Vermeulen
solidice@my-dejanews.com wrote:
> I'm trying to get this guestbook CGI script to work. I've put the script in
> it's own directory called guestbook along with the .htm files and images.
> I've chmod 755 guest.cgi the script. Then went to the add.htm so I could see
> if it would work. I get a 500 Internal Server Error saying this
>
> Internal Server Error
>
> The server encountered an internal error or misconfiguration and was unable to
> complete your request.
>
> Please contact the server administrator, electron@electronicparty.com and
> inform them of the time the error occurred, and anything you might have done
> that may have caused the error.
>
> Premature end of script headers:
> /home/electron/public_html/guestbook/guest.cgi
>
> Additionally, a 404 Not Found error was encountered while trying to use an
> ErrorDocument to handle the request.
>
> Apache/1.3.3 Server at www.electronicparty.com Port 80
>
> I telnet to my server and do perl -c guest.cgi and get guest.cgi syntax ok
> Also print "Content-type: text/html\n\n"; is already in the guest.cgi script
>
> So if anyone can give me some ideas. I'd appreciate it. I have no clue what
> I'm really doing.
>
> -----------== Posted via Deja News, The Discussion Network ==----------
> http://www.dejanews.com/ Search, Read, Discuss, or Start Your Own
------------------------------
Date: Thu, 25 Mar 1999 15:05:35 GMT
From: "Vincent P. Mautone" <vince@oxxfordinfo.com>
Subject: Re: print on win32?
Message-Id: <3hsK2.12$YA1.31766@client.news.psi.net>
You should be able to make an OLE call to any OLE compliant application (MS
Word for example). Reference the Win32::OLE for an example. You should be
able to Open,Print,and then close any OLE server from within perl without
having your user do it for you.
Good luck
Vince
GEMINI <dennis@info4.csie.nctu.edu.tw> wrote in message
news:7db3mu$9ve$1@netnews.csie.NCTU.edu.tw...
>is there any module that can provide
>print function on win32?
>my perl program will generate a GIF
>image and I'd like to print it from
>printer directly by program. Maybe I can
>launch an application to load the image
>and print it, but the user has to close the application.
>Is there any other solution?
------------------------------
Date: Thu, 25 Mar 1999 15:33:36 GMT
From: darrenNO.SPAMsmurthwaite@unn.ac.uk (Darren Smurthwaite)
Subject: Quicksort won't work
Message-Id: <36fa56fa.604315079@news>
I have just started using PERL and am trying to convert some old C++
routines. Can anyone tell me what is wrong with the following code?
It is trying to read a file then quicksort the array but it doesn't
sort anything. Is it something to do with the way the variables work?
Cheers
da5
#-----
#!/usr/local/bin/perl
sub swap #swaps elements in array
{
local($i,$j)=@_;
$temp=@list[i];
@list[i]=@list[j];
@list[j]=$temp;
}
sub quicksort
{
local($l,$r)=@_;
if($r-$l>0)
{
if(@list[$r]<@list[$r-1])
{
swap($r-1,$r); #swap the numbers
}
}
if($r>$l)
{
print "quicksort(l,r)=".$l.",".$r."\n";
$pv=@list[$r];
$i2=$l-1;
$j2=$r;
while($i2<$j2)
{
while(@list[++$i2]<$pv){};
while(@list[--$j2]>$pv){};
if($i2<$j2)
{
swap($i2,$j2);
}
}
swap($i2,$r);
quicksort($l,$i2-1);
quicksort($i2+1,$r);
}
}
#-END OF SUBS---------------------------
$infile='data.txt'; # Name the file
open(INFILE,"<$infile"); # Open the file
@list=<INFILE>; # Read it into an array
close(INFILE); # Close the file
$aend=$#list;
quicksort(0,$aend);
print $aend."\n\n";
foreach $line (@list)
{
print"$line";
}
#-----END-----
------------------------------
Date: Thu, 25 Mar 1999 15:00:24 GMT
From: domat6905@my-dejanews.com
Subject: STDOUT to HTML
Message-Id: <7ddj21$gju$1@nnrp1.dejanews.com>
I want to execute a system command (e.g. "ls directory") and show otput on the
Web page. What would be the proper way to to this?
I'm trying following code but it doesn't appear in the browser:
#!/usr/bin/perl
require "cgi-lib/cgi-lib.pl";
@pag = 'radlist';
...
print &PrintHeader;
print "<html><body>@pag</body></html>";
...
-----------== Posted via Deja News, The Discussion Network ==----------
http://www.dejanews.com/ Search, Read, Discuss, or Start Your Own
------------------------------
Date: Fri, 26 Mar 1999 00:43:52 +0900
From: Cal Bond <cal@spacemoose.com>
Subject: Too Late for -T error
Message-Id: <36FA59B8.5AA1@spacemoose.com>
Hi-
I downloaded a cgi script designed to grade multiple choice forms. When
I got everything sorted out and put on the page, I got a Internal Server
Error (500)- 'premature end of script headers'. I downloaded perl and
ran the script from the command line with the 'perl -d' function and got
an error 'Too late for -T option at (name).cgi line 1'. I latered line
one, the path to perl, for my server. It's
#!/usr/bin/perl -T
I've tried it without the -T extension but then get screens full of
error output. I even tried just running the script with the original
perl path (#!/usr/local/bin/perl) from the command line just to see hwat
would happen and still get the same '-T option' error.
You can probably tell I'm not much of a programmer and apologize if this
is a really dumb question or I've left something major out, but I've
been through all the faqs and I'm still stuck. Can anyone help me out?
Thanks
Callan Bond
------------------------------
Date: Thu, 25 Mar 1999 16:44:05 +0100
From: "Patrice M.I. Parmentier" <ppa@itmasters.com>
Subject: WHY: open (HPIPE, "| notexistfile") or die "..."; DOES NOT DIE ???
Message-Id: <36FA59C5.34975D75@itmasters.com>
I want to open a pipe for writing to the stdin of a program:
open (HPIPE, "| xxxx") or die "...";
!!! The open never fails, even when xxxx does not exist !!!
WHY???
In addition, i have the following problem:
- I open a pipe with an existing xxxx program
- I write to xxxx via HPIPE and i see that xxxx receive the piped data
- I kill xxxx
- The perl script still runs, no SIGPIPE signal is sent ; i can still
write to the pipe... (where are sent the data???)
GENERAL QUESTION:
How to know when the pipe is broken???
(please do not answer with checking for existence of data (files)
produced by xxxx).
PS:
- 1. I have used an activeperl 5.09 on NT4 and a 5.004 perl on solaris.
Both give the same results.
- 2. On NT, the xxxx command is executed inside a CMD. I kill the CMD
and the xxxx command ; the perl script still runs...
--
Patrice M.I. PARMENTIER
Development Engineer
--------------------------------------------------------------------
IT Masters s.a. phone: 32.4.367.83.04
Centre Socran, Av. Pre-Aily fax: 32.4.367.83.12
B-4031 ANGLEUR email: ppa@itmasters.com
BELGIUM internet: http://www.itmasters.com
--------------------------------------------------------------------
------------------------------
Date: 12 Dec 98 21:33:47 GMT (Last modified)
From: Perl-Request@ruby.oce.orst.edu (Perl-Users-Digest Admin)
Subject: Special: Digest Administrivia (Last modified: 12 Dec 98)
Message-Id: <null>
Administrivia:
Well, after 6 months, here's the answer to the quiz: what do we do about
comp.lang.perl.moderated. Answer: nothing.
]From: Russ Allbery <rra@stanford.edu>
]Date: 21 Sep 1998 19:53:43 -0700
]Subject: comp.lang.perl.moderated available via e-mail
]
]It is possible to subscribe to comp.lang.perl.moderated as a mailing list.
]To do so, send mail to majordomo@eyrie.org with "subscribe clpm" in the
]body. Majordomo will then send you instructions on how to confirm your
]subscription. This is provided as a general service for those people who
]cannot receive the newsgroup for whatever reason or who just prefer to
]receive messages via e-mail.
The Perl-Users Digest is a retransmission of the USENET newsgroup
comp.lang.perl.misc. For subscription or unsubscription requests, send
the single line:
subscribe perl-users
or:
unsubscribe perl-users
to almanac@ruby.oce.orst.edu.
To submit articles to comp.lang.perl.misc (and this Digest), send your
article to perl-users@ruby.oce.orst.edu.
To submit articles to comp.lang.perl.announce, send your article to
clpa@perl.com.
To request back copies (available for a week or so), send your request
to almanac@ruby.oce.orst.edu with the command "send perl-users x.y",
where x is the volume number and y is the issue number.
The Meta-FAQ, an article containing information about the FAQ, is
available by requesting "send perl-users meta-faq". The real FAQ, as it
appeared last in the newsgroup, can be retrieved with the request "send
perl-users FAQ". Due to their sizes, neither the Meta-FAQ nor the FAQ
are included in the digest.
The "mini-FAQ", which is an updated version of the Meta-FAQ, is
available by requesting "send perl-users mini-faq". It appears twice
weekly in the group, but is not distributed in the digest.
For other requests pertaining to the digest, send mail to
perl-users-request@ruby.oce.orst.edu. Do not waste your time or mine
sending perl questions to the -request address, I don't have time to
answer them even if I did know the answer.
------------------------------
End of Perl-Users Digest V8 Issue 5224
**************************************