[17516] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 4936 Volume: 9

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Mon Nov 20 21:05:43 2000

Date: Mon, 20 Nov 2000 18:05:11 -0800 (PST)
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)
Message-Id: <974772311-v9-i4936@ruby.oce.orst.edu>
Content-Type: text

Perl-Users Digest           Mon, 20 Nov 2000     Volume: 9 Number: 4936

Today's topics:
    Re: [Perl - file IO] editing & displaying *.CSV files <jeff@vpservices.com>
    Re: Beginners Blues II (David Wall)
        Conditional includes with cookies <frederik.vincx@pandora.be>
    Re: Conditional includes with cookies dtbaker_dejanews@my-deja.com
        copying / renaming associative arrays ---or something.. <mhall@****nwa.quik.com>
        CSV Incrementing Question TIA!! <tgoggin@unforgettable.com>
    Re: CSV Incrementing Question TIA!! <bwalton@rochester.rr.com>
        default perl to execute in current dir ? dtbaker_dejanews@my-deja.com
    Re: Do I need Java to redirect form parameters? <jwhitt@webaccess.net>
        Download image from a html page using perl CGI jzhang_97@my-deja.com
        EXISTS?:  Perl Script to synch a local directory with a <mweatherford@aventail.com>
    Re: EXISTS?:  Perl Script to synch a local directory wi (Martien Verbruggen)
        file names in a new directory <ghrose@unm.edu>
    Re: file names in a new directory (Martien Verbruggen)
    Re: file names in a new directory (Jon Ericson)
        how would you call a subrountine using a button in a we pape_98@my-deja.com
    Re: how would you call a subrountine using a button in  dtbaker_dejanews@my-deja.com
    Re: how would you call a subrountine using a button in  <xzrgpnys@yvtugubhfrovm.pbz>
        Perl and Win98 <c.darlington@virgin.net>
    Re: Perl and Win98 dtbaker_dejanews@my-deja.com
    Re: Perl and Win98 shawnroske@my-deja.com
    Re: Perl and Win98 (Jon Ericson)
    Re: Perl beginner <captmarvil@rcn.com>
    Re: PerlScript and ASP <toddm@waltz.rahul.net>
    Re: Question about Buttons and Subroutines dtbaker_dejanews@my-deja.com
    Re: Random Array with Sort? <jpl@research.att.com>
        Sort strings before numbers <hbhb@gmx.de>
    Re: Sort strings before numbers (Tad McClellan)
    Re: starting a perl script as an NT service <neil@alaweb.com>
        Digest Administrivia (Last modified: 16 Sep 99) (Perl-Users-Digest Admin)

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

Date: Mon, 20 Nov 2000 15:08:59 -0800
From: Jeff Zucker <jeff@vpservices.com>
Subject: Re: [Perl - file IO] editing & displaying *.CSV files
Message-Id: <3A19AF0B.821F08B9@vpservices.com>

Holger wrote:
> 
> did anyone out there have some experience with editing and displaying *.CSV
> files? I plan to on the one hand search an *.CSV file (via a form) and on
> the other add new datasets to it using a fix dataset structure. Also it
> should be possible to download the whole file via a downloadlink to your
> local machine and delete specific datasets.

The modules DBD::CSV and DBD::RAM both are able to treat CSV files as
databases, allowing you to add, update, delete, search, and sort the
file through standard SQL database calls.

-- 
Jeff


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

Date: 20 Nov 2000 18:41:23 -0500
From: darkon@one.net (David Wall)
Subject: Re: Beginners Blues II
Message-Id: <8FF2BF82Ddarkononenet@206.112.192.118>

adelton@informatics.muni.cz (Honza Pazdziora) wrote in
<G4C2r2.CFG@news.muni.cz>: 

>On 20 Nov 2000 07:50:16 -0500, David Wall <darkon@one.net> wrote:
>Note that backslash _has_ a special meanin inside apostrophes. Yes,
>'\@' will work as well, and we've reduced it to the previous case.

Hmm, I missed that parenthetical comment in perldata.  I hadn't considered 
the case where you might want a string consisting only of a backslash.

-- 
David Wall
darkon@one.net


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

Date: Mon, 20 Nov 2000 23:16:22 GMT
From: "Frederik Vincx" <frederik.vincx@pandora.be>
Subject: Conditional includes with cookies
Message-Id: <ahiS5.188061$iI2.3614729@afrodite.telenet-ops.be>

hi,

I've been looking all over the net for stuff about conditional includes, and
this was the online 'good' thing I found
http://wsabstract.com/howto/conssi.shtml . On that page they show you how to
use different includes depending on the browsertype.. well, I'd really like
to use different includes depending on a selection the user made that is
store in a cookie .., but it just won't work..  Does anyone know how to do
that?

Thanx,

Frederik Vincx




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

Date: Tue, 21 Nov 2000 00:54:05 GMT
From: dtbaker_dejanews@my-deja.com
Subject: Re: Conditional includes with cookies
Message-Id: <8vch3a$c1h$1@nnrp1.deja.com>

In article <ahiS5.188061$iI2.3614729@afrodite.telenet-ops.be>,
  "Frederik Vincx" <frederik.vincx@pandora.be> wrote:
> hi,
>
> I've been looking all over the net for stuff about conditional
includes, and
> this was the online 'good' thing I found
> http://wsabstract.com/howto/conssi.shtml . On that page they show you
how to
> use different includes depending on the browsertype.. well, I'd really
like
> to use different includes depending on a selection the user made that
is
> store in a cookie .., but it just won't work..  Does anyone know how
to do
> that?
--------------

are you wanting to use perl, or something else?
cookies are a little unreliable, but if you use CGI::cookie you can
certainly get the values and decide what to do. for instance in a perl
script you could:

require "$FromCookie.pl";

to pull in some specific code. read the docs on the CGI module for more
info about cookies.

D


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


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

Date: Mon, 20 Nov 2000 18:47:51 -0600
From: "Mike Hall" <mhall@****nwa.quik.com>
Subject: copying / renaming associative arrays ---or something...
Message-Id: <twjS5.782$lt6.88233@nnrp2.sbc.net>

I am in the process of writing a calculator type of script that processes
data entered into an HTML form and returns a formatted report of the
results.  All of this is working fine, the problem is that there needs to be
a maximum of 4 forms worth of data entered, but the minimum is 1.  The form
has a "Continue" button for entering into another table and a "Finish"
button to stop entering and calculate the results.The form is printed by the
script.  The data is being read into an associative array for the
calculations, which is fine if there is only one set of information, but
what I need to do is if the "Continue" button is pressed, read in the data,
store it in the array, and spit the form back out for more entry.  Whenever
the "Finish" button is pressed, I need to loop through the "Array of
arrays", extracting one at a time and sending it through the calculator sub
to be processed.  The values returned by the calculator sub also need to be
held for each set and sent out to the print sub.

I have been through the numerous FAQ's available on the web, and I can find
no mention of doing this... is it not possible to do it this way?  Would it
be easier to keep the data as the data returned by the POST from the form so
that it could be stored as a single string variable like $form1, $form2,
$form3, $form4 and then have each be parsed into the associative array and
calculated?  I tend to make things too complicated sometimes...


At this stage of the game I need advice as much as answers, and either are
appreciated.

Thanks.
mh






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

Date: Tue, 21 Nov 2000 01:08:52 GMT
From: "Tim Goggin" <tgoggin@unforgettable.com>
Subject: CSV Incrementing Question TIA!!
Message-Id: <DWjS5.3349$qP3.346293@dfiatx1-snr1.gtei.net>

Hi all!

    I'm modifying a perl script that opens a csv file and writes information
to it.

    For example:

    "Item", "1", "22", "33", "455"

    What I need to do is have the script open the csv file, go to a specific
line, find the item that needs to be changed and increment the number so it
will now read:

    "Item", "2", "22", "33", "455"

    Does anyone know any perl code to do this? I would really appreciate any
help.

Thanks in advance,

Tim




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

Date: Tue, 21 Nov 2000 01:43:17 GMT
From: Bob Walton <bwalton@rochester.rr.com>
Subject: Re: CSV Incrementing Question TIA!!
Message-Id: <3A19D3E8.DE9C4DCD@rochester.rr.com>

Tim Goggin wrote:
 ...
>     I'm modifying a perl script that opens a csv file and writes information
> to it.
> 
>     For example:
> 
>     "Item", "1", "22", "33", "455"
> 
>     What I need to do is have the script open the csv file, go to a specific
> line, find the item that needs to be changed and increment the number so it
> will now read:
> 
>     "Item", "2", "22", "33", "455"
> 
>     Does anyone know any perl code to do this? I would really appreciate any
> help.
 ...
> Tim
I recommend you use the DBI module with DBD::CSV.  Then you can use SQL
to do your modifications just like if it was a real database, and you
don't have to fuss around with properly parsing your CSV file.  See
examples in the relevant docs, like perldoc DBI and perldoc DBD::CSV.
-- 
Bob Walton


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

Date: Tue, 21 Nov 2000 00:09:01 GMT
From: dtbaker_dejanews@my-deja.com
Subject: default perl to execute in current dir ?
Message-Id: <8vceeo$9ts$1@nnrp1.deja.com>



I am having trouble tracking down the difference in the install or
configuration of either windows or perl between two windows 98 PCs. One
one PC, perl scripts execute with the working directory set to the dir
where the script is, and on the other, it defaults to /usr/bin where
perl.exe is installed.

I now I should not rely on the current wd, but for the sake of easy
utility script execution on local files in a dir, I'd really like to
configure perl to open and execute in the dir that the script is fired
up in.

I realize this is probably a windoze issue, but I cant find a solution
in the windows help files either....

thanx,

Dan


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


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

Date: Mon, 20 Nov 2000 18:17:39 -0700
From: "Josh Whitt" <jwhitt@webaccess.net>
Subject: Re: Do I need Java to redirect form parameters?
Message-Id: <3a19cc12$1@news.webaccess.net>


> > 3) whip out LWP and post directly to this external script, grab that
> > script's output, and print it out from your script.
> LWP?
libwww-perl, it's a module set that encapsulates http in Perl.  It's a
little obtuse (there's been an O'Reilly book written strictly about it!) but
it comes in handy sometimes, for spidering and specialty uses like what
you're doing.

- Josh




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

Date: Mon, 20 Nov 2000 23:06:03 GMT
From: jzhang_97@my-deja.com
Subject: Download image from a html page using perl CGI
Message-Id: <8vcaom$6qg$1@nnrp1.deja.com>

Is there a simple way to download a image
file(.gif) from a web server with address:

http://www.webserver.com/img.gif

using perl CGI and saving it locally? I tried
"lynx" and could not figure out a way doing
it. I prefer doing it using standard
Perl commands, if possible.

TIA.

-John


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


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

Date: Mon, 20 Nov 2000 15:07:48 -0800
From: Matt <mweatherford@aventail.com>
Subject: EXISTS?:  Perl Script to synch a local directory with a ftp servers directory
Message-Id: <rfbj1toht627id61ge49is2dl4rn12t4ov@4ax.com>



I am familiar with perl's NET:Ftp module - it works great, thanks! :)

I am wondering if someone has written a script which synchronizes two
directories on different FTP servers, updating and transferring files
between them. The script would run on the local machine, and get/put
files as needed to insure that the same files were in both places,
with some method of specifying the "more trusted" source in case of a
conflict.

thanks,

Matt





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

Date: Tue, 21 Nov 2000 01:10:58 GMT
From: mgjv@tradingpost.com.au (Martien Verbruggen)
Subject: Re: EXISTS?:  Perl Script to synch a local directory with a ftp servers directory
Message-Id: <slrn91jis2.r2.mgjv@verbruggen.comdyn.com.au>

On Mon, 20 Nov 2000 15:07:48 -0800,
	Matt <mweatherford@aventail.com> wrote:
> 
> I am wondering if someone has written a script which synchronizes two
> directories on different FTP servers, updating and transferring files
> between them.

http://search.cpan.org/search?dist=Mirror
http://sunsite.doc.ic.ac.uk/packages/mirror/

www.google.com would have answered that question.

Martien
-- 
Martien Verbruggen              | 
Interactive Media Division      | +++ Out of Cheese Error +++ Reinstall
Commercial Dynamics Pty. Ltd.   | Universe and Reboot +++
NSW, Australia                  | 


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

Date: Mon, 20 Nov 2000 16:32:10 -0800
From: george <ghrose@unm.edu>
Subject: file names in a new directory
Message-Id: <201120001632108960%ghrose@unm.edu>

Dear Perlers,

i am having trouble saving/naming files in a different directory than
where they came from.



open (INx, "cookie/$namelist[$b]") or die "I couldn't get at testmate";
open (OUTx, ">homecookie/www$namelist[$b]") or die "I couldn't get at
testmatennnnnew";

this combination works. it reads files from one directory and saves the
files in another directory with "www" in front of the filename.

the OUTx below ( it is missing the www) does not work:

open (OUTx, ">homecookie/$namelist[$b]") or die "I couldn't get at
testmatennnnnew";


could someone please point out my mistake.

thank you
george


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

Date: Tue, 21 Nov 2000 01:32:30 GMT
From: mgjv@tradingpost.com.au (Martien Verbruggen)
Subject: Re: file names in a new directory
Message-Id: <slrn91jk4e.r2.mgjv@verbruggen.comdyn.com.au>

On Mon, 20 Nov 2000 16:32:10 -0800,
	george <ghrose@unm.edu> wrote:
> 
> open (INx, "cookie/$namelist[$b]") or die "I couldn't get at testmate";
> open (OUTx, ">homecookie/www$namelist[$b]") or die "I couldn't get at
> testmatennnnnew";

Why don't you ask the system to tell you what's wrong?

open (INX, "cookie/$namelist[$b]") 
	or die "Couldn't open 'cookie/$namelist[$b]': $!";
open (OUTX, ">homecookie/www$namelist[$b]") 
	or die "Couldn't open '>homecookie/www$namelist[$b]': $!";

While OUTx and INx are _valid_ file handle names in Perl, generally,
we use all uppercase for them.

> this combination works. it reads files from one directory and saves the
> files in another directory with "www" in front of the filename.

But if it didn't, you wouldn't know why.

> the OUTx below ( it is missing the www) does not work:
> 
> open (OUTx, ">homecookie/$namelist[$b]") or die "I couldn't get at
> testmatennnnnew";

open (OUTX, ">homecookie/$namelist[$b]") 
	or die "Couldn't open '>homecookie/$namelist[$b]': $!";

> could someone please point out my mistake.

The code you submit is fine. Only YOU can discover what's wrong. Ask
the system to tell you. And make sure to use -w and strict, so that
Perl can warn you about typos and such.

Martien
-- 
Martien Verbruggen              | 
Interactive Media Division      | 42.6% of statistics is made up on the
Commercial Dynamics Pty. Ltd.   | spot.
NSW, Australia                  | 


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

Date: 21 Nov 2000 01:13:43 GMT
From: Jonathan.L.Ericson@jpl.nasa.gov (Jon Ericson)
Subject: Re: file names in a new directory
Message-Id: <8FF2ADBA0JonathanLEricsonjpln@137.78.50.25>

On 20 Nov 2000, ghrose@unm.edu (george) wrote:

>open (OUTx, ">homecookie/$namelist[$b]") or die "I couldn't get at
>testmatennnnnew";

You will get better error messages if you include $! and the filename.  
('testmatennnnnew'?)

Jon


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

Date: Mon, 20 Nov 2000 23:45:34 GMT
From: pape_98@my-deja.com
Subject: how would you call a subrountine using a button in a web browser?
Message-Id: <8vcd2t$8qe$1@nnrp1.deja.com>

Hi,
I've been stuck on this problem for quite a while now, and was
wondering if you could help me. I am writing a script with several
different subroutines, but the scripts generate HTML pages.

What I really want to do is to be able to call a subroutine using a
button on the page.

How do I do this??

I've tried:

$button1->Button(name=>'Add', value=>'Add A User', OnClick=>"add()");

but this doesn't work.

and,

print start_form(add());

print p(submit("Add User"));

print end_form;

calls the subroutine automatically.

Can you please help?


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


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

Date: Tue, 21 Nov 2000 00:18:27 GMT
From: dtbaker_dejanews@my-deja.com
Subject: Re: how would you call a subrountine using a button in a web browser?
Message-Id: <8vcf0d$adt$1@nnrp1.deja.com>

In article <8vcd2t$8qe$1@nnrp1.deja.com>,
  pape_98@my-deja.com wrote:
> Hi,
> I've been stuck on this problem for quite a while now, and was
> wondering if you could help me. I am writing a script with several
> different subroutines, but the scripts generate HTML pages.
>
> What I really want to do is to be able to call a subroutine using a
> button on the page.
>
------------

cgi  questions are best asked in a cgi forum like
comp.infosystems.www.authoring.cgi

however, I will attempt to give you a start on the issue...

- html buttons can call javascript, but not server cgi, you need to use
a <FORM> tag, set the values with <INPUT> tags, and POST the information
back to the webserver.

- minor symantics, but you will have the form action call a perl script,
not a subroutine.... a script may have a subroutine.

- you will need to have a local webserver to develop and test on. there
are several free ones available. check out www.xitami.com

- look for FAQs on cgi


Dan


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


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

Date: 21 Nov 2000 01:18:34 GMT
From: kevin metcalf <xzrgpnys@yvtugubhfrovm.pbz>
Subject: Re: how would you call a subrountine using a button in a web browser?
Message-Id: <3A19CDF3.68237714@yvtugubhfrovm.pbz>

pape_98@my-deja.com wrote:
> Hi,
> I've been stuck on this problem for quite a while now, and was
> wondering if you could help me. I am writing a script with several
> different subroutines, but the scripts generate HTML pages.
> What I really want to do is to be able to call a subroutine using a
> button on the page.
> How do I do this??
> I've tried:
> $button1->Button(name=>'Add', value=>'Add A User', OnClick=>"add()");
> but this doesn't work.
> and,
> print start_form(add());
> print p(submit("Add User"));
> print end_form;

I'm confused.  I always just have the  <form action="name_of_script"
method=post> tag in my HTML, and then let the submit button do all the
work.  What are you actually asking?  Is it really a perl related
question?

Kevin
--
email: xzrgpnys@yvtugubhfrovm.pbz
Huh?  http://www.flactem.com/utils/rot13.html


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

Date: Tue, 21 Nov 2000 00:18:23 -0000
From: "Chris Darlington" <c.darlington@virgin.net>
Subject: Perl and Win98
Message-Id: <bajS5.9321$3k.183990@news6-win.server.ntlworld.com>

Can anyone help me?

I have Win 98 and MS PWS and want to test my cgi scripts via the browser
window. How do i configure the PWS to use perl?

Any help welcome

Regards

Chris




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

Date: Tue, 21 Nov 2000 00:48:27 GMT
From: dtbaker_dejanews@my-deja.com
Subject: Re: Perl and Win98
Message-Id: <8vcgoq$bsh$1@nnrp1.deja.com>

In article <bajS5.9321$3k.183990@news6-win.server.ntlworld.com>,
  "Chris Darlington" <c.darlington@virgin.net> wrote:
> Can anyone help me?
>
> I have Win 98 and MS PWS and want to test my cgi scripts via the
browser
> window. How do i configure the PWS to use perl?
-------

forget MSPWS and get the freebie from www.xitami.com

D


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


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

Date: Tue, 21 Nov 2000 01:04:19 GMT
From: shawnroske@my-deja.com
Subject: Re: Perl and Win98
Message-Id: <8vchmf$chf$1@nnrp1.deja.com>

Hello,

i agree with dtbaker, however, if you really want to use pws:

http://www.discusware.com/support/resources/windows/perl-pws.html

-Shawn

In article <8vcgoq$bsh$1@nnrp1.deja.com>,
  dtbaker_dejanews@my-deja.com wrote:
> In article <bajS5.9321$3k.183990@news6-win.server.ntlworld.com>,
>   "Chris Darlington" <c.darlington@virgin.net> wrote:
> > Can anyone help me?
> >
> > I have Win 98 and MS PWS and want to test my cgi scripts via the
> browser
> > window. How do i configure the PWS to use perl?
> -------
>
> forget MSPWS and get the freebie from www.xitami.com
>
> D
>
> Sent via Deja.com http://www.deja.com/
> Before you buy.
>


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


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

Date: 21 Nov 2000 01:04:19 GMT
From: Jonathan.L.Ericson@jpl.nasa.gov (Jon Ericson)
Subject: Re: Perl and Win98
Message-Id: <8FF2AE6E5JonathanLEricsonjpln@137.78.50.25>

On 20 Nov 2000, c.darlington@virgin.net (Chris Darlington) wrote:

>I have Win 98 and MS PWS and want to test my cgi scripts via the browser
>window. How do i configure the PWS to use perl?

Dispite the fact that the string 'perl' is in this question, it isn't a 
perl question.  It's a PWS (whatever that is) question.  If the PWS 
documentation is of no help, try a group for which PWS is on-topic.  
(comp.infosystems.www.servers.ms-windows perhaps?)

Jon


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

Date: Mon, 20 Nov 2000 20:16:21 -0500
From: "David Marvil" <captmarvil@rcn.com>
Subject: Re: Perl beginner
Message-Id: <8vciav$kjs$1@bob.news.rcn.net>

Thanks to all of those that were kind enough to help. Some day I hope to be
able to do the same. This is what I ended up with.
#!/usr/bin/perl -w
open (FILE, "/user_info2")||die "File not found:$!";
 while (<FILE>) {
 chomp;
 ($name, $netbios) = split (/\s+-\s+/,$_);
 $a{$name} = $netbios;
}
print "Enter user name: ";
 chomp ($user = <STDIN>);
 $name = $user;
if (keys(%a)) {
 print "$name\t$a{$name}\n";
}
"David Marvil" <captmarvil@rcn.com> wrote in message
news:8v75dn$jba$1@bob.news.rcn.net...
> I am just starting out and am trying to write a script that will allow me
> to enter a user name at the command prompt, parse a file that has user
names
> and IP's and then match the the corresponding  user name that was entered
at
> the command prompt with an IP and print out the username and their
matching
> IP. It is also important that the match be case insensitive I also might
> mention that I am playing with this on my Linux machine but I am hoping to
> use this script at work on a WinNT  box. I appreciate any help. Thanks
>
> #! /usr/bin/perl -w
> print "Enter users name: ";
> chomp  ($user = <STDIN>);
> open (FILE, "/user_info") || die "File not found";
> while (<FILE>) {
> chomp;
> ($name, $ip) = /(\w+\s+\w+)\s+(\d+\.\d+\.\d+\.\d+)/;
> $a{$name} = $ip;
> }
> $name = $user;
> print "$user\t"$a{name};
>
>




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

Date: 21 Nov 2000 00:59:53 GMT
From: Todd McLaughlin <toddm@waltz.rahul.net>
Subject: Re: PerlScript and ASP
Message-Id: <8vchea$45f$1@samba.rahul.net>

Mark W. Schumann <catfood@apk.net> wrote:
: In article <8v9vkb$i5n$1@samba.rahul.net>,
: Todd McLaughlin  <toddm@waltz.rahul.net> wrote:
:>The folowing code lets me store a value in the application data.  How do I
:>do this if I want to store an array instead of a single value?  Say I had
:>@var1 instead of $var1. 

: $ man perldata

: One example:

: @var1 = ('one thing', 'another', 0xdeadbeef, {1,2,3});

But that doesn't work.  In the following code, the value 3 gets stored in 
$Session->{'MyVar'} instead of the contents of the array.  At least, that's
what I think is happening.

Any ideas?

Thanks!
Todd

<%@ LANGUAGE = PerlScript %>
<HEAD>
<TITLE> Application Object </TITLE>
</HEAD>

<BODY BGCOLOR=#FFFFFF>
hi
<%
my @array=("this", "is", "one");
$Session->{'MyVar'} = @array;
my @array2 = $Session->{'MyVar'};
$Response->Write("output: @array2");
%>

</BODY>
</HTML>




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

Date: Tue, 21 Nov 2000 01:00:52 GMT
From: dtbaker_dejanews@my-deja.com
Subject: Re: Question about Buttons and Subroutines
Message-Id: <8vchg0$cf8$1@nnrp1.deja.com>

In article <8vc4pq$1e0$1@nnrp1.deja.com>,
  pape_98@my-deja.com wrote:
> In article <G4883w.F50@news.muni.cz>,
>   adelton@informatics.muni.cz wrote:
> > On Fri, 17 Nov 2000 23:52:00 GMT, pape_98@my-deja.com <pape_98@my-
> deja.com> wrote:
> >
> > > This is the Sub that I want to call.
> > > sub add {

> > But note that you cannot call from browser window a subroutine in
> > server script this way.
> >
>  Then how do you do it???
----------

you would have to put the whole thing inside a <FORM> tag and instead of
a <BUTTON> you have to change to using an <INPUT type=submit
name=myaction value=add>.  you have to call a MAIN, check the value of
param('myaction') and call your sub.

D


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


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

Date: Sun, 19 Nov 2000 18:20:54 GMT
From: "John P. Linderman" <jpl@research.att.com>
Subject: Re: Random Array with Sort?
Message-Id: <3A181A06.9706AF75@research.att.com>

Quantum Mechanic wrote:

> Someone asked me the "random array" question again. I of course pointed
> them to perlfaq4, etc.
>
> However, I started thinking about the Fisher/Yates Shuffle, and wondered
> if its running time could be improved but still be unbiased (each
> permutation is equally likely). Fisher/Yates is O(n^2), while quicksort
> is O(n.log(n)).
>
> On a whim I tried:
>
>   @array = sort { -rand( 2 ) } @array;
>
> This seems to be about twice as fast as F/Y (and grows less quickly).
>
> However, this is highly biased. Also, for arrays >= 7 elements, most
> permutations never appear, regardless of how many trials are run
> (probably due to efficiencies of sort ;).
>
> Does anyone have any good ideas along these lines?

It would be a very good idea to *not* do that.
Inconsistency about the way two items compare
voids your sorting warranty.  For example,
if you return 0, you assert that two items are equal.
A sort implementor would be justified in using either
element as a sentinal, and expecting to see the same 0
return when the same two elements are compared again.
If the 0 is not forthcoming, don't blame the sort
implementor if the sort crawls past the sentinal and into
forbidden territory, with unpredictable results.  -- jpl



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

Date: Tue, 21 Nov 2000 00:21:46 +0100
From: Holger <hbhb@gmx.de>
Subject: Sort strings before numbers
Message-Id: <9dcj1tgbafus8mrp9knck32pq44f2g7pa5@4ax.com>

Hi,

I'd like to sort the keys of an hash like the following example:
3a - 45bla - 4vier - Anton - Emil - Zwei - berta - drei - 1 - 2 - 6 - 9 -
10 - 12 - 35
Thus, everything that contains a character lexically sorted followed by the
numbers numerically sorted.

My try looks like this (and seems to work):
foreach my $key (sort { (($a =~ m/^(\d+)$/) && ($b =~ m/^(\d+)$/)) ?
$a <=> $b : (($a =~ m/\D/) xor ($b =~ m/\D/)) ?
$b cmp $a : $a cmp $b } (keys %config) )
{...}

But it is a little slow, and I guess there might be a way to improve the
performance?

In <perlfunc> I found an example for sort.
    @new = map { $_->[0] }
                sort { $b->[1] <=> $a->[1]
                                ||
                       $a->[2] cmp $b->[2]
               } map { [$_, /=(\d+)/, uc($_)] } @old;
Unfortunately, I don't comprehend it entirely, especially not the final
pair of brackets. I suppose they form a list, but couldn't find a proof in
the docs. Besides, I am not really sure whether this example helps me at
all.

I hope you are still with me. It got a bit lengthy.

Thanks in advance,

	Holger


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

Date: Mon, 20 Nov 2000 18:58:39 -0500
From: tadmc@metronet.com (Tad McClellan)
Subject: Re: Sort strings before numbers
Message-Id: <slrn91jelf.frr.tadmc@magna.metronet.com>

On Tue, 21 Nov 2000 00:21:46 +0100, Holger <hbhb@gmx.de> wrote:

>I'd like to sort the keys of an hash like the following example:
>3a - 45bla - 4vier - Anton - Emil - Zwei - berta - drei - 1 - 2 - 6 - 9 -
>10 - 12 - 35
>Thus, everything that contains a character lexically sorted followed by the
>numbers numerically sorted.
>

>But it is a little slow, and I guess there might be a way to improve the
>performance?


I don't know if this is faster (use Benchmark with your real data
to determine that), but using a different approach seems easier 
to both code and to understand.

Select ones that contain alphas and sort them, then select those
that are only digits and sort them:

   foreach ( sort(grep /[a-z]/i, keys %config),
             sort {$a <=> $b} grep /^\d+$/, keys %config) {
      print "$_\n";
   }


but grep()ing twice has got to be a waste, so

   my(@alphas, @nums);
   foreach (keys %config) {
      if ( /[a-z]/i )
         { push @alphas, $_ }
      else
         { push @nums, $_ }
   }

   foreach ( sort(@alphas), sort {$a <=> $b} @nums ) {
      print "$_\n";
   }


>In <perlfunc> I found an example for sort.
>    @new = map { $_->[0] }
>                sort { $b->[1] <=> $a->[1]
>                                ||
>                       $a->[2] cmp $b->[2]
>               } map { [$_, /=(\d+)/, uc($_)] } @old;
>Unfortunately, I don't comprehend it entirely, especially not the final
>pair of brackets. I suppose they form a list, but couldn't find a proof in
>the docs. 


I dunno what "brackets" you mean.

The last curly brackets are just a code block.

The last square brackets return a reference to an anonymous array.


>Besides, I am not really sure whether this example helps me at
>all.


I got the ST below to work, but it generates warnings:

   my @sorted = map  { $_->[0] }
                sort { $a->[2] <=> $b->[2] or $a->[1] cmp $b->[1] }
                map  { [ $_, /[a-z]/i ? ($_,'') : ('', $_) ] } keys %config;


I doubt that the ST is a win for what you need to do anyway, just
split up the list of keys as above.


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


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

Date: Mon, 20 Nov 2000 17:29:44 -0600
From: "Neil Trenholm" <neil@alaweb.com>
Subject: Re: starting a perl script as an NT service
Message-Id: <t1jcrrs8tpkq1b@corp.supernews.com>

Many thanks !

"Honza Pazdziora" <adelton@fi.muni.cz> wrote in message
news:G4C38F.LKu@news.muni.cz...
> On Mon, 20 Nov 2000 09:10:10 -0600, Neil Trenholm <neil@alaweb.com> wrote:
> >
> > If this is to the wrong group - please redirect me - I have looked for
an NT
> > group - and may have missed it/them.
>
> Perhaps it's not possible then.
>
> > I have looked through all of the perl docs and CPAN and the perl.org
> > website - to no avail.
>
> Expected.
>
> > I would like to start a perl script as a Windows NT service. If anyone
has
> > any suggestions or ideas I would be very grateful.
>
> There's thing called AutoExNT, distributed in some service pack.
>
> Yours,
>
> --
> ------------------------------------------------------------------------
>  Honza Pazdziora | adelton@fi.muni.cz | http://www.fi.muni.cz/~adelton/
>    .project: Perl, DBI, Oracle, MySQL, auth. WWW servers, MTB, Spain.
> Petition for a Software Patent Free Europe http://petition.eurolinux.org
> ------------------------------------------------------------------------




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

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


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