[11474] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 5074 Volume: 8

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Sat Mar 6 14:07:26 1999

Date: Sat, 6 Mar 99 11:00:17 -0800
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, 6 Mar 1999     Volume: 8 Number: 5074

Today's topics:
        127/8 -> 127.0.0.0/8 <igor@rtsnet.ru>
    Re: cobol line seq. file - one very long line - <gellyfish@btinternet.com>
    Re: does perl discourage obfuscated code? (was Re: Perl <Russell_Schulz@locutus.ofB.ORG>
    Re: does perl discourage obfuscated code? (was Re: Perl <Russell_Schulz@locutus.ofB.ORG>
        FAQ 2.2: How can I get a binary version of Perl?   <perlfaq-suggestions@perl.com>
        FAQ 2.3: I don't have a C compiler on my system.  How c <perlfaq-suggestions@perl.com>
    Re: Form to a text file... <gellyfish@btinternet.com>
    Re: how do i format a forwarded letter <gellyfish@btinternet.com>
    Re: I've flocked up (Tad McClellan)
    Re: input from file or from buffer <jdf@pobox.com>
    Re: listing directory CGI <gellyfish@btinternet.com>
    Re: long lines in data file being cut <jdf@pobox.com>
    Re: Nonscalar Array Access? <gellyfish@btinternet.com>
        NT scripting <S.Kruese<:nospam:>@wxs.nl>
    Re: Perl & OS/2: problems with makefile.pl & makemaker ran@netgate.net
        Speed of running from command line? <dglass@istar.ca>
        Upload file without CGI.pm - possible? (Scott Porter)
    Re: Verifying URL's with perl. chames@my-dejanews.com
        Want to learn Perl <akonopka@mtco.com>
    Re: Web form using perl/cgi <gellyfish@btinternet.com>
    Re: Your opinion on an HTML stripper regex <gellyfish@btinternet.com>
        Special: Digest Administrivia (Last modified: 12 Dec 98 (Perl-Users-Digest Admin)

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

Date: 6 Mar 1999 19:13:09 -0300
From: Igor Vinokurov <igor@rtsnet.ru>
Subject: 127/8 -> 127.0.0.0/8
Message-Id: <36e15415.0@news.rtsnet.ru>

Hello.

Anyone can suggest module/function to expand ip address
in form "127/8" to "127.0.0.0/8"?

-- 
Igor Vinokurov


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

Date: 6 Mar 1999 15:09:20 -0000
From: Jonathan Stowe <gellyfish@btinternet.com>
Subject: Re: cobol line seq. file - one very long line -
Message-Id: <7brgf0$197$1@gellyfish.btinternet.com>

On 6 Mar 1999 13:05:35 -0000 Jonathan Stowe wrote:
> 
> while($string =~ /(.{57}/g )
                          ^----------|
Typo alert there should be a  ) here |

/J\
-- 
Jonathan Stowe <jns@btinternet.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, 6 Mar 1999 13:20:31 -0500
From: Russell Schulz <Russell_Schulz@locutus.ofB.ORG>
Subject: Re: does perl discourage obfuscated code? (was Re: Perl evangelism)
Message-Id: <19990306.132031.8A2.rnr.w164w@locutus.ofB.ORG>

Jerome O'Neil <jeromeo@atrieva.com> quotes me and writes:

>> I believe it.  Perl encourages hard-to-read code.  that's just the
>> way it is, and if you don't apply a strong discipline when writing
>> Perl, you're going to be the proud owner of a ton of read-only code.
>
> Completely disagree.  Given two pieces of well written code used to
> accomplish the same task, I contend that perl is *more* readable than
> just about any other language you can come up with.

I think you mispelled `agree' as `disagree' above.

how do you get this `well written' Perl code?  do you get it by slamming
out the shortest Perl `idiom' to do something, or do you apply a little
extra discipline to make sure it's well written in SPITE of all the
built-in obscurity in Perl?  (is it local \**FH or *\*FH again?)

obviuosly, I don't think you do it without that discipline.
-- 
Russell_Schulz@locutus.ofB.ORG  Shad 86c


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

Date: Sat, 6 Mar 1999 13:03:22 -0500
From: Russell Schulz <Russell_Schulz@locutus.ofB.ORG>
Subject: Re: does perl discourage obfuscated code? (was Re: Perl evangelism)
Message-Id: <19990306.130322.8Z9.rnr.w164w@locutus.ofB.ORG>

  [ less `Perl evangelism', more `Perl fanaticism'? ]

merlyn@stonehenge.com (Randal L. Schwartz) quotes me and writes:

>> Perl encourages hard-to-read code.
> I completely disagree here.  Perl does nothing to encourage this.

those two statements are redundant.

>> if you don't apply a strong discipline when writing Perl,
>
> But in summary, let us please stop passing around the myth that Perl
> *is* write-only code, or *encourages* write-only code.  I've found
> neither of those to be true in my commercial experience, and you are
> merely damaging the Perl community by passing along such lies.  In
> most of the code I've been asked to maintain from others (even
> beginners), the question was never "what are they doing here" but "why
> are they doing this", which would have been true no matter what the
> language.

let's use SuperCite style to paraphrase:

Russell> you need discipline or your code will be read-only.
Randal> write-only
Russell> yes, you need discipline or your code will be write-only.
Randal> my code isn't write-only.
Russell> and you have shown you have discipline, because you know how.
Russell> to create write-only code, but you don't.
Randal> my students' code isn't write-only.
Russell> I assume you would teach this discipline to your students.
Randal> shut up.  you're hurting the Perl community.

Randal, to disagree with me, you have to show that people can use the
same level of discipline of keeping their code readable that they would
have to use in Pascal or Smalltalk, and still have the code not turn
into the mess of S00PR C00L punctuation tangle we often see posted.

obviously, I don't think that's true.  I think that without the
discipline, without the EXTRA discipline specifically to keep your
Perl code from denigrating into The Shortest Way To Do It, it will
be a real mess.

and neither the Perl language nor the Perl community discourage that.

> But in summary, let us please stop passing around the myth that Perl
> *is* write-only code, or *encourages* write-only code.  I've found
> neither of those to be true in my commercial experience

Randal> I haven't experienced it; so neither has Russell.  in fact, I've
Randal> seen all the Perl code Russell's co-workers have written, and it's
Randal> CLEARER than any code in any other language.

> you are merely damaging the Perl community by passing along such lies.

Randal> in fact, I think I'll call him a LIAR!  for calling Perl obscure!
Randal> if he claims it's case-sensitive I'll question his ancestry!

> In most of the code I've been asked to maintain from others

Russell> when I mail someone else my code to look after, I tend to
Russell> give it another look-over to make sure I'm not embarrassed
Russell> by anything I might have done quickly and not cleaned up.
Randal> LIAR!

> (even beginners),

Randal> beginners don't even KNOW about all the obscure features of Perl,
Randal> so their code isn't nearly as obscure (even without discipline).
Russell> well, duh.

> the question was never "what are they doing here" but "why
> are they doing this"

Randal> I know Perl really well, so it's not obscure to me.
Russell> well, duh.
Randal> PS:  LIAR!
-- 
Russell_Schulz@locutus.ofB.ORG  Shad 86c


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

Date: 6 Mar 1999 07:41:31 -0700
From: Tom Christiansen <perlfaq-suggestions@perl.com>
Subject: FAQ 2.2: How can I get a binary version of Perl?  
Message-Id: <36e13e9b@csnews>

(This excerpt from perlfaq2 - Obtaining and Learning about Perl 
    ($Revision: 1.30 $, $Date: 1998/12/29 19:43:32 $)
part of the standard set of documentation included with every 
valid Perl distribution, like the one on your system.
See also http://language.perl.com/newdocs/pod/perlfaq2.html
if your negligent system adminstrator has been remiss in his duties.)

  How can I get a binary version of Perl?

    If you don't have a C compiler because your vendor for whatever
    reasons did not include one with your system, the best thing to
    do is grab a binary version of gcc from the net and use that to
    compile perl with. CPAN only has binaries for systems that are
    terribly hard to get free compilers for, not for Unix systems.

    Some URLs that might help you are:

        http://language.perl.com/info/software.html
        http://www.perl.com/latest/
        http://www.perl.com/CPAN/ports/

    If you want information on proprietary systems. A simple
    installation guide for MS-DOS is available at
    http://www.cs.ruu.nl/~piet/perl5dos.html and similarly for
    Windows 3.1 at http://www.cs.ruu.nl/~piet/perlwin3.html .

-- 
    "Just because you're screwed *up* doesn't mean you're screwed." --Larry Wall


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

Date: 6 Mar 1999 10:11:34 -0700
From: Tom Christiansen <perlfaq-suggestions@perl.com>
Subject: FAQ 2.3: I don't have a C compiler on my system.  How can I compile perl?  
Message-Id: <36e161c6@csnews>

(This excerpt from perlfaq2 - Obtaining and Learning about Perl 
    ($Revision: 1.30 $, $Date: 1998/12/29 19:43:32 $)
part of the standard set of documentation included with every 
valid Perl distribution, like the one on your system.
See also http://language.perl.com/newdocs/pod/perlfaq2.html
if your negligent system adminstrator has been remiss in his duties.)

  I don't have a C compiler on my system.  How can I compile perl?

    Since you don't have a C compiler, you're doomed and your vendor
    should be sacrificed to the Sun gods. But that doesn't help you.

    What you need to do is get a binary version of gcc for your
    system first. Consult the Usenet FAQs for your operating system
    for information on where to get such a binary version.

-- 
Besides, it's good to force C programmers to use the toolbox occasionally.  :-)
        --Larry Wall in <1991May31.181659.28817@jpl-devvax.jpl.nasa.gov>


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

Date: 6 Mar 1999 15:24:00 -0000
From: Jonathan Stowe <gellyfish@btinternet.com>
Subject: Re: Form to a text file...
Message-Id: <7brhag$1av$1@gellyfish.btinternet.com>

On Thu, 4 Mar 1999 16:56:42 +0100 Thomas Leuthard wrote:
> I'm looking for a CGI-Script that make a textfile out of a HTML Form. This
> is because the server uses SSL and I cannot send this encrypted by E-Mail.
> So I write this file to the server and get it over a SSL secured connection.
> 
> Where can I find such a Form to Text script?
> 

I'm sure that given a little time with Documentation for CGI.pm you
could sort it out yourself.

However heres one I prepared earlier - it appends your form data to a 
comma delimited file.  I'm sure you can adapt to suit your needs - I
hope you can anyhow ...


#!/usr/bin/perl -w 

use CGI qw/:standard/;
use Fcntl qw/:flock/;

print header(),
      start_html("Test CGI"),"\n";

if( param )
{
  @params = param;

  if(open(OUTFILE,">>outfile.txt"))
    {
      if(flock OUTFILE,LOCK_EX)
        {
          foreach $parameter ( sort @params)
            {
               push @out,param($parameter);
            }
          seek (OUTFILE,0,2);
          print OUTFILE join("," , @out),"\n";
          print h1("Details stored successfully"),"\n";
        }
      else
       {
          print h1("Couldnt lock file"),"\n";
       }
      close OUTFILE;
    }
  else
    {
      print h1("Error opening file"),"\n";
    }
}
else
{
  print h1("No form data sent");
}

print end_html(),"\n";
__END__

/J\
-- 
Jonathan Stowe <jns@btinternet.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: 6 Mar 1999 15:06:49 -0000
From: Jonathan Stowe <gellyfish@btinternet.com>
Subject: Re: how do i format a forwarded letter
Message-Id: <7brga9$194$1@gellyfish.btinternet.com>

On Sat, 6 Mar 1999 08:59:23 -0500 Poohba wrote:
> you know how when a letter is forwarded it has '>' at the begining of each
> line.  I want to take it out.  How can i do that? I currently tried:

I always fancy

perl -pi.bak -e 's/^>//g;'

otherwise you might want to see the entry in perlfaq5 entitled:


       How do I change one line in a file/delete a line in a
       file/insert a line in the middle of a file/append to the
       beginning of a file?

/J\
-- 
Jonathan Stowe <jns@btinternet.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, 6 Mar 1999 03:02:09 -0500
From: tadmc@metronet.com (Tad McClellan)
Subject: Re: I've flocked up
Message-Id: <1enqb7.klq.ln@magna.metronet.com>

Lee Howells (lee@easypress.co.uk) wrote:

: Yet another flock query,

: Do you get an error trying to open a locked file or does the system wait
: until the file is available again and then allow access?


   You must have missed this part of the description for flock()
   when you looked it up in perlfunc.pod before posting:


      "If LOCK_NB is added to LOCK_SH or LOCK_EX then C<flock()> 
       will return immediately rather than blocking waiting for 
       the lock (check the return status to see if you got it)."


   So, "normal" operation is to block (wait) until the lock is obtained.


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


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

Date: 06 Mar 1999 10:05:03 -0500
From: Jonathan Feinberg <jdf@pobox.com>
To: bart.lateur@skynet.be (Bart Lateur)
Subject: Re: input from file or from buffer
Message-Id: <m3d82my7z4.fsf@joshua.panix.com>

bart.lateur@skynet.be (Bart Lateur) writes:

> I have a little problem: I need to be able to call a sub with a
> file, or a buffer (I think an array of preread lines).

One possible hack would be to make the interface of the sub such that
it receives a reference.

 sub read_from {
    my $ref = shift;
    chomp(my $next_line = ref($ref) eq 'GLOB' ? <$ref> : shift @$ref);
    # do something with $next_line	
 }

Then call it like

  read_from(\*FH);
  read_from(\@array);

-- 
Jonathan Feinberg   jdf@pobox.com   Sunny Brooklyn, NY
http://pobox.com/~jdf


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

Date: 6 Mar 1999 14:46:59 -0000
From: Jonathan Stowe <gellyfish@btinternet.com>
Subject: Re: listing directory CGI
Message-Id: <7brf53$15t$1@gellyfish.btinternet.com>

On Fri, 05 Mar 1999 17:20:13 -0500 Aaron Walker wrote:
> I am using my own apache 1.34 server for this...
> 
> I am attempting to write a perl CGI script that lists the contents of my
> home directory.  Is this possible?
> 
> Here is what I have so far:
> 
> #!/usr/bin/perl
> print Content-type: text/html\n\n";
> 
> $ls \ `ls /home/amwalker`;
> 
> print <<"HTML";
> <html>
> <body>
> <h2>Contents of home directory: </h2>
> $ls
> HTML
> 
> This works when I run it from the shell, but why not in netscape?
> 

There could be a number of reasons why this isnt working and I cant see
one of them that has anything to do with Perl.

Also please note that 'netscape' does not run your script it is run by the
server.

Anyhow just for fun an as food for thought here is a little thing that
produces a directory listing with links that enable you to then open the
file - it isnt very clever about the Content-type and probably could do
with inserting a back link to the index in the displayed files but hey
what do want for a Saturday afternoon ?


#!/usr/bin/perl -w

use CGI qw(:standard);

my $filename = param('filename');

my $directory = '/home/gellyfish';

my $me = script_name();

if ($filename)
  {
    $fullpath = "$directory/$filename";
    if ($filename =~ /html*$/ )
      {
        $content = 'text/html';
      }
    elsif ( -T $fullpath )
      {
        $content = 'text/plain';
      }
    else
     {
        $content = 'application/x-unknown';
     }
    if ( open(INFILE,$fullpath) )
      {
        print header(- type => $content);
        while(<INFILE>)
          {
            print $_;
          }
        close INFILE;
       }
     else
       {
         print header,start_html('Oops');
         print h1('Couldnt open the file');
         print end_html;
       }
  }
else
  {
    print header,start_html("Directory of : $directory");
    
    if ( opendir(DIR,$directory ))
      {
        @files = grep {/^[^.]/ && -f "$directory/$_"} readdir(DIR);
        closedir(DIR);
        print "<UL>\n";
        foreach (@files)
          {
            print "<LI>\n";
            print "<A HREF='$me?filename=$_'>$_</A>\n";
            print "</LI>\n";
          } 
        print "</UL>\n";
        print end_html;
      }
    else
      {
        print h1("Cant open the directory");
        print end_html;
      }
   }

/J\
-- 
Jonathan Stowe <jns@btinternet.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: 06 Mar 1999 10:12:34 -0500
From: Jonathan Feinberg <jdf@pobox.com>
To: rjk@linguist.dartmouth.edu (Ronald J Kimball)
Subject: Re: long lines in data file being cut
Message-Id: <m3aexqy7ml.fsf@joshua.panix.com>

rjk@linguist.dartmouth.edu (Ronald J Kimball) writes:

> 23_skidoo <23_skidoo@geocities.com> wrote:
> 
> > my problem is that the final line, the review of a gig can be any length
> > and when they get over 1833 characters, that's all that gets stored, the
> > rest is lost somewhere.
> 
> It's probably a bug in line 17 of the browser.
> 
> Or line 17 of the server.

>From the jargon file:

   random numbers: /n./ When one wishes to specify a large but random
   number of things, and the context is inappropriate for N, certain
   numbers are preferred by hacker tradition (that is, easily recognized
   as placeholders). These include the following:

     17
          Long described at MIT as `the least random number'; see 23.

-- 
Jonathan Feinberg   jdf@pobox.com   Sunny Brooklyn, NY
http://pobox.com/~jdf


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

Date: 6 Mar 1999 13:44:55 -0000
From: Jonathan Stowe <gellyfish@btinternet.com>
Subject: Re: Nonscalar Array Access?
Message-Id: <7brbgn$113$1@gellyfish.btinternet.com>

On Sat, 06 Mar 1999 06:11:56 -0600 Brent Michalski wrote:
> I was just playing around with arrays (fun huh?) and I decided to try to
> access the array elements WITHOUT using scalar context, like so:
> 
> print @array_name[2];
> 
> This *seemed* to work the exact same as:
> print $array_name[2];
> 
> I was just wondering if this _always_ works or not?  Also, WHY does this
> work.  
> 
> Everything I've read and been told about Perl has said that I need to
> access the elements in scalar context.  (My world is falling apart ;-)
> 
> Anyone out there have info/comments on this?
> 

When you are useing the locution:


> print @array_name[2];

It is an array *slice* - if you do something like this:


#!/usr/bin/perl -w


@array = qw(zero one two three four five six seven);

print @array[1],"\n";
print $array[1],"\n";
print @array[1,2,3,4],"\n";

You will get :

gellyfish@gellyfish:/home/gellyfish/clpmtest > slice.pl
Scalar value @array[1] better written as $array[1] at ././slice.pl line 6.
one
one
onetwothreefour

So yeah you can use an array slice in a scalar context but it *does*
generate that warning - which will happen whenever you try to access a single
item as a hash slice - a warning to catch typos for $array[1] I suppose.

/J\
-- 
Jonathan Stowe <jns@btinternet.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, 6 Mar 1999 15:58:56 +0100
From: "Sander Kruese" <S.Kruese<:nospam:>@wxs.nl>
Subject: NT scripting
Message-Id: <7brfru$5lh$1@reader2.wxs.nl>

Hai,

I am just beginning with Perl and have just finished the syntax part and i
want to go further. I want to be able to stop and start services and kill
processes in NT. Is this possible and if so, how can i do this. Is there a
site which goes into Perl for NT.

Thanks in advance,

Sander Kruese
S.Kruese<nospam>@wxs.nl

---




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

Date: 6 Mar 1999 14:44:54 GMT
From: ran@netgate.net
Subject: Re: Perl & OS/2: problems with makefile.pl & makemaker
Message-Id: <7brf16$rr$1@remarQ.com>

In <wzgSQd1pdrdd-pn2-y5DWzr7I9L99@localhost>, erikh@nospam.com (Erik Huelsmann) writes:
>
>Before, I had perl 5.004_?? for OS/2 (I think). When trying to run 
>Makefile.pl (for any package), it crashed on me. So, after a while, I 
>decided to see if there is a newer version of it somewhere. I found 
>perl 5.005_53 for OS/2 through CPAN.
>
>Now when I run makefile.pl (for any package) it still crashes.

Does this sound like your problem?  This is a quote from an email I send
Ilya a few weeks ago:

 I'm unable to install modules from CPAN,  because some parts of the system
 understand the insertion of the revision in the library paths, and some
 do not.  As a result,  trying to do a "perl Makefile.PL"  fails with:

   Error: Unable to locate installed Perl libraries or Perl source code.

      ...

   (You get this message, because MakeMaker could not find
            "e:/PERLLIB/LIB/os2/CORE/perl.h")


[end quote]

Assuming that's it,  the cause is a small bug in the code to support the
method Ilya came up with to allow multiple versions to co-exist 
(part of which involves using multiple sub-directories off
"/perllib/lib").

The edit_cfg.pl script is replacing various occurences of
"f:/perllib/lib/5.00553" (the "perl root" directory on Ilya's system)
with "e:/perllib/lib" (or whatever you told the install program to use)
in config.pm, but the install program only changes the "f:/perllib/lib"
part in the paths for unzipping.  So,  parts of config.pm are "one node 
short of a full path"  ;-)

I got around it by hand-editing config.pm,  inserting the missing 
"/5.00553"s.  I think all the canges were pretty obvious,  but,  if you
want it, drop me an email, and I'll send you a diff.

NOTE:  this only fixes the symptom,  but I decided I needed a little 
more experience before tackling the cause (in edit_cfg.pl).

Ran




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

Date: Sat, 06 Mar 1999 11:30:35 -0500
From: Dave Glass <dglass@istar.ca>
Subject: Speed of running from command line?
Message-Id: <36E1582A.7D28673@istar.ca>

I have a script that searches for matches in a large text file(8MB) and
output is only one word. When I run it from the command line the results
show in about 4 seconds. When I run it from my HTML page it takes about
12 sec.
I am calling the program the same way in each method.
I don't need help with the code, I will be able to figure it out if it
is
Is just need to know if calling a program from the command line will
always be faster or if there is a different way of calling it from my
page.

Here is how I am calling it(although I don't think this is the problem)
command line --> perl /docs/count.pl
html--> <a href = '/docs/count.pl'>run count</A>
Thanks
    Dave.

This is a scalled down version of the code for those who want to see it;



$count = 0;
open (FH, "<$filepath");
 while(<FH>)
 {
    chomp();
      $count++;
       if ($_ =~ /$count/)
      { last; }
 }
 print $count;
close(FH);



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

Date: Sat, 06 Mar 1999 18:19:46 GMT
From: scott@quick-silver.demon.co.uk (Scott Porter)
Subject: Upload file without CGI.pm - possible?
Message-Id: <36e16dfb.29196808@news.demon.co.uk>

I'm new to Perl, and wish to use it to allow file uploads to my site.
I've learnt enough to extract info about the file being uploaded (with
path from remote machine if it's needed), have opened a local file on
the server to write to and write info after the form "header info" into
the server file.

This all seems to work fine for a text file, but with binary, I just
get a few characters and that's it! I'm assuming that Perl is interpreting
some binary character as the EOF marker or something and closing the
connection?

Anyway, Searching around I find most people use CGI.pm and having
located it I tried to install it on my Win'98 machine (I'm currently
using the sambar4.2 web server with its own version of Perl - reported
to be version 5.004_02 for windows platform) but couldn't as I don't have
"makemaker". Chances are I'm not going to be allowed to compile new perl
modules on the server I'm setting up, and I really don't want to waste 
time writing a script that will not work on the "live" site, so is there
a way to accept a binary file without CGI.pm?

-- 
Scott       < http://www.quick-silver.demon.co.uk/ >
       Dynamic site: DHTML games/music/general eye candy
              
Stop press: DHTML zone spotlight site March '99 :-)
             <http://www.dhtmlzone.com/spotlight/>


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

Date: Sat, 06 Mar 1999 15:59:19 GMT
From: chames@my-dejanews.com
Subject: Re: Verifying URL's with perl.
Message-Id: <7brjcj$1lj$1@nnrp1.dejanews.com>

In article <7bpk52$f0m$1@nnrp1.dejanews.com>,
  sidney_roberts@my-dejanews.com wrote:
>   I have a list of url's and I need to check three things.  First, did I get
> a response back from the server.  Second, was the file found or not?  Third
> (and this is important), was the response that I got back binary or text
> data?
>
>    Right now, I'm doing it this way:
>
> #--
> for ($pic_count = 0; $pic_count < 100; $pic_count++)
> {
>   $pic_url = $pic_array[$pic_count];
>   $agent    = LWP::UserAgent->new();
>
>   print "TESTING: $pic_url";
>   $request  = HTTP::Request->new('HEAD', $pic_url);
>   $response = $agent->request($request);
>
>   $result = $response->code;
>
>   if ($result != '200')
>   {
>     print " not found ($result).\n";
>   } else {
>     print " ", $result, "\n";
>   }
> }
> #---
>
>   There's a few problems with this, though.  First, it's really slow.  I think
> it's because it's downloading the whole file (I'm requesting binary files)
> before it gives a response or not.  What I'd like to do is just download the
> first 64 bytes or so and check that data.  Secondly, can I assume that 200 is
> the "everything was cool" response?  Also, how would I go about setting the
> timeout time before it returns an error?
>
>   Thanks in advance for any help you can give.


Hello,

I'd use the following:

  use LWP::UserAgent;  my $ua = LWP::UserAgent->new;  $ua -> timeout(10); 
#in seconds  $ua -> max_size(1);  # this should be max size in kB of document
(text,img, whatever) - but it doesn't work correctly :-(

  my $req = HTTP::Request->new('HEAD',"$url");


    if ($res->is_success) {   # because not only 200 is ok
        #print "ok $i - ".$res->code." \n";
    }
    else {
        #print "Error: " . $res->status_line . "\n";
    }



Regards,

    Peter

-----------== Posted via Deja News, The Discussion Network ==----------
http://www.dejanews.com/       Search, Read, Discuss, or Start Your Own    


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

Date: Sat, 06 Mar 1999 17:06:39 GMT
From: akonopka <akonopka@mtco.com>
Subject: Want to learn Perl
Message-Id: <36E15FBE.131D8D67@mtco.com>

Hello,

I was looking for information on Websites or Books that may help me get
started learning Perl.  Unfortunately, I run on a windows platform at
home, but I do have the option of using my ISP's services in Unix.  I
would like to develop under both platforms.  My background is C and
mostly VB, but I believe that Perl can be a better solution to Web
development that using Java.  

If anyone has comments on Java vs Perl please let me know, I know Java
is the hot topic, but it is still pretty slow over the net.

Thanks


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

Date: 6 Mar 1999 17:00:25 -0000
From: Jonathan Stowe <gellyfish@btinternet.com>
Subject: Re: Web form using perl/cgi
Message-Id: <7brmv9$1g4$1@gellyfish.btinternet.com>

On Wed, 03 Mar 1999 18:30:11 -0800 Thana Letchumi wrote:
> Hi,
> 
>    I'm using perl5.0001 with cgi script to develop web forms. 

I'd be upgrading that there is a CERT advisory out on that version of Perl I
think.

>                                                               I display
> records on the web form for update. The records are kept in perl dbm
> format. I need to add input type "submit" called "Next" to display the
> next range of data on the same form. How do I call back the same perl
> program which display the same page with different group of record
> display ?. Can this be done ?. 
>   

Ok.  A quick example that demonstrates how you *could* achieve paging - the
input data here is a Comma separated text file and there is no querying
going on but it should be an example to get you started - I cant say that
it would be particularly sensible if you were displaying vast amounts of
data but there you go - it *is* a quick hack whilst watching the Rugby:


#!/usr/bin/perl -w

use CGI qw(:standard);

my $items = 10;

my $start_item = param('start') || 0 ;

my $me = script_name();

print header,start_html;


if ( open(FILE,'phonebook.txt' ))
  {
     while(<FILE>)
       {
         chomp;
         my @stuff = split /,/,$_;
         push @data_array,\@stuff;
       }
     print "<TABLE>\n";
     foreach (@data_array[$start_item ... ($start_item + $items - 1)])
        {
          print Tr(td(@{$_})),"\n";
        }
     print "</TABLE>\n";
     $prev_items = $start_item - $items;
     $prev_items = 0 if ($prev_items < 0 );
     $next_items = $start_item + $items;
     $next_items = 0 if ($next_items > $#data_array);

     print "<TABLE WIDTH=100%>\n";
     print "<TR WIDTH=100%>\n";
     print "<TD WIDTH=50% ALIGN=left>\n";
     if ( $start_item > 0 )
       {
         print "<A HREF=$me?start=$prev_items>Previous Page</A>\n";
       }
     print "</TD>\n";
     print "<TD WIDTH=50% ALIGN=right>\n";
     if ( $next_items > 0 )
       {
         print "<A HREF=$me?start=$next_items>Next Page</A>\n";
       }
     print "</TD>\n";
     print "</TR>\n</TABLE>\n";
  }
else
  {
    print h1('Couldnt open file');
  }

print end_html; 


Anyhow I'm feeling upbeat because Wales beat France in the Five Nations :)

/\
-- 
Jonathan Stowe <jns@btinternet.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: 6 Mar 1999 13:49:57 -0000
From: Jonathan Stowe <gellyfish@btinternet.com>
Subject: Re: Your opinion on an HTML stripper regex
Message-Id: <7brbq5$119$1@gellyfish.btinternet.com>

On Sat, 06 Mar 1999 04:08:13 -0800 James F. Pine wrote:
> Hi, I am working on a regular expression that reads in a string that
> contains HTML formatting, and strips all the HTML tags except opening
> and closing bold, italic, underline, and paragraph tags. Eventually I
> want to add the font tag to the list, but for now, I have this:
> 

<snip code>

I dont suppose you saw the item in perlfaq9 <the autopost has just started
around agin so it will be a little whil before this comes back>:


=head2 How do I remove HTML from a string?

The most correct way (albeit not the fastest) is to use HTML::Parse
from CPAN (part of the libwww-perl distribution, which is a must-have
module for all web hackers).

Many folks attempt a simple-minded regular expression approach, like
C<s/E<lt>.*?E<gt>//g>, but that fails in many cases because the tags
may continue over line breaks, they may contain quoted angle-brackets,
or HTML comment may be present.  Plus folks forget to convert
entities, like C<&lt;> for example.

Here's one "simple-minded" approach, that works for most files:

    #!/usr/bin/perl -p0777
    s/<(?:[^>'"]*|(['"]).*?\1)*>//gs

If you want a more complete solution, see the 3-stage striphtml
program in
http://www.perl.com/CPAN/authors/Tom_Christiansen/scripts/striphtml.gz

=cut

/j\
-- 
Jonathan Stowe <jns@btinternet.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: 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 5074
**************************************

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