[16881] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 4293 Volume: 9

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Tue Sep 12 00:05:28 2000

Date: Mon, 11 Sep 2000 21:05:10 -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: <968731509-v9-i4293@ruby.oce.orst.edu>
Content-Type: text

Perl-Users Digest           Mon, 11 Sep 2000     Volume: 9 Number: 4293

Today's topics:
        @variable_list <todd@mrnoitall.com>
    Re: @variable_list <elephant@squirrelgroup.com>
    Re: @variable_list (Abigail)
    Re: categories <elephant@squirrelgroup.com>
    Re: Change Windows Desktop BG <elephant@squirrelgroup.com>
    Re: cwd, iis, ActiveState Perl 613 <elephant@squirrelgroup.com>
        Easy question, I think <jluongo@mediaone.net>
    Re: Easy question, I think <wyzelli@yahoo.com>
    Re: Easy question, I think <stephenk@cc.gatech.edu>
    Re: Easy question, I think <garry@zvolve.com>
    Re: Easy question, I think <elephant@squirrelgroup.com>
    Re: help in writing a card game <elephant@squirrelgroup.com>
    Re: help in writing a card game <godzilla@stomp.stomp.tokyo>
        How can i install Perl DBI module without the cc compil <kam_ho@infrasys.com.hk>
    Re: How do I access a drive on the network? <elephant@squirrelgroup.com>
    Re: How do I access a drive on the network? <randy_734@my-deja.com>
    Re: How to set userid of a forked process (Gwyn Judd)
    Re: How to set userid of a forked process (Abigail)
    Re: Problem with join function (and split function) <elephant@squirrelgroup.com>
    Re: Qualifications for new Perl programmer????? (Tony L. Svanstrom)
    Re: simple question <elephant@squirrelgroup.com>
        submit buttons - two on one form? <jen@cusatis.net>
    Re: submit buttons - two on one form? <jen@cusatis.net>
    Re: submit buttons - two on one form? <christopher_j@uswest.net>
    Re: submit buttons - two on one form? <jcs@rt.fm>
    Re: submit buttons - two on one form? (Abigail)
    Re: submit buttons - two on one form? <elephant@squirrelgroup.com>
    Re: This *should* be easy, string parsing question <ren.maddox@tivoli.com>
    Re: xml type file parsing help. (Randal L. Schwartz)
        Digest Administrivia (Last modified: 16 Sep 99) (Perl-Users-Digest Admin)

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

Date: Mon, 11 Sep 2000 19:17:24 -0600
From: Todd Anderson <todd@mrnoitall.com>
Subject: @variable_list
Message-Id: <39BD83FC.C28BEA87@mrnoitall.com>

Dear Sirs,
I need to read names from a list based on the state chosen. (The name of
the @list would vary depending on the state chosen) I need code like the
example below but this does not work. Any ideas would be appreciated.
Thanks in advance.

foreach $item (@$form_data{'state'}_companies){



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

Date: Tue, 12 Sep 2000 13:09:18 +1100
From: jason <elephant@squirrelgroup.com>
Subject: Re: @variable_list
Message-Id: <MPG.14282d4b87275810989784@localhost>

Todd Anderson <todd@mrnoitall.com> wrote ..
>I need to read names from a list based on the state chosen. (The name of
>the @list would vary depending on the state chosen) I need code like the
>example below but this does not work. Any ideas would be appreciated.
>Thanks in advance.
>
>foreach $item (@$form_data{'state'}_companies){

what you're after are called symbolic references .. and they're not 
advisable .. you're better off structuring your data thusly

  my %companies
    = ( firstState  => [ 'array', 'elements', 'for', 'first', 'state' ]
      , secondState => [ 'etc', 'etc' ]
      , etc => [ 'etc', 'etc' ]
      );

then you can retrieve it like so

  foreach my $item ( @{$companies{$form_data{state}}} )
  {
    # do stuff with the array elements for $form_data{state}
  }

for more information see the perlref section of the documentation

-- 
  jason -- elephant@squirrelgroup.com --


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

Date: 12 Sep 2000 03:36:41 GMT
From: abigail@foad.org (Abigail)
Subject: Re: @variable_list
Message-Id: <slrn8rr94b.pg4.abigail@alexandra.foad.org>

Todd Anderson (todd@mrnoitall.com) wrote on MMDLXIX September MCMXCIII in
<URL:news:39BD83FC.C28BEA87@mrnoitall.com>:
__ Dear Sirs,

Hmmm. A bit sexist, aren't we?

__ I need to read names from a list based on the state chosen. (The name of
__ the @list would vary depending on the state chosen) I need code like the
__ example below but this does not work. Any ideas would be appreciated.
__ Thanks in advance.
__ 
__ foreach $item (@$form_data{'state'}_companies){


That doesn't compile. You probably want a nested datastructure.
There are several manpages dealing with them. Read them.



Abigail
-- 
perl -we 'print split /(?=(.*))/s => "Just another Perl Hacker\n";'
#    The Last Princess sitting.
#    The Lone Merchant. A woodpecker
#    in an oak.


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

Date: Tue, 12 Sep 2000 12:19:44 +1100
From: jason <elephant@squirrelgroup.com>
Subject: Re: categories
Message-Id: <MPG.142821a7e936604398977e@localhost>

Nolan Brame <nckdistr@pacbell.net> wrote ..
>I using wwwboard by mattscript is the a way that I could add categories.

this is not the Matt Wright Support forum .. if you have a Perl question 
then ask it here - if you have a question about the functionality of a 
script from someone else - then you should ask them

-- 
  jason -- elephant@squirrelgroup.com --


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

Date: Tue, 12 Sep 2000 12:09:52 +1100
From: jason <elephant@squirrelgroup.com>
Subject: Re: Change Windows Desktop BG
Message-Id: <MPG.14281f58a06b93f798977d@localhost>

James M. Luongo <jluongonospam@draper.com> wrote ..
>How would I use Perl for Windows to randomly change my windows desktop
>background each time I logged into my computer?

(assuming that you've checked CPAN in case someone's actually written 
this sort of functionality into a module - I have not checked it)

the windows background setting is stored in the Windows registry .. 
there are two modules for adjusting the registry .. both are (now) 
standard modules

  Win32::TieRegistry
  Win32API::Registry

see the standard documentation for how to use them

see some Windows resource for which setting it is

-- 
  jason -- elephant@squirrelgroup.com --


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

Date: Tue, 12 Sep 2000 12:30:16 +1100
From: jason <elephant@squirrelgroup.com>
Subject: Re: cwd, iis, ActiveState Perl 613
Message-Id: <MPG.14282424f3cfcd8f989780@localhost>

Scott Schaumann <scotts@itinet.com> wrote ..
>I've got a simple script that reports the cwd. It's being called via the web
>(cgi.pm) and consistently returns the wrong answer. My web server is IIS (4)
>on WinNT 4. I'm finding that the the directory returned is the root of the
>virtual directory in which the code resides, instead of the actual
>subdirectory. Has anyone seen this? Know how to fix it?

you don't exactly give us a lot to go on .. you haven't showed what 
you're using to get this cwd

have you tried using the SCRIPT_NAME environment variable ? .. it will 
give you the virtual directory and filename of the script being executed

-- 
  jason -- elephant@squirrelgroup.com --


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

Date: Tue, 12 Sep 2000 02:25:11 GMT
From: James <jluongo@mediaone.net>
Subject: Easy question, I think
Message-Id: <39BD925A.C32A4C47@mediaone.net>

Hmm, I cannot seem to figure this out.  I'm a little new with Perl.  Say
you had a string that contained a sentence.
eg "This line is a sentence"
What would be the regular expression to search and replace the first
letter of each work with a capital so the sentence would now be:
"This Line Is A Sentence"  ??

much appreciation in advance, thanks



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

Date: Tue, 12 Sep 2000 12:04:52 +0930
From: "Wyzelli" <wyzelli@yahoo.com>
Subject: Re: Easy question, I think
Message-Id: <GEgv5.21$no1.3133@vic.nntp.telstra.net>

"James" <jluongo@mediaone.net> wrote in message
news:39BD925A.C32A4C47@mediaone.net...
> Hmm, I cannot seem to figure this out.  I'm a little new with Perl.
Say
> you had a string that contained a sentence.
> eg "This line is a sentence"
> What would be the regular expression to search and replace the first
> letter of each work with a capital so the sentence would now be:
> "This Line Is A Sentence"  ??
>

s/\b(\w)/\U$1/g;

Wyzelli




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

Date: Mon, 11 Sep 2000 22:45:43 -0400
From: Stephen Kloder <stephenk@cc.gatech.edu>
Subject: Re: Easy question, I think
Message-Id: <39BD98D7.D1E3775A@cc.gatech.edu>

James wrote:

> Hmm, I cannot seem to figure this out.  I'm a little new with Perl.  Say
> you had a string that contained a sentence.
> eg "This line is a sentence"
> What would be the regular expression to search and replace the first
> letter of each work with a capital so the sentence would now be:
> "This Line Is A Sentence"  ??
>
> much appreciation in advance, thanks

$string =~ s/(\w+)/\u\L$1/g; # sets everything to Ulll format (Uppercase,
lowercase)
OR:
$string =~ s/(\w+)/\u$1/g; # sets first character in word to uppercase,
leaves other chars alone

perldoc perlre

--
Stephen Kloder               |   "I say what it occurs to me to say.
stephenk@cc.gatech.edu       |      More I cannot say."
Phone 404-874-6584           |   -- The Man in the Shack
ICQ #65153895                |            be :- think.




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

Date: Mon, 11 Sep 2000 22:57:23 -0400
From: "Garry T. Williams" <garry@zvolve.com>
Subject: Re: Easy question, I think
Message-Id: <Pine.SOL.4.21.0009112241540.25474-100000@ifr>

On Tue, 12 Sep 2000, James wrote:

> Hmm, I cannot seem to figure this out.  I'm a little new with Perl.  Say
> you had a string that contained a sentence.
> eg "This line is a sentence"
> What would be the regular expression to search and replace the first
> letter of each work with a capital so the sentence would now be:
> "This Line Is A Sentence"  ??

perldoc perlre

perl -e'$_="This line is a sentence.\n"; s/(\w+)/\u$1/g; print'

perldoc -f ucfirst

perl -e'$,=" "; print map { ucfirst } split / /, "This line is a sentence.\n"'

-Garry Williams



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

Date: Tue, 12 Sep 2000 14:29:33 +1100
From: jason <elephant@squirrelgroup.com>
Subject: Re: Easy question, I think
Message-Id: <MPG.14284014471ca0ee989785@localhost>

James <jluongo@mediaone.net> wrote ..
>Hmm, I cannot seem to figure this out.  I'm a little new with Perl.  Say
>you had a string that contained a sentence.
>eg "This line is a sentence"
>What would be the regular expression to search and replace the first
>letter of each work with a capital so the sentence would now be:
>"This Line Is A Sentence"  ??
>
>much appreciation in advance, thanks

this is a FAQ and brian's answer in there is a lot better that the 
provided ones .. specifically the answer in the FAQ does not wreck

  "this line isn't a sentence"

which the \b and \w+ based solutions do wreck

perlfaq4: "How do I capitalize all the words on one line?"

found with the perldoc utility

  perldoc -q capital

-- 
  jason -- elephant@squirrelgroup.com --


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

Date: Tue, 12 Sep 2000 12:23:34 +1100
From: jason <elephant@squirrelgroup.com>
Subject: Re: help in writing a card game
Message-Id: <MPG.1428228e6971c23098977f@localhost>

Kelley Kent <kelley.a.kent@intel.com> wrote ..
>So I was bored last night and decided to write
>a card program in Perl. (Ah yes, writing code
>for fun.) Actually I was kinda forced into it cause
>I couldn't find a good Spades game on download.com.
>Anywho, I was having some difficulties in figuring
>out how to implement the deck and the players,
>structure-wise.
>
>With regards to the deck: At first a 2 dimension
>array seemed ok (rows=suits, columns=values),
>and then 4 seperate arrays (one for each suit)
>seemed that it might be a better solution, then of
>course a hash table came to mind. But neither of
>these solutions had anything really going for it, in
>my mind.
>
>Haven't given too much thought on how to
>represent the players. Thought the deck should come
>first.
>
>The AI (or lack there-of) might be a pain, as I'm
>planning on just having a one person game with
>3 computer opponents. but that's down the road .....
>
>Any thoughts? Ideas? Suggestions? Comments
>from the peanut gallery? :-)

yeah .. where's the Perl question ? .. this is a question on programming 
structure and data types .. perhaps you'd have better luck in a forum 
that discusses programming rather than Perl

-- 
  jason -- elephant@squirrelgroup.com --


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

Date: Mon, 11 Sep 2000 19:56:13 -0700
From: "Godzilla!" <godzilla@stomp.stomp.tokyo>
Subject: Re: help in writing a card game
Message-Id: <39BD9B4D.F9F3B82E@stomp.stomp.tokyo>

jason wrote:
 
> Kelley Kent wrote:

> >So I was bored last night and decided to write
> >a card program in Perl....

> >With regards to the deck: At first a 2 dimension
> >array seemed ok (rows=suits, columns=values),
> >and then 4 seperate arrays (one for each suit)....


> yeah .. where's the Perl question ? .. this is a 
> question on programming structure and data types
> perhaps you'd have better luck in a forum
> that discusses programming rather than Perl




Perl does not involve programming, does not involve
programming structure, does not involve data types?

whew....  mondo beyondo.


Godzilla!
-- 
Robby The Remarkable Robot
  Zen Poet
    http://la.znet.com/~callgirl/android/zen.cgi


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

Date: Tue, 12 Sep 2000 11:55:30 +0800
From: "kam ho" <kam_ho@infrasys.com.hk>
Subject: How can i install Perl DBI module without the cc compiler
Message-Id: <8pk9b4$a85$1@news.hk.linkage.net>

hi all,

i am now running a SCO-UNIX-5.0.5 open server and only get gcc compiler,
once i want to install Perl DBI module, it generate the following error,

cc -c  -U M_XENIX -D PERL_SCO -D
PERL_SCO5 -w0 -belf -I/usr/local/include -Od    -DVERSION=\"1.13\" -DXS_VERS
ION=\"1.13\" -Kpic -I/usr/local/lib/perl5/5.00503/i386-sco/CORE -DDBI_NO_THR
EADS Perl.c
make: cc: Command not found
make: *** [Perl.o] Error 127

 i guess it is because i don't get the cc compiler, i want to ask how can i
install the module with only gcc, can i do it by editing the Makefile? i
have tried to edit Makefile by setting CC=gcc, but the following error
message appears

gcc: unrecognized option `-w0'
gcc: unrecognized option `-Kpic'
cpp: -lang-c: linker input file unused since linking not done
gcc: installation problem, cannot exec `cc1': No such file or directory
gcc: file path prefix `/usr/local/lib/gcc-lib/elf/2.95.1/' never used
make: *** [Perl.o] Error 1


Regards,
Kam




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

Date: Tue, 12 Sep 2000 12:07:21 +1100
From: jason <elephant@squirrelgroup.com>
Subject: Re: How do I access a drive on the network?
Message-Id: <MPG.14281ec12120b5a298977c@localhost>

Mark <mark_shutt@hotmail.com> wrote ..
>I am writing a utility with a web interface which includes copying a 
>user's directory (including all subdirectories and is specified by the 
>user) to a directory on the network. I am using Perl CGI scripts on a 
>Windows server to accomplish this. I have two questions...

you cannot easily copy a user's directory from their machine to the 
server via a standard web interface

>1) How do I get the path to the root of the directory I want to copy? I am 
>currenty using a form text field and am prompting the user to enter the 
>directory (i.e., c:\directory). I was wondering if there is a way to have 
>a browse button used. The HTML <input type=file> tag needs a specific file 
>entered, not just a directory path, and doesn't send the path of the file 
>as far as I know.

being able to have a "browser button" that allowed a web user to browser 
the server's filesystem would be such an enormous security hole that it 
would render the web almost useless .. the <input type="file"> tag 
allows a user to browse their own filesystem - which is probably not 
what you want

>2) Once I have the path of the user's directory, how do I access it? If I 
>use C:\directory it will assume the c: drive is the server, not the user's 
>c: drive. If it comes down to it, is it possible to temporarily map a 
>user's drive? This is on an internal network and the server will have 
>access to the user's drive.

you should have mentioned that last fact at the very beginning of this 
post .. so you're talking about some intranet type setup where the 
server can access the user's machine via a method OTHER THAN the web 
server

in that case - yes .. use the standard module Win32::NetResource to map 
drives and then use File::Copy and File::Path to copy the directory and 
files to whatever location you want

back to your first question .. the type="file" input tag is a non 
standard tag that supports only a file upload .. it is not for 
specifying directories

you will need to stick with the text input field - or perhaps write a 
java applet to get the value that you want

>Once I am able to access the user's drive and directory, I can use the DOS 
>command XCOPY to copy the directory to the server.

yes .. or the File::Path and File::Copy modules .. probably the 
File::Recurse module too

-- 
  jason -- elephant@squirrelgroup.com --


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

Date: Tue, 12 Sep 2000 01:30:13 GMT
From: Randy <randy_734@my-deja.com>
Subject: Re: How do I access a drive on the network?
Message-Id: <39bd86bb.43013343@207.126.101.100>

The DOS under NT "net use" command will map to a specific drive letter
and unmap when finished..


Mark <mark_shutt@hotmail.com> wrote:

>I am writing a utility with a web interface which includes copying a 
>user's directory (including all subdirectories and is specified by the 
>user) to a directory on the network. I am using Perl CGI scripts on a 
>Windows server to accomplish this. I have two questions...
>
>1) How do I get the path to the root of the directory I want to copy? I am 
>currenty using a form text field and am prompting the user to enter the 
>directory (i.e., c:\directory). I was wondering if there is a way to have 
>a browse button used. The HTML <input type=file> tag needs a specific file 
>entered, not just a directory path, and doesn't send the path of the file 
>as far as I know.
>
>2) Once I have the path of the user's directory, how do I access it? If I 
>use C:\directory it will assume the c: drive is the server, not the user's 
>c: drive. If it comes down to it, is it possible to temporarily map a 
>user's drive? This is on an internal network and the server will have 
>access to the user's drive.
>
>Once I am able to access the user's drive and directory, I can use the DOS 
>command XCOPY to copy the directory to the server.
>
>Any help is greatly appreciated. Thanks.
>
>Mark
>
>--
>Posted via CNET Help.com
>http://www.help.com/



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

Date: Tue, 12 Sep 2000 02:12:09 GMT
From: tjla@guvfybir.qlaqaf.bet (Gwyn Judd)
Subject: Re: How to set userid of a forked process
Message-Id: <slrn8rr47l.7oe.tjla@thislove.dyndns.org>

I was shocked! How could sherry <sherry@zeroknowledge.com>
say such a terrible thing:
>Hi ,
>
>Problem: I would like to run a script as root, and find all users of a
>machine and
>run a program as each user. All these users are non privileged users.
>
>I would like to fork a process,  set userid of that process as userA and
>exec programA.
>How can I do this?

The variables $> and $< hold the real and effective uids of the current
process. You can write to these if necessary (see "perldoc perlvar").
Hope that helps.

-- 
Gwyn Judd (print `echo 'tjla@guvfybir.qlaqaf.bet' | rot13`)
Blessed is he who has reached the point of no return and knows it,
for he shall enjoy living.
		-- W.C. Bennett


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

Date: 12 Sep 2000 03:38:12 GMT
From: abigail@foad.org (Abigail)
Subject: Re: How to set userid of a forked process
Message-Id: <slrn8rr977.pg4.abigail@alexandra.foad.org>

sherry (sherry@zeroknowledge.com) wrote on MMDLXIX September MCMXCIII in
<URL:news:39BD7AEB.78C96837@zeroknowledge.com>:
<> Hi ,
<> 
<> Problem: I would like to run a script as root, and find all users of a
<> machine and
<> run a program as each user. All these users are non privileged users.
<> 
<> I would like to fork a process,  set userid of that process as userA and
<> exec programA.
<> How can I do this?


man perlvar



Abigail
-- 
perl -MLWP::UserAgent -MHTML::TreeBuilder -MHTML::FormatText -wle'print +(
HTML::FormatText -> new -> format (HTML::TreeBuilder -> new -> parse (
LWP::UserAgent -> new -> request (HTTP::Request -> new ("GET",
"http://work.ucsd.edu:5141/cgi-bin/http_webster?isindex=perl")) -> content))
=~ /(.*\))[-\s]+Addition/s) [0]'


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

Date: Tue, 12 Sep 2000 12:50:06 +1100
From: jason <elephant@squirrelgroup.com>
Subject: Re: Problem with join function (and split function)
Message-Id: <MPG.142828cbae4b8ac2989783@localhost>

Geoff Soper <g.soper@soundhouse.co.uk> wrote ..
>In a script I have tried to take an array and join its elements into one
>string delimited by colons. This doesn't seem to be working.
>The line in question is line 95 and the script is
>http://www.soundhouse.co.uk/cgi-bin/2.cgi which is available for
>inspection at http://www.soundhouse.co.uk/geoff as is the database file.
>Through debugging I have established that it is an array before and after
>using join on it.
>
>It doesn't actually affect the program as later the line which should
>split the string into an array (using colon as the delimiter) passes it
>straight through. (line 136)
>
>As I say this means the script functions fine but I would like to know
>more about these two anomolies.

in future please post a short code example showing the problem you're 
having .. people here appreciate not having to go to your web site to 
look at the code

the problem in your code starts with this line

  $form_data{$_} = [param($_)] for param();

which is storing an array REFERENCE into the %form_data hash .. it's not 
storing an array .. therefore when you do the join later on the second 
argument to the join is actually an array reference - where it should be 
an array (or more accurately a list)

an array reference is only one list element .. so there's nothing to 
'join' with .. and you get back the array reference

you need to either store the array itself in the %form_data hash .. or 
dereference the arrayref in the 'join' call like this

  join ":", @{$form_data{$form_field}};

NB: this confusion between an array and an arrayref is probably causing 
problems elsewhere in your code

-- 
  jason -- elephant@squirrelgroup.com --


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

Date: Tue, 12 Sep 2000 03:05:30 +0200
From: tony@svanstrom.com (Tony L. Svanstrom)
Subject: Re: Qualifications for new Perl programmer?????
Message-Id: <1egtsfl.8jxqn97tj0oyN%tony@svanstrom.com>

Steven Merritt <smerr612@mailandnews.com> wrote:

> Oh, and I want a desk made out of Lego bricks.

You've just given my life a new meaning, from this day on I will not
rest until I've gotten myself a desk made out of Lego bricks. *L*


     /Tony
-- 
     /\___/\ Who would you like to read your messages today? /\___/\
     \_@ @_/  Protect your privacy:  <http://www.pgpi.com/>  \_@ @_/
 --oOO-(_)-OOo---------------------------------------------oOO-(_)-OOo--
   on the verge of frenzy - i think my mask of sanity is about to slip
 ---ôôô---ôôô-----------------------------------------------ôôô---ôôô---
    \O/   \O/  ©99-00 <http://www.svanstrom.com/?ref=news>  \O/   \O/


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

Date: Tue, 12 Sep 2000 12:37:44 +1100
From: jason <elephant@squirrelgroup.com>
Subject: Re: simple question
Message-Id: <MPG.142825e3de8e2b7989782@localhost>

interlocator@my-deja.com <interlocator@my-deja.com> wrote ..
>How can I pass a value from one script like username to another script
>to do more stuff with it?

how are you calling that other script ? .. there are many ways of 
passing values from one script to another - but they all depend on how 
you're calling the other script - or how you're calling the functions in 
the other script

>Or at least can you tell me what this is called so I can look it up
>myself.  This has been the biggest problem for me, knowing what some
>process is called to be able to learn it.

you might want to start reading about modules in the perlmod section of 
the documentation .. then read up about the 'require' and 'use' 
functions in perlfunc

-- 
  jason -- elephant@squirrelgroup.com --


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

Date: Mon, 11 Sep 2000 21:53:33 -0400
From: Jen Cusatis <jen@cusatis.net>
Subject: submit buttons - two on one form?
Message-Id: <39BD8C9D.2A7CC023@cusatis.net>

Hello.  I have two perl scripts and a form that contains
one text field and two buttons, one of the buttons is the submit button
and runs one of the scripts.  I would like the second button to run the
other script.  I've tried using the javascript onClick=the URL of the
script I want it
to run inside the input type=button tag, but I keep getting an error.
Is there a way to do this using only perl or a combination of perl and
javascript?  Thanks in advance for any help.
Jen



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

Date: Mon, 11 Sep 2000 22:13:15 -0400
From: Jen Cusatis <jen@cusatis.net>
Subject: Re: submit buttons - two on one form?
Message-Id: <39BD913B.8F38F9D3@cusatis.net>

Hello again.  Just to update, I managed to get the button to run the
script, but I am unable to collect the input from the text box on the
button that is not the submit button.  Is there something I can do?
Thanks.

Jen Cusatis wrote:

> Hello.  I have two perl scripts and a form that contains
> one text field and two buttons, one of the buttons is the submit button
> and runs one of the scripts.  I would like the second button to run the
> other script.  I've tried using the javascript onClick=the URL of the
> script I want it
> to run inside the input type=button tag, but I keep getting an error.
> Is there a way to do this using only perl or a combination of perl and
> javascript?  Thanks in advance for any help.
> Jen



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

Date: Mon, 11 Sep 2000 20:10:19 -0700
From: "Christopher M. Jones" <christopher_j@uswest.net>
Subject: Re: submit buttons - two on one form?
Message-Id: <G8hv5.1041$EW2.441919@news.uswest.net>


"Jen Cusatis" <jen@cusatis.net> wrote:
> Hello.  I have two perl scripts and a form that contains
> one text field and two buttons, one of the buttons is the submit button
> and runs one of the scripts.  I would like the second button to run the
> other script.  I've tried using the javascript onClick=the URL of the
> script I want it
> to run inside the input type=button tag, but I keep getting an error.
> Is there a way to do this using only perl or a combination of perl and
> javascript?  Thanks in advance for any help.


The only real way you can do exactly that is with javascript.

Try something like this

[[up in the header somewhere]]

<script language="javascript">
function reroute(form)
    {
    form.action="[[your other script url]]"
    }
</script>

[[the submit button]]
<input type="submit" name="Button2" value="Button Text"
onClick="reroute(this.form)">



Now, if you don't want to use javascript and you want to do it
all server side, you still have some options.

The best way is to test the parameters passed to the script for
the names of the two buttons.  The button that they pressed
will have it's name=value passed to your script and any buttons
will be absent.  Then you could do whatever you wanted to to
run either one of the other scripts (i.e. an eval, run some
functions, a system call, or an HTTP redirect).





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

Date: Tue, 12 Sep 2000 03:27:30 GMT
From: joshua stein <jcs@rt.fm>
Subject: Re: submit buttons - two on one form?
Message-Id: <Cohv5.8249$%l.234123@news-east.usenetserver.com>

Jen Cusatis <jen@cusatis.net> wrote:
> Hello.  I have two perl scripts and a form that contains
> one text field and two buttons, one of the buttons is the submit button
> and runs one of the scripts.  I would like the second button to run the
> other script.  I've tried using the javascript onClick=the URL of the
> script I want it
> to run inside the input type=button tag, but I keep getting an error.
> Is there a way to do this using only perl or a combination of perl and
> javascript?  Thanks in advance for any help.

I usually encounter this when I need two buttons for the same form data,
such as one for editing and one for deletion.  if possible, try to
combine the two scripts into one and format the code accordingly.

name both buttons the same on the form, give each a different value:

<input type="submit" name="button" value="Edit">
<input type="submit" name="button" value="Delete">

then use cgi to figure out which was pressed and do a certain action:

use CGI;
$query = new CGI;
$button = $query->param("button");

if ($button eq "Edit") {
	...
} elsif ($button eq "Delete") {
	...
}

-- 
joshua stein <jcs@rt.fm>


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

Date: 12 Sep 2000 03:40:13 GMT
From: abigail@foad.org (Abigail)
Subject: Re: submit buttons - two on one form?
Message-Id: <slrn8rr9av.pg4.abigail@alexandra.foad.org>

Jen Cusatis (jen@cusatis.net) wrote on MMDLXIX September MCMXCIII in
<URL:news:39BD8C9D.2A7CC023@cusatis.net>:
-: Hello.  I have two perl scripts and a form that contains
-: one text field and two buttons, one of the buttons is the submit button
-: and runs one of the scripts.  I would like the second button to run the
-: other script.  I've tried using the javascript onClick=the URL of the
-: script I want it
-: to run inside the input type=button tag, but I keep getting an error.
-: Is there a way to do this using only perl or a combination of perl and
-: javascript?  Thanks in advance for any help.


Sounds like an HTML problem to me. The HTML group is thataway.



Abigail
-- 
# Perl 5.6.0 broke this.
%0=map{reverse+chop,$_}ABC,ACB,BAC,BCA,CAB,CBA;$_=shift().AC;1while+s/(\d+)((.)
(.))/($0=$1-1)?"$0$3$0{$2}1$2$0$0{$2}$4":"$3 => $4\n"/xeg;print#Towers of Hanoi


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

Date: Tue, 12 Sep 2000 14:47:13 +1100
From: jason <elephant@squirrelgroup.com>
Subject: Re: submit buttons - two on one form?
Message-Id: <MPG.142844381504f045989786@localhost>

joshua stein <jcs@rt.fm> wrote ..
>Jen Cusatis <jen@cusatis.net> wrote:
>> Hello.  I have two perl scripts and a form that contains
>> one text field and two buttons, one of the buttons is the submit button
>> and runs one of the scripts.  I would like the second button to run the
>> other script.  I've tried using the javascript onClick=the URL of the
>> script I want it
>> to run inside the input type=button tag, but I keep getting an error.
>> Is there a way to do this using only perl or a combination of perl and
>> javascript?  Thanks in advance for any help.
>
>I usually encounter this when I need two buttons for the same form data,
>such as one for editing and one for deletion.  if possible, try to
>combine the two scripts into one and format the code accordingly.
>
>name both buttons the same on the form, give each a different value:
>
><input type="submit" name="button" value="Edit">
><input type="submit" name="button" value="Delete">
>
>then use cgi to figure out which was pressed and do a certain action:
>
>use CGI;
>$query = new CGI;
>$button = $query->param("button");
>
>if ($button eq "Edit") {
>	...
>} elsif ($button eq "Delete") {
>	...
>}

just a small recommendation .. I have found it much more robust to name 
the buttons differently and to test for the existence of that parameter 
 .. interfaces being what they are I have found that it is far more 
frequent for the value of a submit button to change than it is for the 
name of the button to change

and of course - when that happens the script breaks

  <input type="submit" name="editButton" value="Edit">
  <input type="submit" name="deleteButton" value="Delete">

then in the program

  # to make it easy to change them if ever required
  my   $editButton =   'editButton';
  my $deleteButton = 'deleteButton';

  # ... other code

  if   ( defined $q->param(  $editButton) ) {   editFunction() }
  elsif( defined $q->param($deleteButton) ) { deleteFunction() }

-- 
  jason -- elephant@squirrelgroup.com --


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

Date: 11 Sep 2000 18:06:07 -0500
From: Ren Maddox <ren.maddox@tivoli.com>
Subject: Re: This *should* be easy, string parsing question
Message-Id: <m3lmwy1qcg.fsf@dhcp11-177.support.tivoli.com>

cberry@cinenet.net (Craig Berry) writes:

> Adam Trace Spragg (spragg@cs.ucdavis.edu) wrote:
> : Peter J Scott <peter@psdt.com> wrote:
> : : %value = /([^=]+)=([^&]+)(?:&|$)/g;
> : 
> : Would someone mind please adding a little English to this?  I'm trying to 
> : learn regexps as best I can, and this one eludes me.
> 
> First, it's not how I'd do it.  I would use the split trick I posted, and
> if I had to do it as a regex, it would look like this:
> 
>   %value = /(.*?)=(.*?)(?:&|$)/g;
> 

The RE solutions "handle" embedded "&" and "=" in specific ways, while
the split method simply breaks on them.

$_="item=x=3&item2=y";

This breaks the split method completely (similar to having an & in a
parameter name as I mentioned in another post).

Now, I know that you (and I and everyone else) are really going with
the assumption that embedded "=" and "&" are not valid for this
problem statement, but it seems worth pointing out that the REs
described above "handle" them, while the split method does not.

[When I originally started to respond to this post, I was thinking
that non-greedy RE handled these embedded characters differently than
the original RE, but on further consideration I cannot come up with an
example where they behave differently.]

-- 
Ren Maddox
ren@tivoli.com


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

Date: 11 Sep 2000 18:07:23 -0700
From: merlyn@stonehenge.com (Randal L. Schwartz)
Subject: Re: xml type file parsing help.
Message-Id: <m1n1hes9is.fsf@halfdome.holdit.com>

>>>>> "Ric" == Ric Smith <rickyfusion@nospamfusionserver.com> writes:

Ric> Hello,
Ric> I have a couple of thousand files of the below format. They're
Ric> sort of xml'ish. I need to parse them and insert them into a db.
Ric> I need an idea of how to parse these files. Once of got the file
Ric> parsed and the values assigned to vars I can insert them no
Ric> problem.

Well, this program parses your data, returning a nice nested
data structure....

    #!/usr/bin/perl -w
    use strict;
    $|++;

    use XML::Simple;
    my $in = XMLin(join "", <DATA>);

    require Data::Dumper;
    print Data::Dumper::Dumper($in);

    __END__
    <chapter>
    <chapnum>CHAPTER 798</chapnum>
    <chapname>ADULTERY; COHABITATION</chapname>

    <section>
    <sectnum>798.01</sectnum>
    <catchlne>Living in open adultery.</catchlne>
    <sectbody>Whoever lives in an open state of adultery shall be
    guilty of a misdemeanor of the second degree, punishable as
    provided in s. 775.082 or s. 775.083. Where either of the parties
    living in an open state of adultery is married, both parties so
    living shall be deemed to be guilty of the offense provided for in
    this section.</sectbody>
    <hist>s. 1, ch. 1986, 1874; RS 2595; GS 3518; RGS 5406; CGL 7549; s. 772,
    ch. 71-136.</hist>
    </section>

    <section>
    <sectnum>798.02</sectnum>
    <catchlne>Lewd and lascivious behavior.</catchlne>
    <sectbody>If any man and woman, not being married to each other,
    lewdly and lasciviously associate and cohabit together, or if any
    man or woman, married or unmarried, engages in open and gross
    lewdness and lascivious behavior, they shall be guilty of a
    misdemeanor of the second degree, punishable as provided in s.
    775.082 or s. 775.083.</sectbody>
    <hist>s. 6, ch. 1637, 1868; RS 2596; GS 3519; RGS 5407; CGL 7550; s. 773,
    ch. 71-136.</hist>
    </section>
    </chapter>

which yields:

    $VAR1 = {
              'chapnum' => 'CHAPTER 798',
              'section' => [
                             {
                               'hist' => 's. 1, ch. 1986, 1874; RS 2595; GS 3518; RGS 5406; CGL 7549; s. 772,
    ch. 71-136.',
                               'catchlne' => 'Living in open adultery.',
                               'sectbody' => 'Whoever lives in an open state of adultery shall be
    guilty of a misdemeanor of the second degree, punishable as
    provided in s. 775.082 or s. 775.083. Where either of the parties
    living in an open state of adultery is married, both parties so
    living shall be deemed to be guilty of the offense provided for in
    this section.',
                               'sectnum' => '798.01'
                             },
                             {
                               'hist' => 's. 6, ch. 1637, 1868; RS 2596; GS 3519; RGS 5407; CGL 7550; s. 773,
    ch. 71-136.',
                               'catchlne' => 'Lewd and lascivious behavior.',
                               'sectbody' => 'If any man and woman, not being married to each other,
    lewdly and lasciviously associate and cohabit together, or if any
    man or woman, married or unmarried, engages in open and gross
    lewdness and lascivious behavior, they shall be guilty of a
    misdemeanor of the second degree, punishable as provided in s.
    775.082 or s. 775.083.',
                               'sectnum' => '798.02'
                             }
                           ],
              'chapname' => 'ADULTERY; COHABITATION'
            };

Hopefully, you can work it from there.  XML::Simple is in the CPAN.
With a bit of work, you can make it pull 'sectnum' out as a major
index...  it has quite a few configuration options.

-- 
Randal L. Schwartz - Stonehenge Consulting Services, Inc. - +1 503 777 0095
<merlyn@stonehenge.com> <URL:http://www.stonehenge.com/merlyn/>
Perl/Unix/security consulting, Technical writing, Comedy, etc. etc.
See PerlTraining.Stonehenge.com for onsite and open-enrollment Perl training!


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

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


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