[10087] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 3680 Volume: 8

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Thu Sep 10 13:07:48 1998

Date: Thu, 10 Sep 98 10:00:18 -0700
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)

Perl-Users Digest           Thu, 10 Sep 1998     Volume: 8 Number: 3680

Today's topics:
    Re: eof check on output stream <Doug_Azzarito@dell.com>
    Re: eof check on output stream <Doug_Azzarito@dell.com>
    Re: History of Perl - round 1 <elaine@cts.wustl.edu>
        Looping and grep problem <non-spammers_asa.c.martin@boeing.com>
    Re: Objects & type checking <tchrist@mox.perl.com>
    Re: Objects & type checking <eashton@bbnplanet.com>
        Open a file named "blank" (Andreas Karrer)
    Re: Open a file named "blank" <tchrist@mox.perl.com>
        Perl "mkdir" function <darren.hudson@pemail.net>
    Re: Perl & Java - differences and uses (Sean McAfee)
    Re: Perl & Java - differences and uses <borg@imaginary.com>
    Re: Perl & Java - differences and uses (David Cantrell)
    Re: Perl & Java - differences and uses (Clinton Pierce)
        Perl on the AS/400 tballen@copart.com
    Re: Perl Search Engine <jpa@formalsys.ca>
    Re: Perl-Cgi-htaccess is this as simple as I think it i <jeff@vpservices.com>
    Re: Perl-Cgi-htaccess is this as simple as I think it i <dan@fearsome.net>
    Re: Perl/Html - mixing text and graphics dave@mag-sol.com
    Re: Perl/Html - mixing text and graphics <antti.boman***NOSP@M***helsinki.fi>
    Re: QUESTIONS (was: Perl Programmer Needed) (David A. Black)
    Re: Realtime Parsing Syslog for ftp logins <poc@quay.ie>
    Re: replacing text in a string (Kevin Reid)
    Re: Saving an Array or Hash into a $Session Variable in (Kevin Reid)
        Special: Digest Administrivia (Last modified: 12 Mar 98 (Perl-Users-Digest Admin)

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

Date: Thu, 10 Sep 1998 11:46:51 -0500
From: "Doug Azzarito" <Doug_Azzarito@dell.com>
Subject: Re: eof check on output stream
Message-Id: <6t8vm6$sna$1@galaxy.us.dell.com>


Jonathan Feinberg wrote in message ...
>It doesn't make any sense to ask whether a write-only filehandle is at
>end-of-file.  eof() asks "is there anything left to read from a given
>filehandle?".  What are you trying to do?

It's a trick (bad habit) I picked up years ago.  Doing an eof check on an
output stream to find out if the stream is open, or if it is open but empty.

--
Doug Azzarito





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

Date: Thu, 10 Sep 1998 11:52:52 -0500
From: "Doug Azzarito" <Doug_Azzarito@dell.com>
Subject: Re: eof check on output stream
Message-Id: <6t901e$t68$1@galaxy.us.dell.com>


Koos Pol wrote in message <35F79A33.1681@nl.compuware.com>...
>Doug Azzarito (aka "Mr. HPFS") wrote:

I hate people with good memories! :)

>Seems to work ok on 5_004_04 (Solaris)
>Isn't there a later Perl port for the MS series? 5.003 is considered
>old.

Yep. I installed ActivePerl build 502, which says it is 5_005_02, and the
problem went away.  Now I have to convince my users to upgrade!

Thanks,
Doug Azzarito





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

Date: Thu, 10 Sep 1998 11:04:32 -0500
From: elaine ashton <elaine@cts.wustl.edu>
To: John Porter <jdporter@min.net>
Subject: Re: History of Perl - round 1
Message-Id: <Pine.SOL.3.96.980910105919.25583B-100000@helen.cts.wustl.edu>

> You're deluding yourself if you think you're avoiding capitals for any
> reason other than "style".  Because I haven't seen any scarcity of 
> :"<>?~!@#$%^&*()_+{}| characters in your writing (all of which, you
> know, require the use of the Shift key -- at least on most std kbds.)

Please, please, whatever puts the deus machina into your day make this
thread end. I wasn't deluded, I was all warm and fuzzy with miles davis
and a few newcastles. I remap my keys.

e.



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

Date: Thu, 10 Sep 1998 16:14:22 GMT
From: "Asa C. Martin" <non-spammers_asa.c.martin@boeing.com>
Subject: Looping and grep problem
Message-Id: <35F7FADD.60C28BE7@boeing.com>

Hope this isn't too long. I have a large postscript file that contains
both a subject and a number that I am trying to parse out. They are
contained several times in the file, and I just want them once. They
start by SUBJECT and Number. I am parsing the number fine, but the
subject is giving me problems. Here's the postscript:

(SUBJECT\:) s    -2.400 v 
newpath 
grestore 
initclip
60.96 784.56 mt
newpath 
60.96 784.56 mt
550.08 784.56 lt
550.08 608.88 lt
f4 
(NEW) s 2.78 h 
(LOADBOARD) s 2.78 h 
(FOR) s 2.78 h 
(THE) s 2.78 h 
(PROCESSOR) s 2.78 h 
(PRINTED) s 2.78 h 
(CIRCUIT) s 2.78 h 
(ASSEMBLY) s 2.78 h 
(IN) s 2.78 h 
(THE) s    -2.400 v 
   -8.400 v 
  125.280 x 
(RADIO) s 2.78 h 
(COMMUICATION) s 2.78 h 
(PANEL) s    -2.400 v 
newpath 

I want just the words in parentheses, from the first f4 (or sometimes,
f9, f5 etc.) after SUBJECT until the newpath after it. I can only get my
code to work if I use f4 in the grep; f\d does not work! It is driving
me crazy. I also know there must be a more efficient way to code the
routine. Please help!

Here's the code:

open(PS,"$file") || die "Could not open $file: $!\n";

while ($line = <PS>) {
# Looking for SUBJECT
   if ((grep /SUBJECT/, $line) && !($subjFound)) {
      $subjFound = 1; # set the flag to true
      until (grep /f\d/, $junk) {
         $junk = <PS>;
      }
      until (grep /newpath/, $subject_search) {
         $subject_search = <PS>;
         chomp($subject_search);
         $subject .= $subject_search; 
      }
    }
# Looking for Number  
   if ((grep /Number/, $line) && !($numFound)) {
      $numFound = 1;
      until (grep /f\d/, $junk) {
         $junk = <PS>;
      }
      $number = <PS>;
      chomp($number);
   }
}

close(PS);

Thanks,

Asa Martin


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

Date: 10 Sep 1998 16:28:55 GMT
From: Tom Christiansen <tchrist@mox.perl.com>
Subject: Re: Objects & type checking
Message-Id: <6t8uo7$18q$1@csnews.cs.colorado.edu>

 [courtesy cc of this posting sent to cited author via email]

In comp.lang.perl.misc, Mark Lehrer <mark@satch.markl.com> writes:
:Hello.  I am new to using perl objects (i've read the simple docs
:on cpan about a dozen times each and implemented a few classes).

You might also look at the online examples of chapters 11-13 in PCB.

:My question: how can I best implement type checking?  

Don't do that.

:In particular, I
:am used C++ and having the same function name with several different
:sets of arguments.

That's your problem: you're thinking in C++.  Don't do that.  Perl's
treatment of OO is perfectly sensible--if you think in Perl.  For every
problem that you can't solve by writing Perl exactly as though it were
Java or C++, there is a native Perl solution that works perfectly well.

:In order to do this in Perl, do I have to do something really painful
:like going through the @ISA array for each argument?  Yuck.

What would @ISA have to do with arguments?  What are you really
asking here?  Are you asking for advice on writing variadic functions?
Or dealing with overridden methods using SUPER?  Or using the isa()
method from UNIVERSAL?

--tom
-- 
Emacs is a fine programming language, but I still prefer perl. -me


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

Date: Thu, 10 Sep 1998 16:47:23 GMT
From: Elaine -HappyFunBall- Ashton <eashton@bbnplanet.com>
Subject: Re: Objects & type checking
Message-Id: <35F8003E.A9859B38@bbnplanet.com>

> Hello.  I am new to using perl objects (i've read the simple docs
> on cpan about a dozen times each and implemented a few classes).

try 'perldoc perltoot'. tchrist's oop tutorial. well done and easy to
read and understand. 
> 
> My question: how can I best implement type checking?  In particular, I
> am used C++ and having the same function name with several different
> sets of arguments.

hrm. C++ is not Perl. Bad Thinkage.

> In order to do this in Perl, do I have to do something really painful
> like going through the @ISA array for each argument?  Yuck.

Why have an object without a method? Read perltoot. You'll be happy you
did.

e.


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

Date: 10 Sep 1998 18:27:34 +0100
From: karrer@iis.ee.ethz.ch (Andreas Karrer)
Subject: Open a file named "blank"
Message-Id: <slrn6vfvfl.86t.karrer@kuru.ee.ethz.ch>


When opening a file, Perl (I checked Perl 3.044 thru 5.005) seems to
strip leading and trailing blanks (whitespace?) off the filename:

  % echo foo > " "
  % perl -e 'open F, " " or die "$!\n"; print <F>'
  No such file or directory

It seems to work when the -- relative -- filename is preceeded with
a ./ and a null character is appended:

  % perl -e 'open F, "./ \0" or die "$!\n"; print <F>'
  foo

Now filenames with leading/trailing spaces may be a bad idea in the
first place, but if one were to write a "tar" type program, one would
certainly want Perl to be able to open any file.

Using IO::File works well:

  % perl -e 'use IO::File; $h = new IO::File " ", "r"; print <$h>'
  foo

 - Andi


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

Date: 10 Sep 1998 16:35:22 GMT
From: Tom Christiansen <tchrist@mox.perl.com>
Subject: Re: Open a file named "blank"
Message-Id: <6t8v4a$18q$2@csnews.cs.colorado.edu>

 [courtesy cc of this posting sent to cited author via email]

In comp.lang.perl.misc, karrer@iis.ee.ethz.ch (Andreas Karrer) writes:
:It seems to work when the -- relative -- filename is preceeded with
:a ./ and a null character is appended:
:
:  % perl -e 'open F, "./ \0" or die "$!\n"; print <F>'
:  foo

As it is documented.

:
:Now filenames with leading/trailing spaces may be a bad idea in the
:first place, but if one were to write a "tar" type program, one would
:certainly want Perl to be able to open any file.
:
:Using IO::File works well:
:
:  % perl -e 'use IO::File; $h = new IO::File " ", "r"; print <$h>'
:  foo

Not really.  IO::File doesn't understand the beauty of magic open.
It screws things up so you can't pass in "-", for example.

Here's something from the current perlfaq5:

   How can I open a file with a leading "">"" or trailing blanks?

       Normally perl ignores trailing blanks in filenames, and interprets
       certain leading characters (or a trailing "|") to mean something
       special.  To avoid this, you might want to use a routine like this.  It
       makes incomplete pathnames into explicit relative ones, and tacks a

       trailing null byte on the name to make perl leave it alone:

           sub safe_filename {
               local $_  = shift;
               return m#^/#
                       ? "$_\0"
                       : "./$_\0";
           }

           $fn = safe_filename("<<<something really wicked   ");
           open(FH, "> $fn") or "couldn't open $fn: $!";

       You could also use the sysopen() function (see the sysopen entry in the
       perlfunc manpage).

   How come when I open a file read-write it wipes it out?

       Because you're using something like this, which truncates the file and
       then gives you read-write access:

           open(FH, "+> /path/name");          # WRONG (almost always)

       Whoops.  You should instead use this, which will fail if the file
       doesn't exist.  Using ">" always clobbers or creates.  Using "<" never
       does either.  The "+" doesn't change this.

       Here are examples of many kinds of file opens.  Those using sysopen()
       all assume

	   use Fcntl;

       To open file for reading:

	   open(FH, "< $path")                                 || die $!;
	   sysopen(FH, $path, O_RDONLY)                        || die $!;

       To open file for writing, create new file if needed or else truncate
       old file:

	   open(FH, "> $path") || die $!;
	   sysopen(FH, $path, O_WRONLY|O_TRUNC|O_CREAT)        || die $!;
	   sysopen(FH, $path, O_WRONLY|O_TRUNC|O_CREAT, 0666)  || die $!;

       To open file for writing, create new file, file must not exist:

	   sysopen(FH, $path, O_WRONLY|O_EXCL|O_CREAT)         || die $!;
	   sysopen(FH, $path, O_WRONLY|O_EXCL|O_CREAT, 0666)   || die $!;

       To open file for appending, create if necessary:

	   open(FH, ">> $path") || die $!;
	   sysopen(FH, $path, O_WRONLY|O_APPEND|O_CREAT)       || die $!;
	   sysopen(FH, $path, O_WRONLY|O_APPEND|O_CREAT, 0666) || die $!;

       To open file for appending, file must exist:

	   sysopen(FH, $path, O_WRONLY|O_APPEND)               || die $!;

       To open file for update, file must exist:

	   open(FH, "+< $path")                                || die $!;
	   sysopen(FH, $path, O_RDWR)                          || die $!;

       To open file for update, create file if necessary:

	   sysopen(FH, $path, O_RDWR|O_CREAT)                  || die $!;
	   sysopen(FH, $path, O_RDWR|O_CREAT, 0666)            || die $!;

       To open file for update, file must not exist:

	   sysopen(FH, $path, O_RDWR|O_EXCL|O_CREAT)           || die $!;
	   sysopen(FH, $path, O_RDWR|O_EXCL|O_CREAT, 0666)     || die $!;

       To open a file without blocking, creating if necessary:

	   sysopen(FH, "/tmp/somefile", O_WRONLY|O_NDELAY|O_CREAT)
		   or die "can't open /tmp/somefile: $!":

       Be warned that neither creation nor deletion of files is guaranteed to
       be an atomic operation over NFS.  That is, two processes might both
       successful create or unlink the same file!  Therefore O_EXCL isn't so
       exclusive as you might wish.

Perl's open is magical.  Remember that.  Perl goes to some bother to allow
magic filenames, like "-", ">>foo", ">&STDERR", and "cmd|grep -v stuff|".
The leading and trailing blank is just part of this.  It's beautiful 
once you get used to it.

--tom
-- 
 "... the whole documentation is not unreasonably transportable in a
 student's briefcase." - John Lions describing UNIX 6th Edition
 "This has since been fixed in recent versions." - Kernighan & Pike


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

Date: Thu, 10 Sep 1998 17:23:58 +0100
From: "Pemail" <darren.hudson@pemail.net>
Subject: Perl "mkdir" function
Message-Id: <6t8ufq$3a2$1@newsreader1.core.theplanet.net>

Could anyone supply any examples (or url's that provide the source code) of
perl code that includes the function "mkdir". The reference perl books are
rather skeletal!

Thanks

Darren




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

Date: Thu, 10 Sep 1998 15:57:46 GMT
From: mcafee@waits.facilities.med.umich.edu (Sean McAfee)
Subject: Re: Perl & Java - differences and uses
Message-Id: <_FSJ1.2011$F7.8517231@news.itd.umich.edu>

In article <pFRJ1.634$E9.2309187@ptah.visi.com>,
George Reese  <borg@imaginary.com> wrote:
>In comp.lang.java.programmer John Porter <jdporter@min.net> wrote:
>: George Reese wrote:
>:> Anything that can be done in Perl can by done in Python more easily.

>: That's not "backing it up", that's another dangling allegation.
>: It sounds an awful lot like a religious assertion, which I would
>: not have expected from you, based on statements you have made
>: elsewhere in this thread.

>Nonsense.  It is actually a really easily testable hypothesis.  My
>claim is so sweeping, all you need to do is come up with a single
>situation in which Perl accomplishes a task easier.

Trivially accomplished.  Convert a hex number to decimal:

perl -e 'print hex shift' (hexnum)

python -c 'import sys; import string; print string.atoi(sys.argv[1], 16)' \
	(hexnum)

Perl is shorter AND more readable in this instance.  I've taken up studying
Python recently, just to have another language in my repertoire, but it's
hard to get enthusiastic about it when for every Python script I see, I can
envision a shorter Perl script to do the same thing.

-- 
Sean McAfee | GS d->-- s+++: a26 C++ US+++$ P+++ L++ E- W+ N++ |
            | K w--- O? M V-- PS+ PE Y+ PGP?>++ t+() 5++ X+ R+ | mcafee@
            | tv+ b++ DI++ D+ G e++>++++ h- r y+>++**          | umich.edu


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

Date: Thu, 10 Sep 1998 16:35:21 GMT
From: George Reese <borg@imaginary.com>
Subject: Re: Perl & Java - differences and uses
Message-Id: <ddTJ1.673$E9.2366596@ptah.visi.com>

In comp.lang.java.programmer Sean McAfee <mcafee@waits.facilities.med.umich.edu> wrote:
: In article <pFRJ1.634$E9.2309187@ptah.visi.com>,
: George Reese  <borg@imaginary.com> wrote:
:>In comp.lang.java.programmer John Porter <jdporter@min.net> wrote:
:>: George Reese wrote:
:>:> Anything that can be done in Perl can by done in Python more easily.

:>: That's not "backing it up", that's another dangling allegation.
:>: It sounds an awful lot like a religious assertion, which I would
:>: not have expected from you, based on statements you have made
:>: elsewhere in this thread.

:>Nonsense.  It is actually a really easily testable hypothesis.  My
:>claim is so sweeping, all you need to do is come up with a single
:>situation in which Perl accomplishes a task easier.

: Trivially accomplished.  Convert a hex number to decimal:

: perl -e 'print hex shift' (hexnum)

: python -c 'import sys; import string; print string.atoi(sys.argv[1], 16)' \
: 	(hexnum)

: Perl is shorter AND more readable in this instance.  I've taken up studying
: Python recently, just to have another language in my repertoire, but it's
: hard to get enthusiastic about it when for every Python script I see, I can
: envision a shorter Perl script to do the same thing.

Perl can do things in fewer keystrokes than probably any other
language on Earth.  That is exactly its problem.  People actually use
that feature!  Now, while both of the above are about as readable as
doign the task in question can get, in most cases Perl shortcuts are
just an inch away from line noise.

-- 
George Reese (borg@imaginary.com)       http://www.imaginary.com/~borg
PGP Key: http://www.imaginary.com/servlet/Finger?user=borg&verbose=yes
   "Keep Ted Turner and his goddamned Crayolas away from my movie."
			    -Orson Welles


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

Date: Thu, 10 Sep 1998 16:50:37 GMT
From: NukeEmUp@ThePentagon.com (David Cantrell)
Subject: Re: Perl & Java - differences and uses
Message-Id: <35f802b6.85588389@thunder>

On Thu, 10 Sep 1998 16:35:21 GMT,
  George Reese <borg@imaginary.com> enlightened us thusly:

>In comp.lang.java.programmer Sean McAfee <mcafee@waits.facilities.med.umich.edu> wrote:
>: In article <pFRJ1.634$E9.2309187@ptah.visi.com>,
>: George Reese  <borg@imaginary.com> wrote:
>:>In comp.lang.java.programmer John Porter <jdporter@min.net> wrote:
>:>: George Reese wrote:
>:>:> Anything that can be done in Perl can by done in Python more easily.
>
>:>My claim is so sweeping, all you need to do is come up with a single
>:>situation in which Perl accomplishes a task easier.
>
>: Trivially accomplished.
>:
>: [snip]
>
>Perl can do things in fewer keystrokes than probably any other
>language on Earth.  That is exactly its problem.  People actually use
>that feature!  Now, while both of the above are about as readable as
>doign the task in question can get, in most cases Perl shortcuts are
>just an inch away from line noise.

However, your assertion has been proven wrong.  And _why_ is being
concise a problem?  If you actually look at production perl code, it
doesn't appear anything like Obfuscated Perl Contest winners.

-- 
David Cantrell, part-time NT/java/SQL techie
                full-time chef/musician/homebrewer
                http://www.ThePentagon.com/NukeEmUp


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

Date: 10 Sep 1998 16:48:56 GMT
From: cpierce1@cp500.fsic.ford.com (Clinton Pierce)
Subject: Re: Perl & Java - differences and uses
Message-Id: <6t8vto$cu01@eccws1.dearborn.ford.com>

[attributions omitted intentionally]

>>Perl has no real use.  If you have to do scripting or text processing,
>>use Python.  Otherwise, use Java.
>
>Care to back that up?

Caught another one.  Fishing's good this time of year.

Ya know, in 10 years of reading USENET, it always amazed me that people
can get suckered into arguments like this.  (P.T. Barnum was right.)
How do people like this get through primary school?

	"My mom's prettier than your mom."
	"My dad's got a better car than your dad."
	"I've got more Nintendo games than you do."
	"But Nintendo is old.  Playstations are cool."
	"My sister's a bigger troll than yours."
	"Nike's aren't cool this year.  Adiddas is."
	"My school's better than yours."
	"You still like WWF? The WWF sucks, and the NWO is cool."
	"Star Trek is for babies, Babylon 5 is the best."
	"My language does better text processing than yours."

	"Does not!"  "Does so!"  "Does not!"  "Does so!"  "You suck!"

Some kid on the playground has to antagonize, and some other kid has
to stick up for something that otherwise he really wouldn't give a 
shit about.  USENET has to be the biggest sandlot in the world.


Do you really care what the other guy thinks?   I don't, and neither
should you.  I'll be over playing on the swingset if you need me...



ObPerl:
How does one get the debugger to one-step over a instruction, and
print a value _at_the_same_time_, so it can be repeated?
-- 
+------------------------------------------------------------------------+
|  Clinton A. Pierce    |   "If you rush a Miracle Man,   | http://www.  |
|  cpierce1@ford.com    |     you get rotten miracles"    | dcicorp.com/ |
| fubar@ameritech.net   |--Miracle Max, The Princess Bride| ~clintp      |
+------------------------------------------------------------------------+
GCSd-s+:+a-C++UALIS++++P+++L++E---t++X+b+++DI++++G++e+>++h----r+++y+++>y*



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

Date: Thu, 10 Sep 1998 09:45:46 -0700
From: tballen@copart.com
Subject: Perl on the AS/400
Message-Id: <35F8023A.1F168289@copart.com>

I have installed Perl on my AS/400 but have not yet been able to
successfully call a Perl script.
I am trying to run a simple script like "Hello world" but I do not see
anything.  The Net.Data macro seems to process the call to the Perl
interpreter without any problems but I do not see any results.  The only
line in the Perl script is
 
print "<BR>Hello World<BR>";

Any examples of Net.Data macros, simple Perl scripts and/or CL programs
would be extremely helpful.  Apart from that, any info. on Perl on the
AS/400 would be very much appreciated.

Thanks,

Todd
-- 
tballen@copart.com


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

Date: Thu, 10 Sep 1998 13:25:33 -0300
From: John-Paul Arp <jpa@formalsys.ca>
Subject: Re: Perl Search Engine
Message-Id: <35F7FD7D.7FA6BDE0@formalsys.ca>

Thanks for all the help. Glimpse is proving itself to be the solution I
was looking for. Also I dreamed up my own method.

Just in case you interested here is the basic idea of the method.
What is required is a Trinary tree similar to those found in Word
Processors.

Each node would contain a:
  -word
  -references to the three children
  -array of strings (Which will be an array of file names.)

The index would be created by sequentially going through every word of
every file and placing that word in the tree in a order identical to that
found in a word processor's spell checking dictionary. Also placed in the
node would be the Filename that the node was found in. This filename
would be placed in the array of strings. If the same word is found again
in a different file, you would add the filename of the different File to
the Filename array.

Now to run a search, all that the program will have to do is look for the
word in the tree, and then get the filenames from the file list.

Of course it gets more complicated than this, but this is the general
idea. If glimpse proves to be inadequate this is the tout I will follow.

John-Paul




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

Date: 10 Sep 1998 15:37:28 GMT
From: Jeff Zucker <jeff@vpservices.com>
Subject: Re: Perl-Cgi-htaccess is this as simple as I think it is?
Message-Id: <35F7F1B5.2035566D@vpservices.com>

dmorel wrote:
> [...]
> I need to set a variable for the number of times they 
> are allowed to enter.
> [...]
> could I not have a script that would read the contents
> of a form (user-name, password, number of times allowed)

What would prevent someone from creating their own form on their own box
with the same variables (with times_allowed = 1 zillion) and submitting
it to your script?

- Jeff


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

Date: Thu, 10 Sep 1998 17:39:24 +0100
From: "Daniel Adams" <dan@fearsome.net>
Subject: Re: Perl-Cgi-htaccess is this as simple as I think it is?
Message-Id: <905445553.18925.0.nnrp-07.c2deb1c5@news.demon.co.uk>

Well, for a start it is a trivial matter to test where the form was
submitted from and, if it wasn't from your domain, to reject the input.
Hells, even *I* can do this, and I'm Mr Newbie. I do this on about half my
scripts anyway,

--

Dan Adams
dan@fearsome.net


Jeff Zucker wrote in message <35F7F1B5.2035566D@vpservices.com>...
>dmorel wrote:
>> [...]
>> I need to set a variable for the number of times they
>> are allowed to enter.
>> [...]
>> could I not have a script that would read the contents
>> of a form (user-name, password, number of times allowed)
>
>What would prevent someone from creating their own form on their own box
>with the same variables (with times_allowed = 1 zillion) and submitting
>it to your script?
>
>- Jeff




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

Date: Thu, 10 Sep 1998 15:58:45 GMT
From: dave@mag-sol.com
Subject: Re: Perl/Html - mixing text and graphics
Message-Id: <6t8svk$5bu$1@nnrp1.dejanews.com>

In article <6t7n74$3o$1@artemis.backbone.ou.edu>,
  dogboy@doghouse.com wrote:

[snip]

> All this works great until I try to add a map to $AREA.  I add the following
> and Perl generates an error.
>
>     print("<img src="/images/bitmaps/%s.gif" width=400 height=250>",$AREA);
>
> I'm lost on this one and have read the FAQ's, scanned the usegroups and looked
> just about everywhere I can think.  Anybody have a suggestion?

You might want to look at the double quotes in that statement. Having quotes
within a quoted string is generally not such a good idea. Might be better to
rewrite it something like this:

print(qq[<img src="/images/bitmaps/%s.gif" width=400 height=250>],$AREA);

On the other hand, it might be better still if you looked at using CGI.pm for
writing CGI scripts.

hth,

Dave...

--
dave@mag-sol.com
London Perl M[ou]ngers: <http://www.mag-sol.com/London.pm/>

-----== Posted via Deja News, The Leader in Internet Discussion ==-----
http://www.dejanews.com/rg_mkgrp.xp   Create Your Own Free Member Forum


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

Date: Thu, 10 Sep 1998 19:25:02 +0300
From: "Antti Boman" <antti.boman***NOSP@M***helsinki.fi>
Subject: Re: Perl/Html - mixing text and graphics
Message-Id: <6t8ufr$suc$1@hiisi.inet.fi>

>    print("<img src="/images/bitmaps/%s.gif" width=400 height=250>",$AREA);


How about...
   print "<img src="/images/bitmaps/".$AREA".gif" width=400 height=250>";
 ...?

-a




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

Date: Thu, 10 Sep 1998 12:07:06 EDT
From: dblack@saturn.superlink.net (David A. Black)
Subject: Re: QUESTIONS (was: Perl Programmer Needed)
Message-Id: <6t8tfa$p6$1@earth.superlink.net>

Hello -

linberg@literacy.upenn.edu (Steve Linberg) writes:

>In article <6t7oca$o23$1@nnrp1.dejanews.com>, ptimmins@netserv.unmc.edu
>(Patrick Timmins) wrote:

>> For the record (although I secretly believe Craig is just trying to
>> beat me at my own game), I set out to cover as much ground as I could
>> with my original posting:

>I am so gullible, it makes me so mad...  :)

>I was really going to let that one slide, but my God, if you didn't
>realize it was a joke, it did absolutely EVERYTHING wrong.  I actually
>closed the message, thinking "other people will take care of this one,"
>and then went back to it saying "no, dammit, we can't just let this happen
>around here."

>Ah well, egg on face.


I don't know.  It really was incredibly well-written.  In case it makes
any of you who responded to it feel better, I was on the fence about it.
(Not that that means anything - just another, possibly comforting
statistic.)

Had it been a new thread, I probably would have been taken in.

David Black
dblack@saturn.superlink.net


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

Date: Thu, 10 Sep 1998 17:46:10 +0100
From: Paraic O Ceallaigh <poc@quay.ie>
To: Elaine -HappyFunBall- Ashton <eashton@bbnplanet.com>
Subject: Re: Realtime Parsing Syslog for ftp logins
Message-Id: <35F80252.67ED1E4D@quay.ie>

Elaine -HappyFunBall- Ashton wrote:
> 
> Paraic O Ceallaigh wrote:
> 
> > I'm wondering how I could do the following simply in perl:
> > - check for a particular ftp user login
> > - copy all the wu-ftpd session syslog entries each time they log in
> > - mail them to a email address.
> > This would be done from a cron job on a Linux box whcih would run every
> > 15 mins or so and would be a kind of alert system for clients uploading
> > or downloading new releases and tracking their activity in doing so.
> > I was contemplating modifying the code in wu-ftpd to erwrite syslog
> > entries for a particular USER but my C is not up to it I reckon.

> Probably the easiest way is to do 'man ftpaccess' for wuftpd. You can
> customise your logging and from there you can parse the log, sort it,
> output it into a legible form and then mail it to yourself.

`man ftpaccess` says it allows for unique logging of classes only (ie
real anonymous etc) which is no good to me as we have a dozen or so
"real" users and I only need alerts for one. What I really need is a
realtime log parser which will take the process id of the ftp login from
syslog, follow the entries and then cut them out and mail them.


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

Date: Thu, 10 Sep 1998 12:09:29 -0400
From: kpreid@ibm.net (Kevin Reid)
Subject: Re: replacing text in a string
Message-Id: <1df4w2v.195zozxigczcN@slip166-72-108-145.ny.us.ibm.net>

Mark Lehrer <mark@satch.markl.com> wrote:

> What is the best way to substitute a few characters in the middle of
> a string?  I am using the slowest possible method:
> 
> $foo="123abc789";
> 
> $newstr=substr($foo,0,3) . "456" . substr($foo,6);
> 
> This will be used quite heavily in a new project I'm working on, so
> I would like to find a better way to replace text.
> 
> Thanks!
> Mark

I first thought of this:

    $foo = '123abc789';

    $newstr = $foo;
    substr($newstr, 0, 3) = '456';

I also considered this, but thought it would be slower:

    $foo = '123abc789';
    $newstr = $foo;
    $newstr =~ s/^.{3}/456/;

I ran this test and got suprising results:

use Benchmark;

timethese(10000, {
  his => sub {
    $foo="123abc789";
    $newstr=substr($foo,0,3) . "456" . substr($foo,6);
  },
  mine => sub {
    $foo = '123abc789';

    $newstr = $foo;
    substr($newstr, 0, 3) = '456';
  },
  re => sub {
    $foo = '123abc789';
    $newstr = $foo;
    $newstr =~ s/^.{3}/456/;
  }
});

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

Benchmark: timing 200000 iterations of his, mine, re...
       his:  4 secs ( 3.98 usr  0.00 sys =  3.98 cpu)
      mine:  4 secs ( 5.07 usr  0.00 sys =  5.07 cpu)
        re:  3 secs ( 3.62 usr  0.00 sys =  3.62 cpu)

It looks like the regular expression is the fastest.

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


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

Date: Thu, 10 Sep 1998 12:09:39 -0400
From: kpreid@ibm.net (Kevin Reid)
Subject: Re: Saving an Array or Hash into a $Session Variable in ASP?
Message-Id: <1df4v9v.1xxvecy1uq6nggN@slip166-72-108-145.ny.us.ibm.net>

Eric Pan <pan@part.net> wrote:

> I have been trying to save a reference to an array into a Session variable
> and it doesn't work?
> For example,
> 
> <% $Session->{'MyVar'} = \("abc","xyz"); %>
> 
> I get empty result when I try to access it
> 
> <% $Response->write(join(",",@{$Session->{'MyVar'}})) %>
> 
> If I have save array i.e.
> 
> <% $Session->{'MyVar'} = ("abc","xyz"); %>
> 
> I get xyz.
> 
> Anyone know what's wrong? And how do I save reference to an array in Session
> variable.

Your examples show a list, not an array.

Use this instead:

$Session->{'MyVar'} = ["abc","xyz"];

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


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

Date: 12 Jul 98 21:33:47 GMT (Last modified)
From: Perl-Request@ruby.oce.orst.edu (Perl-Users-Digest Admin) 
Subject: Special: Digest Administrivia (Last modified: 12 Mar 98)
Message-Id: <null>


Administrivia:

Special notice: in a few days, the new group comp.lang.perl.moderated
should be formed. I would rather not support two different groups, and I
know of no other plans to create a digested moderated group. This leaves
me with two options: 1) keep on with this group 2) change to the
moderated one.

If you have opinions on this, send them to
perl-users-request@ruby.oce.orst.edu. 


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.  

To submit articles to comp.lang.perl.misc (and this Digest), send your
article to perl-users@ruby.oce.orst.edu.

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.

The Meta-FAQ, an article containing information about the FAQ, is
available by requesting "send perl-users meta-faq". The real FAQ, as it
appeared last in the newsgroup, can be retrieved with the request "send
perl-users FAQ". Due to their sizes, neither the Meta-FAQ nor the FAQ
are included in the digest.

The "mini-FAQ", which is an updated version of the Meta-FAQ, is
available by requesting "send perl-users mini-faq". It appears twice
weekly in the group, but is not distributed in the digest.

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 V8 Issue 3680
**************************************

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