[15618] in Perl-Users-Digest

home help back first fref pref prev next nref lref last post

Perl-Users Digest, Issue: 3031 Volume: 9

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Fri May 12 18:10:47 2000

Date: Fri, 12 May 2000 15:10:23 -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: <958169423-v9-i3031@ruby.oce.orst.edu>
Content-Type: text

Perl-Users Digest           Fri, 12 May 2000     Volume: 9 Number: 3031

Today's topics:
    Re: How do you create a module and pass variables into  (Mark-Jason Dominus)
    Re: Is this new language possible in perl? <andersen+@rchland.ibm.com>
        Job <patric-REMOVE-@kajen.com>
    Re: linked list in perl (Abigail)
    Re: linked list in perl (Abigail)
    Re: linked list in perl <samay1NOsaSPAM@hotmail.com.invalid>
        login/password redirection, and databse file editing <nospam@devnull.com>
    Re: MacPerl: access to floppy and harddisk? <nospam@devnull.com>
        Modem Communications in Perl amerar@my-deja.com
    Re: Modem Communications in Perl (Tad McClellan)
        need regex to see if a string is a valid number <akelingos@petrosys-usa.com>
    Re: need regex to see if a string is a valid number <sariq@texas.net>
    Re: Need to make UNIX autoresponder <gellyfish@gellyfish.com>
    Re: Newbie CGI/Perl <nospam@devnull.com>
    Re: page access dependant on $ENV{HTTP_REFERER} <nospam@devnull.com>
    Re: Perl for Windows - I'm confused... <Oliver.Rose@excite.com>
    Re: Perl question <aqumsieh@hyperchip.com>
    Re: Perl question jlamport@calarts.edu
    Re: PerlIS and IIS5 on Windows 2000 <l.marechal@chello.nl>
        Digest Administrivia (Last modified: 16 Sep 99) (Perl-Users-Digest Admin)

----------------------------------------------------------------------

Date: Fri, 12 May 2000 18:25:44 GMT
From: mjd@plover.com (Mark-Jason Dominus)
Subject: Re: How do you create a module and pass variables into and out of it?
Message-Id: <391c4ca8.63f0$258@news.op.net>


In article <391c5632.22389540@news.wanadoo.es>,
Lou Hevly <lou@visca.com> wrote:
>Mark-Jason Dominus has a good beginner's tutorial; look up 'Hello.pm'
>on Google. 

That's at

        http://www.plover.com/~mjd/perl/Hello/

It's 'The very very short tutorial about modules in Perl'

Blurb:

        [The first part of the tutorial] has an extremely simple
        module, an example program that uses it, and a list of
        exercises. You should do all the exercises. When you are done
        you will know how to write a module in the `module' style. The
        examples are complete, but they are so simple that they will
        both fit on the screen at the same time. Together they are
        eighteen lines long. 

        Then you should move to [the second part], which has an
        extremely simple object-oriented module, a sample program, and
        a list of exercises. Do the exercises. When you're done you
        will know how to write a module in the `object oriented'
        style. The example is a complete object-oriented program that
        creates an object and calls a method on it. It is a little
        longer than the other example. It is thirty-nine lines
        long. Fourteen of the lines are blank. 





------------------------------

Date: Fri, 12 May 2000 13:17:55 -0500
From: "Paul R. Andersen" <andersen+@rchland.ibm.com>
Subject: Re: Is this new language possible in perl?
Message-Id: <391C4AD3.EE30DD45@rchland.ibm.com>

pohanl@my-deja.com wrote:
> 
> Ok, here are some ideas for the new language...
> 
> The evolution of languages started first with load/store primative
> operations for the CPU.  This led to assembly which was basically a
> labeling system for the actual numbers the cpu understands.  When you
> have labels, people created an abstract macro layer above that so that
> it produced multiple assembly labels to be compiled into machine code.
> This is basically what Basic and Fortran, and Colbol did.  But as the
> languages became longer and longer, people started inventing ways to
> package some of the often used routines, and created the concept of a
> method (java), function (c), procedure (pascal), subroutine (basic and
> perl).  They are basically a way store often used instructions for the
> cpu into nice place (label it), and call it anytime you want.  But
> since these functions usually need information passed into it to work,
> pass by reference and pass by value became the norm, and was
> incorporated into the language.  Usually
> when a function is called, the calling function stores the passed
> values on a stack (a separate place in memory).  The called function
> then take these values from the stack and diddles with them.  When it
> is done, it return usually one value (either a reference or value) by
> placing it back on the stack, and the caller then takes it off of the
> stack.  To make it consistent, and less error prone, some languages
> invented the concept of a prototype, which basically says, this
> function can only take in 4 passed parameters of type integer, and
> return type char, etc etc.  Up to this point you have C and pascal.
> 
> Then someone comes along and says, hey, why not package multiple
> functions
> and data into a structure.  And that is how classes got started (which
> lead to object oriented languages like C++ and java).  Now when you are
> calling a function, instead of eat food, you say "tom, eat food" you
> have to tell which structure/class to do it.  Of course tom would have
> to know how to eat and what food to eat.  That is why Tom needs
> a function inside called eat, and you need to pass him food as a
> parameter.
> 
> Well this is fine, but each time you turn on the computer, the classes
> dissapear (well at least the data stored inside of them).  So people
> invented
> components that sort of made classes a little smarter.  Components are
> basically classes that (usually, not all) contains serialization, and
> function query.  Serialization means it can be stored to harddrive and
> back and keep its data intact.  function query (my own term) means you
> can
> ask a component what functions/methods it supports.  Some people group
> the functions into ports and some group them into interfaces.  These
> are basically another layer above the functions that you use to
> actually execute a function inside a component.  COM, Corba, and
> JavaBeans are like these.  (I did some things on Ports, like smart
> ports, which automatically does introspection(check parameter types) and
> automatically
> link methods between components if they match).  I actually created a
> new component architecture before (well contributed to it), but it
> wasn't truly a new language (you still had to program in java to create
> the component pieces to play with).
> 
> Well, Perl is something new to me.  It has some old vestiges of
> assembly type language structures.  For example, a called function
> manually pops stuff off of the stack (well indirectly), as opposed to
> being defined in variables identified in the function definition.
> It can also return multiple values (interesting).
> 
> Well, if you look at most cells in your body, you notice that they have
> a cell wall, and inside contains the DNA and other goodies. Things are
> passed to the cell through the cell wall.  This is very similar to
> passing variables to a component through an
> interface/function.
> 
> This new language would have components with no constraints on values
> passed to it.
> as for the values, instead of being dedicated to a method in a
> component/class/function, it would be placed on a bloodstream/"bus".
> cells/components would grab it when they have appropriate functions
> that can use it.
> 
> and of course there is the concept of dynamic operators.  operators are
> basically built-up from other components.

Wow!  A colorfull history of computer science (and not one I fully agree
with but .....).  It sounds to me like you are describing something
close to what goes on in prolog as its rules fire they have all the
inputs needed (with unsupplied data discovered by backtracking and so
on).  It would be nice to see a more complete description of this
language you describe along with an explanation of what it does that
current languages do not.  A brief program in this language would be
nice too.

-- 
Paul Andersen
-- I can please only ONE person per day.
-- Today is NOT your day.
-- Tomorrow isn't looking good either.


------------------------------

Date: Fri, 12 May 2000 20:34:21 GMT
From: root <patric-REMOVE-@kajen.com>
Subject: Job
Message-Id: <391C6AFB.D03E49E7@kajen.com>

Hi!

I wonder if there is anyone who knows any good sites where you can find
temporary Perl jobs or knows anyone who is looking for a temporary
programmer?  Or any companys that hire overseas Perl programmers?

Thanks in advance,
Patric
patric(at)kajen.com



------------------------------

Date: 12 May 2000 21:13:59 GMT
From: abigail@foad.org (Abigail)
Subject: Re: linked list in perl
Message-Id: <slrn8hot0m.bgd.abigail@ucan.foad.org>

On Thu, 11 May 2000 10:20:47 -0700, Perl Discussion <jmourney@hotmail.com> wrote
++ is it possible to have a linked list in perl?

Well, yes, of course.

++ i simply need to have a structure with 2 items:
++   one variable to contain data/value
++   one pointer to next/another structure
++ 
++ would it be just an array of size 2; item[0] contains
++ my data/value and item[1] is a reference to another array?

That's one way. You could also use a hash, or an object, or even a
closure. But, depending what exactly you want to use linked lists
for, you might just use Perl arrays instead.



Abigail


------------------------------

Date: 12 May 2000 21:19:26 GMT
From: abigail@foad.org (Abigail)
Subject: Re: linked list in perl
Message-Id: <slrn8hotau.bgd.abigail@ucan.foad.org>

On Fri, 12 May 2000 10:12:08 GMT, Bart Lateur <bart.lateur@skynet.be> wrote:
++ Perl Discussion wrote:
++ 
++ >is it possible to have a linked list in perl?
++ >i simply need to have a structure with 2 items:
++ >  one variable to contain data/value
++ >  one pointer to next/another structure
++ 
++ Why? Perl's built-in (onedimenional) arrays do everything you could
++ possibly want from a linked list.

No, they don't. They won't give you O (1) addition of an element, or O (1)
deletion (given a pointer to the appropriate place of update).

Deletion and insertion of elements in random places is linear with 
arrays; but not with linked lists.



Abigail


------------------------------

Date: Fri, 12 May 2000 14:55:46 -0700
From: Samay <samay1NOsaSPAM@hotmail.com.invalid>
Subject: Re: linked list in perl
Message-Id: <1de155f5.7167c2e5@usw-ex0104-087.remarq.com>

"Mastering alogrithms with Perl" explains the linked list very
well..
You can have it with arrays, hash or even objects..

sample code here:

$list = undef;
foreach (reverse 1..5){
  $list = [$_ * $_, $list];
}



* Sent from RemarQ http://www.remarq.com The Internet's Discussion Network *
The fastest and easiest way to search and participate in Usenet - Free!



------------------------------

Date: 12 May 2000 19:26:09 GMT
From: The WebDragon <nospam@devnull.com>
Subject: login/password redirection, and databse file editing
Message-Id: <8fhlsh$g3$0@216.155.32.232>

I'm sure someone has done something similar to this before.. 

basically I want to be able to have a logon/password entry html as the first screen that 
posts to a cgi script, which checks a database and then passes the user to one of two cgi 
scripts (plain user, admin) 

plain user script parses a database file, shows the listings, and allows the user to add 
entries to the list

admin script parses the same database file, shows the listings, and allows the user to 
remove entries or change entries to the list

the list needs to be comprised of 
    gametype|reviewer|reviewer e-mail|map name that reviwer plans to review.|

the listings will be broken down by gametype 
    deathmatch|capturetheflag|domination|assault|other|

I'm planning on using a popup menu that will match up the reviewer with their e-mail 
address, and may use a separate database file to initially grab that info (this prevents 
mistyping one or the other later) 

all fairly simple ( I hope ) stuff.. 

can someone point me to either some simple scripts on CPAN that they would recommend as a 
starting point, or can you recommend any particular modules that I can browse through to 
figure out how this can best be done? 

most of the CGI stuff is easy.. I've pretty much absorbed that, and with the help of some 
kind folks here, I've got my brain wrapped around the dereferencing of complex tables 
(thank you!).. the database entry editing seems to be simple straightforward stuff.. and 
might be as simple as push and pop.. I'd just like to be sure.. 

the other primary concern is the login thing, as I'm not sure whether I should use an 
encryoted password file or not. Access is limited to at most around 17-20 people (the 
reviewing staff). Any recommendations? 

Basically the project is so that the reviewers can submit which maps they are going to 
review this week, to the reviewers personal listing page (limited access), so no one steps 
on each other's toes. :) Then at the end of the week when the admins post the reviews, 
they remove those maps from the 'to be reviewed' list on the reviewer's page.

I know this seems rather long and windy, but I'm also writing it out as much as I can to 
get all the steps straight in MY mind before I begin. (always a good idea) :)

-- 
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: 12 May 2000 19:57:36 GMT
From: The WebDragon <nospam@devnull.com>
Subject: Re: MacPerl: access to floppy and harddisk?
Message-Id: <8fhnng$3jf$0@216.155.32.232>

In article <mario.gunkel-420594.20471211052000@news2.fast-net.de>, Mario Gunkel 
<mario.gunkel@fast-net.de> wrote:

 | MacPerl question 1:
 | How can I access a floppy-disk on the mac. Is there a routine or 
 | function built-in in MacPerl
 | that read out the connected devices and how can I access them. The MacOS 
 | allows it to name the 
 | floppy and hard-disks at will. How can I access a drive without knowing 
 | its name?
 | 
 | MacPerl question 2:
 | Some directories have names with a blank within, like "Macintosh HD". If 
 | I try to read in the
 | contents of such directory, MacPerl can't find it. I used the following 
 | commands:
 | 
 | $path="Macintosh HD";
 | opendir(DIR, $path) || die "can't opendir $path: $!";
 | foreach $filename (glob($path))
 | {
 | print $filename,"\n"
 | } 
 | 
 | MacPerl failed at the command "opendir..."

from macperl.pod: 
MacPerl::Volumes()   In scalar context, return the FSSPEC of the startup volume. In list 
context, return FSSPECs of all volumes. 

-=-

Personally, I recommend using File::Spec if you plan on making your scripts port-able. 

also, all directories need a path. 

top level dir is the hard drive name appended with :

so "Macintosh HD:" is the correct designation for a DIRECTORY rather than a FILE :)

try this on for size. 

#!perl -w
use strict;
use diagnostics -verbose;
use File::Spec;

#works if script is run from primary drive directory.
#my $inputDir = File::Spec->catfile( File::Spec->curdir(), 'Applications', '');

# works ONLY if the drive is actually NAMED "Macintosh HD"
# see File::Spec and macperl.pod for more info. 
my $inputDir = File::Spec->catfile( 'Macintosh HD', '');

opendir(DIR, $inputDir) or die "aCK! Can't opendir $inputDir: $!";
    my @files_List = readdir(DIR);
closedir DIR;

for (@files_List) {print "$_\n"};

# reads from current directory
$inputDir = File::Spec->curdir();

opendir(DIR, $inputDir) or die "aCK! Can't opendir $inputDir: $!";
     @files_List = readdir(DIR);
closedir DIR;

for (@files_List) {print "$_\n"};

-- 
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: Fri, 12 May 2000 19:24:53 GMT
From: amerar@my-deja.com
Subject: Modem Communications in Perl
Message-Id: <8fhlpi$jgg$1@nnrp1.deja.com>



Hello,

I am trying to do some modem communication from Perl.  Basically I need
to dial out to a remote host, which is a mainframe.  Enter a username
and passowrd when prompted, then anter a custom command to download a
file.

I recently found a Perl script at:
http://www.4guysfromrolla.com/linux/100398-2.shtml which actually does
dial out on the modem port, however, it never logs me in.  It just sits
there after connecting.  If I dial out manually, it works and I get the
login prompts.

I need a bit of help here.  Can anyone give me any suggestions or
perhaps know why I am not getting the same output from Perl that I so
manually?

Please respond to:  amerar@ci.chi.il.us

Thanks,

Arthur
amerar@ci.chi.il.us



Sent via Deja.com http://www.deja.com/
Before you buy.


------------------------------

Date: Fri, 12 May 2000 15:20:05 -0400
From: tadmc@metronet.com (Tad McClellan)
Subject: Re: Modem Communications in Perl
Message-Id: <slrn8homb5.og6.tadmc@magna.metronet.com>

On Fri, 12 May 2000 19:24:53 GMT, amerar@my-deja.com <amerar@my-deja.com> wrote:

>I am trying to do some modem communication from Perl.

[snip]

>Please respond to:  amerar@ci.chi.il.us


Please *post* replies to the newsgroup where the question
was asked (and email copies if you like).

There might be other folks here who would like to see the answer.

Let's not hoard answers in email.


-- 
    Tad McClellan                          SGML Consulting
    tadmc@metronet.com                     Perl programming
    Fort Worth, Texas


------------------------------

Date: Fri, 12 May 2000 16:48:43 -0500
From: "Alec Kelingos" <akelingos@petrosys-usa.com>
Subject: need regex to see if a string is a valid number
Message-Id: <shov1drukcp92@corp.supernews.com>

Hi,

I need a regular expression that will see if the value of a string is a
valid number.  Or is there an existing Perl function to do this?

I'm trying to do the following:

sub isNumber {
  my $str = shift;

   if ( SOME REGEX ) {
      return(1);
   } else {
      return(0);
  }
}

&main::isNumber('12      345');    # should return false
&main:isNumber('12a34567');    # should return false
&main::isNumber('       -12345   ')   # should return true



Thanks in advance for any help,

Alec





------------------------------

Date: Fri, 12 May 2000 17:02:40 -0500
From: Tom Briles <sariq@texas.net>
Subject: Re: need regex to see if a string is a valid number
Message-Id: <391C7F80.924BC707@texas.net>

Alec Kelingos wrote:
> 
> Hi,
> 
> I need a regular expression that will see if the value of a string is a
> valid number.

You should *always* check the documentation before posting.

perldoc -q number

- Tom


------------------------------

Date: 12 May 2000 19:55:32 +0100
From: Jonathan Stowe <gellyfish@gellyfish.com>
Subject: Re: Need to make UNIX autoresponder
Message-Id: <8fhk34$vmp$1@orpheus.gellyfish.com>

[ comp.lang.perl.modules removed ]

In comp.lang.perl.misc Mur <jboesNOjbSPAM@qtm.net.invalid> wrote:
> In article <Pine.GSO.4.10.10005110906430.16364-
> 100000@user2.teleport.com>, Tom Phoenix <rootbeer@redcat.com>
> wrote:
>>On Thu, 11 May 2000 acunet3278@my-deja.com wrote:
>>
>>> I would like to make an autoresponder in Perl on a UNIX
> server. Any
>>> ideas tips about doing that?
>>
>>Be sure to use 'use strict' and '-w'. Cheers!
>>
> 
> (Sheesh. While I admire the sentiment, I deplore the
> implementation...)
> 
> If you are looking for specific help with a script, c.l.p.misc
> is the place. If you are looking for a script, it's not. Go to a
> script archive (I happen to like www.perlarchive.com) and search
> for 'autoresponder'. I just did that, and got 9 hits.
> 

Alternatively searching the archives of this newsgroup on Deja News
might throw up examples as we sometimes get bored and write the things
anyway.

/J\
-- 
Dear Lord, thank You for this microwave bounty, even though we don't
deserve it. I mean... our kids are uncontrollable hellions! Pardon my
French... but they act like savages! Did You see them at the picnic? Oh,
of course You did... You're everywhere, You're omnivorous. Oh Lord! Why
did You spite me with this family?
-- 
fortune oscar homer


------------------------------

Date: 12 May 2000 20:36:51 GMT
From: The WebDragon <nospam@devnull.com>
Subject: Re: Newbie CGI/Perl
Message-Id: <8fhq13$6he$0@216.155.32.232>

In article <20000511230644.19175.00002234@ng-ci1.aol.com>, dedsrd@aol.com (DEDSRD) wrote:

 | I've followed the install of Mac Perl.
 | I'm trying to build a comboform cgi script (i think)
 | Never used Perl or MPW
 | Q: Where do I start? 

start by browsing all the pages displayed by the Shuck application, which should give you 
a nice overview, even if you don't understand it all yet.

Also make sure you download the latest version of CGI.pm (currently 2.66) (see internal 
CGI.pm docs for website address) 

Use BBEdit Lite to convert linefeeds from unix to mac and copy the CGI.pm to the 
:MacPerl:lib: directory, and the same for the contents of the CGI folder that comes with 
the CGI.pm .gzipped archive. Usually there's no need to run the "installer" for MacPerl, 
I've found. This varies from module to module, so just pay attention and save previous 
versions so in case a new module doesn't work, you can replace with the previous one 
without having to reinstall MacPerl.

 | Q: Can I run a form on my own machine(Mac) before uploading to simulate 
 | how the form will work in the browser?

YES! just use the WebSharing control panel, and enter 
http://127.0.0.1/cgi-scripts/yourscriptname.cgi (after creating a cgi-scripts directory in 
your Web Pages folder locally)

it's a good idea to put an empty index.html file in this directory to prevent people from 
seeing the scripts and associated files. :) 

 | Q: Is the .cgi and .pl extensions interchangeable does it matter which?

 .pl is typically a straight perl script

 .cgi and .acgi are extensions used to denote a cgi. HOWEVER on the mac, you must save 
these AS a CGI Script (see the popup menu in the Save As dialog)

DEFINITELY get BBedit (line numbers, and proper tabbing, and linefeed conversion are the 
simplest of its features :)

You should also have the latest Stuffit Expander (5.5) to uncompress the gzipped tarfiles 
with if you download modules. 

one other thing: read this newsgroup a LOT -- you'll get to see questions OTHER newbies 
and pros ask, and the answers they get.. which in and of itself can be very educational. 

HTH

-- 
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: 12 May 2000 20:42:04 GMT
From: The WebDragon <nospam@devnull.com>
Subject: Re: page access dependant on $ENV{HTTP_REFERER}
Message-Id: <8fhqas$6he$2@216.155.32.232>

In article <m13dnn6hd6.fsf@halfdome.holdit.com>, merlyn@stonehenge.com (Randal L. 
Schwartz) wrote:

 | >>>>> "Bill" == Bill  <bill@billcampbell.com> writes:
 | 
 | Bill> Below is the code I use in FILE-B. How would I change it so that 
 | instead of
 | Bill> relying on the passed variable from FILE-A, it would be dependant on
 | Bill> $ENV{HTTP_REFERER} being FILE-A ?
 | 
 | Don't.  No.  Just say no.  I've spoken on this subject probably a half
 | dozen times in the past six months, so you apparently haven't done
 | your basic research (a simple trip to reference.com or deja.com)
 | either.
 | 
 | The "Referer" header is trivially faked, dropped, and often wrong.
 | It's useful as a hint or an item for logging, but *never* as a portion
 | of a security policy.
 | 
 | Don't use it.
 | 
 | Don't go there.

heh, just curious, but do you recommend anything else ?

-- 
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: Fri, 12 May 2000 20:31:08 GMT
From: Oliver Rose <Oliver.Rose@excite.com>
Subject: Re: Perl for Windows - I'm confused...
Message-Id: <shoqgcirkcp115@corp.supernews.com>

> 1) Wich one is the best webserver to run perl on windows (free, if
> possible)?
> 
Down to personal preference i'm afraid. apparantly Xitami is quite good, 
while i'm running apache for Win32

> 2) Do I HAVE to get ActiveState? I've heard a lot of criticism about
> ActiveState, so I'm really scared. Is there any other kind of Perl for
> Windows?
As far as i know, all the windows perl stuff has been mixed into one 
package now. it's available from www.perl.com though.

> 
> 3) I've installed Perl Builder here, wich seems to have a Perl
> interpreter. How is that? If it really have a Perl interpreter, how
> can I update it? If I install this ActiveState it will conflict with
> Perl Builder's interpreter?
Perl works on some sort of weird combination of a compiler and an 
interpreter, so none of the parts can be updated individually. however the 
package at www.perl.com is the latest version, and also where the 
developers live, so it shouldn't be a prob getting any more info


--
Posted via CNET Help.com
http://www.help.com/


------------------------------

Date: Fri, 12 May 2000 18:51:33 GMT
From: Ala Qumsieh <aqumsieh@hyperchip.com>
Subject: Re: Perl question
Message-Id: <7au2g37gaw.fsf@Merlin.i-did-not-set--mail-host-address--so-shoot-me>


Haifeng <chj005@email.mot.com> writes:

> I am reading from a file, setting the contents in a structure and
> calling a function with the structure as parameter. Here's the code:

> Line 1: open(FH, "/usr/users/haifeng/f1.txt");

Make that:

	open(FH, '/usr/users/haifeng/f1.txt') or die $!;

In case your open() fails, this will make your program quit and print an
error message as to why it failed.

> Line 2: @data = <FH>;
> Line 3: close(FH);
> 
> Line 4: my($j) = 0;
> Line 5: while($j <= $#data){ $s .= @data[$j++]." "; }

You are assigning an array to a scalar. Anything that starts with a '$'
is a scalar. Period. Anything that starts with a '@' is an
array. Period. An array in scalar context returns the number of elements
in the array. You should change the above to:

	while ($j <= $#data) { $s .= $data[$j++] . " " }

checkout perlfaq4:

	What is the difference between $array[1] and @array[1]?

> Line 6: print (s);

I think you mean:

	print $s;

There are better ways to do what you want though. You can achieve the
same effect as in line 5 simply by doing:

	my $s = "@data";

Another way without reading the whole file into memory would be:

	my $s;
	$s .= "$_ " while <FH>;

Another approach (not sure how efficient it is though):

	my $s = join ' ' => <FH>;

--Ala


------------------------------

Date: Fri, 12 May 2000 19:16:03 GMT
From: jlamport@calarts.edu
Subject: Re: Perl question
Message-Id: <8fhl93$isl$1@nnrp1.deja.com>

In article <391C3328.A0671D34@email.mot.com>,
  Haifeng <chj005@email.mot.com> wrote:
>
> I am reading from a file, setting the contents in a structure and
> calling a function with the structure as parameter. Here's the code:

Without more information, I can't tell exactly what the problem is -- and
to the extent that I could test it myself, your code seemed to work --
but I can give you a quite a few suggestions which will make it much
easier to figure that out what the problem is (and they might even fix
your problem).

First, you should *always* run your programs with "use strict" and with
the -w option on -- there is at least one potential problem here that
would have been flagged at compile time if you had done this.

>
> Line 1: open(FH, "/usr/users/haifeng/f1.txt");

Are you certain this actually worked?  You should *always* test the
result of an open statement, like this:

open(FH, "/usr/users/haifeng/f1.txt") or
  die "Couldn't open file /usr/users/haifeng/f1.txt: $!";

(The $! variable usually contains useful information about what went
wrong.  See perldoc perlvar for more info.)

> Line 2: @data = <FH>;
> Line 3: close(FH);
>

So far so good, but since it's not working, are you certain that @data
actually contains the data you think it does?  Have you inserted a
debugging line like "print @data;" just to make sure?

> Line 4: my($j) = 0;
> Line 5: while($j <= $#data){ $s .= @data[$j++]." "; }

First:
@data[$j++] should be written as $data[$j++] (the -w compiler option
would have warned you about this).

Second:
Let me guess: you're used to programming in C, aren't you?  In Perl, the
above is a needlessly complicated and error-prone way of iterating
through @data.  You can write the above loop as

foreach my $d (@data) { $s .= $d.' '; }

But you don't need a loop at all.  You can get the same effect with:

$s = join(' ', @data) . ' ';

Or do you really even want that extra space at the end?  If not, you can
write this as

$s = join(' ',@data);

> Line 6: print (s);

I assume you mean print($s);  ?

>
> Line 7: $rec->{'raw'} .= $s;
> Line 8: $dbh->setRecord($rec);
>

This looks right -- though are you sure you want to *append* $s to the
end of $rec->{'raw'} rather than simply assign to it?

And of course, you haven't told us what sort of object $dbh is, so it's
impossible for us to know if you're accessing it correctly.

-jason


Sent via Deja.com http://www.deja.com/
Before you buy.


------------------------------

Date: Fri, 12 May 2000 21:09:24 +0200
From: "Laurent Marechal" <l.marechal@chello.nl>
Subject: Re: PerlIS and IIS5 on Windows 2000
Message-Id: <8fhkp6$1ru$1@spectra.a2000.nl>

Hi I just spend some time this afternnon to make it run in the same
environement...Same problem.
I manage to make it run by:
* Filling the mapping in IIS (see below)
* Renaming the file from pl or cgi to plx

Taken from activestate page:
http://www.activestate.com/ActivePerl/docs/faq/Windows/ActivePerl-Winfaq6.ht
ml#How_do_I_configure_Microsoft_IIS

How do I configure Microsoft IIS 4.0 to support ActivePerl?
Microsoft IIS 4.0 ships with Windows NT Server 5.0, and PWS 4.0 ships with
Windows NT Workstation 5.0. Both IIS and PWS are available as part of the
Microsoft Windows NT 4.0 Option Pack. You can find a link to the Option Pack
at http://www.microsoft.com/iis/

To configure IIS or PWS 4.0 to run Perl scripts:

Open the IIS 4.0 Internet Service Manager. This will bring up the Microsoft
Management Console with the Internet Service Manager snap-in selected.

From the tree display on the left, select the level at which to apply the
mappings. You can choose an entire server, web site, or a given virtual
directory.

Select Properties from the Action menu.

If you chose to administer the properties for the entire server, the Server
Properties dialog will appear. Select WWW Service from the Master Properties
pull-down menu and click the Edit button under Master Properties. This opens
WWW Service Master Properties. Select the Home Directory tab and proceed to
step 7.

If you chose to administer the properties for an entire web site, the Web
Site Properties sheet appears. Select the Home Directory tab and proceed to
step 7.

If you chose to administer the properties for a virtual directory, the
Virtual Directory Properties sheet appears. Select the Virtual Directory tab
and proceed to step 7.

Click the Configuration button. This opens the Application Configuration
dialog.

Select the App Mappings tab and click the Add button. You see the Add/Edit
Application Extension Mapping dialog.

To run Perl as a CGI application, type the full path to Perl.EXE followed by
%s %s. When a script is executed, the first %s will be replaced by the full
path to the script, and the second %s will be replaced by the script
parameters.

To run Perl for ISAPI, type the full path to PerlIS.DLL. The %s %s is not
required for ISAPI DLLs.

In the Extension field, type .pl or .plx (or whatever extension you want to
use).

The application mapping is now complete. Click the OK button and click OK to
dismiss any remaining dialogs/property sheets.

Close the IIS 4.0 Internet Service Manager.



Laurent


"new.myratech.net" <Roland@psychenet.co.uk> wrote in message
news:391c0cde.0@news.myratech.net...
> Has anyone managed to get PerlIIS up and running with IIS5 on Windows
2000?
> We have an NT4 server that relies heavily on the PerlIS.dll for working
with
> web pages hosted on the server.  We have been trialling IIS5 on Win2K and
> can't seem to get it configured to work!
>
> When you try and run a script the server reports that the file cannot be
> found.
>
> All the registry entries for scripting have been made and are correct -
> duplicated from current install that works.
>
> I am aware that on the Activestate website (we're running the latest
version
> of Perl from Active State) there is the following bug-report with Win2K:
>
> "PerlScript currently does not function correctly when being run in an ASP
> environment under IIS 5. This appears to be an issue in the `MSVCRT.DLL'
> that ships with Windows 2000. We are working to resolve the problem for a
> future release. "
>
> However, this is referring to Perl script, which I thought was differnet
to
> IISAPI Perl, which we were trying to run.  Maybe I'm mistaken?
>
> If anyone could help me out on this, either by confirming that PerlIS and
> Perscript are the same, or by confirming that they have manged to set it
up,
> then that would be a big help.
>
> Many thanks in anticipation of your help.
>
> Regards
>
> Roland
> Systems Administrator & Developer
> Psyche Solutions LTD
>
>




------------------------------

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 3031
**************************************


home help back first fref pref prev next nref lref last post