[16826] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 4238 Volume: 9

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Wed Sep 6 18:06:31 2000

Date: Wed, 6 Sep 2000 15:05:28 -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: <968277927-v9-i4238@ruby.oce.orst.edu>
Content-Type: text

Perl-Users Digest           Wed, 6 Sep 2000     Volume: 9 Number: 4238

Today's topics:
    Re: $LIST_SEPARATOR bug?? <lr@hpl.hp.com>
    Re: $LIST_SEPARATOR bug?? (Kevin Reid)
    Re: A Challenge <gellyfish@gellyfish.com>
    Re: A question about sleep(). <idleisidle@usa.net>
    Re: Background process (Logan Shaw)
    Re: Beating the perlcc dead horse again... <christopher_j@uswest.net>
        Beginner question about extracting data from file <g.soper@soundhouse.co.uk>
    Re: Beginner question about extracting data from file <jeff@vpservices.com>
    Re: Beginner question about extracting data from file <lr@hpl.hp.com>
    Re: CGI programming book <gellyfish@gellyfish.com>
    Re: CGI Script needed <mark@mark-spring.com>
        CGI.pm: Transaction Management (Was: controlling Back & <kj0@mailcity.com>
        download an HTML page to file <john@eagleinfosystems.com>
    Re: download an HTML page to file <tony_curtis32@yahoo.com>
    Re: download an HTML page to file <john@eagleinfosystems.com>
    Re: flock <lr@hpl.hp.com>
        Digest Administrivia (Last modified: 16 Sep 99) (Perl-Users-Digest Admin)

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

Date: Wed, 6 Sep 2000 11:12:55 -0700
From: Larry Rosler <lr@hpl.hp.com>
Subject: Re: $LIST_SEPARATOR bug??
Message-Id: <MPG.142029013fafde1098ad27@nntp.hpl.hp.com>

In article <c7ocrschjtl5eqchu5le5c7dv551vrt276@4ax.com> on Wed, 06 Sep 
2000 15:22:22 GMT, Bart Lateur <bart.lateur@skynet.be> says...
> jason wrote:
> 
> >I thought 
> >that because there was such a thing as &quot; that a bare " was not 
> >strict HTML .. but I've never checked
> 
> It is. Here is an example of what it's for:
> 
> 	<input name=size value="1.1/4&quot;">
> 
> which defines the value attribute as '1.1/4"'.

Then why not define the value attribute exactly that way?

 	<input name=size value='1.1/4"'>

Not that this subthread any longer has the slightest thing to do with 
Perl, of course.

-- 
(Just Another Larry) Rosler
Hewlett-Packard Laboratories
http://www.hpl.hp.com/personal/Larry_Rosler/
lr@hpl.hp.com


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

Date: Wed, 6 Sep 2000 14:50:46 -0400
From: kpreid@attglobal.net (Kevin Reid)
Subject: Re: $LIST_SEPARATOR bug??
Message-Id: <1egjl5d.1tf34lv7qq17aN%kpreid@attglobal.net>

Larry Rosler <lr@hpl.hp.com> wrote:

> In article <c7ocrschjtl5eqchu5le5c7dv551vrt276@4ax.com> on Wed, 06 Sep 
> 2000 15:22:22 GMT, Bart Lateur <bart.lateur@skynet.be> says...
> > jason wrote:
> > 
> > >I thought 
> > >that because there was such a thing as &quot; that a bare " was not 
> > >strict HTML .. but I've never checked
> > 
> > It is. Here is an example of what it's for:
> > 
> >     <input name=size value="1.1/4&quot;">
> > 
> > which defines the value attribute as '1.1/4"'.
> 
> Then why not define the value attribute exactly that way?
> 
>       <input name=size value='1.1/4"'>
> 
> Not that this subthread any longer has the slightest thing to do with 
> Perl, of course.

<input name=phrase value="He said &quot;it's what it is&quot; three times.">

-- 
 Kevin Reid: |    Macintosh:      
  "I'm me."  | Think different.


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

Date: 6 Sep 2000 07:25:36 +0100
From: Jonathan Stowe <gellyfish@gellyfish.com>
Subject: Re: A Challenge
Message-Id: <8p4o10$qt5$1@orpheus.gellyfish.com>

On Mon, 04 Sep 2000 14:07:43 GMT Bart Lateur wrote:
> Randy wrote:
> 
>>I would like to thank you for your excellent program. I ran it earlier
>>this evening and the pizza arrived about 30 minutes later.
> 
> Can you modify it, so the delivery is late, and I don't have to pay?
> Free pizza, wow! It'll be cold, but you can't have everything.
> 

That's what microwaves are for.

/J\
-- 
yapc::Europe in assocation with the Institute Of Contemporary Arts
   <http://www.yapc.org/Europe/>   <http://www.ica.org.uk>


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

Date: Wed, 6 Sep 2000 16:47:45 -0500
From: "Ben Ben" <idleisidle@usa.net>
Subject: Re: A question about sleep().
Message-Id: <EYyt5.637$Aq4.11935@vixen.cso.uiuc.edu>

I got it. Thank you and those guys who gave me their ideas.

Have a good day.





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

Date: 6 Sep 2000 15:04:16 -0500
From: logan@cs.utexas.edu (Logan Shaw)
Subject: Re: Background process
Message-Id: <8p6800$ffs$1@muenster.cs.utexas.edu>

In article <8p4qj8$l3c$1@nnrp1.deja.com>,  <pedjav@my-deja.com> wrote:
>Hi,
>Can anybody give me example of starting a few sub's in background and
>waiting them to finish and after that print result of those sub's.
>Something like this
>sub test1 {$t1="test 1 finished";}
>sub test2 {$t2="test 2 finished";}
>sub test3 {$t3="test 3 finished";}
>
>backgroundprocess (&test1;&test2;&test3);
>
>wait;
>
>print $t1,$t2,$t3;

You must use fork() to create the child processes, and you probably
want to use wait() to wait until one of them (all of them if you do it
in a loop with the right condition) have exited.

However, it's more complex than that.  What you want to do requires
interprocess communication.  The processes are separate images that
cannot modify each other, so they must talk to each other in order to
pass information.  (Actually, the parent has access to the exit code of
the children through the "$?" variable after you call wait(), but you
want to pass strings, so that won't suffice.)

The simplest way to do this may be to use pipes -- create a pipe,
fork(), and then have the child close one side of the pipe and the
parent close the other side.  The child can then write to the pipe and
the parent can read it, and you have one-way communication.

Talking to more than one process at a time is trickier -- you have to
use IO::Select or something like that.

  - Logan


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

Date: Wed, 6 Sep 2000 11:43:33 -0700
From: "Christopher M. Jones" <christopher_j@uswest.net>
Subject: Re: Beating the perlcc dead horse again...
Message-Id: <ifwt5.2511$Xq2.208247@news.uswest.net>

Sigh.

Well, try this.

First, set the sticky bit on your perl executable.

Next, run your script.

Finally, extract the binary from the memory core and
translate into an executable program (i.e. add the
loader).

Done!




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

Date: Wed, 06 Sep 2000 21:19:53 +0100
From: Geoff Soper <g.soper@soundhouse.co.uk>
Subject: Beginner question about extracting data from file
Message-Id: <39B6A6E9.8F70DA16@soundhouse.co.uk>

If I have a simple file in the format:

user, password, alias
rod, abc, "rod@hotmail.com"
jane, def, "jane@excite.com"
freddy, ghi, "freddy@bigfoot.com"

How can I get them into the format of

$fields(1)="user"
$fields(2)="password"
$fields(3)="alias"

%user="rod,jane,freddy"

$password(rod)="abc"
$password(jane)="def"
$alias(freddy)="freddy"

I hope this makes sense and would be most grateful if somebody could
point me in the right direction.

Many thanks


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

Date: Wed, 06 Sep 2000 13:49:37 -0700
From: Jeff Zucker <jeff@vpservices.com>
Subject: Re: Beginner question about extracting data from file
Message-Id: <39B6ADE1.F6ECEE3A@vpservices.com>

Geoff Soper wrote:
> 
> If I have a simple file in the format:
> 
> user, password, alias
> rod, abc, "rod@hotmail.com"
> jane, def, "jane@excite.com"
> freddy, ghi, "freddy@bigfoot.com"
> 
> How can I get them into the format of
> 
> $fields(1)="user"
> $fields(2)="password"
> $fields(3)="alias"

If you intend various kinds of database operations such as sorting,
selecting, inserting, deleting, you may want to use DBD::CSV or DBD::RAM
which would allow you say things like 

my $pswd = $dbh->selectrow_array(qq/
    SELECT password FROM users WHERE user = 'jane'
/);


-- 
Jeff


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

Date: Wed, 6 Sep 2000 14:51:56 -0700
From: Larry Rosler <lr@hpl.hp.com>
Subject: Re: Beginner question about extracting data from file
Message-Id: <MPG.14205c5c8ef332e98ad2f@nntp.hpl.hp.com>

In article <39B6A6E9.8F70DA16@soundhouse.co.uk> on Wed, 06 Sep 2000 
21:19:53 +0100, Geoff Soper <g.soper@soundhouse.co.uk> says...
> If I have a simple file in the format:
> 
> user, password, alias
> rod, abc, "rod@hotmail.com"
> jane, def, "jane@excite.com"
> freddy, ghi, "freddy@bigfoot.com"
> 
> How can I get them into the format of
> 
> $fields(1)="user"
> $fields(2)="password"
> $fields(3)="alias"

Array indexes in Perl start from 0 and are delimited by square brackets.

> %user="rod,jane,freddy"

That isn't the way to set up hash keys.

> $password(rod)="abc"
> $password(jane)="def"
> $alias(freddy)="freddy"

Hash keys are delimited by curly brackets.

> I hope this makes sense and would be most grateful if somebody could
> point me in the right direction.

The right direction is a two-dimensional data structure, a hash-of-hash-
references keyed off the user names.  The user names needn't be repeated 
in the hashes that contain the associated values (password and alias).

    perldoc perldsc

Here is some compactly-writtten code to play with.  I don't have time to 
write a detailed explanation.  Breaking it down into beginner-level code 
may be instructive as an exercise.


#!/usr/bin/perl -w
use strict;

my %users;
chomp(my $fields = <DATA>);
my @fields = split /,\s+/ => $fields;

/([^,]+),\s+([^,]+),\s+"([^@]+)/ and
    @{$users{$1}{@fields[1, 2]}} = ($2, $3) while <DATA>;

{
  local ($,, $\) = ("\t", "\n");
  print @fields, "\n";
  print $_, @{$users{$_}{@fields[1, 2]}} for sort keys %users;
}
__END__
user, password, alias
Rod, abc, "rod@hotmail.com"
Jane, def, "jane@excite.com"
Freddy, ghi, "freddy@bigfoot.com"

Output:

user    password        alias

Freddy  ghi     freddy
Jane    def     jane
Rod     abc     rod

-- 
(Just Another Larry) Rosler
Hewlett-Packard Laboratories
http://www.hpl.hp.com/personal/Larry_Rosler/
lr@hpl.hp.com


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

Date: 6 Sep 2000 07:18:27 +0100
From: Jonathan Stowe <gellyfish@gellyfish.com>
Subject: Re: CGI programming book
Message-Id: <8p4njj$qsg$1@orpheus.gellyfish.com>

On Tue, 05 Sep 2000 08:44:55 GMT Tim Hammerquist wrote:
> unicef2k@my-deja.com <unicef2k@my-deja.com> wrote:
>> I recently landed a job as a web programmer.
>> Can someone recommend a CGI programming book? Or is there a site where
>> I can find reviews of that type of book.  I'll be using Perl.
> 
> Lemme get this straight: you got a CGI programming job _before_ you knew
> how to program CGI?  Are you admitting fraud?  =)
> 

Its only an application environment, nothing to get excited about, 
programmers take jobs working in new (to them ) environments all the time.

/J\
-- 
yapc::Europe in assocation with the Institute Of Contemporary Arts
   <http://www.yapc.org/Europe/>   <http://www.ica.org.uk>


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

Date: Wed, 6 Sep 2000 20:19:18 +0200
From: "Mark Spring" <mark@mark-spring.com>
Subject: Re: CGI Script needed
Message-Id: <8p61ov$qkh$1@blue.nl.gxn.net>


> I've been looking around and I could get a basic script for free - but
> obviously the security isn't there. One good script was available for
> about £60.
>
> The problem is, I can't afford to fork out much, as we don't charge for
> any of our services and are gradually building the site up to be a
> large UK online magazine where bands can have their own pages dedicated
> to them. We have a number of projects in development which will bring
> in revenue, but these can't really start until the site is fully
> finished.
>
> Let me know if you know where I can get some help

Well my knowledge of Perl is not enough to write a perl script like that
from scratch but you might want to try www.scriptsearch.com you might find a
freescript and get somebody to adapt it to suit your needs, ..
Basically what you need is the following:

Several scripts :

This script will be called by a 'Join' button, you can either send data to
the script
using an html form or using a cgi generated page, obviously the person who
is joining
will have to fill in some info, this info will be saved in a database.
(There are several free database
scripts out there: dbman, woda, both of the aforementioned script are
flat-text databases,
meaning that the info is stored in a (comma seperated?) text file in a
dirctory on your server.
Obviously the script will have check wheather the username is already taken
or not and,
if the name is already taken, the script will come back with a warning (a
free script is account manager lite).
After someone has sucussfully joined the script will redirect them to a page
where they can upload
their info.

As soon as the account is created the 1st script will create a directory in
the base directory that you are using on the
server for the whole setup, then the script has to chgrp the directory so
that it belongs to the group 'users' (forexample).
Then the script will have to chown the script so that it is owned by the
person who has just logged in.

Looking at what you want, the best way to upload the pics might be with a
script which also checks the number of
 .jpg or .gif images that are already present in the directory, this check
will have to be performed everytime a single file
is uploaded (these scripts can generally be found under the web-editor
section of script rescourse sites).
lets say that you have another script in the directoy called index.cgi, when
this script is called
(ie by clicking on the name of the band in a list of the bands that are
listed) it generates a HTML page with the pics and a
bit of info about the band.
it is a bit of a work around to set it up like this, you will be using lots
of little scripts and stuff, the advantages however are
that it can be done on a very low budget, you just need someone to make
small changes, on the other hand a custom
databast could take care of all of the above mentioned things.

I know that this is not an answer to your question, but it might point you
on the right direction so that
you can start looking for small scripts.

Regards,

Mark





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

Date: 6 Sep 2000 16:40:12 -0400
From: kj0 <kj0@mailcity.com>
Subject: CGI.pm: Transaction Management (Was: controlling Back & Reload)
Message-Id: <8p6a3c$13b$1@panix3.panix.com>







Is there a good source (book, article, pod, website, etc.) on
Transaction Management in perl?

kj


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

Date: Wed, 6 Sep 2000 15:08:10 -0400
From: "John Menke" <john@eagleinfosystems.com>
Subject: download an HTML page to file
Message-Id: <39b6961e$1_2@news.eclipse.net>

Is there any module that will help me do this?

--
----------------------------------------------------------------------
                Best viewed with courier 10 ppt. Font

      .---.        .----------   John Menke
     /     \  __  /    ------   JCN Capital
    / /     \(  )/    -----    Eagle Information Systems
   //////   ' \/ `   ---      Research Consultant - Web Developer
  //// / // :    : ---      Home Phone No. 908-876-1538
 // /   /  /`    '--       Work Phone No. 914-627-1115
//         ///..\\\       Email: john@eagleinfosystems.com
         ==UU====UU==    http://www.eagleinfosystems.com




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

Date: 06 Sep 2000 14:09:52 -0500
From: Tony Curtis <tony_curtis32@yahoo.com>
Subject: Re: download an HTML page to file
Message-Id: <87r96xz69r.fsf@limey.hpcc.uh.edu>

>> On Wed, 6 Sep 2000 15:08:10 -0400,
>> "John Menke" <john@eagleinfosystems.com> said:

> Is there any module that will help me do this?  --

perldoc lwpcook

(1 line of text and 11 of signature?)

hth
t
-- 
WWNKD?


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

Date: Wed, 6 Sep 2000 15:22:41 -0400
From: "John Menke" <john@eagleinfosystems.com>
Subject: Re: download an HTML page to file
Message-Id: <39b69986$1_2@news.eclipse.net>

tony,  thanks for pointing the sig thing out to me.  Just installed a new
news reader and forgot to take the signature file off.... sorry


Tony Curtis <tony_curtis32@yahoo.com> wrote in message
news:87r96xz69r.fsf@limey.hpcc.uh.edu...
> >> On Wed, 6 Sep 2000 15:08:10 -0400,
> >> "John Menke" <john@eagleinfosystems.com> said:
>
> > Is there any module that will help me do this?  --
>
> perldoc lwpcook
>
> (1 line of text and 11 of signature?)
>
> hth
> t
> --
> WWNKD?




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

Date: Wed, 6 Sep 2000 12:10:13 -0700
From: Larry Rosler <lr@hpl.hp.com>
Subject: Re: flock
Message-Id: <MPG.1420366c3cf03f6698ad29@nntp.hpl.hp.com>

In article <39B60538.43F6@tpi.uni-jena.de> on Wed, 06 Sep 2000 10:50:00 
+0200, Thomas Lotze <T.Lotze@tpi.uni-jena.de> says...
> I want to program some CGI application involving a database. In order
> to prevent it from being messed up in case two processes access it
> at the same time, I want to lock the data file using flock. I tried
> to do it like this:
> 
> open (file_handle,$filename):
> flock (file_handle,2);
> 
> #do something with the file
> 
> flock (file_handle,8);
> close (file_handle);
> 
> However, if I stretch the whole process by a sleep ($quite_a_lot)
> command and log the system time of opening and after closing the
> files, the database still gets messed up if I run the process twice,
> starting the second one while the first one sleeps, and the second
> process doesn't wait for the lock (opening and closing time are the
> same). What do I do wrong?

Perhaps you haven't read perlfaq5: "How can I lock a file?" and the 
documentation referred to in it.  In particular, you may find that you 
cannot lock a file unless it has been opened for writing or updating.  
The file in your code is opened only for reading.

-- 
(Just Another Larry) Rosler
Hewlett-Packard Laboratories
http://www.hpl.hp.com/personal/Larry_Rosler/
lr@hpl.hp.com


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

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


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