[6914] in Perl-Users-Digest
Perl-Users Digest, Issue: 539 Volume: 8
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Thu May 29 13:17:24 1997
Date: Thu, 29 May 97 10:00:22 -0700
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)
Perl-Users Digest Thu, 29 May 1997 Volume: 8 Number: 539
Today's topics:
Bindkey in perl??? <jm@staff.interrlog.com>
Re: books (David Cross)
Re: Can I perl script download a HTML page??? (I R A Aggie)
Re: getopt examples (Nathan V. Patwardhan)
Re: getting started.. <ulsass@berlin.snafu.de>
Re: Idiom for list summation? <jklein@alerts.co.il>
Re: Idiom for list summation? fawcett.NOSPAM@nynexst.com
intranet page from web. <dphi@ix.netcom.com>
Looking for calendar and to-do list script (Chris Sattler)
Re: Mass emailing <steveb@wwisp.com>
NT Perl + Excel (Scott McMahan)
Re: NT Perl + Excel (David G. Risner)
Object Oriented DataBases <janaudy@eerie.fr>
ODBC, PERL, SQL and Access heidi_ahders@non-hp-om.cv.hp.com
Re: Open and print HTML file insside CGI script (Deepak Dutta)
Re: Password Protection - NT (Craig S. Riter)
Re: Perl & database (Deepak Dutta)
Re: Perl Online Documentation errors. (Brian Orpin)
print \@ slices <alex.t.silverstein@bender.com>
Re: print \@ slices <merlyn@stonehenge.com>
Problem with cgi script <ceetm@cee.hw.ac.uk>
Re: Random number problem (Deepak Dutta)
Re: Slices of lists fawcett.NOSPAM@nynexst.com
Solved: Re: Help with ( <dave_boswell@nt.com>
Re: Standalone web database for Perl? (Gary Weinfurther)
Re: String comparsion (Bill Kannawin)
Re: undef, split: bug? (Paul D. Smith)
Digest Administrivia (Last modified: 8 Mar 97) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: 29 May 1997 14:57:17 GMT
From: "Jason Morehouse" <jm@staff.interrlog.com>
Subject: Bindkey in perl???
Message-Id: <01bc6c40$a67df2b0$e39635c6@nog-office>
Does anyone know of a bindkey routine for perl? If I am correct, bindkey
in csh (shell) provides for an interface something like pine's main menu.
This being able to toggle and highlight items in the menu by using they
cursor keys or by hitting the index key.
I could be way off here, but and suggestions would be appreciated.
Thanks in advance,
-Jason
Jason Morehouse
Interlog Internet Services, Network Operations Group
http://www.interlog.com
jm@staff.interlog.com
------------------------------
Date: Thu, 29 May 1997 10:48:55 GMT
From: crossd@ln4d110swk.usenet (David Cross)
Subject: Re: books
Message-Id: <CROSSD.97May29114855@ln4d110swk.usenet>
In article <338CBCF2.2156@corp.sun.com> Pierre Merle <pmerle@corp.sun.com> writes:
> I think this as already been asked ...
> I writing html/perl pages and I need a book.
> Which is better ? I don't need a book with cdrom
> and tons of unusefull PC oriented stuff. I need a book to explain perl
> AND html in details. To complement brilliant net resources I've found.
> Maybe two separates books are better, I use perl by exemple by
> Ellie Quipley and HTML for fun and profit.
> First is good but only perl, second is old and too simple.
> What about Oreilly books ?
Pierre,
Go O'Reilly and you can't go wrong. All of the following are O'Reilly books.
For Perl you need 'Learning Perl' by Randal Schwarz (is the second edition
of this out yet?) and 'Programming Perl' by Larry Wall, Tom Christiansen
and Randal Schwarz (make sure you get the second edition - the blue one).
For HTML, try 'HTML: The Definitive Guide' by Chuck Musciano and
Bill Kennedy.
If you want to use a combination of HTML and Perl, take a look at
'CGI Programmming on the World Wide Web' by Shishir Gundavaram.
Hope this helps,
Dave... .. .
--
Opinions are mine, not the company's - hell I don't think the company even
knows who I am!
Dave.Cross@gb.swissbank.com
------------------------------
Date: Thu, 29 May 1997 09:42:41 -0500
From: fl_aggie@hotmail.com (I R A Aggie)
Subject: Re: Can I perl script download a HTML page???
Message-Id: <fl_aggie-ya02408000R2905970942410001@news.fsu.edu>
In article <338d78e9.4032899@news.tiac.net>, smithj@statenislandonline.com
(Johnathan Mark Smith) wrote:
+ Can I perl script download a HTML page???
Yes.
+ Please Email me back
No.
James
--
Consulting Minister for Consultants, DNRC
Support the anti-Spam amendment <url:http://www.cauce.org/>
To cure your perl CGI problems, please look at:
<url:http://www.perl.com/perl/faq/idiots-guide.html>
------------------------------
Date: 29 May 1997 13:39:16 GMT
From: nvp@shore.net (Nathan V. Patwardhan)
Subject: Re: getopt examples
Message-Id: <5mk0u4$pu7@fridge-nf0.shore.net>
Tom Lynch (toml@synnet.com) wrote:
: getopt ('p:');
: I would like to error out saying "-v" unknown switch.
getopt('p');
if($opt_p) { # we have it
# do something
} else {
# wrong switch - output error message
}
--
Nathan V. Patwardhan
nvp@shore.net
------------------------------
Date: Thu, 29 May 1997 15:38:49 +0200
From: "Markus Ulsa_" <ulsass@berlin.snafu.de>
To: Arathena Sprankle <marien@goodnet.com>
Subject: Re: getting started..
Message-Id: <338D86E9.8DF437F9@berlin.snafu.de>
Arathena Sprankle wrote:
> I am just getting started with learning how to pogram in perl in order
> to
> make cgi scripts for my web page. I understand the language fairly
> well....I have only one problem. How to get started? I downloaded perl
> 5.
> Is this the right program to make my filename.pl files? When I tried
> to
> write to the dos box opened when I exucuted perl.exe I couldn't save
> the
> file from there. Instead I transfered it to notepad and saved it as
> filename.pl. But how then do I test the file? I know I need to type
> "perl
> filename.pl" while in the same dir but it doesn't work. I am running
> on Win
> 95/dos. If only I could get how to make and exxcute the files I will
> be
> well on my way. PLease help.
>
> marien@goodnet.com
Hi there,
the problem is, that PERL was originally created for Unix (and the
longer I do PERL on Win95 an NT I understand why :-) ).
But for the beginning of understanding and writing things like "Hello
World" try WinPerl from Maxwell Nairn Andrews. This great Prog compiles,
executes and debugs PERL on Win95 and NT. Just write your .pl and
execute it with WinPerl (Freeware).
After you get your first success with this, install Perl for Win32 on
your machine. Take one of the most recent versions from
http://www.perl.com .
This will also add registry-settings to your Win 95 and NT. Then you can
execute and debug from the command-line in a Dos-Box.
You get WinPerl from here
http://www.servtech.com/public/spider/perl32b3.zip
Regards,
Markus
See you at:
http://www.inx.de/~ulsass
------------------------------
Date: Thu, 29 May 1997 14:06:23 +0300
From: Joe Klein <jklein@alerts.co.il>
Subject: Re: Idiom for list summation?
Message-Id: <Pine.SOL.3.95.970529140319.6509o-100000@cain.alerts.co.il>
On 29 May 1997, Tim Smith wrote:
> In article <5mj3d3$et7$1@marina.cinenet.net>,
> Craig Berry <cberry@cinenet.net> wrote:
> >I have the need to take a list of numbers and determine their sum. I can
> >easily to this with code like this:
>
> [ ... ]
>
> >However, I can't shake the nagging feeling that there must be an easier
> >way, using a 'map' or something like that. Any suggestions?
>
> I don't know if this is "easier" or not...
>
> #!/usr/bin/perl -w
>
> my @nums = (1, 2, 3, 4, 5);
> my $sum = eval join ' + ', @nums;
> die $@ if $@;
> print "Sum is: $sum\n";
> exit 0;
>
>
> Tim
Or if you REALLY want use map...
#!/usr/local/bin/perl -w
my @nums = (1, 2, 3, 4, 5);
$total=0;
map $total+=$_, @nums;
print "Total: $total\n";
(Please don't flame me; I know you're not supposed to use map solely for
it's side effects - this is just another way of answering the question).
------------------------------
Date: 29 May 1997 11:38:36 -0400
From: fawcett.NOSPAM@nynexst.com
Subject: Re: Idiom for list summation?
Message-Id: <8j3er6nv9f.fsf@nynexst.com>
cberry@cinenet.net (Craig Berry) writes:
> I have the need to take a list of numbers and determine their sum. I can
> easily to this with code like this:
>
> @nums = ( 1, 2, 3, 4 );
> $sum = 0;
>
> foreach $n (@nums) {
> $sum += $n;
> }
>
> However, I can't shake the nagging feeling that there must be an easier
> way, using a 'map' or something like that. Any suggestions?
You've done it about the most direct way possible. You can use map to do
foreach's job, but you'd just be discarding map's return value so map is
less efficient for this.
The simple answer is no, there's no simple perl function (like Lisp's
reduce) to do this automatically.
-Tom
------------------------------
Date: Thu, 29 May 1997 08:32:27 -0700
From: Dale Phillips <dphi@ix.netcom.com>
Subject: intranet page from web.
Message-Id: <338DA18B.616A@ix.netcom.com>
I have been told to create a "beep list" that can be
accessed from our internal web. I have a single modem on
our web server and our pagers are numeric only. I can figure out
the list of users and a list of phone numbers with a list of
canned numeric messages for the web page...
But how does perl talk to a port
with a modem i.e. ATDT 18008008000,,,,,,,56
Thanks
--
----------------------
Dale Phillips
dphillip@tabfs.com
------------------------------
Date: 29 May 1997 15:42:28 GMT
From: sattlerc@cig.mot.com (Chris Sattler)
Subject: Looking for calendar and to-do list script
Message-Id: <5mk854$sqa$1@trotsky.cig.mot.com>
Keywords: to-do calendar
Does anyone out there have a perl script to keep an appointment calendar and
to-do list? Something using TkPerl to handle the graghics shouldn't be too
hard to write, but I'd rather not do something that has already been done, or
at least not start from scratch. Any source you'd like to contribute will be
greatly appreciated. Please send replies to the email address below, I'm still
trying to catch up on my backlog of comp.lang.perl.misc reading.
--
Chris Sattler Motorola Inc
sattlerc@cig.mot.com
------------------------------
Date: Thu, 29 May 1997 11:14:16 -0500
From: Steve Buchanan <steveb@wwisp.com>
To: Lauri Laakso <lauri@nettipaja.clinet.fi>
Subject: Re: Mass emailing
Message-Id: <338DAB58.41C67EA6@wwisp.com>
Lauri Laakso wrote:
>
> I am working with mass mailing system (not spam, user have to register
> first), and I need to know what is best way to send same email to
> all of @emails ?
Here is a piece of code I use all the time for exactly that. List all
of your email addresses in a file, one per line. Then run the
following:
#!/usr/bin/perl
$count = 0;
open (in, '/path/to/address/list.txt');
while(<in>){
foreach $_ (split (/[ \t\n]+/))
{$name = $_;}
$count ++;
if ($count == 20)
{
$count = 0;
sleep 2;
}
#system ("mail $name < /path/to/file/you/you/want/to/send");
}
close in;
--
Steve Buchanan
System Administrator
WWISP.COM / WWISP.NET
http://www.wwisp.com
------------------------------
Date: 29 May 1997 13:33:13 GMT
From: scott@lighthouse.softbase.com (Scott McMahan)
Subject: NT Perl + Excel
Message-Id: <5mk0ip$555$3@mainsrv.main.nc.us>
I'm trying to control Excel using OLE Automation from NT Perl.
Does anyone have a working example of using the Workbook.Open
command from a Perl script? There aren't any examples of this.
All the examples I've seen use Add to create a new workbook.
By analogy with the other VBA -> Perl examples, I would
expect it to be:
$excel->Workbooks->Open()->{'filename'} = 'whatever.xls';
This doesn't work, it gives me an error.
Scott
------------------------------
Date: Thu, 29 May 1997 16:23:09 GMT
From: dgrisner@netcom.com (David G. Risner)
Subject: Re: NT Perl + Excel
Message-Id: <dgrisnerEAyAuL.BpJ@netcom.com>
In article <5mk0ip$555$3@mainsrv.main.nc.us>,
Scott McMahan <scott@lighthouse.softbase.com> wrote:
>I'm trying to control Excel using OLE Automation from NT Perl.
>
>Does anyone have a working example of using the Workbook.Open
>command from a Perl script? There aren't any examples of this.
>All the examples I've seen use Add to create a new workbook.
>
>By analogy with the other VBA -> Perl examples, I would
>expect it to be:
>
> $excel->Workbooks->Open()->{'filename'} = 'whatever.xls';
>
>This doesn't work, it gives me an error.
This script does opens a file in Excel and adds some stuff to it. I put the
whole script here in case there were other things with Excel you might be
interested in doing.
It took me a while to figure out how to do some of these things. Ways of
doing things which seem like they should work sometimes don't. I don't know
if it was just my not understanding things, if it was bugs in Perl's OLE
routines, or in Microsoft's assorted programs, OS and DLLs.
Good luck!
#----- start of script -----
use OLE;
#Name of file from searches_cleanup.txt
$cleanfileName = "C:\\Windows\\Temp\\cleanfile.txt";
#Name of Excel template file to use
$TemplateFile = "E:\\Searches\\SearchTemplate.xls";
#Directory to store search printouts in. All backslashes must be
# in pairs. The last pair of slashes is necessary.
$searchDir = "E:\\Searches\\";
#Column to enter the data for the book to search
$entryColumn = "A";
#Last column which entry should stretch across
$lastEntryColumn = "G";
#Row where the first book's entry will go
$firstEntryRow = 1;
#Number increment row by for next book's entry
$rowsToSkip = 13;
#Constants used in calls to Excel. You shouldn't mess with these.
$xlNormal = -4143;
$xlNoChange = 1;
$xlLocalSessionChanges = 2;
$xlCenterAcrossSelection = 7;
$xlBottom = -4107;
$xlHorizontal = -4128;
$xlManual = -4135;
#---------------------------------------------------------------------------
#Start of script, do not change anything below here unless you know what you
# are doing
#---------------------------------------------------------------------------
#Names of the months used for saving Search file
@monthNames = ('Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug',
'Sep', 'Oct', 'Nov', 'Dec');
print "\nRunning Excel...\n";
$excel = CreateObject OLE 'Excel.Application.5'
or die "Couldn't create new instance of Excel App!";
#Uncomment this to make Excel visibile as it does the following steps
#$excel->{Visible} = 1;
$excel->Workbooks->Open($TemplateFile);
$myWorksheet = $excel->Workbooks(1)->Worksheets('Sheet1');
$rowOn = $firstEntryRow;
open(CLEANFILE, $cleanfileName);
$/ = ""; # paragraph mode
while ($paragraph = <CLEANFILE>) {
chomp $paragraph;
print "$paragraph\n";
if ($rowOn > $firstEntryRow) {
$copyRange = $entryColumn . ($rowOn - $rowsToSkip) . ":"
. $lastEntryColumn . ($rowOn - 2);
print "Copy range = $copyRange\n";
$pasteRange = $entryColumn . $rowOn;
print "Paste Range = $pasteRange\n";
$excel->Workbooks(1)->Worksheets('Sheet1')->Range("$copyRange")->Copy();
$excel->Workbooks(1)->Worksheets('Sheet1')->Range($entryColumn . $rowOn)->Activate();
$excel->Workbooks(1)->Worksheets('Sheet1')->Paste();
if ( ($rowOn - $firstEntryRow) % (2 * $rowsToSkip) == 0) {
$excel->Workbooks(1)->Worksheets('Sheet1')->
Rows($rowOn)->{'PageBreak'} = $xlManual;
}
}
$myWorksheet->Range($entryColumn . $rowOn)->{'Value'} = $paragraph;
$rowOn += $rowsToSkip;
}
close(CLEANFILE);
($sec,$min,$hour,$mday,$mon,$year,$wday,$yday,$isdst) = localtime(time);
$excel->ActiveWorkbook->SaveAs($searchDir . "Searches$mday$monthNames[$mon]$year.xls",
$xlNormal, "", "", 0, 0, $xlNoChange, $xlLocalSessionChanges);
#$excel->ActiveWindow->SelectedSheets->PrintOut();
$excel->Quit();
print "\nDone with Excel.\n";
#----- end of script -----
--
David G. Risner -- dgrisner@netcom.com
http://members.aol.com/dgrisner/Home.html
My own view from my own account.
------------------------------
Date: Thu, 29 May 1997 16:59:34 +0200
From: Thierry Janaudy <janaudy@eerie.fr>
Subject: Object Oriented DataBases
Message-Id: <338D99D6.281C@eerie.fr>
Hi,
Does someone know if there are some Perl libs
that deal with OODB like O2 ?
Please answer-me by mail.
Thank you.
- T
--
JANAUDY Thierry
Diplome ingenieur informaticien le 4 juillet 1997
http://www.eerie.fr/~janaudy http://www.eerie.fr/~javateam/
mailto:janaudy@eerie.fr
------------------------------
Date: Thu, 29 May 1997 11:35:19 -0600
From: heidi_ahders@non-hp-om.cv.hp.com
Subject: ODBC, PERL, SQL and Access
Message-Id: <864923064.23438@dejanews.com>
I am using MS Access, Perl5, ODBC module by Roth, on a Windows NT4.0.
I would like to be able to display 10 items from my database at a time
on the web. Then have a link so that the users can continue viewing the
database. Something like the search engines have.
There is a procedure called SetPos in the ODBC.pm file but I am not sure
if this is the correct way to do it. I can do it in perl, but as the
database gets larger it is going to get slower.
Any help is greatly appreciated. Thanks!
Heidi Ahders
Webmaster MCD Hewlett-Packard
-------------------==== Posted via Deja News ====-----------------------
http://www.dejanews.com/ Search, Read, Post to Usenet
------------------------------
Date: Thu, 29 May 1997 14:55:05 GMT
From: ddutta@siu.edu (Deepak Dutta)
Subject: Re: Open and print HTML file insside CGI script
Message-Id: <338d9825.1132556@saluki-news.siu.edu>
On 27 May 1997 11:34:41 GMT, "Miran Sepic" <miran.sepic4@mss.tel.hr>
wrote:
Try this one
for each $filein (@filein) {
print $filein;
}
I have dozens of scripts which use the the above construct. And it
works fine. It just print each line at a time of @filein array
>I have a following problem:
>
>From inside Perl script I try to open a HTML file, and print it back.
>This part of script looks like that:
>
>$login_page = "/user/download.html";
>open (FILE, "$login_page");
>@filein = <FILE>;
>print "Content-type: text/html\n\n";
>print @filein;
>
>The response is:
>
>Internet explorer cannot open the Internet site .....
>The operation completed successfully.
>
>When I put HTML directly inside script, everything is OK.
>
>
------------------------------
Date: Thu, 29 May 1997 13:40:01 GMT
From: criter@lucent.com (Craig S. Riter)
Subject: Re: Password Protection - NT
Message-Id: <338d69fa.31429579@nntp.cb.lucent.com>
I thought you could check for somekind of session id that would be
generated when they login to your application. I have seen some
scripts like that before, it may have been on Selena Sol's site.
Craig@Riter.com
______________________________________________________________________
Craig S. Riter criter@riter.com criter@povpartners.com
www.riter.com PGP key available upon request
It infuriates me to be wrong when I know I'm right. -Moliere
______________________________________________________________________
Craig S. Riter criter@riter.com criter@povpartners.com
www.riter.com PGP key available upon request
A conclusion is the place where you got tired of thinking. -A. Block
------------------------------
Date: Thu, 29 May 1997 15:03:33 GMT
From: ddutta@siu.edu (Deepak Dutta)
Subject: Re: Perl & database
Message-Id: <338d98f9.1344531@saluki-news.siu.edu>
On 27 May 1997 11:34:37 GMT, "Miran Sepic" <miran.sepic4@mss.tel.hr>
wrote:
>I need a help for a following topic:
>I have to make a list which will contain usernames and dates of expiration
>of their maintenance agreement:
>
>username1:date1
>username2:date2
>........................
>username(x):date(x)
>
>How can I open such file, use split function (split /:/ - something like
>that), and compare date(x) with today's date?
>
>Thanks, Miran
I think it will be pretty easy. A Perl Book will help you to get the
exact syntax for doing each of the following.
1. Open the file: open (FILEHANDLE, $yourfile)
2. Read each line of the file: @entirefile=<FILEHANDLE>
3. get today's date from the system
4. start looping through @entire file: foreach $entirefile
(@entirefile)
5. Split the $entirefile and collect each splitted element in
@your_splitted_element array (one line ): @your_splitted_element=split
()
6. the date will be in $your_splitted_element[1]
7. Do what ever you like to do
Deepak
------------------------------
Date: Thu, 29 May 1997 14:00:13 GMT
From: brian.orpin@gecmX.com (Brian Orpin)
Subject: Re: Perl Online Documentation errors.
Message-Id: <33998a5d.24684857@news.geccs.gecm.com>
On Thu, 29 May 1997 07:35:53 -0600, kadifeli@yunus.cmpe.boun.edu.tr
wrote:
>I downloaded the Perl Online Documentation as "a giant tarfile of all
>the HTML pages" (namely, PerlDoc-5.004beta-html.tar.gz). It looks like
>the nmanual/pod/perlfunc/ directory does not contain the necessary HTML
>files. (It has only a file called X.html). Where are the other files?
>Does anybody know a place where I can find an official non-beta (such as
>5.003) documentation for Perl 5?
I will add a me too to this. I tried to unzip using winzip which
filed miserably until I renamed the file perldoc.tar.zip then it
seemed to work OK. I did find some of the perlfunc files in other
directories but not all.
On another tack the CPAN man pages are also broken. For example the
link to the qw function from the perlfunc page
http://www.perl.org/CPAN/doc/manual/html/pod/perlfunc/qw.html returns
404 file not found.
--
Brian Orpin (These thoughts are my own ......... for once!)
brian.orpin@gecmX.com or BrainOrpin@BigfootX.com
http://www.borpin.demon.co.uk/ **Anti-spam reply-to remove X**
------------------------------
Date: Sun, 25 May 1997 20:39:08 -0700
From: alex <alex.t.silverstein@bender.com>
Subject: print \@ slices
Message-Id: <338905DC.4148@bender.com>
I can't seem to find the documentation
on how to print, say, the 0th thru 3rd
elements of a ref to an array. This is
as far as I got, but it only prints one
element. Is the answer in one
of the texts (I own a few)?
#!/usr/local/gnu/bin/perl -w
@refarrr= (130, 150, 2, 1);
$refar = \@refarrr;
print "$refar->[2]\n";
--
just what are people for? K.V.
------------------------------
Date: 26 May 1997 06:16:42 -0700
From: Randal Schwartz <merlyn@stonehenge.com>
To: alex <alex.t.silverstein@bender.com>
Subject: Re: print \@ slices
Message-Id: <8c206uidad.fsf@gadget.cscaper.com>
>>>>> "alex" == alex <alex.t.silverstein@bender.com> writes:
alex> I can't seem to find the documentation
alex> on how to print, say, the 0th thru 3rd
alex> elements of a ref to an array. This is
alex> as far as I got, but it only prints one
alex> element. Is the answer in one
alex> of the texts (I own a few)?
alex> #!/usr/local/gnu/bin/perl -w
alex> @refarrr= (130, 150, 2, 1);
alex> $refar = \@refarrr;
alex> print "$refar->[2]\n";
Just use the slice syntax:
print "@{$refar}[0..3]\n";
print "Just another Perl hacker," # but not what the media calls "hacker!" :-)
## legal fund: $20,495.69 collected, $182,159.85 spent; just 463 more days
## before I go to *prison* for 90 days; email fund@stonehenge.com for details
--
Name: Randal L. Schwartz / Stonehenge Consulting Services (503)777-0095
Keywords: Perl training, UNIX[tm] consulting, video production, skiing, flying
Email: <merlyn@stonehenge.com> Snail: (Call) PGP-Key: (finger merlyn@ora.com)
Web: <A HREF="http://www.stonehenge.com/merlyn/">My Home Page!</A>
Quote: "I'm telling you, if I could have five lines in my .sig, I would!" -- me
------------------------------
Date: Mon, 26 May 1997 00:16:27 GMT
From: Triantafyllos Marakis <ceetm@cee.hw.ac.uk>
Subject: Problem with cgi script
Message-Id: <Pine.SUN.3.95.970526010514.17427A-100000@loki>
I don't know if you are all familiar with the webget program that
fetches files across the net.
I wrote a script that uses webget and calls one other script.
The first script reads all the variables of the QUERY_STRING
correctly.
The problem that I am having is that when I am using webget
for a strange reason only one of the variables is recognised
by the second script.
My program is:
#!/usr/local/bin/perl
MAIN:
{
$cgi_bin = "http://www.cee.hw.ac.uk/ceetm-cgi-bin";
$cgi_dir = "/u1/cs4/ceetm/www/cgi-bin";
$| = 1; #Force output to be displayed immediately
print &PrintHeader;
$in = $ENV{'QUERY_STRING'};
@in = split(/&/,$in);
foreach $i (0 .. $#in) {
($key, $val) = split(/=/,$in[$i],2);
$in{$key} .= "\0" if (defined($in{$key}));
$in{$key} .= $val; }
$query = $in{'query'};
$force = $in{'extra'};
`$cgi_dir/webget $cgi_bin/search.cgi?p=$query&k=$force`;
}
As I mentioned above the second script seems that it can only recognise
the p variable and not the k variable.
Thanks.
TRIANTAFYLLOS MARAKIS |George Burnett Hall(2.54), Heriot-Watt Univ.,
BSc in Computer Science IV|Edinburgh,EH14 4AS, Scotland UK
HERIOT-WATT University |Email:ceetm@cee.hw.ac.uk
WEB: www.cee.hw.ac.uk/~ceetm, members.tripod.com/~tmarakis
------------------------------
Date: Thu, 29 May 1997 14:49:46 GMT
From: ddutta@siu.edu (Deepak Dutta)
Subject: Re: Random number problem
Message-Id: <338d96ea.817116@saluki-news.siu.edu>
You arte not picking up a random seed.
The seed is fixed so also the sequence of randon numbers generated
from the seed.
You need to get a different seed each time your script runs.
using the local time as seed generator is the most common way to
change the seed.
If this helps.
On Tue, 27 May 1997 19:55:14 +0000, brennan@byte-back.com wrote:
>I am trying to get to create a perl that will randomly select a page and
>display it. Pretty simple. I have tested on my local machine and it
>works great. On the Apache linux server that the site is on I
>continuely get number 9. here is the script.
>
>#!/usr/local/bin/perl
>
>print "Pragma: no-cache", "\n";
>print "Content-type: text/html", "\n\n";
>
>$random = int (rand (78));
>$random_card = $random;
>print "Location: /cards/", $random_card, "card.html", "\n\n";
>
>exit (0);
>
>I have 78 pages I want it to pick from. I can't figure out what is
>going on. I have tested it from 5 machines that all return with 9.
>
>Help please.
>
>Brennan
------------------------------
Date: 29 May 1997 11:49:19 -0400
From: fawcett.NOSPAM@nynexst.com
Subject: Re: Slices of lists
Message-Id: <8j206qnurk.fsf@nynexst.com>
brian.orpin@gecmX.com (Brian Orpin) writes:
> I wish to replace a slice of an array.
>
> I used a grep to find if the item (string) exists in the array but
> could not find a function to tell me it's position other than by going
> through the array and incrementing a counter. Is there a better way?
There are other ways, but nothing built-in, if that's what you want. You
might look at Ixhash, which combines features of arrays and hashes.
> So I can find the start and end points of the slice I want to remove.
>
> @new = @old[$start..$end];
>
> However, how do I replace the slice with a different array e.g. or
> even delete those elements I have identified.
>
> @old = ("one", "two", "three");
> @new = ("twoa", "twob");
>
> to get an array ("one", "twoa", "twob", "three")
Simply:
@old[$start..$end] = @new;
In this case, $start==$end==1, so your slice is only one element long.
-Tom
------------------------------
Date: Thu, 29 May 1997 08:38:00 -0400
From: Dave Boswell <dave_boswell@nt.com>
Subject: Solved: Re: Help with (
Message-Id: <338D78A8.5F9E@nt.com>
Dave Boswell wrote:
>
> We have just recently moved to 5.004 and I am getting the following
> error, which I am unable to figure out.
>
> syntax error at line 2 : `(' unexpected
>
> The script that generates this is as follows:
>
> #!/usr/local/perl-5.004/bin/perl -w
> print ( "hello world\n" );
>
> When run from the command line, with 'perl -w file' it works fine, if I
> however make the file executable and run it I get the error. I have
> removed the () pair and ran it as an executable and everything is OK.
> Any and all ideas would be helpful since we are now basically dead in
> the water.
>
> Thanks in advance ... Dave Boswell.
Thanks to all! I must admit that I have spent too much time in the
Windoze world. To all who suggested that the #! line was too long,
that's what it was.
I created a link to the executable, got it less than 32 and all is fine.
Thanks again ... Dave Boswell.
------------------------------
Date: Thu, 29 May 1997 08:42:22 -0400
From: NoSpam@NoJunk.com (Gary Weinfurther)
Subject: Re: Standalone web database for Perl?
Message-Id: <MPG.df743b5f5ad96c4989681@news.mich.com>
In article <01bc6baf$4f066800$8ccd78cf@default>, guess@somewhere.com
says...
> depending on how large the Database file will be you may not even need a
> Database management system. Perl can work with text files with the fields
> on separate lines and the records separated with a blank line.
>
> Name: B J'S CAFE
> Address: 207 S RALEIGH ST
> City: ANGIER
> State: NC
> Zip Code: 27501
> Telephone: (919) 639-0788
>
> Name: CORNER GRILL
> Address: HIGHWAY 55 S
> City: ANGIER
> State: NC
> Zip Code: 27501
> Telephone: (919) 639-2312
One table may have up to 6000 records, and there will be several tables.
Record subsets need to be selected based on certain criteria. Data will
be added and deleted by multiple users. Is it efficient to code such an
application using text files?
...Gary
------------------------------
Date: 29 May 1997 09:57:15 -0600
From: kannawin@gargantubrain.osmre.gov (Bill Kannawin)
To: "Alexander K. M. Leung" <kmleung@fg702-6.abct.polyu.edu.hk>
Subject: Re: String comparsion
Message-Id: <5mk90r$b9f@gargantubrain.osmre.gov>
You may what to try out chop or better yet chomp to get rid of the nl chars.
In article <01bc6bf1$f5641ac0$0e1f849e@fg702-4.polyu.edu.hk>, "Alexander K. M. Leung" <kmleung@fg702-6.abct.polyu.edu.hk> writes:
|> Hi,
|>
|> I want to use Perl to develop a small utility in my SGI workstaiton. Such
|> utility will have a menu with 3 options (A, B, C). How can I use a if
|> statement to detect which option is chosen.
|>
|> I have try the following script, but it is not work.
|>
|> $option=<STDIN>
|> if ($option="a") {
|> :
|> } elsif ($option="b") {
|> :
|> } elsif ($option="c") {
|> :
|> }
|>
|> How can I modify this script? Thanks.
|> --
|> ///
|> {. .} ~~~~ My name is Alexander K. M. Leung
|> _______oOO-(_)-OOo_______HKPolyU Dept. Appl. Bio. & Chem. Tech._____
|> <-> kmleung@fg702-6.abct.polyu.edu.hk
|> URL: http://fg702-6.abct.polyu.edu.hk/~kmleung
--
Bill Kannawin (303)844-1479 kannawin@osmre.gov|
Technical Information Processing System |
US Office of Surface Mining; 1999 Broadway, |
Suite 3320, Denver, Colorado 80202 |
------------------------------
Date: 29 May 1997 10:02:39 -0400
From: psmith@baynetworks.com (Paul D. Smith)
To: ced@carios2.ca.boeing.com
Subject: Re: undef, split: bug?
Message-Id: <p5n2pegyv4.fsf@baynetworks.com>
[Not emailed to Zenin, since his mail address is munged]
I think this has been reported already and a patch made available.
Here's my email archive of the patch. Note I haven't applied it, or
tested it, or anything, so YMM very definitely V!
Famous last words WRT perl: "Looks harmless enough!"
If this doesn't fix it, please use perlbug to report the bug along with
relevant test cases.
On Thu, 22 May 1997 14:58:22 -0700 (PDT), someone said:
> In some cases I use undefs to discard unwanted array values. After
> installing perl5.004 this seems to cause split() to misbehave in some
> circumstances.
This patch from Gurusamy Sarathy should fix it. It will be included in
the next bug fix release ...
--- op.c.dist Fri May 16 18:56:44 1997
+++ op.c Fri May 16 19:24:19 1997
@@ -978,6 +978,7 @@
switch (op->op_type) {
case OP_UNDEF:
+ modcount++;
return op;
case OP_CONST:
if (!(op->op_private & (OPpCONST_ARYBASE)))
--
-------------------------------------------------------------------------------
Paul D. Smith <psmith@baynetworks.com> Network Management Development
"Please remain calm...I may be mad, but I am a professional." --Mad Scientist
-------------------------------------------------------------------------------
These are my opinions--Bay Networks takes no responsibility for them.
------------------------------
Date: 8 Mar 97 21:33:47 GMT (Last modified)
From: Perl-Request@ruby.oce.orst.edu (Perl-Users-Digest Admin)
Subject: Digest Administrivia (Last modified: 8 Mar 97)
Message-Id: <null>
Administrivia:
The Perl-Users Digest is a retransmission of the USENET newsgroup
comp.lang.perl.misc. For subscription or unsubscription requests, send
the single line:
subscribe perl-users
or:
unsubscribe perl-users
to almanac@ruby.oce.orst.edu.
To submit articles to comp.lang.perl.misc (and this Digest), send your
article to perl-users@ruby.oce.orst.edu.
To submit articles to comp.lang.perl.announce, send your article to
clpa@perl.com.
To request back copies (available for a week or so), send your request
to almanac@ruby.oce.orst.edu with the command "send perl-users x.y",
where x is the volume number and y is the issue number.
The Meta-FAQ, an article containing information about the FAQ, is
available by requesting "send perl-users meta-faq". The real FAQ, as it
appeared last in the newsgroup, can be retrieved with the request "send
perl-users FAQ". Due to their sizes, neither the Meta-FAQ nor the FAQ
are included in the digest.
The "mini-FAQ", which is an updated version of the Meta-FAQ, is
available by requesting "send perl-users mini-faq". It appears twice
weekly in the group, but is not distributed in the digest.
For other requests pertaining to the digest, send mail to
perl-users-request@ruby.oce.orst.edu. Do not waste your time or mine
sending perl questions to the -request address, I don't have time to
answer them even if I did know the answer.
------------------------------
End of Perl-Users Digest V8 Issue 539
*************************************