[12005] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 5605 Volume: 8

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Sat May 8 13:07:13 1999

Date: Sat, 8 May 99 10:00:16 -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           Sat, 8 May 1999     Volume: 8 Number: 5605

Today's topics:
    Re: **Free CGI Scripts!** <gellyfish@gellyfish.com>
    Re: Date::Manip and pwd: cannot determine current direc (Ron Feral)
    Re: Excel graph using PERL ? (Jan Dubois)
    Re: Find all files regardless of extension (Bart Lateur)
    Re: Find all files regardless of extension (Larry Rosler)
        hash slice tutorial (was Re: HASH references...) <uri@sysarch.com>
        HTML POST to Perl script problem <johnson-kl@sed.redstone.army.mil>
    Re: HTML POST to Perl script problem <rafeco@rc3.org>
    Re: https help (Miles R. Fidelman)
    Re: local vs. my (Tad McClellan)
    Re: local vs. my <uri@sysarch.com>
    Re: local vs. my <adept@globalreach.net>
    Re: Need help with hash tables (Tad McClellan)
    Re: New to perl (Tad McClellan)
        Newbie: Why doesn't this example code work ? <hbatra@NOSPAM.adelphia.net>
        Old Activestate perl (Andrew Payne)
    Re: read files in Perl (Tad McClellan)
    Re: read files in Perl <no@onehere.not>
        regular expression question <rafeco@rc3.org>
    Re: Rejecting unwanted hits <gellyfish@gellyfish.com>
        Security issues wth Perl-Win32 <bennettd@asdi.saic.com>
    Re: using $, (was Re: having problems) (Bart Lateur)
        Special: Digest Administrivia (Last modified: 12 Dec 98 (Perl-Users-Digest Admin)

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

Date: 8 May 1999 15:17:55 -0000
From: Jonathan Stowe <gellyfish@gellyfish.com>
Subject: Re: **Free CGI Scripts!**
Message-Id: <7h1kj3$34l$1@gellyfish.btinternet.com>

On Sat, 08 May 1999 07:15:03 -0700 Nate wrote:
> David Cassell wrote:
>> 
>> IlIIIIIIII wrote:
>> >
>> > get free CGI scripts at:
>> > http://tofs.cjb.net
>> 
>> One question:
>> 
>> Doesn't ANYONE know the difference between CGI and Perl?
>> 
> 
> CGI's can also be written in other languages, such as "C" or whatever
> the server you are using allows. That's why you see the first line
> showing what language type the file is for. #!/usr/local/bin/perl
> 

Kewl! does that mean this will work :

#!/usr/bin/cc

#include <stdio.h>

main()
{
  printf("Content-type: text/plain\n\n");
  printf("Hello, World");
}

;-}

More specifically :

NAME
       execve - execute program

SYNOPSIS
       #include <unistd.h>

       int  execve  (const  char  *filename, char *const argv [],
       char *const envp[]);

DESCRIPTION
       execve() executes the  program  pointed  to  by  filename.
       filename  must  be either a binary executable, or a script
       starting with a line of the form "#!  interpreter  [arg]".
       In  the latter case, the interpreter must be a valid path-
       name for an executable which is not itself a script, which
       will be invoked as interpreter [arg] filename.

/J\
-- 
Jonathan Stowe <jns@gellyfish.com>
Some of your questions answered:
<URL:http://www.btinternet.com/~gellyfish/resources/wwwfaq.htm>
Hastings: <URL:http://www.newhoo.com/Regional/UK/England/East_Sussex/Hastings>


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

Date: Sat, 08 May 1999 16:26:55 GMT
From: feral@vaxxine.com (Ron Feral)
Subject: Re: Date::Manip and pwd: cannot determine current directory!
Message-Id: <37346546.68454632@news.vaxxine.com>


Look at the Manip.pm, particularly:

#   I'd like to get rid of the call to cwd (which does `pwd`).
sub FullFilePath {
  my($file)=shift;
  $file=&ExpandTilde($file);
  return ""  if (! $file);
  my($cwd) = cwd;

There's a directory that the UID your server runs as  can't
get the location of.


On Sat, 3 Apr 1999 18:44:47 -0800, moseley@best.com (Bill Moseley)
wrote:

>I'm using Date::Manip::ParseDate to convert a string date to unix time.  
>When running as a CGI script and calling ParseDate I get the error
>
>   pwd: cannot determine current directory!
>
>written to my STDERR.



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

Date: Sat, 08 May 1999 17:30:56 +0200
From: jan.dubois@ibm.net (Jan Dubois)
Subject: Re: Excel graph using PERL ?
Message-Id: <37394f2e.35789913@news3.ibm.net>

scott@aravis.softbase.com (Scott McMahan) wrote:

>tvn007@my-dejanews.com wrote:
>> Time         speed
>
>> 0            0
>> 2            10
>> 5            18
>> 9            22
>> 12           25
>
>> I would like to have these data read in MS-Excel table and
>> automatically graph Time VS. speed.
>
>> Would someone help me on this ?
>
>Write it to a comma-delimited file, and write an Excel sub
>to read the file and plug the numbers in and graph it.
>(Hint: use the macro recorder to generate a lot of the code.)
>Then, use Automation and call this macro from Perl using
>Application.Run. You do NOT want to get into trying to use
>the Excel object model from Perl if you can help it.
>Any time I've done that the result has been disaster.

Really? I find it a little slow because of all the inter-process calls,
but otherwise things work pretty well for me. I'm attaching a (different)
sample that just sends some data to Excel and creates a chart. Adaptation
should be trivial.

-Jan

use strict;
use Win32::OLE qw(with);
use Win32::OLE::Const 'Microsoft Excel';

my $Excel = Win32::OLE->new("Excel.Application");
$Excel->{Visible} = 1;

my $Book = $Excel->Workbooks->Add;
my $Sheet = $Book->Worksheets(1);
my $Range = $Sheet->Range("A2:C7");
$Range->{Value} = 
    [['Arrived at Port', 'Parked in Staging', 'Loaded Onto Ship'],
     [807, 104, 0],
     [1218, 210, 0],
     [1635, 371, 0],
     [1784, 561, 0],
     [1884, 706, 0]];

my $Chart = $Excel->Charts->Add;
$Chart->{ChartType} = xlAreaStacked;
$Chart->SetSourceData({Source => $Range, PlotBy => xlColumns});
$Chart->{HasTitle} = 1;
$Chart->ChartTitle->{Text} = "Closure Profile Graph (Number of Pieces)";



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

Date: Sat, 08 May 1999 15:03:54 GMT
From: bart.lateur@skynet.be (Bart Lateur)
Subject: Re: Find all files regardless of extension
Message-Id: <373551e7.3001816@news.skynet.be>

Jonathan Stowe wrote:

>One usually would do something like:
>
>   @files = grep !/^\.{1,2}$/,readdir(DIR);

That's a complex regex for such a simple test.

How about 

	/[^.]/

or even

	$_ ne '.' && $_ ne '..'


Waiter! Benchmarks! (Only kidding... ;-)

	Bart.


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

Date: Sat, 8 May 1999 08:55:39 -0700
From: lr@hpl.hp.com (Larry Rosler)
Subject: Re: Find all files regardless of extension
Message-Id: <MPG.119dfe53a16e06da989a13@nntp.hpl.hp.com>

In article <373551e7.3001816@news.skynet.be> on Sat, 08 May 1999 
15:03:54 GMT, Bart Lateur <bart.lateur@skynet.be> says...
> Jonathan Stowe wrote:
> >One usually would do something like:
> >
> >   @files = grep !/^\.{1,2}$/,readdir(DIR);

      @files = grep !/^\.\.?$/,readdir(DIR);

is two characters shorter.  :-)

> That's a complex regex for such a simple test.
> 
> How about 
> 
> 	/[^.]/

What do you have against my files named '...' or '....' or ...  :-)

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


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

Date: 08 May 1999 11:21:57 -0400
From: Uri Guttman <uri@sysarch.com>
Subject: hash slice tutorial (was Re: HASH references...)
Message-Id: <x7vhe3si22.fsf_-_@home.sysarch.com>


i have been asked to repost my hash slice tutorial so here it is:

uri

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


well, it goes to show you that when you try to inject something useful
into this group, it fails. i had only 2 (TWO) respondants to my
quiz. anyway i decided t owrite up the answer and some extra tutorial
stuff on the theme. if you find this kind of stuff useful, let me know
and maybe it could be made a (semi) regular kind of post (especially
with help from other perl hackers for quiz ideas and answers).

the original code was this and i asked what good is it?

@array = qw( a b c d ) ;

@array{ @array } = ( [ @array ] ) x @array ;

there is a very useful perl idiom here which all good perl hackers
should have in their vocabulary. it is called hash slices and it has
many different uses which i will illustrate. it is a rare perl script
(which is not trivially small) that couldn't use hash slices to improve its
efficiency, clarity and elegance.

the fundamental hash slice expression is:

@hash{ @array } = ( list )

this is semantically equivilent to:

( $hash{ $array[0] }, ... $hash{ $array[$#array]  } ) = ( list )

that means you are doing an array assignment to a list of entries in the
hash. each entry is indexed by the next array value and is assigned
corresponding value in the list. the list as always can be any
combination of list values and arrays.

the hash slice can be indexed by a list instead of an array but i
haven't found it to be as useful (though it is used sometimes) so i
won't go into it here.


NEWBIE NOTE:
remember that the @ means an array context but it is the {} after the
variable name that marks it as a hash. many newbies fall for this trap.
all hashes use {} and all arrays use []. the prefix char is used ONLY to
mark context, not data type.

Q: what are the interesting ways of assigning to a hash slice?

the simplest is when you have two arrays of values and you want a hash
to convert a value from one array to another

@foo_array = qw( abc def ghi ) ;
@bar_array = qw( jkl mno pqr ) ;

@foo_to_bar{ @foo_array } = @bar_array

now you can easily convert from foo values to bar values like this:

$foo_value = 'def' ;
$bar_value = $foo_to_bar{ $foo_value } ;
$bar_value now is 'mno'

you can even convert a whole array of foo values in one statement:

@bar_values = @foo_to_bar{ @foo_values } ;

another very common hash slice idiom i use all the time is testing if a
string is in a given lsit of strings.  we actually don't care about the
values in the hash but i use 1 for clarity and to skip the need for
exists (though exists might be faster i have never benchmarked it. i
leave that as an assignment for the reader).

@foo_array = qw( abc def ghi ) ;

@is_a_foo{ @foo_array } = (1) x @foo_array ;

$input = 'def' ;

if ( $is_a_foo{ $input } ) {
	...

	or

if ( exists( $is_a_foo{ $input } ) ) {
	...

the assignment uses an interesting operator that most newbies never have
seen. it is called the repetition operator and it is just the plain
letter 'x'. it duplicates its left operand by the value of its right
operand. in a scalar context it replicates its left operand as a string
and returns that. in this case we have a list context and a left operand
of a list, so it creates a new list with N duplicates of the list. in
this case N is 3 (the scalar value of @foo_array) so we get a list of
(1, 1, 1) which is assigned to the hash slice.

a variant on the existance test is conversion from a string to an
numerical index value. we use the range operator (..) to generate the
list of integers which is assigned to the hash slice.

@foo_array = qw( abc def ghi ) ;

for 0 based use:

@foo_to_index{ @foo_array } = ( 0 .. $#foo_array ) ;

for 1 based use:

@foo_to_index{ @foo_array } = ( 1 .. @foo_array ) ;


$i_am_a_foo = 'def' ;

$foo_index = $foo_to_index{ $i_am_a_foo } ;

note that this form can also be used to test if a value is a foo as well
as converting it to an index. remember though that if you use the 0
(zero) based version, you MUST use exists since the value 0 will be
false for the simple test.

NEWBIE NOTE:
notice the selection of names for each of the hashes, %foo_to_bar,
%is_a_foo, $foo_to_index. they are very descriptive of the operation
they perform. in fact i treat them as very fast and simple
subroutines. indexing into a hash is a transformation of the input data
to the output values. thinking this way will make your perl scripts much
easier to design and write.

now let us look at the original quiz version of the hash slice idiom.

@array{ @array } = ( [ @array ] ) x @array ;

the first thing to notice is that the hash AND the array are both named
array but they are DIFFERENT variables. hashes and arrays (and scalars)
have different nam spaces. i chose the same name to make the quiz a
little trickier. other than that, the left side is just an assignment to
a hash slice, but what is being assigned?

notice that there is the 'x' operator and @array on its right as its
replication count and some list on its left and we are in a list context
(hash slices are list contexts). so we are creating a replicated list of
an anonymous array which contains the values in @array. this means the
hash %array looks like this:

%array = (
	'a' => [ 'a', 'b', 'c', 'd' ],	
	'b' => [ 'a', 'b', 'c', 'd' ],	
	'c' => [ 'a', 'b', 'c', 'd' ],	
	'd' => [ 'a', 'b', 'c', 'd' ],	
) ;

except that all the anonymous arrays are the same one (the above code
creates 4 different anonymous arrays with the same values).

what good is this structure?

well i was thinking about alias expansion when i devised this. what if
you had a set of aliases and you wanted to expand any one of them to the
full list. this data structure will do that. enter any of the single
elements and you get the entire list. by itself it isn't much but what
if you had multiple sets of aliases? you could do this:

@foo_list = qw( a b c d ) ;
@bar_list = qw( j k l m n o ) ;
@baz_list = qw( w x ) ;

@expand_aliases{ @foo_list } = ( [ @foo_list ] ) x @foo_list ;
@expand_aliases{ @bar_list } = ( [ @bar_list ] ) x @bar_list ;
@expand_aliases{ @baz_list } = ( [ @baz_list ] ) x @baz_list ;

now if you had a single token of unknown type you could get its alias
list in one step:

@aliases = @{ $expand_aliases{ $alias } } ;

NEWBIE NOTE:
the surrounding @{} is used to dereference the stored anonymous list
back into a list for assignment to @aliases.

this is only one way of using this idiom. try to think of others as an
exercise and report them back to me.

lesson is over (for now).


uri


-- 
Uri Guttman  -----------------  SYStems ARCHitecture and Software Engineering
uri@sysarch.com  ---------------------------  Perl, Internet, UNIX Consulting
Have Perl, Will Travel  -----------------------------  http://www.sysarch.com
The Best Search Engine on the Net -------------  http://www.northernlight.com


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

Date: Sat, 08 May 1999 11:37:56 -0500
From: Kent Johnson <johnson-kl@sed.redstone.army.mil>
Subject: HTML POST to Perl script problem
Message-Id: <37346863.5DA147B7@sed.redstone.army.mil>

I've inherited a website with several Perl scripts and I'm not a Perl
programmer.  One html page calls a perl script using:

<form action="http://www.mysite.com/cgi_stuff/script.pl" method=post>

and I get the following error:

METHOD NOT ALLOWED

It is accessing the script in question.  It's on a UNIX-based server.
I've played with permissions but it hasn't helped.  Any ideas from you
Perl gurus?

Thanks,

Kent Johnson
Huntsville, AL



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

Date: Sat, 08 May 1999 12:59:32 -0400
From: Rafe Colburn <rafeco@rc3.org>
Subject: Re: HTML POST to Perl script problem
Message-Id: <37346D74.29E6B9F4@rc3.org>

It sounds to me like your Web server configuration does not allow
programs in that directory to accept submissions via the POST method. 
If the Web server is Apache, you probably need to check out the
access.conf file and the relavent .htaccess files to see which methods
are allowed.

The directory also might not be set up to run CGI programs.  You may
want to look into that as well.

Kent Johnson wrote:
> 
> I've inherited a website with several Perl scripts and I'm not a Perl
> programmer.  One html page calls a perl script using:
> 
> <form action="http://www.mysite.com/cgi_stuff/script.pl" method=post>
> 
> and I get the following error:
> 
> METHOD NOT ALLOWED
> 
> It is accessing the script in question.  It's on a UNIX-based server.
> I've played with permissions but it hasn't helped.  Any ideas from you
> Perl gurus?

-- 
Rafe Colburn . . . . . . . . . . . . . . . . . rafeco@rc3.org
Outraged! Daily Edition . . . . . . . . . . .  http://rc3.org
Teach Yourself CGI in a Week . . . . . http://rc3.org/cgibook


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

Date: Sat, 8 May 1999 16:38:11 GMT
From: fidelman@world.std.com (Miles R. Fidelman)
Subject: Re: https help
Message-Id: <FBFA7n.A2H@world.std.com>

mjz01@health.state.ny.us wrote:
: I need to check a server to see that it is up and running properly.  The
: server is accessed using https:// connection where the user has to enter a
: valid user name and passwd to gain access.  I would like to write a script
: that will go to this https site, enter the valid user id and passwd and
: verify that it gained access to the server (thereby stating that the server
: is up and running)

I can't get you all the way there, but what I do is a shell script that
simply invokes the following:

lynx -dump https://site.name/test.html

It doesn't do password validation, but who needs to validate a simple test
page.


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

Date: Sat, 8 May 1999 05:49:40 -0400
From: tadmc@metronet.com (Tad McClellan)
Subject: Re: local vs. my
Message-Id: <kb11h7.6a9.ln@magna.metronet.com>

Phil Voris (pvorishatesspam@earthlink.net) wrote:
: quick n dirty:

: You almost always want to use my.  my limits scope to the sub whereas
: local replaces the global version of something for the duration of the
: scope, returning the original global value at the end of the block. 
: Makes perfect sense, right?  Use my.


   quicker 'n dirtier:

      Use local() for Perl's special variables. 

      Use my() for everything else.


   (until later, when you know when to break this rule)


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


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

Date: 08 May 1999 11:26:22 -0400
From: Uri Guttman <uri@sysarch.com>
Subject: Re: local vs. my
Message-Id: <x7so97shup.fsf@home.sysarch.com>

>>>>> "TM" == Tad McClellan <tadmc@metronet.com> writes:

  TM> Phil Voris (pvorishatesspam@earthlink.net) wrote:
  TM> : quick n dirty:

  TM> : You almost always want to use my.  my limits scope to the sub whereas
  TM> : local replaces the global version of something for the duration of the
  TM> : scope, returning the original global value at the end of the block. 
  TM> : Makes perfect sense, right?  Use my.


  TM>    quicker 'n dirtier:

  TM>       Use local() for Perl's special variables. 

and typeglobs

  TM>       Use my() for everything else.


  TM>    (until later, when you know when to break this rule)

good rule for newbies. but it doesn't cover file scoped my.

uri

-- 
Uri Guttman  -----------------  SYStems ARCHitecture and Software Engineering
uri@sysarch.com  ---------------------------  Perl, Internet, UNIX Consulting
Have Perl, Will Travel  -----------------------------  http://www.sysarch.com
The Best Search Engine on the Net -------------  http://www.northernlight.com


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

Date: Sat, 8 May 1999 10:30:28 -0500
From: "Chris Waymire" <adept@globalreach.net>
Subject: Re: local vs. my
Message-Id: <37345a0d@news.globalreach.net>

 a variable defined by my is a brand new variable that exists ONLY in the
block it is defined in and is NOT viewable by any other subroutines. Since
it only exists in its current block it can have the same name as a global
variable if it wants. A local variable on the other hand is a little
different. If you define a local variable with the same name as a global
variable, perl will store the old value of the global variable and replace
it with whatever you define as the local value. This variable is viewable by
any other subroutine just as if you had changed the global variable itself.
Difference is that when the block that the local variable is contained in
ends, the original value of the global variable is restored. Not sure if i
made any sense or not but.. never said i could teach for shit.

rmhaman@bigfoot.com wrote in message <7gvohj$3d1$1@nnrp1.deja.com>...
>I've been reading thru the FAQ on the difference between local() and my()
and
>have been getting confused.  What is the difference and in which situations
>should I use either?
>
>Thanks in advance
>Ryan Haman
>rmhaman@bigfoot.com
>
>-----------== Posted via Deja News, The Discussion Network ==----------
>http://www.dejanews.com/       Search, Read, Discuss, or Start Your Own




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

Date: Sat, 8 May 1999 05:36:44 -0400
From: tadmc@metronet.com (Tad McClellan)
Subject: Re: Need help with hash tables
Message-Id: <cj01h7.6a9.ln@magna.metronet.com>

Vincent P. Mautone (vince@oxxfordinfo.com) wrote:

: I need to enter a key that starts with a number into a hash table

: Does anyone know how I can do this.

:  txtHits => "2", txtRadius => "60", 1stTypes => "0",


   Having trouble with hashes?

   Gotta go read up on hashes then I guess.

   Perl's data types are documented in the perldata.pod man page.

   Searching for the first occurrence of "=>" there, and reading
   that area of the docs yields:

------------------------
It is often more readable to use the C<=E<gt>> operator between key/value
pairs.  The C<=E<gt>> operator is mostly just a more visually distinctive
synonym for a comma, but it also arranges for its left-hand operand to be
interpreted as a string--if it's a bareword that would be a legal identifier.
------------------------


   Note that last part.

   "1stTypes" is not a legal identifier (see "Variable names"
   at the top of perldata.pod).

   So you don't get auto-quoting of =>'s left argument.

   So quote it yourself  :-)


      txtHits => "2", txtRadius => "60", '1stTypes' => "0",


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


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

Date: Sat, 8 May 1999 05:58:02 -0400
From: tadmc@metronet.com (Tad McClellan)
Subject: Re: New to perl
Message-Id: <ar11h7.4c9.ln@magna.metronet.com>

Mace (mace@calweb.com) wrote:

: but could anyone give me a quick run down of subroutines?


   Subroutines are documented in the perlsub.pod man page
   that comes with the perl distribution.


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


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

Date: Sat, 08 May 1999 15:13:14 GMT
From: "Harjit S. Batra" <hbatra@NOSPAM.adelphia.net>
Subject: Newbie: Why doesn't this example code work ?
Message-Id: <ewYY2.1128$5g5.10970@server1.news.adelphia.net>

I'm running PWS on a Win98 box with IE5 and have installed Perl build 515. I
have set up my registry keys
([HKEY_LOCAL_MACHINE\System\CurrentControlSet\Services\W3SVC\Parameters\Scri
pt Map]) based upon various posts I've read here and elsewhere, however I
cannot explain why the following HTML code works only partially ! Under
Internet Options, Advanced I've turned on "Display a notification about
every script error". The $window->document->write works, but clicking on the
PerlScript button produces the following error: Can't call method "Text1" on
an undefined value at (eval 4) line 4.

Can someone help ?


<html>

<head>
<title>PerlScript sample: Hello, world</title>
</head>

<body>
<font size="5">
 <p>
  <script language="PerlScript">
   $window->document->write("PerlScript says: Hello, world!");
  </script>
  <br>
 </p>
 <form method="POST" name="MyForm">
  <p>
   <input type="text" size="32" name="Text1" value="Text1 says: Hello,
world!">
  </p>
  <p>
   <input type="button" name="PLSBtnHello" value="PerlScript">
   <script language="PerlScript">
    sub PLSBtnHello_onClick
    {
     $MyForm->Text1->{'value'} =  "PerlScript says: Hello, world!";
    }
    sub PLSBtnHello_onclick
    {
     PLSBtnHello_onClick
    }
   </script>
  </p>
 </form>
</font>
</body>
</html>
--
Harjit S. Batra
mailto:hbatra@adelphia.net




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

Date: 8 May 1999 16:32:37 GMT
From: nospam@merp.demon.co.uk (Andrew Payne)
Subject: Old Activestate perl
Message-Id: <slrn7j8pp5.fdh.nospam@merp.demon.co.uk>

I'm being made to port a chunk of Perl from a unix machine to
someone's NT box -- but they are stuck with running Activestate build
307 from the last ice-age.

If anyone here can remember the old 300-series, I'm having a few
problems. It was bad enough that "use fcntl qw(:flock)" doesn't work
(did this get fixed?), but I am seeing very strange behaviour in
foreach loops.

No matter how many elements there are, on the last cycle the control
variable gets set to "1". I'm having difficulty isolating the exact
triggering cause, as obviously many foreach loops are fine, but has
anyone ever seen similar phenomena?

I think I must be going mad.


Andrew.


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

Date: Sat, 8 May 1999 05:55:49 -0400
From: tadmc@metronet.com (Tad McClellan)
Subject: Re: read files in Perl
Message-Id: <5n11h7.4c9.ln@magna.metronet.com>

Roberto (roberto@mysacramento.com) wrote:

: how can I read a file from another url using Perl script?


   use LWP::Simple;


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


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

Date: Sat, 08 May 1999 08:08:05 -0700
From: Nate <no@onehere.not>
Subject: Re: read files in Perl
Message-Id: <37345355.32DF@onehere.not>

Roberto wrote:
> 
> Hi,
> how can I read a file from another url using Perl script?
> Thank you very much
> 
> 
> -------------------------------------------
>   roberto azzimonti
>   mailto:roberto@mysacramento.com
>   http://www.mysacramento.com/azzimonti
> -------------------------------------------

>From my site....

#!/usr/local/bin/perl

## get_web_test.pl

###########################################################
# Gets any web page's source and sends the HTML to the
# browser, the output could have been stored in a file
# at your site, or directed to further code that
# parses the output and makes a web page based on the
# information downloaded. This is the start of some
# really cool scripts, the possibilities are endless!
#
# For more examples and free sources, visit www.nocrash.com
###########################################################

use IO::Socket;

#print "Content-Type: text/html\n\n";
 
print "\n-BEGIN-\n";

    $host = "www.nasa.gov";  ## in this example we get
'www.nasa.gov/index.html'
    $document = "/index.html";
    $EOL = "\015\012";
    $BLANK = $EOL x 2;

        $remote = IO::Socket::INET->new( Proto     => "tcp",
                                         PeerAddr  => $host,
                                         PeerPort  => "http(80)",
                                        );
        unless ($remote) { die "cannot connect to http daemon on $host"
}
        $remote->autoflush(1);
        print $remote "GET $document HTTP/1.0" . $BLANK;

## we don't have to print here, you now have the page's source, do with
it what you want!

        while ( <$remote> ) { print }
        close $remote;

print "\n-END-\n";

***************************************************************
Computer Problems? Free on-line solutions to your problems at:
http://www.nocrash.com/      * Database of solutions, free!
Drivers, DLL's, Programs, Free CGI Scripts, Programmer's Area
***************************************************************


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

Date: Sat, 08 May 1999 12:13:46 -0400
From: Rafe Colburn <rafeco@rc3.org>
Subject: regular expression question
Message-Id: <373462BA.5CB4114C@rc3.org>

 I'm using this regular expression to parse some code (specifically to
extract variable names and types):
 
code =~ /(procedure\s+(\w+)\s*\(.*\))/gi
 
 it matches this:
 
procedure register(name in varchar2)
 
but not this:
 
procedure waitone(name in varchar2, 
                  message out varchar2, 
                  status out integer,
                  timeout in number default maxwait)
 
  The code is all in one huge string.  Do I have to tell it something
special to get it to cross line feeds?  I thought that the .* would
just do it.

-- 
Rafe Colburn . . . . . . . . . . . . . . . . . rafeco@rc3.org
Outraged! Daily Edition . . . . . . . . . . .  http://rc3.org
Teach Yourself CGI in a Week . . . . . http://rc3.org/cgibook


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

Date: 8 May 1999 15:43:09 -0000
From: Jonathan Stowe <gellyfish@gellyfish.com>
Subject: Re: Rejecting unwanted hits
Message-Id: <7h1m2d$395$1@gellyfish.btinternet.com>

On Sat, 08 May 1999 09:09:46 -0500 Ed Lake wrote:
> Jonathan Stowe wrote:
> 
>> On Fri, 07 May 1999 16:45:06 -0500 Ed Lake wrote:
>> > I'm looking for a way to reject hits on my web site that come from links
>> > on certain other web sites.  Someone told me that it can be done by
>> > inserting some PERL code into the index.cgi file.
>> >
>>
>> I'm sure that its entirely possible
>>

<snip>

>> Yes there is a FAQ but unfortunately it isnt for this group :
>>
>>   <http://www.webthing.com/tutorials/cgifaq.html>
>>
>> The group in question is :
>>
>>   comp.infosystems.www.authoring.cgi
>>
> 
> Basically, all I want to do is reject hits coming from links on two specific
> sites, while letting everyone else in the world through.
> 

Yeah but this is still basically a CGI question that should be asked in
the appropriate group - However a quick hack would be:

use CGI qw(:standard);

if (referer() =~ /www.blah.com/ )
  {
    # do whatever 
    print redirect('http://www.microsoft.com');
  }
else
  {
    # thats fine ....
  }

/J\
-- 
Jonathan Stowe <jns@gellyfish.com>
Some of your questions answered:
<URL:http://www.btinternet.com/~gellyfish/resources/wwwfaq.htm>
Hastings: <URL:http://www.newhoo.com/Regional/UK/England/East_Sussex/Hastings>


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

Date: Sat, 8 May 1999 09:00:30 -0700
From: "Darren Bennett" <bennettd@asdi.saic.com>
Subject: Security issues wth Perl-Win32
Message-Id: <87009917@NEWS.SAIC.COM>

            I'm working on scripts to do sysadmin
logging/monitoring/reporting on my NT servers.. just how bad are the
Security issues with this?? (and what can I do to tighten them up?)

                            -Darren




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

Date: Sat, 08 May 1999 15:01:40 GMT
From: bart.lateur@skynet.be (Bart Lateur)
Subject: Re: using $, (was Re: having problems)
Message-Id: <373450d1.2724115@news.skynet.be>

Larry Rosler wrote:

>> Doesn't use of '/dev/null' or equivalent change the execution speed?
>
>Intentionally.  It reduces system overhead and variance.  In this 
>newsgroup, we should be more interested in the performance of perl than 
>in the performance of the file system.

But it's cheating. People might get carried away over a benchmarked
speed difference of 10%, while in real worlds situations, i.e. using
real files, you might get completely different ratio's. At least, the
relative differences will be a lot smaller.

That reminds me of the story of that guy who was so damn proud he had
reduced the execution time of some assembly routine by a whole 10%. It
turned out that this was run only once day, and the total time it took
was around 10 microseconds.

Don't loose perspective.

	Bart.


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

Date: 12 Dec 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 Dec 98)
Message-Id: <null>


Administrivia:

Well, after 6 months, here's the answer to the quiz: what do we do about
comp.lang.perl.moderated. Answer: nothing. 

]From: Russ Allbery <rra@stanford.edu>
]Date: 21 Sep 1998 19:53:43 -0700
]Subject: comp.lang.perl.moderated available via e-mail
]
]It is possible to subscribe to comp.lang.perl.moderated as a mailing list.
]To do so, send mail to majordomo@eyrie.org with "subscribe clpm" in the
]body.  Majordomo will then send you instructions on how to confirm your
]subscription.  This is provided as a general service for those people who
]cannot receive the newsgroup for whatever reason or who just prefer to
]receive messages via e-mail.

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

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