[17270] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 4692 Volume: 9

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Sun Oct 22 21:05:34 2000

Date: Sun, 22 Oct 2000 18:05:10 -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: <972263109-v9-i4692@ruby.oce.orst.edu>
Content-Type: text

Perl-Users Digest           Sun, 22 Oct 2000     Volume: 9 Number: 4692

Today's topics:
    Re: A Simpler perlish way <MBalenger@worldnet.att.net>
    Re: branch coverage testing <ianb@ot.com.au>
        Calling CGI (counter) from HTML <blah.xyathn@yahoo.com>
    Re: Calling CGI (counter) from HTML <elephant@squirrelgroup.com>
    Re: CGI and SHTML <elephant@squirrelgroup.com>
    Re: CGI and SHTML <flavell@mail.cern.ch>
    Re: executing UNIX-commands on remote systems (mailq) <ianb@ot.com.au>
        File locking <g.soper@soundhouse.co.uk>
    Re: File locking (Mark-Jason Dominus)
    Re: help printing variable in table <jeff@vpservices.com>
    Re: how to debug perl script? <elephant@squirrelgroup.com>
        IPC::Open2 problem, process doesn't see input (Darren Stuart Embry)
        local file handle <MY_FILE> percy_yip@my-deja.com
    Re: local file handle <MY_FILE> (Mark-Jason Dominus)
    Re: local file handle <MY_FILE> <bwalton@rochester.rr.com>
        Out of Memory - ActivePerl 5.6/Win98 SE 192MB RAM <grichards@flashcom.net>
    Re: redirection Location help <elephant@squirrelgroup.com>
    Re: Send Mail and Pass Data to URL <elephant@squirrelgroup.com>
    Re: Send Mail and Pass Data to URL <elephant@squirrelgroup.com>
    Re: Stripping non-contents from HTML snippet <elephant@squirrelgroup.com>
    Re: textfield length (Mark-Jason Dominus)
        Unwarranted Warning andre_sanchez@my-deja.com
    Re: Unwarranted Warning (Mark-Jason Dominus)
    Re: Unwarranted Warning <elephant@squirrelgroup.com>
    Re: Win32::OLE ??? <bwalton@rochester.rr.com>
        Digest Administrivia (Last modified: 16 Sep 99) (Perl-Users-Digest Admin)

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

Date: Sun, 22 Oct 2000 23:11:51 GMT
From: "Michael Balenger" <MBalenger@worldnet.att.net>
Subject: Re: A Simpler perlish way
Message-Id: <XuKI5.3072$UL.186466@bgtnsc07-news.ops.worldnet.att.net>

>
>         It was almost correct except 2000 is a leap year so today is 288
> instead
> of the 287 your answer gave.

I got caught by that, too.

You're seeing a difference of bases, not a leap-year bug.

The element you're referencing is 0-based, not 1-based.  On the other hand,
the Unix date(1) command returns a 1-based julian date.  It's not *obvious*
from the documentation that the $yday is zero-based.  It is obvoius from the
documenation (although annoying in many applications) that $mon and $wday
*are* 0-based.


$ perl -e 'print((localtime())[7], "\n")'
295
$ date +%j
296
$









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

Date: Mon, 23 Oct 2000 10:34:50 +1100
From: Ian Boreham <ianb@ot.com.au>
Subject: Re: branch coverage testing
Message-Id: <39F37999.BB23AC9B@ot.com.au>

"Randal L. Schwartz" wrote:

> >>>>> "Michael" == Michael Carman <mjcarman@home.com> writes:
>
> Michael> Matt Leinhos wrote:
> >>
> >> Could anyone tell me if there is a branch coverage test program/script
> >> for perl? I am interesting in testing all the branches of a perl
> >> script I've been working on.
>
> Michael> Not that I'm aware of. I'd like one too, but I have a bad feeling that
> Michael> Perl's syntax is a bit too flexible to make such a thing feasible.
>
> That's why you hook into it after the parser, using the debugger
> hooks, as Devel::Coverage and Devel::DProf have already done.

One of the things that worries me is that since you can dynamically create code
and fool with the symbol table, you just can't guarantee that you are covering all
the program, because what the program is is not static. I like the idea of testing
all my code, and I like being able to create new code on-the-fly, but the
combination gives me indigestion.

I can't see any general solution...you just have to know the sorts of things your
progrm is trying to do, and try to ensure you cover any bits you could reasonably
expect to appear at run-time.

Regards,


Ian




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

Date: Sun, 22 Oct 2000 18:28:12 -0400
From: "Corey French" <blah.xyathn@yahoo.com>
Subject: Calling CGI (counter) from HTML
Message-Id: <XNJI5.17633$cO4.634420@nntp3.onemain.com>

I'm sure this has been discussed here before but I've only been subscribed
for three days .. and I know how to call an html file from a cgi, however
what I want to do is put a counter in the middle of a page so I need to be
able to call the cgi script from within the html file.  I tried:

<SCRIPT LANGUAGE="CgiScript">
 <!--#include file="count.cgi"-->
 </SCRIPT>

and

<SCRIPT LANGUAGE="PerlScript">
<!--#include file="count.cgi"-->
 </SCRIPT>

neither of which worked, if you have any ideas

Thanks,

Corey




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

Date: Mon, 23 Oct 2000 10:57:12 +1000
From: jason <elephant@squirrelgroup.com>
Subject: Re: Calling CGI (counter) from HTML
Message-Id: <MPG.145e37efdd8feeef989837@localhost>

Corey French wrote ..
>I'm sure this has been discussed here before but I've only been subscribed
>for three days .. and I know how to call an html file from a cgi, however
>what I want to do is put a counter in the middle of a page so I need to be
>able to call the cgi script from within the html file.  I tried:
>
><SCRIPT LANGUAGE="CgiScript">
> <!--#include file="count.cgi"-->
> </SCRIPT>
>
>and
>
><SCRIPT LANGUAGE="PerlScript">
><!--#include file="count.cgi"-->
> </SCRIPT>
>
>neither of which worked, if you have any ideas

this has nothing to do with Perl .. you should ask your question in a 
more appropriate group

BUT

before you do .. use a newsgroup search utility like that found at

  http://www.deja.com/usenet/

to search for similar questions to yours .. also locate and read any 
FAQs associated with the newsgroup before posting

the group you're after is

  comp.infosystems.www.authoring.cgi

-- 
  jason -- elephant@squirrelgroup.com --


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

Date: Mon, 23 Oct 2000 10:53:21 +1000
From: jason <elephant@squirrelgroup.com>
Subject: Re: CGI and SHTML
Message-Id: <MPG.145e370ebb3f9f26989836@localhost>

Greg Griffiths wrote ..
>I have been quite happily returning text/html from a CGI script, but
>would like to return some SSI includes in my file, using a content type
>of text/shtml fails, any ideas ?

most web servers process a file only once .. and the output of that 
processing is sent directly to the browser .. so what's happening with a 
CGI program is this

  1. the server recognises that the browser has requested a special file

  2. the appropriate handler is called for that file (in our case - that
     will be a Perl interpreter of some sort)

  3. the output of step 2 is sent directly to the browser

so .. if you put SSI tags in your output you can see that they're 
completely ignored by the server - and hence no Server-Side Includes are 
processed .. what you need to happen is

  1. the server recognises that the browser has requested a special file

  2. the appropriate handler is called for that file (in our case - that
     will be a Perl interpreter of some sort)

  3. the output of step 2 is further checked by the server to ensure
     that no further processing is requred - if more processing is
     required then repeat step 2

  4. when no further processing is required send the output to the
     browser

if you're desperate for this behaviour - then for Apache (compiled to 
use chaining) there is a Perl module that utilises the mod_perl 
interface for chaining various handlers together .. I'm not sure on its 
release status at present - so read the docs closely before installing 
it into production

take a look on CPAN for Apache::OutputChain

-- 
  jason -- elephant@squirrelgroup.com --


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

Date: Mon, 23 Oct 2000 01:42:12 +0200
From: "Alan J. Flavell" <flavell@mail.cern.ch>
Subject: Re: CGI and SHTML
Message-Id: <Pine.GHP.4.21.0010230137040.2137-100000@hpplus03.cern.ch>

On Sun, 22 Oct 2000, Greg Griffiths wrote:

> I have been quite happily returning text/html from a CGI script, but
> would like to return some SSI includes in my file, using a content type
> of text/shtml fails, 

Did your web server offer any facility to resolve SSIs in CGI script
output?  (Hint: web servers come with documentation, and have their
associated usenet groups.  Apache even comes with an FAQ document).  
Did you suppose the behaviour would be any different with Perl scripts
than with scripts in any other CGI-supporting language? (Hint: the
answer is "no", which means your question is in the wrong place).

> any ideas ?

Yes, pick the appropriate group and look there (e.g courtesy of
www.deja.com).  Where you'd find your question had already been asked
and answered boringly often.  In the event that you're using Apache,
consult its FAQ, which is part of the distribution.  FAQs are good for
you: take one frequently, and not only when the symptoms recur...

good luck




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

Date: Mon, 23 Oct 2000 10:48:20 +1100
From: Ian Boreham <ianb@ot.com.au>
Subject: Re: executing UNIX-commands on remote systems (mailq)
Message-Id: <39F37CC4.9547F6B8@ot.com.au>

Karsten Perlich wrote:

> Hi folks,
>
> I want to monitor the mail-queue of a remote system. to see how long the
> mailq is, something like the response of "mailq | head -1 | cut -f2
> -d'(' | cut -f1 -d' '" should be executed on the romote-system and the
> result end in a variable of my local perl-script.

What about "rsh"?


Ian




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

Date: Sun, 22 Oct 2000 23:36:21 +0100
From: Geoff Soper <g.soper@soundhouse.co.uk>
Subject: File locking
Message-Id: <4a11af8f9eg.soper@soundhouse.co.uk>

I have three scripts running on an Apache (Unix) installation which open
files, sometimes for reading and sometimes for writing. Its conceivable
that two occurances of the same script or occurances of two different
scripts will try and access the same files. Do I need to use locks when
reading files? Am I right in assuming the operating system takes care of
that? I am assuming I need to lock files when writing to them though, is
this correct? I notice the flock command waits indefinitely for a file to
become unlocked, what happens if a process with a lock open crashed? Will
any other process waiting for that lock hang too?

I'd appreciate any advice or tips, I have read the relavent parts of the
FAQ but don't feel my quesions have been answered.

Many thanks

-- 
Geoff Soper
g.soper@soundhouse.co.uk
Take a look at the Soundhouse page http://www.soundhouse.co.uk/


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

Date: Sun, 22 Oct 2000 23:11:04 GMT
From: mjd@plover.com (Mark-Jason Dominus)
Subject: Re: File locking
Message-Id: <39f37408.5099$343@news.op.net>
Keywords: Ursula, climate, guardian, standpoint


In article <4a11af8f9eg.soper@soundhouse.co.uk>,
Geoff Soper  <g.soper@soundhouse.co.uk> wrote:
>Do I need to use locks when reading files? 

Yes.  If you do not, you might end up reading the file at the same
time that another process is writing it.  If this happens, the first
process might read the file while it is in an incomplete or
inconsistent, partiaully-written state.

> Am I right in assuming the operating system takes care of that?

No. 

>I am assuming I need to lock files when writing to them though, is
>this correct? 

You usually need to lock files whenever there is a chance that one
process might access the file, wither for writing *or* reading, while
it is being written by some other file.

>I notice the flock command waits indefinitely for a file to become
>unlocked, what happens if a process with a lock open crashed? 

Whenever a process exits, either by crashing or in a more normal way,
all of its locks are released immediately.

>I'd appreciate any advice or tips, I have read the relavent parts of the
>FAQ but don't feel my quesions have been answered.

The section in the Perl Cookbook about file locking is very complete.


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

Date: Sun, 22 Oct 2000 17:12:17 -0700
From: Jeff Zucker <jeff@vpservices.com>
Subject: Re: help printing variable in table
Message-Id: <39F38261.E602C2BE@vpservices.com>

"Erin M. McDaniel" wrote:
> 
> there is no output at all. However, if I just use
> 
> print $comments;
> 
> the output is perfect. There is no output however if it is placed inside a
> table.

When you say there is no output, do you mean there is no visbile output
when viewed in the browser, or there is no output at all?  What happens
when you run the script from the command line, or when you look at the
script with "view source"?  The code you have showed is perfectly valid
Perl, so either you aren't telling us something, or you are printing bad
HTML and not checking what you are actually printing.

-- 
Jeff


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

Date: Mon, 23 Oct 2000 10:45:24 +1000
From: jason <elephant@squirrelgroup.com>
Subject: Re: how to debug perl script?
Message-Id: <MPG.145e352ee7a6f6da989835@localhost>

Zimmen Huang wrote ..
>     I'm completely new to the perl world. The following question might
>be very elmentary.
>    I have a perl script in web server to handle forms. What is
>procedure to debug it? Basically,  I need to generate a web environment
>so that the script receive data from the web input. Any pointer is
>greatly appreciated.

either

install and set up a web server (there are a number of small light web 
servers around the place for just this sort of thing - but even Apache 
is pretty simple top set up (although you have to be prepared to read 
some documentation - there's no point and click setup)

  http://www.boutell.com/faq/oldfaq/swinnt95.htm

or

use the standard CGI.pm module which has a debug mode allowing you to 
input your CGI parameters from various sources (of course - reading the 
output can be less than fun - which is why the 'install a web server' 
option was first)

  perldoc CGI

-- 
  jason -- elephant@squirrelgroup.com --


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

Date: 23 Oct 2000 00:09:54 GMT
From: dsembr01+usenet@slug.louisville.edu (Darren Stuart Embry)
Subject: IPC::Open2 problem, process doesn't see input
Message-Id: <slrn8v70ei.ugu.dsembr01+usenet@ox.slug.louisville.edu>

Environment --- perl-5.6.0/mod_perl-1.24 on an apache-1.3.12 server.

Problem --- I'm trying to use the IPC::Open2 module to do a
bidirectional pipe in a mod_perl handler, but it is not working
properly.

What happens is that the program I want to read from/write to doesn't
see what I'm inputting into it but I can still see what it's
outputting.  And that's even though I'm autoflushing all input and
output handles, both from the parent and inside the script.

The same thing happens if I use pipe() and fork() manually.

This problem does not occur if I'm using perl-5.005_03, all other
things being the same.

This problem does also not occur when I run a program using such code
from the command line.

Files included in this post, in order:

- WebOnAStick::Test::Test (don't ask about the name), a demo module I
  wrote which implements the two different forms of using a
  bidirectional pipe, and which also serves as the content handler.

- test-io, the program I want to read from and write to.

- test-io2, a command-line program that uses the demo Perl modoule to
  illustrate that bidirectional pipes work fine from the command line.

The content handler's output:

	<H2>Input</H2>

	<PRE>
	This is a test.  foo.
	This is another test.  foo.
	</PRE>

	<H2>Output 1</H2>

	<PRE>
	I received 0 lines.
	</PRE>

	<H2>Output 2</H2>

	<PRE>
	I received 0 lines.
	</PRE>

The command line program's (test-io2) output:

	<OUTPUT_1>
	{test-io was here}This is a test.  bar.
	{test-io was here}This is another test.  bar.
	I received 2 lines.
	</OUTPUT_1>
	<OUTPUT_2>
	{test-io was here}This is a test.  bar.
	{test-io was here}This is another test.  bar.
	I received 2 lines.
	</OUTPUT_2>

Thanks,
Darren

========================================================================

package WebOnAStick::Test::Test;
###---------------------------------------------------------------------
### This module contains try_pipe_1() and try_pipe_2(), two different
### demonstrations of how to use a bidirectional pipe.  The first uses
### IPC::Open2(); the second uses pipe() and fork().  It also
### contains a mod_perl content handler to demonstrate that the code
### doesn't work properly when using perl-5.6.0/mod_perl-1.24.  This
### type of code works properly when using perl-5.005_03/mod_perl-1.24
### (well, you'd have to change the our declarations, obviously), and 
### it also works just fine from the command line.
###---------------------------------------------------------------------
use strict;
use Exporter;
our @ISA = qw(Exporter);
our @EXPORT = qw();
our @EXPORT_OK = qw(try_pipe_1 try_pipe_2);

use Apache::Constants qw(:common);
use IPC::Open2;
use IO::Handle;

sub try_pipe_1 {
    my $input = shift();
    my @pipe = ('/home/dse/bin/test-io');
    my $rh = new IO::Handle; my $wh = new IO::Handle;
    my $pid = open2($rh,$wh,@pipe); # can't pass undef handles under 5.005...
    unless($pid) {
        return (0,"open2 failed: $!\n");
    }
    $rh->autoflush(); $wh->autoflush();
    $wh->print($input); $wh->close();
    my $output = join('',<$rh>); $rh->close();
    waitpid($pid,0);
    return (1,$output);
}

sub try_pipe_2 {
    my $input = shift();
    my @pipe = ('/home/dse/bin/test-io');
    my $r1 = new IO::Handle; my $w1 = new IO::Handle; pipe($r1,$w1);
    my $r2 = new IO::Handle; my $w2 = new IO::Handle; pipe($r2,$w2);
    $w1->autoflush(); $r2->autoflush();
    $w2->autoflush(); $r1->autoflush();
    my $pid = fork();
    if (!defined($pid)) {
        return (0,"could not fork: $!\n");
    }
    if (!$pid) {
        # child: read from pipe1, write to pipe2
        close($w1); close($r2);
        open(STDIN,'<&='.fileno($r1));
        open(STDOUT,'>&='.fileno($w2));
        select(STDIN); $|=1;
        select(STDOUT); $|=1;
        exec(@pipe) or exit(86);
    }
    # parent: read from pipe2, write to pipe1
    close($r1); close($w2);
    $w1->print($input); $w1->close();
    waitpid($pid,0);
    my $output = join('',<$r2>); $r2->close();
    return (1,$output);
}

use HTML::Entities;

sub handler {
    my $r = shift();
    my $input = "This is a test.  foo.\nThis is another test.  foo.\n";
    my ($status1,$output1) = try_pipe_1($input);
    if (!$status1) {
        $r->log_error($output1);
        return SERVER_ERROR;
    }
    my ($status2,$output2) = try_pipe_2($input);
    if (!$status2) {
        $r->log_error($output2);
        return SERVER_ERROR;
    }
    $r->content_type('text/html');
    $r->send_http_header();
    $r->print("<H2>Input</H2>\n");
    $r->print("<PRE>".encode_entities($input)."</PRE>\n\n");
    $r->print("<H2>Output 1</H2>\n");
    $r->print("<PRE>".encode_entities($output1)."</PRE>\n\n");
    $r->print("<H2>Output 2</H2>\n");
    $r->print("<PRE>".encode_entities($output2)."</PRE>\n\n");
    return OK;
}

1;

========================================================================

#!/usr/bin/perl -w
###---------------------------------------------------------------------
### This is test-io, a simple script that modifies every line
### of input and prints the results, and also prints a line
### telling how many lines of input it read.
###---------------------------------------------------------------------
use strict;
select(STDIN); $| = 1;
select(STDOUT); $| = 1;
my $count = 0;
while (<>) {
    ++$count;
    chomp;
    s/foo/bar/g;
    s/^/{test-io was here}/g;
    print "$_\n";
}
print "I received $count lines.\n";

========================================================================

#!/usr/bin/perl -w
###---------------------------------------------------------------------
### This is test-io2, a script that demonstrates that IPC::Open2
### (and manual pipe hacking) works fine from the command line.
###---------------------------------------------------------------------
use strict;
use lib '/usr/local/webonastick/perl';
use WebOnAStick::Test::Test qw(try_pipe_1 try_pipe_2);
my $input = "This is a test.  foo.\nThis is another test.  foo.\n";
my ($status1,$output1) = try_pipe_1($input);
die "FAILED #1: $output1\n" unless $status1;
my ($status2,$output2) = try_pipe_2($input);
die "FAILED #2: $output2\n" unless $status2;
print "<OUTPUT_1>\n$output1</OUTPUT_1>\n";
print "<OUTPUT_2>\n$output2</OUTPUT_2>\n";

========================================================================

-- 
Darren Stuart Embry.  DNRC Resident Stick Figure Artist.
http://www.webonastick.com/
    ``Do pardon me for crediting the average person with intelligence.''
	-- Beverley White, in alt.religion.kibology


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

Date: Sun, 22 Oct 2000 23:03:40 GMT
From: percy_yip@my-deja.com
Subject: local file handle <MY_FILE>
Message-Id: <8svroa$o61$1@nnrp1.deja.com>

I need to use a local file handle in a function because I am doing a
recursive function there.

I tried to use
@sub my_function {

my <FILE> = @_[0];       # it doesn't work!!!!!
 .
 .
 .
 .
     my_function ( new_file );
}

For normal variables, I can use my to create local variables, but not
for file handle.  Anyone can tell me why, and how to solve this problem.

Thanks in advance.


Sent via Deja.com http://www.deja.com/
Before you buy.


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

Date: Sun, 22 Oct 2000 23:57:32 GMT
From: mjd@plover.com (Mark-Jason Dominus)
Subject: Re: local file handle <MY_FILE>
Message-Id: <39f37eec.5182$4d@news.op.net>

In article <8svroa$o61$1@nnrp1.deja.com>,  <percy_yip@my-deja.com> wrote:
>I need to use a local file handle in a function because I am doing a
>recursive function there.

See perlfaq5, "How can I make a filehandle local to a subroutine?"

>For normal variables, I can use my to create local variables, but not
>for file handle.  Anyone can tell me why, 

Short answer: Because Perl is screwed up.


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

Date: Mon, 23 Oct 2000 00:04:48 GMT
From: Bob Walton <bwalton@rochester.rr.com>
Subject: Re: local file handle <MY_FILE>
Message-Id: <39F38090.C0118BC5@rochester.rr.com>

percy_yip@my-deja.com wrote:
> 
> I need to use a local file handle in a function because I am doing a
> recursive function there.
> 
> I tried to use
> @sub my_function {
> 
> my <FILE> = @_[0];       # it doesn't work!!!!!
 ...
>      my_function ( new_file );
> }
> 
> For normal variables, I can use my to create local variables, but not
> for file handle.  Anyone can tell me why, and how to solve this problem.
 ...
Well, you've got a couple of problems there.  First, you can't assign to
<FILE> without the my, so why would you think you could assign to it
with the my?  Second, the correct terminology for a "my" variable is a
lexical variable, not a local variable.  

I'm guessing what you really want to do is pass a reference to a
filehandle to your subroutine, right?  If so, call it with:

    &my_function(\*FILEHANDLE);

and put:

    my $fh_ref=shift;

in the sub.  You can use the filehandle reference $fh_ref anywhere you
could have used as filehandle, as in, for example:

    my @contents=<$fh_ref>;

Also, if you are really using this sub recursively as you state, you
should be a bit careful about what you do with the file in it, as a file
is a global, not a lexical, resource.  The filehandle reference,
however, can be lexical.
-- 
Bob Walton


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

Date: Sun, 22 Oct 2000 18:03:18 -0700
From: "Gabriel Richards" <grichards@flashcom.net>
Subject: Out of Memory - ActivePerl 5.6/Win98 SE 192MB RAM
Message-Id: <sv73gomi0d0g26@corp.supernews.com>

Getting out of memory error. When I comment out the OUTFILE print loop, no
out of memory, but of course, I have to print the results! Here's the code.

#!c:/perl/bin/perl -w

use strict;

my $infile = "c:/prog/acct001.txt";
my $outfile = "c:/prog/acct002.txt";
open(INFILE, "$infile");
my @dir=();
my $flag = 0;
my ($name, $addr1, $city, $state, $zip, $phone, $fax, $email, $spec, $desc)
= "";
while (<INFILE>) {
 my $line = $_;
 if (($line !~ /[a-z]/) && ($line =~ /[A-Z]/) && ($line !~ /\d/)) {
  if ($flag == 6) {
   push (@dir, { name => $name, addr1 => $addr1, city => $city, state =>
$state, zip => $zip, phone => $phone, fax => $fax, email => $email, spec =>
$spec, desc => $desc });
   ($name, $addr1, $city, $state, $zip, $phone, $fax, $email, $spec, $desc)
= "";
  }
  $name .= $line;
  $flag = 1;
  next;
 }
 elsif ($flag == 1) {
  unless (($line !~ /[a-z]/) && ($line =~ /[A-Z]/) && ($line =~ /\d/)) {
   $addr1 .= $line;
   next;
  }
  else {
   $line =~ /(.*)\, (.*) (\d*)/;
   $city = $1; $state = $2; $zip = $3;
   $flag = 2;
   next;
  }
 }
 elsif ($flag == 2) {
  if ($line =~ /Telephone: \((...)\) (...)\-(....)/) {
   $phone = $1.$2.$3;
  }
  $flag = 3;
 }
 elsif ($flag == 3) {
  if ($line =~ /FAX: \((...)\) (...)\-(....)/) {
   $fax = $1.$2.$3;
  }
  $flag = 4;
 }
 elsif ($flag == 4) {
  $email = $1 if ($line =~ /E-mail\: (.*)/);
  $flag = 5;
 }
 elsif ($flag == 5) {
  if ($line ne "\n") {
   $spec .= $line;
  }
  elsif ($line eq "\n") {
   $flag = 6;
   next;
  }
 }
 elsif ($flag == 6) {
  unless ($line eq "\n") {
   $desc .= $line;
   next;
  }
 }
}
close INFILE;
open(OUTFILE, ">$outfile");
foreach my $i (@dir) {
 chomp ($dir[$i]{name}, $dir[$i]{addr1}, $dir[$i]{city}, $dir[$i]{state},
$dir[$i]{zip}, $dir[$i]{phone}, $dir[$i]{fax}, $dir[$i]{email},
$dir[$i]{spec}, $dir[$i]{desc});
 print
"$dir[$i]{name}\t$dir[$i]{addr1}\t$dir[$i]{city}\t$dir[$i]{state}\t$dir[$i]{
zip}\t$dir[$i]{phone}\t$dir[$i]{fax}\t$dir[$i]{email}\t$dir[$i]{spec}\t$dir[
$i]{desc}\n";
}
close OUTFILE;

Thanks for any assistance!

Gabe




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

Date: Mon, 23 Oct 2000 10:29:56 +1000
From: jason <elephant@squirrelgroup.com>
Subject: Re: redirection Location help
Message-Id: <MPG.145e3190975a7a96989833@localhost>

metamp@my-deja.com wrote ..
>I want to do redirection
>I'm useing the print "Location: http://mysite.com/\n\n";
>
>but I want to redirect to a web page and to a download file
>
>if I do  second  line Print "Location: http://myfile.zip\n\n"
>my first redirect is ignored.
>
>is here any way to do Location target =_blank or _self so I could
>redirect to 2 diferent locations
>or
>system timer would be an alternative but I'm not sure if I can do that
>something like this  timer set to 10000
>                     on timer {
>                     redirect to file;
>                     timer disable;
>                     }
>
>can anybody help with this

it's really unclear to me what you're trying to do .. but here are some 
facts that might help

1) you can only have one Location header per response

2) there is another HTTP header called Refresh that allows you to 
refresh from one page to another page after a supplied number of seconds

3) you can put an entire URL inside a Location header - so (if I 
understand what you're wanting to do correctly) you can do this

  print "Location: http://mysite.com/myfile.zip\n\n";

-- 
  jason -- elephant@squirrelgroup.com --


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

Date: Mon, 23 Oct 2000 10:24:25 +1000
From: jason <elephant@squirrelgroup.com>
Subject: Re: Send Mail and Pass Data to URL
Message-Id: <MPG.145e3044fec67fea989832@localhost>

Richard wrote ..
>I'm using a form to send data to the URL of our credit card transaction
>service. However, they don't return data from any custom fields. We would
>like to send the data to our "mailer.cgi" and have the script forward the
>data to the URL of the card processor where the customer can complete the
>transaction. Is there a line of code I can add to the script that would
>forward the data?
>
>Any assistance would be greatly appreciated!

have a look at the LWP::Simple module for how to submit the required 
fields to the card processing web site

-- 
  jason -- elephant@squirrelgroup.com --


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

Date: Mon, 23 Oct 2000 10:36:30 +1000
From: jason <elephant@squirrelgroup.com>
Subject: Re: Send Mail and Pass Data to URL
Message-Id: <MPG.145e331ee424879a989834@localhost>

jason wrote ..
>Richard wrote ..
>>I'm using a form to send data to the URL of our credit card transaction
>>service. However, they don't return data from any custom fields. We would
>>like to send the data to our "mailer.cgi" and have the script forward the
>>data to the URL of the card processor where the customer can complete the
>>transaction. Is there a line of code I can add to the script that would
>>forward the data?
>>
>>Any assistance would be greatly appreciated!
>
>have a look at the LWP::Simple module for how to submit the required 
>fields to the card processing web site

sorry .. I meant the LWP::UserAgent module

-- 
  jason -- elephant@squirrelgroup.com --


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

Date: Mon, 23 Oct 2000 10:18:54 +1000
From: jason <elephant@squirrelgroup.com>
Subject: Re: Stripping non-contents from HTML snippet
Message-Id: <MPG.145e2efda33955e0989831@localhost>

Stephane Barizien wrote ..
>I have an entire HTML page in $str.
>
>I want to detect if $str contains some patterns, but NOT within
>"non-contents", like lists, comments, etc.
>
>Concrete case: I have  the contents of
>http://www.ddj.com/articles/2000/0010/0010toc.htm in $str, and I don't
>want to find "Compression" within the "GO TO..." listbox in the upper
>right.
>
>I've tried Gisle Aas's HTML::FormatText but as it doesn't support tables
>(yet) and that page (for instance) is just a big table, that won't do...
>
>Any clue?

  HTML::Parser

-- 
  jason -- elephant@squirrelgroup.com --


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

Date: Sun, 22 Oct 2000 23:05:49 GMT
From: mjd@plover.com (Mark-Jason Dominus)
Subject: Re: textfield length
Message-Id: <39f372cd.5070$65@news.op.net>

In article <B61754A6.96F1%star@sonic.net>, arthur  <star@sonic.net> wrote:
> textfield('question'),

textfield(-name => 'question', -size => 100);

The CGI module comes with really excellent documentation.  You should
be able to display this with the command

        perldoc CGI

or by doing a web search.


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

Date: Sun, 22 Oct 2000 22:56:38 GMT
From: andre_sanchez@my-deja.com
Subject: Unwarranted Warning
Message-Id: <8svrb5$nqn$1@nnrp1.deja.com>

I am getting the following warning (Perl 5.00503, RH Linux 6.2):

Subroutine restore_parameters redefined at Commonsubs.pm line 45.

I searched for where I could possibly be redefining the subroutine:

$ grep restore_parameters *
Commonsubs.pm:sub restore_parameters {
Commonsubs.pm:my $query = restore_parameters();

Any thoughts on why I am getting this warning, and on how to correct it?

Thanks.

Andre Sanchez

--
Their's not to make reply,
Their's not to reason why,
Their's but to do or die: -- Tennyson


Sent via Deja.com http://www.deja.com/
Before you buy.


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

Date: Sun, 22 Oct 2000 23:54:51 GMT
From: mjd@plover.com (Mark-Jason Dominus)
Subject: Re: Unwarranted Warning
Message-Id: <39f37e4a.5173$26@news.op.net>

In article <8svrb5$nqn$1@nnrp1.deja.com>,  <andre_sanchez@my-deja.com> wrote:
>Subroutine restore_parameters redefined at Commonsubs.pm line 45.
>
>I searched for where I could possibly be redefining the subroutine:

Would it be out of line for me to ask you to show us line 45?



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

Date: Mon, 23 Oct 2000 11:19:41 +1000
From: jason <elephant@squirrelgroup.com>
Subject: Re: Unwarranted Warning
Message-Id: <MPG.145e3d28dd8b521f989838@localhost>

andre_sanchez@my-deja.com wrote ..
>I am getting the following warning (Perl 5.00503, RH Linux 6.2):
>
>Subroutine restore_parameters redefined at Commonsubs.pm line 45.
>
>I searched for where I could possibly be redefining the subroutine:
>
>$ grep restore_parameters *
>Commonsubs.pm:sub restore_parameters {
>Commonsubs.pm:my $query = restore_parameters();
>
>Any thoughts on why I am getting this warning, and on how to correct it?

herein lies the perfect argument AGAINST importing functions from 
modules - especially in function sets

there is a function within the CGI.pm modules called restore_parameters 
 .. and you obviously import it into your namespace at some point .. most 
likely with something like this

  use CGI ':standard';

if you use this style of importing functions into your namespace then 
you should get used to this "subroutine redefined" error message

my recommendation(s)

import them explicitly by name

  use CGI qw[param header start_html end_html];

or .. use the full function names (it's not that much typing)

  use CGI;

  my $foo = CGI::param('foo');

or .. use the OO interface

  use CGI;
  my $q = new CGI;

  my $foo = $q->param('foo');

-- 
  jason -- elephant@squirrelgroup.com --


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

Date: Mon, 23 Oct 2000 00:31:28 GMT
From: Bob Walton <bwalton@rochester.rr.com>
Subject: Re: Win32::OLE ???
Message-Id: <39F386CF.52C4AAD@rochester.rr.com>

Denys Kotseba wrote:
 ...
> I have faced the following problem after upgrading ActiveState Perl 5.22 to
> 6.18.
> Here is the code:
> 
> #$rs is a recordset resulted from the query to SQL server
> 
> $Response->Write($rs->Fields('DateCreated')->Value);
> $a=$rs->Fields('DateCreated')->Value;
> $Response->Write($a);
> $Response->Write($a.$a);
> 
> And here is the output (I inserted '|' for readability):
> 
> 21.10.2000 12:17:19 | 21.10.2000 12:17:19 |
> Win32::OLE::Variant=SCALAR(0x4a2f870)Win32::OLE::Variant=SCALAR(0x4a2f870)
> 
> The old version produced normal output (i.e. real value instead of
> Win32::OLE::Variant=SCALAR(0x4a2f870) thingy). What has changed? Could
> anyone please advise?
 ...
> Denys Kotseba

My advice is to ditch OLE for this job, and use the DBI module.  It
might even work, and the resulting program would run on any platform,
not just Windoze, and also with any database server, not just the one
you're now using.

Also, are you sure that Perl was the only thing upgraded?  If you also
went to a new version of your SQL server (you didn't mention which one
you're using), its OLE interface may have changed.

I'm guessing that the OLE Value method is generating an object, rather
than a plain unblessed scalar, and that in the past that object was
intended to be used with a method to generate a Perl scalar value, and
that you misused that object by referencing it directly to produce a
value.  In the past that worked, but wasn't guaranteed to work in future
upgrades.  This is that future time at which an upgrade was performed. 
The documented object interface wouldn't have changed, but the
undocumented shortcuts might.

Or maybe the Value method is producing a reference, which the Write
method is then expecting.  When you do $a.$a, you are getting the scalar
value of the reference, which would look like what got printed above. 
But since I don't know what your server's Write OLE method does, I don't
know if that is a possibility or not.

But I can't prove any of that without the docs from your server, and I
don't even know which server it is.
-- 
Bob Walton


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

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


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