[15800] in Perl-Users-Digest
Perl-Users Digest, Issue: 3213 Volume: 9
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Tue May 30 21:06:51 2000
Date: Tue, 30 May 2000 18:05:25 -0700 (PDT)
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)
Message-Id: <959735125-v9-i3213@ruby.oce.orst.edu>
Content-Type: text
Perl-Users Digest Tue, 30 May 2000 Volume: 9 Number: 3213
Today's topics:
@array <todd@mrnoitall.com>
Re: @array (Abigail)
Re: @array <brian@bluecoat93.org>
accessing library files in a module <michalak@hwr.arizona.edu>
Re: Basic question <makarand_kulkarni@My-Deja.com>
Re: BO's in Perl? (Bart Lateur)
Re: CGI Forms: Save File Dialog instead of processing f (David Efflandt)
Re: command line argument (newbie) <frank@french-connexion.com>
Re: Data Hiding in OO Perl <tcuffel@exactis.com>
DB_File on Unix vs. Windows <zyl@yahoo.com>
Re: directory permissions in NT <carvdawg@patriot.net>
Re: directory permissions in NT <scumjr@deja.com>
First (implicit) argument passed to a method? <ilesandrew@hotmail.com>
Re: First (implicit) argument passed to a method? (Damian Conway)
forms and Web Client <msanderso@hotmail.com>
Re: forms and Web Client <tina@streetmail.com>
Re: forms and Web Client <msanderso@hotmail.com>
Re: forms and Web Client <tony_curtis32@yahoo.com>
Re: Help - I've been spammed with PERL (Abigail)
Help reading data from file squidrocks@my-deja.com
Re: Help reading data from file <nospam@devnull.com>
Re: Help reading data from file <dave@dave.org.uk>
Re: Help reading data from file (Jerome O'Neil)
Re: Help reading data from file <michalak@hwr.arizona.edu>
Re: Help reading data from file <makarand_kulkarni@My-Deja.com>
Re: Help reading data from file <tina@streetmail.com>
Re: Help reading data from file <brian@bluecoat93.org>
Re: How to access documents on other servers? (Abigail)
Re: how to set the filename when sending content of unk (Abigail)
Digest Administrivia (Last modified: 16 Sep 99) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: Tue, 30 May 2000 18:23:28 -0600
From: Todd Anderson <todd@mrnoitall.com>
Subject: @array
Message-Id: <39345B57.6D5A83DB@mrnoitall.com>
Dear Sirs and or Madams,
I've got 2 arrays and I need to print each element in each array in
parrallel...
Can this be done? Thanks for your help.
@numbers = (0..177);
@array = ( "r_name0", "r_name1", etc. to 177);
print qq~"$array|$number|=|string";\n~;
or...
"r_name0|0|=|string";
"r_name1|1|=|string";
etc...
------------------------------
Date: 31 May 2000 00:36:20 GMT
From: abigail@arena-i.com (Abigail)
Subject: Re: @array
Message-Id: <8h1mq4$8c8$1@news.panix.com>
On Tue, 30 May 2000 18:23:28 -0600, Todd Anderson <todd@mrnoitall.com> wrote:
That is odd. Your References header contains 2 Message-IDs, yet, you
don't seem to be responding to anyone.
++ Dear Sirs and or Madams,
++
++ I've got 2 arrays and I need to print each element in each array in
++ parrallel...
++ Can this be done? Thanks for your help.
Sure. Just use a loop.
Abigail
------------------------------
Date: Tue, 30 May 2000 20:35:05 -0400
From: "Brian Landers" <brian@bluecoat93.org>
Subject: Re: @array
Message-Id: <saZY4.729$BL4.8875@news1.atl>
#!/usr/local/bin/perl -w
use strict;
# Arrays truncated for simplicity.
# We ASSUME the arrays are exactly the same length
my @numbers = (0..4);
my @array = qw( r_name0 r_name1 r_name2 r_name3 r_name4 );
# Using a for loop with an array index is the "simple" way to do this.
# I'm sure some of the Perl golfers will come up with a "tricky" way.
for( my $i = 0; $i < (scalar @numbers); $i++ ) {
print "$array[$i]|$numbers[$i]|=|string\n";
}
"Todd Anderson" <todd@mrnoitall.com> wrote in message
news:39345B57.6D5A83DB@mrnoitall.com...
> Dear Sirs and or Madams,
>
> I've got 2 arrays and I need to print each element in each array in
> parrallel...
> Can this be done? Thanks for your help.
> @numbers = (0..177);
> @array = ( "r_name0", "r_name1", etc. to 177);
>
> print qq~"$array|$number|=|string";\n~;
> or...
> "r_name0|0|=|string";
> "r_name1|1|=|string";
> etc...
>
>
>
------------------------------
Date: Tue, 30 May 2000 15:49:31 -0700
From: Zolla Michalak <michalak@hwr.arizona.edu>
Subject: accessing library files in a module
Message-Id: <3934457B.324CBEFC@hwr.arizona.edu>
I'm using a module (mapscript.pm) which I didn't write and with "use
mapscript" it is not accessing all of the library files. Any hints on
how I can gather these up so I can use them? I've tried all the
suggestions I can find in "Programming Perl," including use POSIX, and
some other things that I can't remember right now.
The error message I'm getting is this:
Can't locate auto/layerObj/queryByPoin.al in @INC at testmakemap.pl line
93,
and line 93 is:
$pointQueryObj = $svhucsq->queryByPoint($map, $point, MS_SINGLE, 1);
Thanks! -zm
------------------------------
Date: Tue, 30 May 2000 17:35:01 -0700
From: Makarand Kulkarni <makarand_kulkarni@My-Deja.com>
Subject: Re: Basic question
Message-Id: <39345E35.2D4E49D9@My-Deja.com>
> I have read at many IC -design companies' websites that they need people who
> know VHDL/VERILOG and Perl.
> Can anybody tell me whats the use of Perl with VHDL/Verilog? Any specific
> application?
some more info on using Perl alongwith Verilog/VHDL etc.
http://home.europa.com/~celiac/tools.html
--
------------------------------
Date: Tue, 30 May 2000 23:23:06 GMT
From: bart.lateur@skynet.be (Bart Lateur)
Subject: Re: BO's in Perl?
Message-Id: <393631fc.2760475@news.skynet.be>
jdimov@my-deja.com wrote:
>How exactly does Perl prevent BO's?
Body Odor?
A good deodorant? I guess.
> Are Perl scripts absolutely safe from buffer overflows?
Ah, buffer overflow!
Perl will allocate enough memory to store the entire string. Thus it
will TEST the length of the string before doing anything with it.
By contrast, in C (for example), people often predeclare a string of
fixed length, in which the copy the string, no matter how long it is
(even if it's longer than the buffer).
A whole different philosophy. Lots safer.
--
Bart.
------------------------------
Date: 30 May 2000 23:56:07 GMT
From: efflandt@xnet.com (David Efflandt)
Subject: Re: CGI Forms: Save File Dialog instead of processing form data
Message-Id: <slrn8j8l8e.lnp.efflandt@efflandt.xnet.com>
On Tue, 30 May 2000, 9jerry9@my-deja.com <9jerry9@my-deja.com> wrote:
>Any ideas why the browser presents a "Save File" dialog box when I try
>to submit form data instead running the perl script?
>
>Browser is: Internet Explorer 4.0 (Netscape 4.0 always gives the dialog
>box)
>OS is NT4 and Win95
>Server is NT4, Running IIS v2.0
I have seen this happen with MSIE, but not Netscape. The reason that if
Perl is installed on the client box, the .pl extension is associated with
perl.exe and considered an insecure executable by MSIE (which ignores
content type header). Therefore, the SaveAs dialog. But Netscape should
not do this unless you specifically added the .pl file extension to its
Applications list to directly execute perl scripts from the browser
without the use of a web server.
>Code is from ch. 4, O'Reilly, CGI Programming 3rd edition.
>
>Actually, the code works fine when I just print the Name data. When I
>try to print the email data that's when I get the 'Save' dialog box
>instead of running the Perl script.
There is no field with NAME="email". Maybe the EMAIL="email" is confusing
the browser or the script.
># -------------------
># Code Sample
>(File.htm)
># -------------------
>
><FORM ACTION="/cgi-bin/auto.pl" METHOD="GET">
>
><STRONG><FONT size=3>
> Your Name:    <INPUT TYPE="text" NAME="user"
> SIZE=60></FONT></STRONG>
> <font size=4 color=red>*</font>
><BR><BR>
><STRONG><FONT size=3>
> Your Email:    <INPUT TYPE="text" EMAIL="email"
> SIZE=60></FONT></STRONG>
> <font size=4 color=red>*</font>
><P>
><INPUT TYPE="submit" VALUE="Submit">
><INPUT TYPE="button" NAME="reset" VALUE="Clear All">
></FORM>
>
>Name data is obtained in the Query String but not the 'email' data.
>
># -----------------------------------
>perl script
># -----------------------------------
>
>#!/bin/perl
>
> &parse_form_data (*auto_form) ; # Parse Form Data
>
># DEBUG
> $user = $auto_form {'user'} ;
> $email = $auto_form {'email'} ;
># DEBUG
>
>
> print "Content-type: text/plain.\n\n" ;
Two problems, there should not be any dots in a Content-type header and it
is the wrong content type anyway. Try this instead:
print "Content-type: text/html\n\n" ;
> print "<HTML>" ;
> print "<HEAD>" ;
> print "<TITLE>Testing CGI Form</TITLE>" ;
> print "</HEAD>" ;
> print "<BODY>" ;
> print "<H2>Testing CGI Form</H2>" ;
BTW did you have a Perl question?
--
David Efflandt efflandt@xnet.com http://www.de-srv.com/
http://www.autox.chicago.il.us/ http://www.berniesfloral.net/
http://hammer.prohosting.com/~cgi-wiz/ http://cgi-help.virtualave.net/
------------------------------
Date: Wed, 31 May 2000 01:36:39 +0200
From: frank <frank@french-connexion.com>
Subject: Re: command line argument (newbie)
Message-Id: <39345087.A6486DE2@french-connexion.com>
Thanx to all. I really appreciate your help. This is a great newsgroup :)
Kragen Sitaker a ?it :
> In article <u9em6k56do.fsf@wcl-l.bham.ac.uk>, <nobull@mail.com> wrote:
> >frank <frank@french-connexion.com> writes:
> >
> >> How can I pass variables thru the command line ?
> >
> >To all intents and purposes you can't (you'll have to make your script
> >parse the command line) but see also the answers given to this question
> >last time it was asked here.
>
> Well, you can use -s, which will make Perl parse the command line and
> put it in variables. See perldoc perlrun. @ARGV is far better if your
> script is more than one line long, as a rule of thumb.
> --
> <kragen@pobox.com> Kragen Sitaker <http://www.pobox.com/~kragen/>
> The Internet stock bubble didn't burst on 1999-11-08. Hurrah!
> <URL:http://www.pobox.com/~kragen/bubble.html>
> The power didn't go out on 2000-01-01 either. :)
------------------------------
Date: Tue, 30 May 2000 16:27:11 -0500
From: "Tim" <tcuffel@exactis.com>
Subject: Re: Data Hiding in OO Perl
Message-Id: <n%WY4.3637$Rx.422922@den-news1.rmi.net>
kdmasary@my-deja.com wrote in message <8h0ra5$gso$1@nnrp1.deja.com>...
>I have started a new project in Perl and I wish to keep things as
>Object Oriented as possible. I've discovered, so far, that Perl's
>equivalent of the C++ 'class' is the 'package.' I've played around with
>the syntax a bit and now have (almost) no problems creating my objects.
>
>The only problem I do have is with Data Hiding. It appears to me that
>this fundamental concept of OOP is not supported in Perl. Could this be
>true? Or have I overlooked something?
Here is a little example for you:
#include <iostream.h>
#define private public
#include <some_class.h>
#undef private
main()
{
SomeClass a;
a.set_private_member(42);
cout << a.private_member;
}
So C++ doesn't have data hiding, either...:)
-T
------------------------------
Date: Tue, 30 May 2000 16:26:11 -0700
From: Roel Zylstra <zyl@yahoo.com>
Subject: DB_File on Unix vs. Windows
Message-Id: <39344E13.D5033B0B@yahoo.com>
I am using Windows to develop a Perl script (with DB_File) and Unix
to run it. I would like the database file to be able to be
read by both OS's, but when I use lines like:
tie(my %hash, "DB_File", $file_name, O_RDWR|O_CREAT|O_TRUNC, 0755,
$DB_TREE);
...
untie %hash;
the operating systems cannot read the other's database file. (When I
use binary to ftp array databases they work, so I know I'm transferring
them correctly.) What can I use so that the databases are transferable?
Thank you,
Roel Zylstra
--
Please send reply email to ruler[at]iname[dot]com. This is to protect
against scanning software from extracting my email address.
------------------------------
Date: Tue, 30 May 2000 19:09:15 -0400
From: H C <carvdawg@patriot.net>
Subject: Re: directory permissions in NT
Message-Id: <39344A1B.668741A8@patriot.net>
I've read through your post several times, and even the follow-ups, and
it's still
not clear to me what you want to do...however, I think I can help with
the permissions
issue.
Dave Roth's Win32::Perms is THE way to go...http://www.roth.net/perl/perms
scumjr@my-deja.com wrote:
> I've just started playing around with Perl (on an NT 4 system) and am
> scanning through directories gathering various statistics. I want to
> report on directories that I do not have access to and I've tried all
> of the file tests, but none of them appear to work (although the tests
> to check whether or not it is a directory works fine). I've tried
> using the full path name and just the directory name itself, but the
> tests always come back "true". Are these tests only valid for Unix
> systems? I've looked through the documentation and could see no
> mention of them not working on an NT system.
>
> If these tests do not work on NT what options do I have to check for
> permissions?
>
> Thanks in advance,
>
> SJ
>
> Sent via Deja.com http://www.deja.com/
> Before you buy.
------------------------------
Date: Wed, 31 May 2000 00:14:57 GMT
From: "scumjr" <scumjr@deja.com>
Subject: Re: directory permissions in NT
Message-Id: <5QYY4.909$uw6.30937@news20.bellglobal.com>
> I've read through your post several times, and even the follow-ups, and
> it's still not clear to me what you want to do...however, I think I can
help with
OK....I'll try to clear up my intentions as I'd like to know if what I've
tried should or should not work.
First off....I've just started using Perl so my thinking on the file tests
may be way off.
The script that I'm playing with goes through directories collecting
information on file sizes and dates. The script is running on a Win NT 4
system and therefore there are directories that I do not have permission to
view/access. I want my script to then display a message informing me that
the dir could not be accessed. My plan was to use one of the file tests to
check if I have read access to the directory. From what I've read the -R
test sounds like what I wanted (I've also tried r,w,o,x,W,O,X) but I had no
luck with it. I did however figure another (probably easier) way to do
it.....I just used chdir() which returns a success/failure when trying to
change to a directory.
I hope that clarifies my intentions as I'd like to know if this should work
or not.
Here's a segment of the (original) code if it helps.....
$dirName is a directory in the current directory
if (-d $dirName)
{
if (-R $dirName)
{
chdir($dir);
.... do stuff ....
}
else
{
print "Could not access", $dirName;
}
}
Like I mentioned before, I tried r,w,o,x,R,O,W,X but it always yields a true
(even if the dir is inaccessible to me).
>go...http://www.roth.net/perl/perms
OK....thanks....I'll check it out.
Thanks again....
SJ
------------------------------
Date: Tue, 30 May 2000 22:05:23 -0500
From: Andrew Iles <ilesandrew@hotmail.com>
Subject: First (implicit) argument passed to a method?
Message-Id: <39348173.47C86EE4@hotmail.com>
I have a simple question regarding the first argument passed to methods
when using object oriented perl. It seems to me that the first argument
passed is implicitly a pointer to the class that the function is blessed
into, or at least some kind of pointer to the calling package. I'm
having to look through some perl code that was written by someone else
and a typical bit is as follows:
.
.
.
sub activate {
my($this) = @_;
...
$cgi = $this->get_cgi();
...
.
.
.
What I don't understand is that the function will be called with no
parameters. So is this reference always the first element of @_ ?
I suppose it's terribly simple but I can't seem to find any specific
examples discussing it.
Thanks in advance
Andrew iles
------------------------------
Date: 31 May 2000 00:45:37 GMT
From: damian@cs.monash.edu.au (Damian Conway)
Subject: Re: First (implicit) argument passed to a method?
Message-Id: <8h1nbh$cl4$1@towncrier.cc.monash.edu.au>
Andrew Iles <ilesandrew@hotmail.com> writes:
>I suppose it's terribly simple but I can't seem to find any specific
>examples discussing it.
Take a look at http://www.manning.com/Conway/chap03.pdf
That might help.
To summarize it: yes, the reference to the object on which a method is
called is passed as $_[0]. Any arguments are passed as $_[1], $_[2], etc.
Damian
------------------------------
Date: Tue, 30 May 2000 23:22:12 GMT
From: abaxaba <msanderso@hotmail.com>
Subject: forms and Web Client
Message-Id: <8h1iej$3gd$1@nnrp1.deja.com>
I'm writing a testing app for my company's product, so that we can
automate testing. Using LWP::UserAgent along with some data extracted
from an XML file, I post the data in my request. Problem is this:
if Data looks like -- Name=John Henry Hohandle, I need to convert it to
John+Henry+Hohandle. A simple ~s//+/ won't suffice, since I also need
to be concerned with escaping characters. I've tried URI::escape and
HTML::Entities::en/decode, but these don't seem to achieve the desired
results.
What I basically need to do is "unparse" formdata. Any steps I can
take to make this relatively painless??
Thanks in Advance
msa
Sent via Deja.com http://www.deja.com/
Before you buy.
------------------------------
Date: 30 May 2000 23:48:56 GMT
From: Tina Mueller <tina@streetmail.com>
Subject: Re: forms and Web Client
Message-Id: <8h1k18$2716d$1@fu-berlin.de>
hi,
abaxaba <msanderso@hotmail.com> wrote:
> if Data looks like -- Name=John Henry Hohandle, I need to convert it to
> John+Henry+Hohandle. A simple ~s//+/ won't suffice, since I also need
> to be concerned with escaping characters.
which escaping characters?
if you just want to convert "Name=John Henry Hohandle" into
"Name=John+Henry+Hohandle", this
should work:
$s =~ s!\s+!+!g;
> What I basically need to do is "unparse" formdata. Any steps I can
> take to make this relatively painless??
say exactly what else than the above case you have to handle
tina
--
http://www.tinita.de \ enter__| |__the___ _ _ ___
tina's moviedatabase \ / _` / _ \/ _ \ '_(_-< of
search & add comments \ \ _,_\ __/\ __/_| /__/ perception
------------------------------
Date: Wed, 31 May 2000 00:40:14 GMT
From: abaxaba <msanderso@hotmail.com>
Subject: Re: forms and Web Client
Message-Id: <8h1n1b$706$1@nnrp1.deja.com>
In article <8h1k18$2716d$1@fu-berlin.de>,
news@tinita.de wrote:
> hi,
>
> abaxaba <msanderso@hotmail.com> wrote:
>
> > if Data looks like -- Name=John Henry Hohandle, I need to convert
it to
> > John+Henry+Hohandle. A simple ~s//+/ won't suffice, since I also
need
> > to be concerned with escaping characters.
>
> which escaping characters?
> if you just want to convert "Name=John Henry Hohandle" into
> "Name=John+Henry+Hohandle", this
> should work:
>
> $s =~ s!\s+!+!g;
>
> > What I basically need to do is "unparse" formdata. Any steps I can
> > take to make this relatively painless??
>
> say exactly what else than the above case you have to handle
>
> tina
>
As there will be some idiocy in testing this app [purposefully], I need
to have all my bases covered. I basically need to reverse the
following code [used in parsing cgi]
$value = ~s/%([a-fA-F0-0][9a-fA-F0-9])/pack("C",hex($1))/eg;
which, as you know, is the common method clean up special characters in
a query string. I need to get back to the query string from parsed
data.
Sent via Deja.com http://www.deja.com/
Before you buy.
------------------------------
Date: 30 May 2000 19:53:24 -0500
From: Tony Curtis <tony_curtis32@yahoo.com>
Subject: Re: forms and Web Client
Message-Id: <87zop74k1n.fsf@limey.hpcc.uh.edu>
>> On Wed, 31 May 2000 00:40:14 GMT,
>> abaxaba <msanderso@hotmail.com> said:
> As there will be some idiocy in testing this app
> [purposefully], I need to have all my bases covered. I
> basically need to reverse the following code [used in
> parsing cgi]
> $value =
> ~s/%([a-fA-F0-0][9a-fA-F0-9])/pack("C",hex($1))/eg;
"use CGI;" does this in a much nicer way.
> which, as you know, is the common method clean up
> special characters in a query string. I need to get
> back to the query string from parsed data.
http://search.cpan.org/doc/GAAS/URI-1.06/URI/Escape.pm
hth
t
--
"Trying is the first step towards failure"
Homer Simpson
------------------------------
Date: 31 May 2000 00:11:27 GMT
From: abigail@arena-i.com (Abigail)
Subject: Re: Help - I've been spammed with PERL
Message-Id: <8h1lbf$7ba$10@news.panix.com>
On Mon, 29 May 2000 15:43:06 -0400,
new <booksellersunion@booksellersunion.org> wrote:
++ some crazy people started adding dozens of links at a time to my free for
++ all links page.
Well, don't make such a page then.
++ [SNIP]
++
++ I am logging these 'spam' attacks.
++ Any suggestions on what to do to counter or thwrat shennanigans like this??
And your Perl question is?
++ One friend suggested sending a ping of death to their IP when this stuff
++ comes through.
Nice friends you have. Does he also have a ping of death wand? Or do you
want to buy one on eBay?
Abigail
------------------------------
Date: Tue, 30 May 2000 22:19:53 GMT
From: squidrocks@my-deja.com
Subject: Help reading data from file
Message-Id: <8h1eqa$770$1@nnrp2.deja.com>
I'm a beginner programmer and I'm writing a modified hangman program that
reads the words to be used from a datafile.
#!/usr/bin/perl
open(MYFILE,"filename") || die; #opens the file with the words
@words=<MYFILE>; #creates an array for the file
close(MYFILE);
the problem is that I can't get it to read the words individually. When I run
hangman it fills spaces for all the letters of all the words. I've tried
rewritting it so
@words=qw<MYFILE>; #hoping this would seperate each word.
but I can't come up with anything that divides the words up seperately. If
anyone can offer assistance it would be appreciated.
Sent via Deja.com http://www.deja.com/
Before you buy.
------------------------------
Date: 30 May 2000 22:55:13 GMT
From: The WebDragon <nospam@devnull.com>
Subject: Re: Help reading data from file
Message-Id: <8h1gsh$d53$0@216.155.32.165>
In article <8h1eqa$770$1@nnrp2.deja.com>, squidrocks@my-deja.com wrote:
| I'm a beginner programmer and I'm writing a modified hangman program
| that reads the words to be used from a datafile.
|
| #!/usr/bin/perl
|
| open(MYFILE,"filename") || die; #opens the file with the words
| @words=<MYFILE>; #creates an array for the file
| close(MYFILE);
|
| the problem is that I can't get it to read the words individually.
| When I run hangman it fills spaces for all the letters of all the
| words. I've tried rewritting it so
|
| @words=qw<MYFILE>; #hoping this would seperate each word.
|
| but I can't come up with anything that divides the words up
| seperately. If anyone can offer assistance it would be appreciated.
#!/usr/bin/perl
open(MYFILE,"filename") || die "$!"; #opens the file with the words,
#and reports the specific error if
#not
while (<MYFILE>) { #creates an array for the file
chomp; #assumes \n delimiting
push @words, $_;
}
close(MYFILE);
--
send mail to mactech (at) webdragon (dot) net instead of the above address.
this is to prevent spamming. e-mail reply-to's have been altered
to prevent scan software from extracting my address for the purpose
of spamming me, which I hate with a passion bordering on obsession.
------------------------------
Date: Wed, 31 May 2000 00:03:30 +0100
From: Dave Cross <dave@dave.org.uk>
Subject: Re: Help reading data from file
Message-Id: <e5i8jskss0oevechupn0pgomeg9janpqeh@4ax.com>
On Tue, 30 May 2000 22:19:53 GMT, squidrocks@my-deja.com wrote:
>I'm a beginner programmer and I'm writing a modified hangman program that
>reads the words to be used from a datafile.
>
>#!/usr/bin/perl
>
>open(MYFILE,"filename") || die; #opens the file with the words
>@words=<MYFILE>; #creates an array for the file
>close(MYFILE);
>
>the problem is that I can't get it to read the words individually. When I run
>hangman it fills spaces for all the letters of all the words. I've tried
>rewritting it so
>
>@words=qw<MYFILE>; #hoping this would seperate each word.
>
>but I can't come up with anything that divides the words up seperately. If
>anyone can offer assistance it would be appreciated.
Have you looked at the 'split' function?
Dave...
--
<http://www.dave.org.uk> SMS: sms@dave.org.uk
yapc::Europe - London, 22 - 24 Sep <http://www.yapc.org/Europe/>
"There ain't half been some clever bastards" - Ian Dury [RIP]
------------------------------
Date: Tue, 30 May 2000 23:03:52 GMT
From: jerome@activeindexing.com (Jerome O'Neil)
Subject: Re: Help reading data from file
Message-Id: <sNXY4.677$S_3.37870@news.uswest.net>
The WebDragon <nospam@devnull.com> elucidates:
> | but I can't come up with anything that divides the words up
> | seperately. If anyone can offer assistance it would be appreciated.
What does your data look like?
is it
word word word
or
word
word
word
?
> while (<MYFILE>) { #creates an array for the file
> chomp; #assumes \n delimiting
> push @words, $_;
> }
chomp(@words = <MYFILE>);
Golfin'!
------------------------------
Date: Tue, 30 May 2000 16:02:49 -0700
From: Zolla Michalak <michalak@hwr.arizona.edu>
Subject: Re: Help reading data from file
Message-Id: <39344899.E9D2B5DC@hwr.arizona.edu>
I don't have time right now for a detailed response, but there is an awsome
tutorial for beginners at http://agora.leeds.ac.uk/Perl/start.html. Read
especially the sections on file handling, control structures, and string matching
(about regular expressions). I think you can use regular expressions to divide up
words (\b is a word boundary). See the tutorial for more on this... is very
detailed and easy to read.
-zm
squidrocks@my-deja.com wrote:
> I'm a beginner programmer and I'm writing a modified hangman program that
> reads the words to be used from a datafile.
>
> #!/usr/bin/perl
>
> open(MYFILE,"filename") || die; #opens the file with the words
> @words=<MYFILE>; #creates an array for the file
> close(MYFILE);
>
> the problem is that I can't get it to read the words individually. When I run
> hangman it fills spaces for all the letters of all the words. I've tried
> rewritting it so
>
> @words=qw<MYFILE>; #hoping this would seperate each word.
>
> but I can't come up with anything that divides the words up seperately. If
> anyone can offer assistance it would be appreciated.
>
> Sent via Deja.com http://www.deja.com/
> Before you buy.
------------------------------
Date: Tue, 30 May 2000 16:14:11 -0700
From: Makarand Kulkarni <makarand_kulkarni@My-Deja.com>
Subject: Re: Help reading data from file
Message-Id: <39344B43.E0CD79B3@My-Deja.com>
> @words=<MYFILE>; #creates an array for the file
what this does entirely depends on whether you have one word on each line,
or all the words on one single line or several lines each containing one or more
words.
--
------------------------------
Date: 30 May 2000 23:56:05 GMT
From: Tina Mueller <tina@streetmail.com>
Subject: Re: Help reading data from file
Message-Id: <8h1kek$2716d$2@fu-berlin.de>
hi,
The WebDragon <nospam@devnull.com> wrote:
> In article <8h1eqa$770$1@nnrp2.deja.com>, squidrocks@my-deja.com wrote:
> | open(MYFILE,"filename") || die; #opens the file with the words
> | @words=<MYFILE>; #creates an array for the file
> | close(MYFILE);
> |
> | the problem is that I can't get it to read the words individually.
> | When I run hangman it fills spaces for all the letters of all the
> | words. I've tried rewritting it so
> open(MYFILE,"filename") || die "$!"; #opens the file with the words,
> #and reports the specific error if
> #not
> while (<MYFILE>) { #creates an array for the file
> chomp; #assumes \n delimiting
> push @words, $_;
> }
this is unnecessary, just do:
@words = <MYFILES>;
chomp @words;
(as perldoc says, it works also on a list)
> close(MYFILE);
tina
--
http://www.tinita.de \ enter__| |__the___ _ _ ___
tina's moviedatabase \ / _` / _ \/ _ \ '_(_-< of
search & add comments \ \ _,_\ __/\ __/_| /__/ perception
------------------------------
Date: Tue, 30 May 2000 20:25:51 -0400
From: "Brian Landers" <brian@bluecoat93.org>
Subject: Re: Help reading data from file
Message-Id: <%ZYY4.710$BL4.8447@news1.atl>
#!/usr/local/bin/perl -w
use strict;
open( MYFILE, 'filename' ) || die "$!";
# Assumes a "word" cannot contain whitespace
my @words = map { split } <MYFILE>;
close MYFILE;
<squidrocks@my-deja.com> wrote in message
news:8h1eqa$770$1@nnrp2.deja.com...
> I'm a beginner programmer and I'm writing a modified hangman program that
> reads the words to be used from a datafile.
>
> #!/usr/bin/perl
>
> open(MYFILE,"filename") || die; #opens the file with the words
> @words=<MYFILE>; #creates an array for the file
> close(MYFILE);
>
> the problem is that I can't get it to read the words individually. When I
run
> hangman it fills spaces for all the letters of all the words. I've tried
> rewritting it so
>
> @words=qw<MYFILE>; #hoping this would seperate each word.
>
> but I can't come up with anything that divides the words up seperately. If
> anyone can offer assistance it would be appreciated.
>
>
> Sent via Deja.com http://www.deja.com/
> Before you buy.
------------------------------
Date: 30 May 2000 23:58:50 GMT
From: abigail@arena-i.com (Abigail)
Subject: Re: How to access documents on other servers?
Message-Id: <8h1kjq$7ba$6@news.panix.com>
On Mon, 29 May 2000 00:32:44 +0800, Johnson Lau <johnson@siukeung.com> wrote:
++ I can't install LWP module on my web server.
++ How can I get documents on other servers by using socket or other methods?
++ Since I know nothing about socket,
++ please include the script if possible, thank you.
NFS.
Abigail
------------------------------
Date: 31 May 2000 00:05:30 GMT
From: abigail@arena-i.com (Abigail)
Subject: Re: how to set the filename when sending content of unknown type to a browser?
Message-Id: <8h1l0a$7ba$7@news.panix.com>
On Mon, 29 May 2000 10:58:50 GMT, M. van den Bos <mvdbos@integral.nl> wrote:
++ I don't even know if this is the right group to ask this question in,
++ but I hope you can help me.
++
++ I have this perl script I'm working on that sends a delimited file to
++ a browser with "content-type: unknown" so that the user gets to save
++ the file.
No, not at all. The browser will typically do what the user has
instructed the browser to do. If the user has some sense, it will
instruct the browser to just throw away things that have an unknown
content.
After all, what's the user supposed to do with a file that has an
unknow content type? Only if the user knows what it is, (s)he can do
something with it.
++ So far this all works fine, but the default filename in the dialog is
++ the name of the script which sends the output. Is there any way of
++ setting that filename to something else?
Yes.
Write your own browser, and put in an obnoxious disclaimer on your
page "works only with foobar browser".
Now, what's your Perl question again?
Abigail
------------------------------
Date: 16 Sep 99 21:33:47 GMT (Last modified)
From: Perl-Users-Request@ruby.oce.orst.edu (Perl-Users-Digest Admin)
Subject: Digest Administrivia (Last modified: 16 Sep 99)
Message-Id: <null>
Administrivia:
The Perl-Users Digest is a retransmission of the USENET newsgroup
comp.lang.perl.misc. For subscription or unsubscription requests, send
the single line:
subscribe perl-users
or:
unsubscribe perl-users
to almanac@ruby.oce.orst.edu.
| NOTE: The mail to news gateway, and thus the ability to submit articles
| through this service to the newsgroup, has been removed. I do not have
| time to individually vet each article to make sure that someone isn't
| abusing the service, and I no longer have any desire to waste my time
| dealing with the campus admins when some fool complains to them about an
| article that has come through the gateway instead of complaining
| to the source.
To submit articles to comp.lang.perl.announce, send your article to
clpa@perl.com.
To request back copies (available for a week or so), send your request
to almanac@ruby.oce.orst.edu with the command "send perl-users x.y",
where x is the volume number and y is the issue number.
For other requests pertaining to the digest, send mail to
perl-users-request@ruby.oce.orst.edu. Do not waste your time or mine
sending perl questions to the -request address, I don't have time to
answer them even if I did know the answer.
------------------------------
End of Perl-Users Digest V9 Issue 3213
**************************************