[13620] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 1030 Volume: 9

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Sun Oct 10 10:05:42 1999

Date: Sun, 10 Oct 1999 07:05:23 -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: <939564323-v9-i1030@ruby.oce.orst.edu>
Content-Type: text

Perl-Users Digest           Sun, 10 Oct 1999     Volume: 9 Number: 1030

Today's topics:
    Re: Anyone know Everysoft Everyauction cgi script and i <gellyfish@gellyfish.com>
    Re: Bug with localtime() in Perl 5.004 and 5.005 (M.J.T. Guy)
    Re: Das GlasPerlenspiel <nmorison@ozemail.com.au>
    Re: Do you now an affordable Perl editor for Windows NT <mike@crusaders.no>
        help! (one more time)... <acacia@online.no>
    Re: HELP! Why don't cookies work correctly with PERL... <gellyfish@gellyfish.com>
    Re: how to call a sub roght by form <gellyfish@gellyfish.com>
    Re: howto load modules to an ISP website? (David Efflandt)
    Re: Is there a good perl friendly text editor for WinNT <gellyfish@gellyfish.com>
    Re: NEWBIE QUESTION ON ORACLE <gellyfish@gellyfish.com>
    Re: Parsing Config File <gellyfish@gellyfish.com>
        Perl CGI msut send two PDF forms. Help! (Rob Cairns)
    Re: saving images <mike@crusaders.no>
    Re: saving images <dave@dave.org.uk>
    Re: saving images (Martien Verbruggen)
        search a file on a remote server <tf2@duke.edu>
    Re: search a file on a remote server (d.k. henderson)
    Re: serching flat file database <gellyfish@gellyfish.com>
    Re: Setting up Asctive Perl on Personal Web Server <gellyfish@gellyfish.com>
    Re: Shell and Perl have different $? (Philip 'Yes, that's my address' Newton)
    Re: Shell and Perl have different $? (Martien Verbruggen)
    Re: Simple flock question <dan@tuatha.sidhe.org>
    Re: Spreadsheets. (Bbirthisel)
        Trouble understanding HTML Parsing <webresearch@indy-soft.com>
    Re: Trouble understanding HTML Parsing <gellyfish@gellyfish.com>
    Re: trouble with hash (Martien Verbruggen)
    Re: Ubi nil vales...  1603   [1/2] <gellyfish@gellyfish.com>
    Re: Win 32 and PERL installation problems <gellyfish@gellyfish.com>
        Digest Administrivia (Last modified: 16 Sep 99) (Perl-Users-Digest Admin)

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

Date: 9 Oct 1999 11:31:21 -0000
From: Jonathan Stowe <gellyfish@gellyfish.com>
Subject: Re: Anyone know Everysoft Everyauction cgi script and its addons?
Message-Id: <7tn929$40o$1@gellyfish.btinternet.com>

On Fri, 8 Oct 1999 11:52:50 -0500 Jason Latek wrote:
> I am building a site and am trying to use everysoft's everyauction. I can
> get the basic script to work, but I want to use the addons. I am having
> trouble with most of them. Please let me know if you know how to configure
> them and how much you charge to do it.
> 

What did the author of the software say when you asked them ?

/J\
-- 
Jonathan Stowe <jns@gellyfish.com>
<http://www.gellyfish.com>
Hastings: <URL:http://dmoz.org/Regional/UK/England/East_Sussex/Hastings>


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

Date: 9 Oct 1999 15:11:22 GMT
From: mjtg@cus.cam.ac.uk (M.J.T. Guy)
Subject: Re: Bug with localtime() in Perl 5.004 and 5.005
Message-Id: <7tnluq$b52$1@pegasus.csx.cam.ac.uk>

Larry Rosler <lr@hpl.hp.com> wrote:
>In article <MPG.1266d2bf4e71e783989689@news.logica.co.uk> on Thu, 7 Oct 
>1999 16:55:19 -0400, shapirojNOSPAM@logica.com 
><shapirojNOSPAM@logica.com> says...
>> If I remember some obscure research I once did into time standards, I 
>> recall some standard allowing the possibility of 2 leap second being 
>> added at once. That's what the 61 is for.
>
>I think you are right about that, which is why the pedants put 61 into 
>the spec.  But it is wrong nevertheless, because it is understood that 
>there will never be a change of more than one leap second at a time, nor 
>more frequently than once every six months.
>
>I haven't found a definitive statement of this, though.

Nor have I yet, but I can report that it's only partly true.

>Here is one quote <http://campus.fortunecity.com/newton/98/second.htm>:
>
>"Whenever a difference of greater than 0.9 seconds is observed between 
>astronomical time and the atomic clock, the NIST adds a leap-second to 
>their official time signal.  Thus, the variance between the two is never 
>greater than 0.9 seconds.  A leap-second has been added almost every 
>year since 1972.  While it is theoretically possible that a second may 
>have to be subtracted at some point, according to the NIST this is not 
>likely to be necessary any time in the foreseeable future."

Actually, the authority is the International Earth Rotation Service (IERS)
based at the Observatoire de Paris.    (Wonderful name, that   -   I have
this image of a team of people cranking a huge handle, to keep it all
going round.)    Web site is http://hpiers.obspm.fr/ .    NIST (and other
national standards organisations) just follow their instructions.

At http://hpiers.obspm.fr/iers/bul/bulc/BULLETINC.GUIDE I find



                             Bulletin C

   

        TAI is the atomic time scale of BIPM; its unit interval is exactly 
 one SI second at sea level. The origin of TAI is such that UT1-TAI is
 approximately 0 on 1958 January 1. The instability of TAI is about 6 orders
 of magnitude smaller than that of UT1.The terrestrial Dynamical Time TDT is
 presently defined as TAI + 32.184s. Discussion is taking place in the IAU 
 Working Group on Reference Systems (WGRS) about improved definition of time.
 
      
         UTC is defined by the CCIR Recommendation 460-4 (1986). It differs 
 from TAI by an integral number of seconds, in such a way that UT1-UTC stays
 smaller than 0.9s in absolute value. The decision to introduce a leap second
 in UTC to meet this condition is the responsability of the IERS. According to
 the CCIR Recommendation, first preference is given to the opportunities at the
 end of December and June,and second preference to those at the end of March
 and September. Since the system was introduced in 1972 only dates in June and
 December have been used.
   

So leap seconds can in principle occur every 3 months rather than 6.   But
that won't in practice happen till long after our lifetimes.

Authority for the "only one leap second" is presumably to be found in the
CCIR recommendation.    I'll leave someone else to track that down.


Mike Guy


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

Date: Sun, 10 Oct 1999 00:43:04 +1000
From: "Neale Morison" <nmorison@ozemail.com.au>
Subject: Re: Das GlasPerlenspiel
Message-Id: <FyIL3.739$D33.1403@ozemail.com.au>

Mark-Jason Dominus <mjd@op.net> wrote in message
news:7tlo0g$pho$1@monet.op.net...
> [Mailed and Posted]
>
> I implemented a CGI version of this two or three years ago.
> At your request, I revived the code.
>
> http://www.plover.com/cgi-bin/mjd/gp.cgi
>
> Best regards,
>
Thanks Mark-Jason. A simple and elegant answer to my entirely facetious
question. So the World Wide Web is the Glass Bead Game, and the various WWW
and Internet Perl modules are a gameboard on which it can be played.




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

Date: Sun, 10 Oct 1999 13:47:10 +0200
From: "Trond Michelsen" <mike@crusaders.no>
Subject: Re: Do you now an affordable Perl editor for Windows NT
Message-Id: <IY_L3.2838$nU4.12895@news1.online.no>


Matt King <mattking@techie.com> wrote in message
news:7thmra$d0c$1@news.uk.ibm.com...
> Why not just use the Windows notepad.exe? Works fine for me......

I'd rather write Perl-programs with a chisel and a rock than with
notepad.exe

--
Trond Michelsen





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

Date: Sun, 10 Oct 1999 13:54:36 +0100
From: "Acacia" <acacia@online.no>
Subject: help! (one more time)...
Message-Id: <B6%L3.2842$nU4.12757@news1.online.no>

ok, i think i made myself a bit unclear last time....

the following code is for sorting and printing the top10 visited locations
(subdirectories within home.domain.com in this case...).
however, i'm not interested in the entire URL. I just want the last
directory
to be displayed. At the end of the code...

Content of 'npcount.db'

2|http://home.domain.com/meredith/|
1|http://home.domain.com/eddy/|
4|http://home.domain.com/lucas/|
1|http://home.domain.com/mista/|

# END

Content of 'top10.pl'

#!/usr/bin/perl
$data = '/usr9/home/acacia/public_html/home/cgi-bin/npcount.db';

open(DATA,"$data") || die "Open DATA Failed: $!\n";
@data = <DATA>;
close(DATA);

 foreach $line (@data) {
  chomp($line);

  ($number,$download) = split(/\|/,$line);

  $data[$x] = "$number||$download";

  $x++;
 }

 @data = sort { $b <=> $a } @data;

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

 for ($i=0; $i<10; $i++) {
  $link = $data[$i];

  if ($link ne "") {
   ($number,$download) = split(/\|\|/,$link);

    print "- <a href=\"$download\">$download</a><br>\n";
  }
 }

# END


This code results in the output...

- http://home.domain.com/lucas/
- http://home.domain.com/meredith/
- http://home.domain.com/eddy/
- http://home.domain.com/mista/


What I would like would look something like...

- /lucas/
- /meredith/
- /eddy/
- /mista/


Thanks in advance

Acacia




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

Date: 10 Oct 1999 10:10:57 -0000
From: Jonathan Stowe <gellyfish@gellyfish.com>
Subject: Re: HELP! Why don't cookies work correctly with PERL.........
Message-Id: <7tponh$59c$1@gellyfish.btinternet.com>

On Fri, 8 Oct 1999 22:03:54 +0200 Matt King wrote:
> 
> If I call the script *directly* with the browser the script sends the cookie
> to the browser, but if I put a redirect header in a html file to point to
> this scipt, or change the script into an ssi (or or or), the cookie is not
> sent. There is no error from the server and the script does execute, just
> the cookie is not sent. Why the difference? Same script. What do I need to
> change to make this work as a ssi and a cgi?
> 

Then this is not a Perl question is it ?  I would ask in a more appropriate
group such as comp.infosystems.www.authoring.cgi

[followups set]

/J\
-- 
Jonathan Stowe <jns@gellyfish.com>
<http://www.gellyfish.com>
Hastings: <URL:http://dmoz.org/Regional/UK/England/East_Sussex/Hastings>


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

Date: 10 Oct 1999 11:00:48 -0000
From: Jonathan Stowe <gellyfish@gellyfish.com>
Subject: Re: how to call a sub roght by form
Message-Id: <7tprl0$5cf$1@gellyfish.btinternet.com>

On Sun, 10 Oct 1999 00:28:01 +0200 Yuval Hamberg wrote:
> hi,
> I want that the user will enter his password in a cgi output like this:
> <html><body>
> <h1>Password?</h1><form method="POST">
> <input type="hidden" name="action" value="main">
> <input type="password" name="password"><br>
> <input type="submit" value=" Enter ">
> </form></body></html>
> 
> than the cgi will do:
> if ($FORM{'action'}) { &checkpassword; }
> if ($FORM{'action'} eq "main") { &main; }
> 
> But that dosent work. i lerned that i sould put this in before:
> 

<snip nasty CGI parsing code>

> But i don't know excekly what it does and not why he does it. anyway it
> still wont work...
> 

That code is used to extract and decode the CGI parameters and it or
its equivalent is required in any CGI program that uses parameters.

OK firstly it is generally recommended to be using the module CGI.pm
to do the parsing of the CGI parameters.  This module is standard with
all recent releases of Perl so it should be present on your installation.

Here is a quick example that does the equivalent of what you seem to be
doing but using CGI.pm and using a more robust method of calling 
subroutines based on user input:


#!/usr/bin/perl -w

use strict;
use CGI qw(:standard);

my $default_action = 'main';

my %dispatch = (
                 main    => \&main,
                 add     => \&add,
                 remove  => \&remove
                );

my $action = param('action') || $default_action;

if( ref( $dispatch{$action} )  eq 'CODE')
  {
    $dispatch{$action}->();
  }
else
  {
    $dispatch{$default_action}->();
  }

sub main
{
   print header,
         start_html(-title => 'Main Function'),
         h1('Main Function'),
         end_html;
}
   

sub remove
{
   print header,
         start_html(-title => 'Remove Function'),
         h1('Remove Function'),
         end_html;
}

sub add
{
   print header,
         start_html(-title => 'Add Function'),
         h1('Add Function'),
         end_html;
}

Of course you will have to fill the bodies of the subroutines in yourself.
You will notice that most of the work of deciding which subroutine to call
is done via the %dispatch hash and the code references that are its
values - you might want to read the perlref manpage to find more about
references and their use - you might also want to look at the perlsub
manpage.

HTH

/J\
-- 
Jonathan Stowe <jns@gellyfish.com>
<http://www.gellyfish.com>
Hastings: <URL:http://dmoz.org/Regional/UK/England/East_Sussex/Hastings>


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

Date: 10 Oct 1999 00:51:46 GMT
From: efflandt@xnet.com (David Efflandt)
Subject: Re: howto load modules to an ISP website?
Message-Id: <slrn7vvopo.3ul.efflandt@efflandt.xnet.com>

On Sat, 09 Oct 1999 17:38:07 -0500, Dan Baker <dtbaker@busprod.com> wrote:
>I have a website that needs to use the optional module Image/Size.pm and
>my ISP is reluctant to load it for some reason. I have been attempting
>to copy required files and create a "site" for optional modules in my
>cgi-bin dir, but I must be missing copying or editting some pieces for
>the auto-loader or something because I cant get things to work
>correctly.
>
>Is there a reasonably easy way to upload a module like this (things that
>are normally installed to /usr/bin/site ) to a user cgi-bin site and
>configure it?

I am not familar with that particular module or whether it involves any
binaries, but it is simple if the module is just Perl code.  For example
to install MIME::Lite I simply created my own 'site_perl' dir.  Made a
MIME dir there and put Lite.pm in that.  Then a 'use lib' statement will
unshift your path to the @INC search paths:

use lib '/full_path_to_my/site_perl';
use MIME::Lite;		# searches for MIME/Lite.pm in my site_perl

I did similarly for Mail::Sendmail on a free site that has Unix sendmail
disabled due to spammers and it works fine.

>-- 
>Thanx, Dan
>
># If you would like to reply-to directly, remove the - from my username
>* no spam please... regulated by US Code Title 47, Sec.227(a)(2)(B)  *

-- 
David Efflandt  efflandt@xnet.com  http://www.xnet.com/~efflandt/
http://www.de-srv.com  http://cgi-help.virtualave.net/
http://thunder.prohosting.com/~cv-elgin/


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

Date: 9 Oct 1999 11:38:53 -0000
From: Jonathan Stowe <gellyfish@gellyfish.com>
Subject: Re: Is there a good perl friendly text editor for WinNT?
Message-Id: <7tn9gd$40u$1@gellyfish.btinternet.com>

On Fri, 08 Oct 1999 15:14:50 +0200 Hauk Langlo wrote:
> Hi there. I'm sure many of you will suggest I should install Linux and
> use eMacs as I hear this all day long at work. I do not however think
> I'm ripe for Linux just yet, but I do miss a lot of the fancy functions
> in editors like eMacs. I'm currently using Ultra Edit 6.00a wich is good
> in many ways. I do however miss important things like function block
> deflating or function jumping along with a more effective auto indenting
> function. Colour coding for Perl is also a must. I would be very happy
> if anyone know about an editor that will let me do that and even more
> happy if you would reply by mail : )
> 

Please see:

<http://www.perl.com/reference/query.cgi?editors>

Before the usual boring thread about peoples editor preferences begins.

/J\
-- 
Jonathan Stowe <jns@gellyfish.com>
<http://www.gellyfish.com>
Hastings: <URL:http://dmoz.org/Regional/UK/England/East_Sussex/Hastings>


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

Date: 9 Oct 1999 11:48:32 -0000
From: Jonathan Stowe <gellyfish@gellyfish.com>
Subject: Re: NEWBIE QUESTION ON ORACLE
Message-Id: <7tna2g$41g$1@gellyfish.btinternet.com>

On Fri, 08 Oct 1999 11:07:48 -0500 Jerry Preston wrote:
> I am new at this.  I am using Perl/CGI to access Oracle.  In following code:
> 
>       insert into twroot.scrap_status( C_REMOVED_BY, C_REMOVED_NAME,
>           C_REMOVED_REASON, c_removed_date )
>       values( $Emp_Number, $Emp_Name, $Reason, $c_date );
> 
> gives the following error:
> 
> Software error:
> 
> syntax error at /pdeweb/dm5pde/htdocs/cgi-pde/jerryp/insert.pl line 18, near
> ") values" syntax error at
> /pdeweb/dm5pde/htdocs/cgi-pde/jerryp/insert.pl line 33, near ") values"
> 
> What am I doing wrong?
> 

By the looks of things you are trying to execute an sql statement in a 
perl program.

Assuming you are using DBI and you have an open database handle in $dbh
then you should be doing something like:

my $statement =<<EOSQL;
insert into twroot.scrap_status( C_REMOVED_BY, C_REMOVED_NAME,
           C_REMOVED_REASON, c_removed_date )
       values( ?, ?, ?, ? )
EOSQL

my $statementhandle = $dbh->prepare($statement);

$statementhandle->execute($Emp_Number, $Emp_Name, $Reason, $c_date);

/J\
-- 
Jonathan Stowe <jns@gellyfish.com>
<http://www.gellyfish.com>
Hastings: <URL:http://dmoz.org/Regional/UK/England/East_Sussex/Hastings>


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

Date: 10 Oct 1999 12:11:25 -0000
From: Jonathan Stowe <gellyfish@gellyfish.com>
Subject: Re: Parsing Config File
Message-Id: <7tpvpd$5im$1@gellyfish.btinternet.com>

On Sun, 10 Oct 1999 04:36:12 GMT Chris Fairbanks wrote:
> I am trying to parse an apache config file to print out to a file the
> virtualwebsite:homedirectory.  I have searched but cannot find anyway
> to do it.  Any help would be appreciated.
> 

<snip httpd.conf>

> --------------
> I need to get a list like this
> 
> www.joebob.com:/home/j/joebob
> www.joe.com:/home/j/joe
> www.bob.com:/home/b/bob
> 

Well I dont think that what you want to is particularly useful in a general
sense so I present here a quick way of getting all of the Directives and
values for VirtualHost from an httpd.conf (I have deliberately ignored
any <Directory> sections (and probably should for any other embedded sections
but the httpd.conf I tested with didnt have any)):


#!/usr/bin/perl -w

use strict;


my %virthosts;
my $invirthost;
my $currhost;
my $skipit;

while(<>)
{
  chomp;
  if (/<VirtualHost\s+([^\s>]+)\s*>/)
    {
     $invirthost++;
     $currhost = $1;
    }
  elsif ( m#</VirtualHost>#)
    {
      $invirthost = 0;
    }
  elsif ( $invirthost )
    {
      $skipit++,next if ( /<Directory/ );
      $skipit = 0, next if (m#</Directory#);
      next if ($skipit);  
      s/^\s+//g;
      my ($attr,$value) = split / /,$_,2;
      $virthosts{$currhost}->{$attr} = $value;
    }
}

my $host;
foreach $host (keys %virthosts)
 {
   print $host,":\n";
   my $config;
   foreach $config (keys %{$virthosts{$host}})
     {
       print "\t$config :\t $virthosts{$host}->{$config}\n";
     }
}

Of course to do what you want you will want to replace the last foreach with:

my $host;
foreach $host (keys %virthosts)
{
  print $virthosts{$host}->{'ServerName'},':',
        $virthosts{$host}->{DocumentRoot},"\n";
}

/J\
-- 
Jonathan Stowe <jns@gellyfish.com>
<http://www.gellyfish.com>
Hastings: <URL:http://dmoz.org/Regional/UK/England/East_Sussex/Hastings>


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

Date: Sun, 10 Oct 1999 11:34:12 GMT
From: robkc@home.com (Rob Cairns)
Subject: Perl CGI msut send two PDF forms. Help!
Message-Id: <robkc-1010990733260001@192.168.2.2>

I have a forms application that uses PDF/FDF and I have a submit in one 
form that has to do two things; it must update the present form, and then it 
must open a new form.
I can do one of the two but not both. 
Basically it works like this.
The user is working in a PDF form, and wants to add a new sheet to his
form (it's actually a different PDF than the first). Each page has "n of n
pages" on them. So I have to update the first page from 1 of 1 to 1 of 2,
then I have to 
open the second form up and send it 2 of 2. 
The way FDF works is that you send it the URL of the pdf file in response
to the submit if you want a new PDF to come up and you send no URL if you
want to 
continue to use the first sheet.

So basically I'm doing something like this (syntax may not be correct
cause I'm doing this from memory...)

print "Content-type: application/vnd.fdf\n\n"
print $first_form_with_update_page_1;

print  "Content-type: application/vnd.fdf\n\n"
print $second_new_form_page_2;


What I get is the second page coming up but the first does not update!

If, however, I turn off buffering, I get the first updating, but no new file.

Are you supposed to send something at the end to signify the end of the page?
Are you supposed to close then open STDOUT? & how would you do that??

Help! I am sure this must be possible, but I don't know what I am doing wrong! 

This should be analogous to "pushing updates " to a web page so it MUST be
possible! 

Any & all help would be greatly appreciated!

   Rob Cairns


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

Date: Sun, 10 Oct 1999 13:43:35 +0200
From: "Trond Michelsen" <mike@crusaders.no>
Subject: Re: saving images
Message-Id: <mV_L3.2836$nU4.12564@news1.online.no>


Ron Seifenberger <troja2977@my-deja.com> wrote in message
news:7tpr6n$shn$1@nnrp1.deja.com...
> $page = get "http://www.perl.com/images/source_ii.gif";
> @lines =  $page;

What is this good for?

> binmode(DATEI);
> open (DATEI, ">picture.gif");
> foreach $line (@lines) {print DATEI $line;}
> close(DATEI);

I think you set binmode too early. I'm pretty sure you have to set binmode
on an already open filehandle.

open (DATEI, ">picture.gif");
binmode(DATEI);
print DATEI $page;
close(DATEI);

--
Trond Michelsen




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

Date: Sun, 10 Oct 1999 14:30:31 +0100
From: Dave Cross <dave@dave.org.uk>
Subject: Re: saving images
Message-Id: <HpQAOH7YohuBuiwLc2dcfa6CnSvm@4ax.com>

On Sun, 10 Oct 1999 10:53:12 GMT, Ron Seifenberger
<troja2977@my-deja.com> wrote:

>Hello,
>
>I have the following problem:
>I want to read a picture from a website and save it. It works with
>normal text but not with pictures (I work under Windows).
>I think some newlines or special characters get lost. Has someone an
>idea what is wrong with my script (or knows another script doing that?)
>
>Thanks,
>  Ron
>
>---------------------
>and here the program
>
>use LWP::Simple;
>
>$page = get "http://www.perl.com/images/source_ii.gif";
>@lines =  $page;
>binmode(DATEI);
>open (DATEI, ">picture.gif");
>foreach $line (@lines) {
>             print DATEI $line;
>                       }
>close(DATEI);

LWP::Simple has a getstore function that would seem to greatly
simplify what you're trying to do here.

use strict;
use LWP::Simple;

getstore 'http://www.perl.com/images/source_ii.gif', 'picture.gif';


Why make it any harder than it needs to be?

hth,

Dave...

--
Dave Cross <dave@dave.org.uk>
<http://www.dave.org.uk>


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

Date: 10 Oct 1999 13:42:58 GMT
From: mgjv@wobbie.heliotrope.home (Martien Verbruggen)
Subject: Re: saving images
Message-Id: <slrn8015rj.778.mgjv@wobbie.heliotrope.home>

On Sun, 10 Oct 1999 10:53:12 GMT,
	Ron Seifenberger <troja2977@my-deja.com> wrote:

> I want to read a picture from a website and save it. It works with
> normal text but not with pictures (I work under Windows).

> use LWP::Simple;
> 
> $page = get "http://www.perl.com/images/source_ii.gif";
> @lines =  $page;
> binmode(DATEI);
> open (DATEI, ">picture.gif");

These two are the wrong way around, and you should always check the
return code from a system call, like open.

open(DATEI, ">picture.gif") 
	or die "Cannot open picture.gif for write: $!"
binmode(DATEI);

But it might be even easier or better if you used the functions that
LWP::Simple provides for this.

# perldoc LWP::Simple
# perldoc -f binmode
# perldoc -f open

Martien
-- 
Martien Verbruggen                  | 
Interactive Media Division          | The gene pool could use a little
Commercial Dynamics Pty. Ltd.       | chlorine.
NSW, Australia                      | 


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

Date: Sat, 9 Oct 1999 11:14:19 -0400
From: Tao Fan <tf2@duke.edu>
Subject: search a file on a remote server
Message-Id: <Pine.SOL.3.91.991009111110.4206A-100000@teer23.acpub.duke.edu>

Hello, everybody,

I need to write a script that can ftp files from one server to another. 
The problem is, if only I know a filename on the remote server, but not 
the directory or the full path, how can I locate the file? I know I can 
use find() to search the file structure of the local server, can I do it 
remotely? Another question, can I chmod a file remotely? Any idea will be 
greatly appreciated. If possible, please show me some examples, Thx.

Tao


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

Date: Sat, 09 Oct 1999 15:37:22 GMT
From: dalekh@hotmail.com (d.k. henderson)
Subject: Re: search a file on a remote server
Message-Id: <8E5973BF1dkhenderson@207.14.236.97>

There is an info(?) file that has filenames along with directory paths on the 
ftp server.



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

Date: 10 Oct 1999 10:37:16 -0000
From: Jonathan Stowe <gellyfish@gellyfish.com>
Subject: Re: serching flat file database
Message-Id: <7tpq8s$5ap$1@gellyfish.btinternet.com>

On Sat, 09 Oct 1999 18:08:11 GMT lowdogg@my-deja.com wrote:
> I'm currently working on a script that serches a flat file database the
> database is really more like a list with two collums one collum is the
> persons first name the second collum is the persons last name, i'm try
> to creat a list that will search this data base and if the persons first
> and last name are present than I don't want it to print to the database
> casue that would just casue duplicates,and if the names are not present
> thatn I want it to print. I have tryed the grep function but that did't
> here is the source I have so far(by the way the first and last name will
> be entered via a form)
> 
> 
> open(DATA, ">>empdata.dat");
> 

opening file for append without checking for success.
also unintentional use of the special DATA filehandle.

> @b = <DATA>;

reading from a file that was previously opened for writing.

> foreach $n (@b)
> {
> if ($n eq "$FORM{'fname'}|$FORM{'lname'}")
> {

as you have it currently $n will have a line terminator on it which will
most likely not be on the end of $FORM{'lname'}.

> print DATA "$FORM{'fname'}|$FORM{'lname'}\n";
> }
> else
> {
> }
> }
> close(DATA);
> I am using the foreach method in this version but have also tryed the
> grep function as well
> please help thanks
> 

Its not really surprising this didnt work at all.

See the following - I have used CGI.pm as I dont where your %FORM is
defined and have *not* addressed any concurrency issues:


#!/usr/bin/perl -w

use strict;
use CGI qw(:standard);
use CGI::Carp qw(fatalsToBrowser);

open(DATAFILE,'thedatafile.txt') || die "Cant open file - $!\n";

chomp(my @data = <DATAFILE>);

close DATAFILE;

my $record = join '|',param('fname'),param('lname');

unless (grep /\Q$record\E/,@data )
{
  open(DATAFILE,'>>thedatafile.txt') || die "Cant open file to write - $!\n";
  print DATAFILE $record,"\n";
  close DATAFILE;
}

Of course this is most probably not the most efficient way of doing this
but it most closely mirrors what you were trying to do.

/J\
-- 
Jonathan Stowe <jns@gellyfish.com>
<http://www.gellyfish.com>
Hastings: <URL:http://dmoz.org/Regional/UK/England/East_Sussex/Hastings>


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

Date: 9 Oct 1999 11:34:38 -0000
From: Jonathan Stowe <gellyfish@gellyfish.com>
Subject: Re: Setting up Asctive Perl on Personal Web Server
Message-Id: <7tn98e$40r$1@gellyfish.btinternet.com>

On Sat, 9 Oct 1999 16:56:33 +1000 Kim Saunders wrote:
>>But if want a wise-ass answer I can give you a 2 step process:
>>
>>1) Delete MS PWS
>>2) Download Apache and install it.
> 
> 
> And then
> 
> 3) Delete Apache
> 4) Install TinyWeb!
> 

Wrong !!!

1) post question in comp.infosystems.www.servers.ms-windows

Questions about web-servers are never on topic here.

/J\

-- 
Jonathan Stowe <jns@gellyfish.com>
<http://www.gellyfish.com>
Hastings: <URL:http://dmoz.org/Regional/UK/England/East_Sussex/Hastings>


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

Date: Sun, 10 Oct 1999 12:20:13 GMT
From: nospam.newton@gmx.net (Philip 'Yes, that's my address' Newton)
Subject: Re: Shell and Perl have different $?
Message-Id: <38007e9e.70253337@news.nikoma.de>

On 8 Oct 1999 18:44:10 GMT, ilya@math.ohio-state.edu (Ilya
Zakharevich) wrote:

>> $ia = system("rcp $file_to_copy user\@machine:/path/$file_remote");
>> print "\$? = $?      \$ia = $ia \n";
>
>I think this is more or less equivalent to
>
>  (rcp file.x user@machine:/path/somedir/copy.x)
>
>Use multiarg-system() instead.

Does this imply that using multi-arg system puts rcp's exit status
into $?, whereas single-arg system puts the shell's exit status into
$? ? In that case, $? == 0 would (sort of) make sense for an rcp
failure; after all, the shell itself exited successfully (or does it
propage $? ?).

Cheers,
Philip
-- 
Philip Newton <nospam.newton@gmx.net>


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

Date: 10 Oct 1999 13:46:59 GMT
From: mgjv@wobbie.heliotrope.home (Martien Verbruggen)
Subject: Re: Shell and Perl have different $?
Message-Id: <slrn801633.778.mgjv@wobbie.heliotrope.home>

On Sun, 10 Oct 1999 10:24:27 GMT,
	Kragen Sitaker <kragen@dnaco.net> wrote:
> In article <37fee858.236621587@news.iprolink.ch>,
> Sam Carmalt <scarmalt@swconsult.ch> wrote:
> >kragen@dnaco.net (Kragen Sitaker) wrote:
> >>In other words, if you want the command's exit status -- what you get
> >>with sh or csh $? -- you want ($? >> 8) in Perl.
> >
> >Yes.  But I don't really care about the value.  I just need to know
> >whether the command ran successfully.
> 
> Well, most standard Unix commands return 0 on success or -1 on failure;
> a few return 0 on "nothing interesting", 1 on "something interesting",
> or -1 on failure; and there are some (e.g. the pieces of qmail) that
> have more elaborate schemes.

Just some pedantry: Most unix commands actually return 0 on success
and something positive on failure. The normal convention is that
anything that is not equal to 0 is an error, and indeed it is up to
the program to decide what those non-zero exit codes mean.

Do you have an example of a negative one? I can't say I ever saw one.

I have however seen programs that reversed this, for some odd reason.

Martien
-- 
Martien Verbruggen                  | 
Interactive Media Division          | Failure is not an option. It comes
Commercial Dynamics Pty. Ltd.       | bundled with your Microsoft product.
NSW, Australia                      | 


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

Date: Sun, 10 Oct 1999 13:31:27 GMT
From: Dan Sugalski <dan@tuatha.sidhe.org>
Subject: Re: Simple flock question
Message-Id: <Py0M3.239$IZ5.10792@news.rdc1.ct.home.com>

Warren Bell <wjbell@erasejps.net> wrote:
> If I use flock to lock files in my perl script but the machine it's
> running on doesn't have flock will the script still work, just not lock
> the file?

Nope. flock dies if it's not implemented on the platform you're on. So if
you want to be safe, wrap it in an eval.

However... Check the platform-specific docs for whatever system you're on.
At least some of them (VMS does, and I'm not sure about Win32) do support
file locking, just not flock. You may have other alternatives.

					Dan


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

Date: 10 Oct 1999 13:13:04 GMT
From: bbirthisel@aol.com (Bbirthisel)
Subject: Re: Spreadsheets.
Message-Id: <19991010091304.05076.00000455@ng-cl1.aol.com>

Hi Jonathan:

>I thought I had the ageing code of sc around here to hack on but it appears
>not.

That was my thought as well. The sc saved_data file is pure
ascii KEY=VALUE format, so parsing one would be very easy.
And you could put a shell command into a cell (e.g perl ...).

I have not needed to do either of these. But I DO have the
source (6.21 I think, with a few makefile mods to compile
on RedHat 5.2). Let me know if you want a copy.

-bill
Making computers work in Manufacturing for over 25 years (inquiries welcome)


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

Date: Sat, 09 Oct 1999 14:57:37 GMT
From: "Web Research" <webresearch@indy-soft.com>
Subject: Trouble understanding HTML Parsing
Message-Id: <BJIL3.6697$yg.196351@news.rdc1.tn.home.com>

I'm a bit stumped. I've written a script which accepts htm file uploads,
then takes the content and places it in a template for display. Right now I
know it is a severe no-no, but the htm upload is printed right between the
script-generated body tags, etc... html, head and all. Since html ignores
useless tags, this works *for now*.. Yes.. I realize it's a hack... I want
it to go away.

Ultimately I would like to extract all the markup between the <body ?>
</body> tags but am having great difficulty when it comes to ignoring the
characters and markup possible such as bgcolor=, topmargin, etc in my
regexp. I intend to conquer that, but have turned to modules since I have to
get this thing out the door and can no longer fiddle with it.

I've been looking through the HTML modules but none of them seem to say (in
english) "This will return all the HTML markup between the <body ?></body>
(or other) tags". I've seen parsing that returns just text, or attributes...
but nothing making the specific claim I am looking for. I've even found
markup in the O'Reilly books for (flawed) extraction between tags but I need
something that is pretty close to correct.

The end user will be using a 'DummySoft' client to build the html, so I know
I can avoid stuff like...

<body <!-- this is stupid --> bgcolor="#adskas">

Obviously, I've overlooked something here in my searching. Can someone help
me down the right path? Which module do I need?

Rusman




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

Date: 10 Oct 1999 10:03:33 -0000
From: Jonathan Stowe <gellyfish@gellyfish.com>
Subject: Re: Trouble understanding HTML Parsing
Message-Id: <7tpo9l$599$1@gellyfish.btinternet.com>

On Sat, 09 Oct 1999 18:11:47 GMT Web Research wrote:
> 
> James Tolley <jtolley@bellatlantic.net> wrote in message
> news:37FF7410.FDA5A7ED@bellatlantic.net...
>> Have you looked into HTML::Parser? I think it'll solve your problems.
>>
> I think Parser had a few speed issues I wished to avoid.
> 

Benchmark ?

/J\
-- 
Jonathan Stowe <jns@gellyfish.com>
<http://www.gellyfish.com>
Hastings: <URL:http://dmoz.org/Regional/UK/England/East_Sussex/Hastings>


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

Date: 10 Oct 1999 13:51:34 GMT
From: mgjv@wobbie.heliotrope.home (Martien Verbruggen)
Subject: Re: trouble with hash
Message-Id: <slrn8016bn.778.mgjv@wobbie.heliotrope.home>

On Sun, 10 Oct 1999 01:07:51 -0700,
	Larry Rosler <lr@hpl.hp.com> wrote:
> In article <slrn8008dg.36a.mgjv@wobbie.heliotrope.home> on 10 Oct 1999 
> 05:20:43 GMT, Martien Verbruggen <mgjv@wobbie.heliotrope.home> says...

> > @new_answer = @$answer{$question};
> > 
> > This will work. ...
> 
> Well, no, it won't.  I know you know this; you just took your eye off 
> the ball.  The answer he got, and which works, is:
> 
>   @new_answer = @{$answer{$question}};

You are right. Thanks for the correction.

That'll teach me to quickly finish posting while the 2 year old
daughter is demanding play time :)

Martien
-- 
Martien Verbruggen                  | 
Interactive Media Division          | Freudian slip: when you say one thing
Commercial Dynamics Pty. Ltd.       | but mean your mother.
NSW, Australia                      | 


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

Date: 9 Oct 1999 15:47:56 -0000
From: Jonathan Stowe <gellyfish@gellyfish.com>
Subject: Re: Ubi nil vales...  1603   [1/2]
Message-Id: <7tno3c$423$1@gellyfish.btinternet.com>

On 08 Oct 1999 21:27:04 -0400 Uri Guttman wrote:
>>>>>> "s" == scwdbw  <scwdbw@rec.uk> writes:
> 
>   s> If you feel, that you are absolutely happy, totally satisfied with
>   s> your accomplishments and your energy level is on the top, please,
>   s> disregard this mail......
> 
>   s> ....Otherwise, you may want to spend a few minutes reading the
>   s> attached letter and find something that could be very helpful to
>   s> you !
> 
> 
>   s> zbhlwqbyfhpbwreffrromtuifgzcbiyytpdkouvtmpfphzpwjqkpeprmkhnkirjhct
> 

I have noticed this before as well I think it is a way of driving down
the BI - anyone from the cabal reading who might wish to comment ?

> very interesting. i want to buy it or send you all my money and
> savings. where do i send my loot?
> 
> 
> anyone else notice this new breed of usenet spam? 
> 

No, I never saw the original post - I guess that either btinternet 
servers respond to control messages quicker or they implement some local
spam blocking which is wise to these gimmicks.

> die spammers die!!
> 

Absolutely.

/J\
-- 
Jonathan Stowe <jns@gellyfish.com>
<http://www.gellyfish.com>
Hastings: <URL:http://dmoz.org/Regional/UK/England/East_Sussex/Hastings>


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

Date: 10 Oct 1999 10:15:53 -0000
From: Jonathan Stowe <gellyfish@gellyfish.com>
Subject: Re: Win 32 and PERL installation problems
Message-Id: <7tpp0p$59f$1@gellyfish.btinternet.com>

On Sat, 09 Oct 1999 15:07:50 +0000 dedalus@pressroom.com wrote:
> Hi, my name is Mike and I am having a tough time getting Perl to run on
> my webserver. What I am running is Win 98 on a PIII with PWS 4.0  and
> Cold Fusion 4.0 installed. I have also installed ActivePerl build 520,
> and edited the registry by adding a .pl key under
> HKLM/system/currentcontrolset/services/w3svc/parameters/scriptmap. This
> key refers to [the current location of perl on my drive] %s %s, and this
> should get the program to work through PWS. But what is happening is the
> page times out after about 30 seconds and the following error is
> generated in the PWS log:
> 
> 10/8/99, 23:39:13, The script started from the URL '/SCRIPTS/hello.pl'
> with parameters '' has not responded within the configured timeout
> period.  The HTTP server is terminating the script. [0]
> 
> 
> I've tried running the script with a ? after it, I've tried running it
> through the DOS shell (where it works fine), and I've even tried
> offering the computer money to get it to tell me what the problem is.
> Now, after my PC has extorted piles of cash from my wallet and left me a
> cold and hungry scripter with PERL not working as a web service, I turn
> to you kind people in the hopes that someone, anyone can help me with
> what should be a simple installation. Please, please help!
> 

This almost certainly a server configuration issue that is not directly
related to Perl.  Have you read the  Win32 FAQ that was installed with
ActivePerl - this has an entire section on configuring various web servers
to work with Perl.  If the answer can't be found in there then I would 
suggest that you pose this question to a newsgroup that is concerned with
server configuration such as comp.infosystems.www.servers.ms-windows.

[followups set]

/J\
-- 
Jonathan Stowe <jns@gellyfish.com>
<http://www.gellyfish.com>
Hastings: <URL:http://dmoz.org/Regional/UK/England/East_Sussex/Hastings>


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

Date: 16 Sep 99 21:33:47 GMT (Last modified)
From: Perl-Users-Request@ruby.oce.orst.edu (Perl-Users-Digest Admin) 
Subject: Digest Administrivia (Last modified: 16 Sep 99)
Message-Id: <null>


Administrivia:

The Perl-Users Digest is a retransmission of the USENET newsgroup
comp.lang.perl.misc.  For subscription or unsubscription requests, send
the single line:

	subscribe perl-users
or:
	unsubscribe perl-users

to almanac@ruby.oce.orst.edu.  

| NOTE: The mail to news gateway, and thus the ability to submit articles
| through this service to the newsgroup, has been removed. I do not have
| time to individually vet each article to make sure that someone isn't
| abusing the service, and I no longer have any desire to waste my time
| dealing with the campus admins when some fool complains to them about an
| article that has come through the gateway instead of complaining
| to the source.

To submit articles to comp.lang.perl.announce, send your article to
clpa@perl.com.

To request back copies (available for a week or so), send your request
to almanac@ruby.oce.orst.edu with the command "send perl-users x.y",
where x is the volume number and y is the issue number.

For other requests pertaining to the digest, send mail to
perl-users-request@ruby.oce.orst.edu. Do not waste your time or mine
sending perl questions to the -request address, I don't have time to
answer them even if I did know the answer.


------------------------------
End of Perl-Users Digest V9 Issue 1030
**************************************


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