[16417] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 3829 Volume: 9

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Fri Jul 28 03:05:23 2000

Date: Fri, 28 Jul 2000 00:05:11 -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: <964767910-v9-i3829@ruby.oce.orst.edu>
Content-Type: text

Perl-Users Digest           Fri, 28 Jul 2000     Volume: 9 Number: 3829

Today's topics:
        CGI Execution URGENT <glodalec@yahoo.com>
        Checking for a sub before calling <jasonb885@my-deja.com>
    Re: date conversions... (Andrea LN Spinelli)
    Re: Delete records in 2 weeks time trwww@my-deja.com
    Re: document set to execute? (Rafael Garcia-Suarez)
    Re: download file from another server <tony_curtis32@yahoo.com>
    Re: Help with SQL query in Perl script <atrus@atrustrivalie.eu.org>
    Re: home-grown encryption (Prasanth A. Kumar)
    Re: How to use "touch" in perl <lr@hpl.hp.com>
    Re: HTTP/1.1 404 Object Not Found ... The system cannot (David Efflandt)
    Re: Linked list etc. <jeff@yoak.com>
    Re: Linked list etc. (Pjtg0707)
    Re: newb Q, Our perl guy left!! <jeff@yoak.com>
    Re: Perl->CGI->Textarea anomaly (Keith Calvert Ivey)
        Should truncate length be 0? (BUCK NAKED1)
        Store Order Form <look@in.message.com>
    Re: Suggestion for syntax change <iltzu@sci.invalid>
    Re: what is the best way to search multiple files? <jeff@yoak.com>
    Re: Writing HTML within Perl <iltzu@sci.invalid>
        WWWBoard.PL <bnp@lknetlon.dk>
    Re: WWWBoard.PL (Bernard El-Hagin)
        Digest Administrivia (Last modified: 16 Sep 99) (Perl-Users-Digest Admin)

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

Date: Fri, 28 Jul 2000 08:30:39 +0200
From: Mouse <glodalec@yahoo.com>
Subject: CGI Execution URGENT
Message-Id: <3981288F.1594@yahoo.com>

Hi !

I have a small script:

#!/usr/local/bin/perl -w
use CGI qw/:standard/;
$sys = param('sys');
print "Content-type: text/html\n\n";
print "<HTML><BODY>\n";
if( $sys )
{
   @ARRAY=`rsh -l guest ${sys} ls -al`;
   foreach $A (@ARRAY)
   {
      print $A,"<BR>\n";
   }
}
print "</BODY></HTML>\n";

If I run it manually from the UNIX shell, I get following result.

# myscript.pl
(offline mode: enter name=value pairs on standard input)
sys=machine1
^D
Content-type: text/html

<HTML><BODY>
file1 file2 file3 file4
file5 file6 file7 file8
</BODY></HTML>
#
As you can see, "rsh" was executed properly.
But If I run the same script from Browser    
http://mymachine/cgi-bin/myscript.pl?sys=machine1,
then "rsh" is ignored (well, it is not executed).
Mode of myscript.pl is 755 which is to be ok.


Do you have any thought about why this is not working as it should be ?

Regards
Alex


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

Date: Fri, 28 Jul 2000 03:56:10 GMT
From: |Odo| <jasonb885@my-deja.com>
Subject: Checking for a sub before calling
Message-Id: <8lr08p$n7g$1@nnrp1.deja.com>

I have something similar to:

use strict;
use AutoLoader;

sub parse {
	my ($self,$func,$some_var) = @_;
	my $result = $self->$$func($some_var);
}

__DATA__

sub foo { return 'stuff'; }

__END__


As it stands, if $$func isn't the name of an existing subroutine or
autoloadable through SelfLoader, Perl exits with an undefined subroutine
error.

Is there any way to prevent this from being fatal?

Something like

eval { $result = $self->$$func($some_var) }

won't work for me because a 'feature' in Perl prevents the eval {} from
correctly seeing the current value of $some_var in Perl 5.005_02 (but
not 03).

 ... do stuff ... if ! defined &$$func;

doesn't seem to work, either.

Perhaps I should try to catch the exception in $SIG{__DIE__} or
something?

Any help's appreciated!  Thanks!


--
Sincerely,
Jason Boxman


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


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

Date: Fri, 28 Jul 2000 05:54:05 GMT
From: aspinelli@etsteam.it (Andrea LN Spinelli)
Subject: Re: date conversions...
Message-Id: <39811dc3.2026761@news.iol.it>

On Tue, 04 Jul 2000 22:11:07 +0200, Abe Timmerman
<abe@ztreet.demon.nl> wrote:

>On Fri, 30 Jun 2000 16:47:34 -0600, "Kris" <kaweed@micron.com> wrote:
>
>> hello-
>hi,
>> the format I have.  So what I need to do is convert each date into a number.
>> So, if I convert the first date in the file to a 1 (say it's 3/30/2000) then
>> I need to convert 3/31/2000 to 2, and 4/1/2000 to 3, and so on.

>You could use the 'yyyymmdd' date format. It is sortable and even
>readable:
Since the final purpose is to plot something against dates, this
would give unwanted results. For instance, on x axis of the plot
the distance between 20000228 and 20000229 would be 1 unit, while
the distance between 20000229 and 20000301 would be 72 units,
distorting the plot.

I think the way to go is

use Time::Local;

(find its documentation)

and use `timelocal' to convert from your dates to seconds from
1970-01-01.  Now you can divide by 86400 (the seconds in a day)
and subtract a convenient first date to obtain small enough numbers.
Note that this will correctly handle some subtle points, like
the days where Daylight savings time goes on or off (these
are 23-hour or 25-hour days).

HTH
   Andrea


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

Date: Fri, 28 Jul 2000 04:01:58 GMT
From: trwww@my-deja.com
Subject: Re: Delete records in 2 weeks time
Message-Id: <8lr0jk$nhi$1@nnrp1.deja.com>

In article <0146ce5a.9abac41e@usw-ex0108-061.remarq.com>,
  Taurean <jaurangNOjaSPAM@crosswinds.net.invalid> wrote:
> Thanks trwww. But how do I extract the reference number and
> then compare with time()? My record contains HTML tags and
> is absorbed into this message. It won't should up here.
> Basically, here is how it looks like (ignore the {}
> brackets):
>
> {HTML tags}Reference: 9xxxxxxxx{line break}{HTML tags}
>
> The ref no is 9 characters long and starts with a 9. Any
> ideas on how to do it?

take the loop I posted earlier and replace the part that says somthing
like "(parse record here)" and replace it with:

($records_seconds = $_) =~ s/.*Reference: (\d+).*/$1/;

I looked over your code and I have a couple suggestions I've seen some
give others... (ive been working with perl several hours a day for a
year now... but I am by no means a "perl-guru")..

1. Never manually unlock files (let close do it for you, it does it
automatically)
2. Dont make an array when you dont need one

Also... before posting go to http://www.deja.com/usenet/ and search for
your question before posting to the ng... chances are its already been
answered well over a thousand of times. Get "Learning Perl" by Randal
Schwartz. Ive read a couple "beginners guide to [SOMELANGUAGE]" but
none have ever came across so well to the reader as this one does.

Im not tryin 2 chase you away from posting, its great that your
interested in it, just letting you know of some invaluable tools
available to you for this work.

enjoy



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


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

Date: Fri, 28 Jul 2000 06:46:29 GMT
From: rgarciasuarez@free.fr (Rafael Garcia-Suarez)
Subject: Re: document set to execute?
Message-Id: <slrn8o2bbi.g1o.rgarciasuarez@rafael.kazibao.net>

pooh23@my-deja.com wrote in comp.lang.perl.misc:
>hello,
>I have a perl script on my website for a survey I created.  When i
>click the submit button on the survey,  a dialog box pops up asking me
>if I want to download the perl script.  Could my permissions be set
>incorrectly? If not, what could be the problem?

The script could be in an area where execution of scripts is not allowed.

>If so, can the
>hostsing company reset the permissions or can I if they're using a
>windows server?

Use netcraft: http://www.netcraft.com/whats/

-- 
Rafael Garcia-Suarez


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

Date: 27 Jul 2000 23:34:00 -0500
From: Tony Curtis <tony_curtis32@yahoo.com>
Subject: Re: download file from another server
Message-Id: <87d7jy27rb.fsf@limey.hpcc.uh.edu>


[ dejeopardised ]

>> On Thu, 27 Jul 2000 23:13:43 +0200,
>> Sebastian Erlhofer <Seb.Erlhofer@evc.net> said:

>> That depends which protocol you use. I'd suggest to use
>> NFS, then you could just copy the file.
>> 

> I want / have to use Tcp/IP What's NFS and where to
> get?- sorry knowing perl only for 2 weeks now :)

The reply is probably a somewhat cryptic request for more
information about what you want to do.  There are many
solutions to "transferring a file"; to get the one that
does the job you want, this group needs more info. about
the problem space.

So...what *exactly* are you trying to transfer?  An
example would help enormously.  My PSI::ESP module tells
me this could well be a "URL downloading in perl" context,
but only you can tell us for sure.

hth
t
-- 
"With $10,000, we'd be millionaires!"
                                           Homer Simpson


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

Date: Thu, 27 Jul 2000 21:23:17 -0700
From: Yann Ramin <atrus@atrustrivalie.eu.org>
Subject: Re: Help with SQL query in Perl script
Message-Id: <39810AB5.88D162A2@atrustrivalie.eu.org>

Try to see if you can run the script on the command line.  You won't be
able to "submit" it, but you should get a spew of HTML.  Is the HTML
correct as well?

Look in the Apache error_log for any clues if everything seems happy.

Yann

Michael Segulja wrote:
> 
> I am learning Perl 5, and following along with a tutorial I found on the
> Internet.  First, here's my setup... Mandrake Linux 7.1 server, Apache
> Web Server, MySql database, and Perl 5.  Basically, the tutorial walks
> through creating a simple MySql database called Clients, a MySql user I
> named webdb, and a CGI script in Perl that will create a nice looking
> form that, after entering certain criteria, will return a query from the
> database.  My question is how do I test this to find out why it doesn't
> work?  I know there are no typos, so I'm guessing it's probably some
> setup problem.  When I load the form in my web browser, I just get a
> blank screen.  I don't really know what to do to see what's happening
> behind the scenes.  As far as I can tell, I'm not even getting an
> attempted connection to the database, and I have no idea why.
> 
> I know this might sound like I'm fumbling in the dark, but it's quite a
> lot to try to digest all at once, between getting Apache working like I
> want it, Perl like I want it, and then setting up MySql.  Thank you in
> advance for any help.
> 
> Michael

-- 

--------------------------------------------------------------------
Yann Ramin			atrus@atrustrivalie.eu.org
Atrus Trivalie Productions	www.redshift.com/~yramin
Monterey High IT		www.montereyhigh.com
ICQ 				46805627
AIM				oddatrus
Marina, CA

IRM Developer                   Network Toaster Developer
SNTS Developer                  KLevel Developer

(yes, this .signature is way too big)

"All cats die.  Socrates is dead.  Therefore Socrates is a cat."
	- The Logician

		THE STORY OF CREATION

In the beginning there was data.  The data was without form and null,
and darkness was upon the face of the console; and the Spirit of IBM
was moving over the face of the market.  And DEC said, "Let there be
registers"; and there were registers.  And DEC saw that they carried;
and DEC seperated the data from the instructions.  DEC called the data
Stack, and the instructions they called Code.  And there was evening
and there was a maorning, one interrupt...
		-- Rico Tudor

William Safire's Rules for Writers:

Remembe


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

Date: Fri, 28 Jul 2000 04:15:03 GMT
From: kumar1@home.com (Prasanth A. Kumar)
Subject: Re: home-grown encryption
Message-Id: <m3ya2mlwl5.fsf@C654771-a.frmt1.sfba.home.com>

Zachary Kent <zkent@mail.com> writes:

> I have created a simple encryption routine to encrypt social security
> numbers collected on a website I have developed.  I tried and tested the
> routine many times, but apparently there is something wrong.  Every now
> and again, I get a record that does not contain all of the original
> digits.  I must be running into a rounding error.
> 
> The basic idea is to create an aplhanumeric key, convert that key to
> ascii equivalents to get an array numbers, and use the elements of that
> array to perform a series of mathematical somersaults on the SSN to
> jumble the SSN. In theory, I can then take the resulting number, run the
> series of steps backwards and end up with the original SSN.  It works...
> 99% of the time.  I have never done much more than simple math with perl
> and would appreciate any insight to the error here or any alternative.  
> 
> Thanks,
> Zach
> 
<snip>
>         # Run 6 calcualtions based on the new @asciikey array
>         # elements.
> 
>         #step 1
>         $ssn = $ssn+($asciikey[0]*$asciikey[5]);
> 
>         #step 2
>         $ssn = $ssn-$asciikey[1];
> 
>         #step 3
>         $ssn = $ssn/$asciikey[2];
> 
>         #step 4
>         $ssn = $ssn*$asciikey[3];
> 
>         #step 5
>         $ssn = $ssn/$asciikey[4];
> 
>         #step 6
>         $ssn = $ssn+2*$asciikey[5];
> 
>         return $ssn;
> }

It is probably rounding errors. Furthermore, your encryption algorithm
will simplify down to the form "=$c1 * $ssn + $2" where $c1 and $c2 are
functions of the components of the @asciikey array. Thus the
encryption could be broken with transformations of two key pairs. So
you might as well use it in the simplified form and eliminate the
complicated functions and roundoff errors because they don't help any!

-- 
Prasanth Kumar
kumar1@home.com


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

Date: Thu, 27 Jul 2000 22:28:39 -0700
From: Larry Rosler <lr@hpl.hp.com>
Subject: Re: How to use "touch" in perl
Message-Id: <MPG.13eab9e27394e23b98ac00@nntp.hpl.hp.com>

In article <8lqtiv$7fp$1@dipsy.missouri.edu>, 
mcnuttj@nin.iats.missouri.edu says...
+ >> In article <1eeg96o.10h3f3e1uhjkxsN%otto.wyss@bluewin.ch>,
+ >>     Otto Wyss <otto.wyss@bluewin.ch> wrote:
+ >> 
+ >> : I'd like to set the modification time of files to the value of a
+ >> : reference file. While in a shell I could use touch, i.e.
+ >> : 
+ >> :         touch -r foo bar

 ...

+ Suppose the file does not already exist.  Will this work?
+ 
+ open DUMMY,">>file";
+ close DUMMY;
+ 
+ ...and *then* do the utime() trick mentioned in the man pages?
+ 
+ My purpose, for instance, is to create a zero-byte file, change its
+ permissions to rw-rw-rw-, and then use it as a target for a TFTP
+ upload (tftpd insists that anonymous uploads be sent to a world-
+ writable file).
+ 
+ Right now, I'm just using the backticks.  I then check that the file
+ was actually created with:
+ 
+ stat "file";
+ if ( -e _ ) {
+ 	chmod 0666,"file";
+ } else {
+ 	print "Foo!\n";
+ 	die "\n";
+ }

  open DUMMY, '>>file' or die "Couldn't open 'file'. $!\n";
  close DUMMY;
  chmod 0666, 'file' or die "Couldn't chmod 'file'. $!\n";

But you can do it all in one swell foop using sysopen.

perldoc -f sysopen

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


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

Date: Fri, 28 Jul 2000 04:11:18 +0000 (UTC)
From: efflandt@xnet.com (David Efflandt)
Subject: Re: HTTP/1.1 404 Object Not Found ... The system cannot find the file specified.
Message-Id: <slrn8o25fl.1c3.efflandt@efflandt.xnet.com>

On Thu, 27 Jul 2000, Nils-Eric Pettersson <nils-eric@telia.com> wrote:
>I have a perl program that should connect to a server and get a page
>from it.
>
>I can connect to the server but when I try to get to page I only get a
>message that the server can't find it.
>
>
>
>Instead of the page I get this header:
>
>HTTP/1.1 404 Object Not Found
>Set-Cookie:...; 
>path=/
>Server: Microsoft-IIS/4.0 Date:
>Thu, 27 Jul 2000 05:01:46 GMT
>Content-Type: text/html
>Content-Length: 102
>The system cannot find the file specified.
>
>
>
>I think the problem is on the row telling the server to send a page:
>print SOCKET "GET $page 1.1\n\n";
>This I think because the server answers.

Yes, but that is not how you typed it below and is NOT a valid HTTP/1.1
header.

>Is there anyone who can help me:
>
>
>
>My program look like this:
>
>#!/usr/bin/perl -w
>use strict;
>use DBI;
>use Socket;
>sub open_SOCKET;
>sub hamta_sida;
>print "Content-type: text/html\n\n";
>print get_page ("http://server/path/page.end");

Lose the space after 'get_page' or you will get an error.

>sub open_SOCKET {
>   my ($server_namn, $port) = @_;
>   $port = getservbyname($port, 'tcp') if $port !~ /^[0-9]/;
>   socket SOCKET, PF_INET, SOCK_STREAM, 0 or die "socket: $!";
>   connect (SOCKET, sockaddr_in($port, inet_aton($server_namn)));
>}
>
>sub get_page {
>   my ($page) = @_;
>   my ($server, $text, $row) = "";
>   unless ($page =~ m{http://(.*?)(/.*)})
>      {die "Anropa programmet som: $0"."http://server/path/page.\n"}
>   $server = $1;
>   $page = $2;
>   if (open_SOCKET($server, "http")) {
>      select SOCKET;
>      $| = 1;
>      select STDOUT;
>      print SOCKET "GET$page 1.1\n\n";

    print SOCKET "GET $page HTTP/1.0\n\n";

Net sure what would be required for HTTP/1.1, but it would at least
require a Host: header (also needed for virtual hosts with HTTP/1.0).
Like maybe:

    print SOCKET "GET $page HTTP/1.0\nHOST: $server\n\n";


>      while ($row = <SOCKET>)

    while (defined($row = <SOCKET>)

>         {$text.=$row;}
>      close SOCKET;
>      $text;
>   }
>   else {" WRONG "}
>}
>
>
>
>/Nils-Eric Pettersson


-- 
David Efflandt  efflandt@xnet.com  http://www.de-srv.com/
http://www.autox.chicago.il.us/  http://www.berniesfloral.net/
http://hammer.prohosting.com/~cgi-wiz/  http://cgi-help.virtualave.net/



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

Date: Thu, 27 Jul 2000 22:41:50 -0800
From: "Jeff Yoak" <jeff@yoak.com>
Subject: Re: Linked list etc.
Message-Id: <8lqvfd0304p@news2.newsguy.com>


[posted and mailed]

In article <7la7up5g.fsf@macforce.sumus.dk>, Jakob Schmidt <sumus@aut.dk>
wrote:
> Pjtg0707@Netscape.net (Pjtg0707) writes:
> 
>> Is there any resources on the web where I can get to to either look at
>> some codes or get a module for setting up linked lists  and buffers?
> 
> Dunno, but generally these structures are very simple to implement in
> perl. And usually you don't want linked lists for it at all - not in
> perl.

Linked lists are discussed in Algorithms in Perl from ORA in the advanced
data structures section.  They might be desirable where you have long
lists and you might want to add and remove from the center.  Splicing in
the center of long lists can be expensive.  Examples are probably
available through the ora website somewhere.


>> I have some stock ticker data I'd like to read in, arrange them in
>> correct  temperal order in a hash table ( hash in a hash in a hash 
>> etc...). 

I don't understand this at all.  hashes aren't ordered like that.  But you
seem to know that because you say you need a linked list.  If you are only
going to be adding to the end though, linked lists are probably just overhead.

Cheers,
Jeff




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

Date: Fri, 28 Jul 2000 05:54:13 GMT
From: Pjtg0707@Netscape.net (Pjtg0707)
Subject: Re: Linked list etc.
Message-Id: <so2805pp3j129@corp.supernews.com>

On Thu, 27 Jul 2000 22:41:50 -0800, Jeff Yoak <jeff@yoak.com> wrote:
>
>Linked lists are discussed in Algorithms in Perl from ORA in the advanced
>data structures section.  They might be desirable where you have long
>lists and you might want to add and remove from the center.  Splicing in
>the center of long lists can be expensive.  Examples are probably
>available through the ora website somewhere.
>
>
>>> I have some stock ticker data I'd like to read in, arrange them in
>>> correct  temperal order in a hash table ( hash in a hash in a hash 
>>> etc...). 
>
>I don't understand this at all.  hashes aren't ordered like that.  But you
>seem to know that because you say you need a linked list.  If you are only
>going to be adding to the end though, linked lists are probably just overhead.
>
>Cheers,
>Jeff
>
>

Thanks for the info.

The stock data I have are not just the open and closing price, but highs, 
lows volumes and time stamps. So I have to put all the dat into multilayer
hashes, and in correct temperal order so they can be searched and retrieved. 
And te data don't come in sequentially. I figured I'll need linked lists for
this sort of thing, unless someone has a suggestion for a better solution.


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

Date: Thu, 27 Jul 2000 23:06:34 -0800
From: "Jeff Yoak" <jeff@yoak.com>
Subject: Re: newb Q, Our perl guy left!!
Message-Id: <8lr0tp01tmb@news1.newsguy.com>


[posted and emailed]

In article <8lq7d9$5dl$1@nnrp1.deja.com>, rbfitzpa@my-deja.com wrote:

> Greg, Did you have any friends when you were growing up? Or are you
> trying to impress the people here that you know the answer but don't
> want to share it?
> 

Christ.  I've been on about a three year break from Usenet and I've
decided to read again, maybe answer some questions and see what's going on
generally.  Greg's is one of the names I remember from when I was around
here last time.  And he was always helping people.  It is because of posts
like this that I left in the first place.  Lazy bastards who don't want to
learn or understand, but instead want free handouts.  And the apologists
who criticize the people who generally have spent years helping and
contributing to the community, but who don't want to do free consulting
for people who won't be the better for it.  Maybe usenet is pointless. 
And yes, if I learned anything, it should have been that posts like this
one I'm making now don't help.
 
Cheers,
Jeff




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

Date: Fri, 28 Jul 2000 03:28:29 GMT
From: kcivey@cpcug.org (Keith Calvert Ivey)
Subject: Re: Perl->CGI->Textarea anomaly
Message-Id: <3980fc40.16005109@news.newsguy.com>

thewolf23_2000@my-deja.com wrote:

>Why won't my Textarea "-default=>" value work when I hit my "Submit"
>button?

Because that's the way CGI.pm works.  Values are sticky, so once
you've set the value it doesn't change unless the user changes
it.  If you don't want that, then see the documentation:

# General note 2. The default values that you specify for the
# forms are only used the *first* time the script is invoked.
# If there are already values present in the query string,
# they are used, even if blank. 
#
# If you want to change the value of a field from its previous
# value, you have two choices: 
#
#   1. call the param() method to set it.
#   2. use the -override (alias -force) parameter. (This is a
#      new feature in 2.15) This forces the default value to
#      be used, regardless of the previous value of the field:
#
#          print $query->textfield(-name=>'favorite_color',
#                                  -default=>'red',
#                                  -override=>1);
(http://stein.cshl.org/WWW/CGI/)

-- 
Keith C. Ivey <kcivey@cpcug.org>
Washington, DC


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

Date: Fri, 28 Jul 2000 00:25:15 -0500 (CDT)
From: dennis100@webtv.net (BUCK NAKED1)
Subject: Should truncate length be 0?
Message-Id: <2427-3981193B-97@storefull-245.iap.bryant.webtv.net>

One more question. Since Abigail questioned using 0 byte length in the
truncate coding below, I'd like to hear other opinions about whether it
is correct or not.

truncate(COUNT, 0) or die "can't TRUNCATE data file: $!";

While I'm here, did I get the "chomp" and the "close COUNT" (as
suggested) done in the proper sequence?

Of course, feel free to point out anything else that you don't like in
the below coding. (thanks for the "here doc" tip... I went and did some
more homework on it).
I'm really trying hard to finalize the below coding. Believe me, I am
more tired of looking at it than you are. :-/ 


ENTIRE CODE: line spacing for readability only

#!/usr/local/bin/perl -w 

use strict;

use Fcntl qw/:flock :DEFAULT/;

my $counter = 'counter.dat';

sysopen(COUNT, $counter, O_RDWR|O_CREAT) 
       or die "Can't OPEN data file for                 READING and
WRITING: $!"; 

flock(COUNT, LOCK_EX) 
       or die "Cannot get an EXCLUSIVE             LOCK on data file:
$!";

my $num = <COUNT> || 0;

chomp $num;

$num++;

seek(COUNT, 0, 0) 
     or die "can't REWIND to beginning of         data file: $!";

truncate(COUNT, 0) 
     or die "can't TRUNCATE data file: $!";     
print COUNT "$num\n";

1 while $num =~ s/(.*\d)(\d\d\d)/$1,$2/; 

for($num) {s/(1[123]|[4-90]$)/$1th/      or 
s/(1$)/$1st/ or s/(2$)/$1nd/      or 
s/(3$)/$1rd/;};

close COUNT or warn $!;

print "Content-type: text/html\n\n"; 

## NOTE: fontsize is a webtvonly tag 

print <<HTML;
<head><title>Counter Page</title></head><body bgcolor='white'
fontsize='medium'>
<table bgcolor='white' width='100%' 
align='center'>
<TR>
<td width='100%' bgcolor='#003300' 
align='center'>
<font size='2' color='#99FF99'>
You are the</font>
<font size='3' color='#FF6666'>
<b>- $num</b></font>
<font size='2' color='#99FF99'>
person NOT to visit this page :-(</font></td>
</tr></table></body>
HTML
## END SCRIPT

Kind regards,
Dennis



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

Date: Thu, 27 Jul 2000 22:08:40 -0600
From: "Streamline" <look@in.message.com>
Subject: Store Order Form
Message-Id: <398108c2@news.in-tch.com>

I have a script that's essentially a store.  If after filling in the
required information the user submits the info, then it emails a
confirmation to the user and submits me another email with info.  For
security reasons I would like to strip out the credit card number from the
email sent to the user.  Without rewriting this whole script how can I
access the hash from the form and strip that one field out?  Any help
greatly appreciated.

--
Richard




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

Date: 28 Jul 2000 06:48:26 GMT
From: Ilmari Karonen <iltzu@sci.invalid>
Subject: Re: Suggestion for syntax change
Message-Id: <964765164.27110@itz.pp.sci.fi>

In article <MPG.13eb5ede556bace989695@news>, jason wrote:
>Ilmari Karonen writes ..
>>In article <MPG.13eaa2e8babbb2cb989692@news>, jason wrote:
>>>HOWEVER .. it doesn't solve the behaviour that Keith is proposing where 
>>>within list index context the negative arguments of '..' are evaluated 
>>>first (to be indices relative to the end of the list) and THEN the '..' 
>>>is evaluated to produce a forward list
>>
>>..for which I've already proposed a better (less klugy) alternative,
>>namely having a special variable contain the last index of the list
>>for the innermost surrounding [].
>
>I don't see anything kludgy about changing the evaluation order of the 
>already magic negative index .. think about it

The problem is that "evaluation order" has really nothing to do with
it.  A slice is just like an ordinary function in that it takes a list
of parameters.  It then maps these parameters to elements of the list.

For array or list slices, this mapping is done by truncating the value
of each parameter to an integer, and if the result is negative, adding
the length of the array or list to it.  Then the value is used as an
index to the array or list, and the corresponding element is returned.

Hash slices, of course, treat their parameters as strings, so none of
this discussion applies there.


>what Keith and I are talking about is simply increasing the evaluation 
>precedence of the magic negative index .. so that
>
>  (LIST)[0..-2]
>
>for a 5 element list first becomes
>
>  (LIST)[0..3]
>
>and THEN the '..' is done giving
>
>  (LIST)[0,1,2,3]

But done this way, it'd not just break some existing code using .. in
list slices, it'd actually break *any* code using negative numbers in
expressions inside [].

Are you really suggesting that, say:

  (qw/a b c d e/)[print join ':' => -2 .. 0  ?  1, 2  :  3, 4]

should be magically transformed into:

  (qw/a b c d e/)[print join ':' =>  3 .. 0  ?  1, 2  :  3, 4]

before evaluation?


>>It also involves less magic, and is therefore easier to understand.
>
>our point is that the negative index magic is ALREADY THERE .. a 
>negative index already provides an index relative to the end of the list 

But that "magic", which is really no more magical than substr(),
splice() and quite a few other functions, is all done _inside_ the
indexing code.  It does not affect the evaluation of the expression
between the [].  Your proposal would require that it did.

-- 
Ilmari Karonen - http://www.sci.fi/~iltzu/
"The screwdriver *is* the portable method."  -- Abigail
Please ignore Godzilla and its pseudonyms - do not feed the troll.



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

Date: Thu, 27 Jul 2000 23:00:19 -0800
From: "Jeff Yoak" <jeff@yoak.com>
Subject: Re: what is the best way to search multiple files?
Message-Id: <8lr0i30318b@news2.newsguy.com>

In article <8lq67a$4fe$1@nnrp1.deja.com>, dakotamitchell@my-deja.com
wrote:
> Here is my situation: I have an input file which contains some 170,000
> unique records. I also have 36 additional files (labeled filename1,
> filename2, ..., filename36) in which the records from the input file are
> contained but each record is not in each file.  I need to take the input
> file, read through it record by record, then find all of the matches in
> the 36 files for each record and output to another file.  Each line in
> the output file will contain the record from the input file followed by
> all of the values found in the other 36 files.  So if the first record
> from the input file was "1234ABCD" and that record was in 2 of the
> 36 files (files 1 and 4) with values of 11 and 22, the output file for
> that record would read:
>      1234ABCD11000022000000000000000000000000000000000000  etc
> 

Larry's solution is a good one, but personally I think I would prefer
building a single hash that contains the answer for memory efficiency. 
Something like the following pseudocode:

my %stuff
foreach my $file (1..37) {
	while (get record_id and value from filename$file){
		$stuff{record_id} ||= '00'x37;
		substr($stuff{record_id},($file-1)*2,2)=$value;
	}
}
while(get record_id from the input file){
	print $stuff{record_id};
}

Hope this helps.

Cheers,
Jeff




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

Date: 28 Jul 2000 07:02:46 GMT
From: Ilmari Karonen <iltzu@sci.invalid>
Subject: Re: Writing HTML within Perl
Message-Id: <964767296.2267@itz.pp.sci.fi>

In article <MPG.13ea60b978191df398abfc@nntp.hpl.hp.com>, Larry Rosler wrote:
>Paired delimiters () {} [] <> are better.  Then you don't get in trouble 
>unless you have an unmatched delimiter in the text, which is far less 
>likely.

 ..except when you do.  I seem to recall this one poster who had a
RecDescent grammar between {} delimiters, with matched {} pairs in the
grammar.  Only he also had a comment line in it with a lone {.

>But here-docs are better yet, of course.

Agreed.

-- 
Ilmari Karonen - http://www.sci.fi/~iltzu/
"The screwdriver *is* the portable method."  -- Abigail
Please ignore Godzilla and its pseudonyms - do not feed the troll.



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

Date: Fri, 28 Jul 2000 08:17:23 +0200
From: "Bjørn Nørgaard" <bnp@lknetlon.dk>
Subject: WWWBoard.PL
Message-Id: <39812543@194.255.58.12>

Does any of you have experience with wwwboard.pl from Matt's Script Archive?

- Can it run on an Intranet?
- Can it run on a "ordinary" NT4.0/Win2000 Server without having to install
some kind of Perl-server-support?


Bjørn




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

Date: Fri, 28 Jul 2000 07:07:22 GMT
From: bernard.el-hagin@lido-tech.net (Bernard El-Hagin)
Subject: Re: WWWBoard.PL
Message-Id: <slrn8o2c0e.61h.bernard.el-hagin@gdndev25.lido-tech>

On Fri, 28 Jul 2000 08:17:23 +0200, Bjørn Nørgaard <bnp@lknetlon.dk> wrote:
>Does any of you have experience with wwwboard.pl from Matt's Script Archive?

Oh boy, the shit's gonna hit the fan now. :-)

Bernard
--
perl -le 'open(JustAnotherPerlHacker,"")or$_="B$!e$!r$!n$!a$!r$!d$!";
print split/No such file or directory/;'


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

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


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