[18821] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 989 Volume: 10

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Fri May 25 18:06:02 2001

Date: Fri, 25 May 2001 15: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: <990828310-v10-i989@ruby.oce.orst.edu>
Content-Type: text

Perl-Users Digest           Fri, 25 May 2001     Volume: 10 Number: 989

Today's topics:
    Re: "Alan J. Flavell" wrote: <bart.lateur@skynet.be>
        archieve newsgroups me@nowhere.com
    Re: Constant -vs- Variable File Handles? <pettyr_no_spam@hotmail.com>
        getting a web page from secure URL (Prad S)
    Re: getting perl internal calculated hash value? (Mark Jason Dominus)
    Re: hash array <todd@designsouth.net>
    Re: Help a script to prompt to input and have those inp <lmoran@wtsg.com>
        How to determine a return is a hash, array, or referenc <wstsoi@hongkong.com>
    Re: How to determine a return is a hash, array, or refe <ren@tivoli.com>
    Re: How to determine a return is a hash, array, or refe (Damian James)
    Re: I don't want global variables ? <newspost@coppit.org>
    Re: I don't want global variables ? (Abigail)
    Re: I don't want global variables ? <elijah@workspot.net>
    Re: I don't want global variables ? <uri@sysarch.com>
    Re: I don't want global variables ? <joe+usenet@sunstarsys.com>
    Re: Installing Perl on Win NT/2000 Re: Match Parsing Gl <nospam@xx.com>
    Re: looking 4 NMAP style perl module <carvdawg@patriot.net>
    Re: Match Parsing Glitch <nospam@xx.com>
    Re: module for combinatorics? (partitions etc) (Mark Jason Dominus)
        Output unix data with perl.vvp <vprasad@americasm01.nt.com>
    Re: Perl CGI <buggs@geekmail.de>
    Re: Permuting days of the week <bart.lateur@skynet.be>
        Q:  RPC::PlServer, Storable <ml2316@hotmail.com>
        rfc date conversion <j2lab@my-deja.com>
        SCAN <kasi@students.uiuc.edu>
    Re: SCAN <todd@designsouth.net>
    Re: url parsing (Craig Berry)
    Re: url parsing <krahnj@acm.org>
    Re: url parsing <godzilla@stomp.stomp.tokyo>
        What modules are being used? <tpg@umich.edu>
    Re: wwwboard.pl - Taint and Use Strict <AgitatorsBand@yahoo.com>
    Re: wwwboard.pl - Taint and Use Strict <bart.lateur@skynet.be>
    Re: wwwboard.pl - Taint and Use Strict <godzilla@stomp.stomp.tokyo>
        Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)

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

Date: Fri, 25 May 2001 19:50:00 GMT
From: Bart Lateur <bart.lateur@skynet.be>
Subject: Re: "Alan J. Flavell" wrote:
Message-Id: <0rdtgtctt5i5l086s35of7d6mnl2a61qaa@4ax.com>

Chris wrote:

>BUT I am in Australia, to find a suitable ISP is almost impossible as
>most charge a commercial operation like mine for data at 18 -20c PER
>MEGABYTE 

We are in Europe.

The company I work for, rents a server in the USA. We can do whatever we
want with it.

Country borders are virtually meaningless.

-- 
	Bart.


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

Date: 25 May 2001 04:05:42 -0500
From: me@nowhere.com
Subject: archieve newsgroups
Message-Id: <165634527897443.Post@ithinknot.net>

is it ethical to copy the newsgroups from google into my database?



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

Date: Fri, 25 May 2001 19:28:35 GMT
From: "Robert" <pettyr_no_spam@hotmail.com>
Subject: Re: Constant -vs- Variable File Handles?
Message-Id: <DnyP6.290334$fs3.49792653@typhoon.tampabay.rr.com>


<nobull@mail.com> wrote in message news:u9y9rl4gbz.fsf@wcl-l.bham.ac.uk...
> > my ($FH) = "";
> > open ($FH, "< /etc/passwd");
>
> Loose the ="" bit.  You want to be using filehandle reference

Seems I am just experienced enough to be dangerous...  I have not been using
strict due to the difficulties with constant filehandle names and not
declaring them (
probably my sloppy error.)  Every example/explaination I have found in the
texts or
even the perldoc's illustrates a constant type variable name in the open().
I just
stumbled on  a need to pass a filehandle name to a sub last night and was
able to
do it but wanted to understand the ramifications a little bit better.

> autovivification[1], not a symbolic reference to the symbol with a
> null name.
>
> "use strict" would have caught this mistake for you.

My poor excuse: "" (i.e. NULL)

>
> BTW: You can combine the two statements into one:
>
> open (my $FH, '<', '/etc/passwd')
>    or die "Could not open /etc/passwd: $!";

Thanks for the tip.

>
> Since you'd put a space after the < it is clear that you wanted to
> make clear that the the < was not part of the filename.  You can do
> this more elegantly with a 3-arguent open[1].
>
> [1] New in 5.6
>

Still dragging my feet in 5.005.  Who has time to upgrade? I can't keep up
with the deprecated
stuff!

Robert




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

Date: Fri, 25 May 2001 21:14:29 GMT
From: ps@siteindia.com (Prad S)
Subject: getting a web page from secure URL
Message-Id: <3b0eca8b.600719178@news1.sfba.home.net>

Hi,

I want to get a web page and save the content from a secure URL. I am
able to successfuly save from a normal URL and one with authentication
also but not with https,

here is what I am doing :

    $url="https://www.mysite.com/cgi-admin/AdminLogin";
    $post="transaction_id=$tid";
    # Create a user agent object
    $ua = new LWP::UserAgent;
    $ua->agent("AgentName/0.1 " . $ua->agent);

    # Create a request
    $req = new HTTP::Request POST => $url;
    $req->content_type('application/x-www-form-urlencoded');
$req->protocol('HTTPS/1.1'); # ***********************
    $req->content($post);

    $req->authorization_basic( $uname, $pass);
    # Pass request to the user agent and get a response back
    my $res = $ua->request($req);

I get the response :

Error Response $VAR1 = bless( {
                 '_headers' => bless( {}, 'HTTP::Headers' ),
                 '_msg' => 'Protocol scheme \'https\' is not
supported',
                 '_rc' => 501,
                 '_content' => ''
               }, 'HTTP::Response' );

pls advise.

Thanks in Advance

Prad


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

Date: Fri, 25 May 2001 18:22:14 GMT
From: mjd@plover.com (Mark Jason Dominus)
Subject: Re: getting perl internal calculated hash value?
Message-Id: <3b0ea2c7.2047$1b9@news.op.net>

In article <3b0e7b06.1cc9$396@news.op.net>,
Mark Jason Dominus <mjd@plover.com> wrote:
>In article <9elcfq$sdm$1@mamenchi.zrz.TU-Berlin.DE>,
>Anno Siegel <anno4000@lublin.zrz.tu-berlin.de> wrote:
>>If by "hash value" you mean the hash key generated out of a string,
>>that's documented in perlguts (p. 8 in my printout).  
>
>Note that Perlguts is wrong in 5.7.0 and 5.7.1.

Sorry, my mistake---it is correct in 5.7.0, and wrong in 5.7.1.



-- 
@P=split//,".URRUU\c8R";@d=split//,"\nrekcah xinU / lreP rehtona tsuJ";sub p{
@p{"r$p","u$p"}=(P,P);pipe"r$p","u$p";++$p;($q*=2)+=$f=!fork;map{$P=$P[$f^ord
($p{$_})&6];$p{$_}=/ ^$P/ix?$P:close$_}keys%p}p;p;p;p;p;map{$p{$_}=~/^[P.]/&&
close$_}%p;wait until$?;map{/^r/&&<$_>}%p;$_=$d[$q];sleep rand(2)if/\S/;print


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

Date: Fri, 25 May 2001 21:34:11 GMT
From: "Todd Smith" <todd@designsouth.net>
Subject: Re: hash array
Message-Id: <ndAP6.70962$I5.15872424@news1.rdc1.tn.home.com>

> > >
> > >        %hash = ();
> >
> > Better, worse or same as
> >
> >          undef (%hash);
>
> That depends if you want %hash to rember how many buckets it grew to
> last time.

How do you ask a hash how big it used to be?




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

Date: Fri, 25 May 2001 16:15:36 -0400
From: Lou Moran <lmoran@wtsg.com>
Subject: Re: Help a script to prompt to input and have those input add or append certain lines in a text file
Message-Id: <b8ftgtct78ope76pssfr01aopv5q8a0oph@4ax.com>

On 23 May 2001 10:02:49 -0500, Tony Curtis <tony_curtis32@yahoo.com>
wrote wonderful things about sparkplugs:

SNIP
>
>> I would I go about writting a perl script to do that I
>> think you are a perl programmer it would not be so hard
>> to write this script.
>
>Eh? :-)
>

Translation

I would go about writing this script to do this but I am not a Perl
programmer (I am a Sys Admin) but I think this would be easy for a
Perl programmer to write this script (for me.)

>
>hth
>t

--
BSOD? In my day we didn't have 0000FF!
lmoran@wtsg.com


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

Date: Sat, 26 May 2001 04:05:38 +0800
From: "Lucas" <wstsoi@hongkong.com>
Subject: How to determine a return is a hash, array, or reference?
Message-Id: <9emd8a$l681@imsp212.netvigator.com>

HI all,

How to determine a return is a hash, array, or reference?

which articles should I read?




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

Date: 25 May 2001 15:25:25 -0500
From: Ren Maddox <ren@tivoli.com>
Subject: Re: How to determine a return is a hash, array, or reference?
Message-Id: <m37kz59nwq.fsf@dhcp9-172.support.tivoli.com>

On Sat, 26 May 2001, wstsoi@hongkong.com wrote:

> How to determine a return is a hash, array, or reference?

I assume that you want to know what sort of data a subroutine
returns.  A subroutine can only return a scalar or a list, and it does
so based on the context in which it is called.  Of course, that scalar
could be a reference (to another scalar, a hash, an array, a
subroutine, etc.) and that list could contain references.

If you want to know what kind of reference something is, use ref().

> which articles should I read?

perldoc -f ref
perlsub(1)  (or "perldoc perlsub")
perlref(1)  (or "perldoc perlref")

-- 
Ren Maddox
ren@tivoli.com


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

Date: 25 May 2001 21:29:24 GMT
From: damian@qimr.edu.au (Damian James)
Subject: Re: How to determine a return is a hash, array, or reference?
Message-Id: <slrn9gtjm3.a26.damian@puma.qimr.edu.au>

Lucas chose Sat, 26 May 2001 04:05:38 +0800 to say this:
>...
>How to determine a return is a hash, array, or reference?
>

Actually, what is returned from a sub is a *list* in a list context,
otherwise a scalar. Hashes and arrays are flattened into lists. References
are just scalars (though you can have a list of them, and you can tell
whether a scalar contains a reference with the ref() function).

>which articles should I read?
>

perldoc perlsub
perldoc perlref
perldoc -f ref
perldoc -f wantarray (if you're interested in working out what context a
sub was called in)

HTH
Cheers,
Damian
-- 
@:=grep!($;+=m!$/|#!),split//,<DATA>;@;=0..$#:;while(@;){for($;=@;;--$;;)
{@;[$;,$:]=@;[$:,$;]if($:=rand$;+$|)!=$;}push@|,shift@;if$;[0]==@|;select
$,,$,,$,,1/80;print qq x\bxx((@;+@|)*$|++),@:[@|,@;],!@;&&$/} __END__
Just another Perl Hacker # rev 3.1 -- a JAPH in progress, I guess...


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

Date: Fri, 25 May 2001 14:22:01 -0400
From: David Coppit <newspost@coppit.org>
Subject: Re: I don't want global variables ?
Message-Id: <Pine.SUN.4.33.0105251421040.3375-100000@mamba.cs.Virginia.EDU>

On 25 May 2001, Anno Siegel wrote:

> According to David Coppit  <newspost@coppit.org>:
> > On Fri, 25 May 2001, it was written:
> >
> > > One answer that I have discovered is to wrap the code up in {} code block
> > > and hey it works. Is this the best (only) way of doing this?
> >
> > "{}" introduces a scope. The "file scope" is like having {} around
> > your whole file. Any "my" declared variable is visible in the current
> > scope as well as all enclosing scopes. This is why your %in, which was
>                              ^^^
> ITYM enclosed.

Whoops. Yep.

[I knew I couldn't get a whole post off without some mistake. :) I
thought for sure someone would have corrected my knowledge of scoping
in Perl...]

David



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

Date: Fri, 25 May 2001 20:20:55 +0000 (UTC)
From: abigail@foad.org (Abigail)
Subject: Re: I don't want global variables ?
Message-Id: <slrn9gtfl7.ca6.abigail@tsathoggua.rlyeh.net>

Anno Siegel (anno4000@lublin.zrz.tu-berlin.de) wrote on MMDCCCXXIV
September MCMXCIII in <URL:news:9elq91$acm$2@mamenchi.zrz.TU-Berlin.DE>:
||  According to David Coppit  <newspost@coppit.org>:
|| > On Fri, 25 May 2001, it was written:
|| > 
|| > > One answer that I have discovered is to wrap the code up in {} code block
|| > > and hey it works. Is this the best (only) way of doing this?
|| > 
|| > "{}" introduces a scope. The "file scope" is like having {} around
|| > your whole file. Any "my" declared variable is visible in the current
|| > scope as well as all enclosing scopes. This is why your %in, which was
||                               ^^^
||  ITYM enclosed.


Nah. If "{}" introduces scope, variables can appear in enclosing scopes too.


     #!/opt/perl/bin/perl -l
     use strict;

     {
     ;+
         {
             my $foo = "Gotcha"
         ,   my $bar = "Really!"
         }

     ;   # Enclosing scope.
     ;   print $foo

     }
     __END__
     Gotcha



Abigail
-- 
#!/opt/perl/bin/perl   --   # Remove trailing newline!
BEGIN{$SIG{__WARN__}=sub{$_=pop;y-_- -;print/".*(.)"/;  
truncate$0,-1+-s$0;exec$0;}}//rekcaH_lreP_rehtona_tsuJ


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

Date: 25 May 2001 20:52:21 GMT
From: Eli the Bearded <elijah@workspot.net>
Subject: Re: I don't want global variables ?
Message-Id: <eli$0105251642@qz.little-neck.ny.us>

In comp.lang.perl.misc, Abigail <abigail@foad.org> wrote:
> Nah. If "{}" introduces scope, variables can appear in enclosing scopes too.

I don't get this.

>      #!/opt/perl/bin/perl -l
>      use strict;
> 
>      {
>      ;+
>          {
>              my $foo = "Gotcha"
>          ,   my $bar = "Really!"
>          }
> 
>      ;   # Enclosing scope.
>      ;   print $foo
> 
>      }
>      __END__
>      Gotcha

That is a very confusing example. If I run it through 'perl -MO=Deparse'
I get back a script which does not print "Gotcha", so something very
subtle seems to be going on. The smallest script I can get to do that
odd thing is:

	+{my$c="Gotcha"};print$c

But this gives me a parse error:

	+{my$c="Gotcha";my$d="Again"};print$c.$d

	syntax error at /tmp/gotcha line 1, near ";my"

Which suggests that perl does not think there is a bare block in
there, instead it is doing something else with that {}.

Elijah
------
has learned a lot about perl dissecting Abigail's scripts


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

Date: Fri, 25 May 2001 21:02:25 GMT
From: Uri Guttman <uri@sysarch.com>
Subject: Re: I don't want global variables ?
Message-Id: <x7y9rl16se.fsf@home.sysarch.com>

>>>>> "A" == Abigail  <abigail@foad.org> writes:

  A> Nah. If "{}" introduces scope, variables can appear in enclosing
  A> scopes too.


  A>      #!/opt/perl/bin/perl -l
  A>      use strict;

  A>      {
  A>      ;+
  A>          {
  A>              my $foo = "Gotcha"
  A>          ,   my $bar = "Really!"
  A>          }

  A>      ;   # Enclosing scope.
  A>      ;   print $foo

  A>      }
  A>      __END__
  A>      Gotcha

try putting a my $baz before or after the inner {}. then strict will
barf about the print $foo.

it seems perl is optimizing away the inner {} as they don't do any
narrowing of scope so $foo is visible to the print. adding something in
the outer {} makes the inner {} meaningful and it does what you think.

uri

-- 
Uri Guttman  ---------  uri@sysarch.com  ----------  http://www.sysarch.com
SYStems ARCHitecture and Stem Development ------ http://www.stemsystems.com
Learn Advanced Object Oriented Perl from Damian Conway - Boston, July 10-11
Class and Registration info:     http://www.sysarch.com/perl/OOP_class.html


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

Date: 25 May 2001 17:47:12 -0400
From: Joe Schaefer <joe+usenet@sunstarsys.com>
Subject: Re: I don't want global variables ?
Message-Id: <m3y9rlqexr.fsf@mumonkan.sunstarsys.com>

Uri Guttman <uri@sysarch.com> writes:

> >>>>> "A" == Abigail  <abigail@foad.org> writes:
> 
>   A> Nah. If "{}" introduces scope, variables can appear in enclosing
>   A> scopes too.
> 
> 
>   A>      #!/opt/perl/bin/perl -l
>   A>      use strict;
> 
>   A>      {
>   A>      ;+
>   A>          {
>   A>              my $foo = "Gotcha"
>   A>          ,   my $bar = "Really!"
>   A>          }
> 
>   A>      ;   # Enclosing scope.
>   A>      ;   print $foo
> 
>   A>      }
>   A>      __END__
>   A>      Gotcha
> 
> try putting a my $baz before or after the inner {}. then strict will
> barf about the print $foo.
> 
> it seems perl is optimizing away the inner {} as they don't do any
> narrowing of scope so $foo is visible to the print. adding something in
> the outer {} makes the inner {} meaningful and it does what you think.

Huh?  Try enabling warnings to see exactly what those inner 
"curly braces" are doing.

-- 
Joe Schaefer     "The eternal mystery of the world is its comprehensibility."
                                               --Albert Einstein


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

Date: Fri, 25 May 2001 12:18:29 -0700
From: Eric <nospam@xx.com>
Subject: Re: Installing Perl on Win NT/2000 Re: Match Parsing Glitch
Message-Id: <3B0EB005.6F1D88DF@xx.com>

Malcolm Hoar wrote:
> In article <3b0e41df.3872945721@news.isholf.is>, helgi@NOSPAMdecode.is wrote:
> >but also be downloaded from
> >http://download.microsoft.com/download/platformsdk/wininst/1.0/WIN98/EN-US/Inte
> >lSDK.msi
> 
> Ummm, that's an MSI file which might be kind of hard to install
> if you don't already have MSI. It's also an outdated version.
> 
> It may be more productive to start here:
> 
> http://aspn.activestate.com/ASPN/Downloads/ActivePerl/Requirements#windows
> 
Thank you Malcolm (& Helgi) ... am downloading the WIN98 version right
now.


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

Date: Fri, 25 May 2001 15:09:31 -0400
From: H C <carvdawg@patriot.net>
Subject: Re: looking 4 NMAP style perl module
Message-Id: <3B0EADEB.EF2E2328@patriot.net>

Uhm...CPAN, as in http://www.cpan.org

jeff wrote:

> No I have not,...do you have a ref URL ?
> -j
>
> > Have you looked at Net::RawIP on CPAN yet?
> >
> > jeff wrote:
> >
> > > greetings
> > > Im looking for a module or script that will execute a simple tcp port
> > > scan like namp does.
> > >
> > > this is the scan from nmap that I need written in perl.
> > >
> > > ./nmap -v -sS -O -p 3453 my.friggin.host
> > >
> > > if anyone can point me to a MAN page or a URL that could explain to me
> > > How to do this, or if anyone knows of a module already written that will
> > > do the same feature. Please reply off list.
> > >
> > > Thanks In Advance.
> > >
> > > --jeff
> >



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

Date: Fri, 25 May 2001 12:14:46 -0700
From: Eric <nospam@xx.com>
Subject: Re: Match Parsing Glitch
Message-Id: <3B0EAF26.2CFE56B8@xx.com>

Abe Timmerman wrote:
> [ please do _not_ send stealth CC's ]

What's a "stealth CC" ???
>
>         perldoc perldiag
>
Tnx, but I have no clue where this is on my WIN32 install of 5.003 
 
> You can also let perl do the lookup for you, if you put the line
>         use diagnostics;
> near the top of your program whilst developing.

Tnx for the tip!
> 
> It looks like you need to declare the variables with my() or the "use
> vars" pragma.
> 
>         perldoc -f my
>         perldoc vars

Oh gosh...I'm clueless here again.  Hopefully, I'll get the Build 626 
installed and find all this stuff.
> 
> Well, it seems the my $line = <INPUT> declaration within the while
> condition was introduced in Perl 5.004, I forgot you are running an
> older Perl (5.003_07).

No problem...I sincerely appreciate all your kind assistance.  As I type
am also downloading that .msi installation widget thing several kind
folks
told me I need.

Will then give everything a whirl later tonight.

Regards,

Eric


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

Date: Fri, 25 May 2001 18:30:40 GMT
From: mjd@plover.com (Mark Jason Dominus)
Subject: Re: module for combinatorics? (partitions etc)
Message-Id: <3b0ea4bf.2071$c0@news.op.net>

In article <slrn9gmm2o.l37.dave@sydney.daveb.net>,
Dave Bailey <dave@sydney.daveb.net> wrote:
>On Wed, 23 May 2001 03:16:19 GMT, Mark Jason Dominus <mjd@plover.com> wrote:
>>The problem does have such bounds.  If you're trying to partition the
>>number X, the integers employed in the solution must be in [1..X].
>>If you allow integers lress than 1, the problem is no longer
>>well-posed.  Allowing integers larger than X does not change the
>>problem because such integers are useless.
>
>I think the problem is still well-posed if the integers are not in 
>[1,X], because of the k-constraint (the constraint that there must
>be exactly k integers in the solution set).  For example if I wish
>to count the k-partitions of 0 over [-1,1], I get 1 + (k >> 1).


Yes, you're right.  I was stuck on the idea of partitions where the
number of parts is unspecified.  Thanks for the correction.
-- 
@P=split//,".URRUU\c8R";@d=split//,"\nrekcah xinU / lreP rehtona tsuJ";sub p{
@p{"r$p","u$p"}=(P,P);pipe"r$p","u$p";++$p;($q*=2)+=$f=!fork;map{$P=$P[$f^ord
($p{$_})&6];$p{$_}=/ ^$P/ix?$P:close$_}keys%p}p;p;p;p;p;map{$p{$_}=~/^[P.]/&&
close$_}%p;wait until$?;map{/^r/&&<$_>}%p;$_=$d[$q];sleep rand(2)if/\S/;print


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

Date: Fri, 25 May 2001 15:59:03 -0400
From: "Prasad, Victor [FITZ:K500:EXCH]" <vprasad@americasm01.nt.com>
Subject: Output unix data with perl.vvp
Message-Id: <3B0EB987.535D3EA4@americasm01.nt.com>

Hello,

I have a unix script that does a lot of stuff.  I want to use a perl
script to pass it parameters  - run the unix script - and spit out the
unix messages to the screen from within the PERL script?

ie.

#/usr/bin/perl

my $cgi = new CGI; 

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



foreach my $name (@param_names)
        {
        print "<br>$name: ", $cgi->param($name), "\n";
        }

$catalog=$cgi->param('catalog');
$dataset=$cgi->param('dataset');

if ($catalog && $dataset)
       {
       system("upd_catalog.sh -c $catalog -d $dataset");
        }

print "</html>";


This is not the whole script - for brevity sake.
But the unix script out puts messsages like what it is doing, what
number it has completed - and other stuff.  How do I get the output from
the Unix script to appear on a web page even though it is in a PERL
script?

Thanks,

V


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

Date: Fri, 25 May 2001 22:07:30 +0200
From: buggs <buggs@geekmail.de>
Subject: Re: Perl CGI
Message-Id: <9eme1f$9bb$03$1@news.t-online.com>

Mark Jason Dominus wrote:

> In article <u9ofsh4d7w.fsf@wcl-l.bham.ac.uk>,  <nobull@mail.com> wrote:
>>Gabriel Angel Moll Ibacache <gmoll@anakena.dcc.uchile.cl> writes:
>>
>>> Anyone knows how to "run" a CGI?
>>> Where the CGI must be in?
>>
>>A web server.
> 
> It occurs to me that it would be very easy to write a perl program
> which ran some other CGI program *as if* there were a web server
> available, even when there wasn't.  Of course, it won't be an exact
> simulation, but it might be close enough to be useful.
> 

If you add HTTP::Daemon you can get input from browser :-)

Add a Disclaimer like:

# Keep in mind that the CGI-script will inherit your user priveleges.
# This means to test a unknown CGI-script this can be even
# more of a security risk than running it under your webserver,
# unless your webserver runs as root.

And some changes in diff -u format:

-       $ENV{SCRIPT_NAME} = $program;
-       $ENV{REMOTE_PORT} = 0;
+       $ENV{REMOTE_PORT} = 1200;
+       $ENV{SCRIPT_NAME} = "/cgi-bin/$program";
+       $ENV{GATEWAY_INTERFACE} = 'CGI/1.0'
+       $ENV{CONTENT_TYPE} = 'application/x-www-form-urlencoded';
+       $ENV{HTTP_REFERER} = 'http://127.0.0.1/index.html'

And a "local(%ENV)" could also be nice,
one should then add:

$ENV{PATH} = '/sbin:/bin:/usr/sbin:/usr/bin'

For encode() one could use URI::Escape.

Buggs





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

Date: Fri, 25 May 2001 20:45:45 GMT
From: Bart Lateur <bart.lateur@skynet.be>
Subject: Re: Permuting days of the week
Message-Id: <0ggtgtg2af7dnr5qgc3qjtoinjt1teka9h@4ax.com>

James Weisberg wrote:

>   Given the days of the week: Sun, Mon, Tue, Wed, Thu, Fri, Sat
>I would like to take various permuations and sequences of those strings 
>and fill the days in between. Examples: 
>
>Sun-Sat = "Sun,Mon,Tue,Wed,Thu,Fri,Sat"
>Mon-Sun = "Mon,Tue,Wed,Thu,Fri,Sat,Sun"

"Permutations"? That doesn't really sound like permutation. And I do
feel that the other way around, i.e. recognizing contiguus sequences of
days, would be harder.

Anyway, here's my shot.

    BEGIN {
        my @weekday = qw/Sun Mon Tue Wed Thu Fri Sat/;
        my %weekday = map { $weekday[$_] => $_ } 0 .. $#weekday;
        sub daysequence {
            my($first, $last) = @weekday{split /-/, shift};
            $last += 7 if $last < $first;
            return join ', ', @weekday[map { $_ % 7 } $first .. $last];
        }
    }
    $\ = "\n";
    print daysequence('Sat-Wed');
-->
	Sat, Sun, Mon, Tue, Wed

-- 
	Bart.


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

Date: Fri, 25 May 2001 13:48:56 -0700
From: swen <ml2316@hotmail.com>
Subject: Q:  RPC::PlServer, Storable
Message-Id: <3B0EC538.9720C110@hotmail.com>

Hi,

Has anyone here experienced errors with a RPC::PlServer where Storable
complains about conflicting binary image versions.  I'm using dbi
proxyserver which is just an rpc plserver and when I try to log in (to
the server on windows) from my linux box (latest perl, 5.6.1) I get an
error. Storable is trying to call thaw and either complains with the
error "bad hash" or "Storable binary image newer (v2.4) than I am (v2.3)
at thaw.al". I looked through the docs and code and I'm guessing the
versions refer to a way of numbering serialized data.  Other than that
I'm totally confused.  I don't have this problem when I log in from my
other (digital unix) machine.



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

Date: Fri, 25 May 2001 11:54:14 -0700
From: John Smith <j2lab@my-deja.com>
Subject: rfc date conversion
Message-Id: <3B0EAA56.1C8F2E2E@my-deja.com>

I send a date in rfc format to one of my scripts.  I assign the rfc to a
variable $date.  Is there a way to take that date and format it any way
I want?

I was thinking that I would have to accept the date as an array and then
format it from there.  I was hoping there would be another way to do
this.

Any help would be greatly appreciated,
John



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

Date: Fri, 25 May 2001 16:24:48 -0500
From: karthy muthiah kasi <kasi@students.uiuc.edu>
Subject: SCAN
Message-Id: <Pine.GSO.4.31.0105251620380.15448-100000@ux13.cso.uiuc.edu>


After opening a file, is there a way that I can scan the next two lines
without having to move the read cursor?  The problem I am encountering is
that after invoking <FILENAME>, the next line of the file is read and I am
unable to read a previous line.


Karthy Kasi




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

Date: Fri, 25 May 2001 21:32:13 GMT
From: "Todd Smith" <todd@designsouth.net>
Subject: Re: SCAN
Message-Id: <xbAP6.70958$I5.15871075@news1.rdc1.tn.home.com>


"karthy muthiah kasi" <kasi@students.uiuc.edu> wrote in message
news:Pine.GSO.4.31.0105251620380.15448-100000@ux13.cso.uiuc.edu...
>
> After opening a file, is there a way that I can scan the next two lines
> without having to move the read cursor?  The problem I am encountering is
> that after invoking <FILENAME>, the next line of the file is read and I am
> unable to read a previous line.
>

just put it in an array:

@file = <FILENAME>;

then iterate through with i:

for $i (0..$#file) {
    $file[$i-1]; #previous line
    $file[$i]; #this line
    $file[$i+1]; #next line
}

You'll want to do some error checking so that you don't evaluate [0-1] and
get [-1] and return the last line in the file, and you don't do [$#file + 1]
and return an undefined value.




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

Date: Fri, 25 May 2001 20:08:31 -0000
From: cberry@cinenet.net (Craig Berry)
Subject: Re: url parsing
Message-Id: <tgtetvhqvn182d@corp.supernews.com>

Ilmari Karonen (iltzu@sci.invalid) wrote:
: Yes, URLs can be parsed with a regexp.  In fact, RFC 2396, which is the
: authoritative document on anything you wanted to know about URLs, gives
: the regexp in Appendix B.  I've pasted it here for you:
: 
:   $url =~ /^(([^:/?#]+):)?(//([^/?#]*))?([^?#]*)(\?([^#]*))?(#(.*))?$/s
:        or die "Invalid URL: $url\n";

So a valid url can contain newlines practically anywhere?

-- 
   |   Craig Berry - http://www.cinenet.net/~cberry/
 --*--  "God becomes as we are that we may be as he is."
   |               - William Blake


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

Date: Fri, 25 May 2001 20:46:57 GMT
From: "John W. Krahn" <krahnj@acm.org>
Subject: Re: url parsing
Message-Id: <3B0EC4E2.68996991@acm.org>

Craig Berry wrote:
> 
> Ilmari Karonen (iltzu@sci.invalid) wrote:
> : Yes, URLs can be parsed with a regexp.  In fact, RFC 2396, which is the
> : authoritative document on anything you wanted to know about URLs, gives
> : the regexp in Appendix B.  I've pasted it here for you:
> :
> :   $url =~ /^(([^:/?#]+):)?(//([^/?#]*))?([^?#]*)(\?([^#]*))?(#(.*))?$/s
> :        or die "Invalid URL: $url\n";
> 
> So a valid url can contain newlines practically anywhere?

The actual quote from RFC 2396 is:

   The following line is the regular expression for breaking-down a URI
   reference into its components.

      ^(([^:/?#]+):)?(//([^/?#]*))?([^?#]*)(\?([^#]*))?(#(.*))?
       12            3  4          5       6  7        8 9

   The numbers in the second line above are only to assist readability;
   they indicate the reference points for each subexpression (i.e., each
   paired parenthesis).  We refer to the value matched for subexpression
   <n> as $<n>.

So I guess Ilmari added the /s for some reason.


John
-- 
use Perl;
program
fulfillment


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

Date: Fri, 25 May 2001 14:07:16 -0700
From: "Godzilla!" <godzilla@stomp.stomp.tokyo>
Subject: Re: url parsing
Message-Id: <3B0EC984.D9DD9FA5@stomp.stomp.tokyo>

John W. Krahn wrote:
 
> Craig Berry wrote:

> > Ilmari Karonen wrote:

> > : Yes, URLs can be parsed with a regexp.  In fact, RFC 2396, which is the
> > : authoritative document on anything you wanted to know about URLs, gives
> > : the regexp in Appendix B.  I've pasted it here for you:
> > :
> > :   $url =~ /^(([^:/?#]+):)?(//([^/?#]*))?([^?#]*)(\?([^#]*))?(#(.*))?$/s
> > :        or die "Invalid URL: $url\n";

> > So a valid url can contain newlines practically anywhere?
 
> The actual quote from RFC 2396 is:
 
>    The following line is the regular expression for breaking-down a URI
>    reference into its components.
 
>       ^(([^:/?#]+):)?(//([^/?#]*))?([^?#]*)(\?([^#]*))?(#(.*))?
>        12            3  4          5       6  7        8 9
 
(snipped)
 
> So I guess Ilmari added the /s for some reason.


So Karonen has been caught red-handed practicing deceit
and, his deceitful ways led him to post bad code, much
like your attempt at deceit led you to being called out
by me, with vigor.

Amazing how many of you boys use "we" in your dialog.
All these innumerable identical personal idioms in
language usage lead me to believe you boys are truly,
Borg.

Godzilla!


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

Date: Fri, 25 May 2001 14:19:12 -0400
From: Terry Gliedt <tpg@umich.edu>
Subject: What modules are being used?
Message-Id: <3B0EA220.869447B7@umich.edu>

I'm working on a rather large project which eventually I'd like to make
available to other sites. I have the problem of trying to accurately list all
the modules being used by my code. I know what modules I had to install as I
wrote the code, but what I don't know is what modules I (or someone else) had
installed earlier which were used by my code.

Simply put, for a given Perl script, what are all the modules (and the version)
used?

I have this vague recollection that somewhere I saw some code which would simply
list what was used, but I can't recall enough details. Can someone refresh my
poor memory? 

Please also copy me directly on your response, less I miss your reply. TIA
-- 
=============================================================
Terry Gliedt     tpg@umich.edu       http://www.hps.com/~tpg/
Biostatistics, Univ of Michigan  Personal Email:  tpg@hps.com


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

Date: Fri, 25 May 2001 18:34:38 GMT
From: Scratchie <AgitatorsBand@yahoo.com>
Subject: Re: wwwboard.pl - Taint and Use Strict
Message-Id: <2BxP6.303$aG6.26929@news.shore.net>

Uri Guttman <uri@sysarch.com> wrote:
: you can't take a pile of manure and make it into art (unless you are in
: the brooklyn museum). if you did make it into a decent program, you
: probably did a complete rewrite. that is not fixing something. there is
: no way you can just spend a day cleaning up a matt script to make it
: pass -w, strict and -T and get something that is good quality. there are
: deeper flaws in his code than just simple declaration issues. his
: locking typically is flawed, he doesn't use decent data structures, the
: design is not flexible, etc. i have examined many of his scripts (and
: dozens of others based on his or which ripped off code and style from
: his) and i would never touch them. they have to written correctly from
: scratch (and maybe by scratchie).

Well, hopefully in a day or so (maybe next week) you'll be able to tear my
code apart "in person" instead of speculating. I certainly rewrote a *lot*
of Matt's script but I didn't rewrite the whole thing. Stuff that worked,
I left in, mainly because I *didn't* want to spend the time to rewrite it
from scratch (e.g. all the HTML is still contained in-line in
"print" statements because I didn't want to take the time to turn it into
a template system) (but I did clean up the print statements to use <<HERE 
docs so it would be a lot easier to change in the future). 

But, I disagree with the notion that there was nothing at all of value in
his script. As I mentioned before, I liked his basic concept for updating
the static HTML pages, and with a little added security (to avoid the
"Alaskan Electrician" hack or buffer overflows or simply writing megabytes
of data to my server's hard drive) it seems to work fine, and it was a
*lot* faster than trying to write my own code to do the same thing. 

Truth be told, I haven't even looked at the thing (other than very
briefly) since I wrote it a couple years ago, but once I get an hour or
two to clean it up (a little) and post a working version to my website,
you can all check it out for yourselves.

--Art


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

Date: Fri, 25 May 2001 19:58:49 GMT
From: Bart Lateur <bart.lateur@skynet.be>
Subject: Re: wwwboard.pl - Taint and Use Strict
Message-Id: <obetgt45qcc7a0em0og8ks929bovef8l29@4ax.com>

Godzilla! wrote:

>This ironic humor is other than Randal and perhaps one or two
>others whom have slipped out of my memory, I know of no others
>here who actually write or have written any real programs.

If you check CPAN, you'll see that many of the useful modules are
written by regulars in this newsgroup.

And no, that doesn't include me. I have nothing on CPAN. Yet.

-- 
	Bart.


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

Date: Fri, 25 May 2001 13:37:53 -0700
From: "Godzilla!" <godzilla@stomp.stomp.tokyo>
Subject: Re: wwwboard.pl - Taint and Use Strict
Message-Id: <3B0EC2A1.F6B01241@stomp.stomp.tokyo>

Bart Lateur wrote:

(unnoted snippage by Lateur, mild context change)
 
> Godzilla! wrote:
 
> >This ironic humor is other than Randal and perhaps one or two
> >others whom have slipped out of my memory, I know of no others
> >here who actually write or have written any real programs.
 
> If you check CPAN, you'll see that many of the useful modules are
> written by regulars in this newsgroup.
 
> And no, that doesn't include me. I have nothing on CPAN. Yet.

I expected at least one person to mention modules, which
is fair. Those who write modules do exhibit a quality
of programming skill directly proportionate to the
quality of their module or modules. However, modules
are utility programs, not full featured programs.
Nonetheless, appropriate credit is due to those
creating modules.

Snipped from my original article, my words included:

 "I have yet to witness any of you actually writing a 
  full featured program."

This is a true statement. I only know of a few, very few,
participating here who have written full featured programs.
My knowledge of those whom do or have, is clearly limited
to those whom have publically announced these types of
programs, such as Randal, myself and those few I mentioned
having slipped from my memory.

My point is a lot of participants here bitch and bellyache
about scripts of others, about Matt's scripts, yet there
is no evidence these Peanut Gallery participants have
ever written a real program.

I find this ironically humorous.

Godzilla!


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

Date: 6 Apr 2001 21:33:47 GMT (Last modified)
From: Perl-Users-Request@ruby.oce.orst.edu (Perl-Users-Digest Admin) 
Subject: Digest Administrivia (Last modified: 6 Apr 01)
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.  

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 V10 Issue 989
**************************************


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