[7614] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 1240 Volume: 8

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Tue Oct 28 17:17:14 1997

Date: Tue, 28 Oct 97 14:00:24 -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           Tue, 28 Oct 1997     Volume: 8 Number: 1240

Today's topics:
     Re: ADVANCED: Clearing a namespace/package? <rootbeer@teleport.com>
     Re: ADVANCED: Clearing a namespace/package? (brian d foy)
     Re: ADVANCED: Clearing a namespace/package? (Charles DeRykus)
     anyone familiar with the extract_links() method? <silvia@mathworks.com>
     Re: Children only inherit redirects if use system "perl <dan_oct97@unitech.com>
     Client/server problems with understanding sockets zingbust@montana.com
     DBD-Oracle-0.47.tar.gz corrupted? (Larry Mulcahy)
     detecting reload (Mike Rambour)
     Exception.pm? (Jason Bodnar)
     Re: filehandle storage in class? (Jason Gloudon)
     Re: Filehandles and nested-if-loops <kermit@ticnet.com>
     help for perl NT4.0 theresa@nytimes.com
     ingperl's connect command problem <berny@nortel.com>
     Installing on SGI Irix 6.2 Hangs <John.P.Reber@mail.tju.edu>
     Multiple filehandles <jjune@midway.uchicago.edu>
     Re: Please Help getting keystrokes. <rootbeer@teleport.com>
     shtlm problem though perl works (Kris Carroll)
     Simulating ${parm:-$parm2} <valentin@cssdomain.com>
     String manipulation - Help Required <hnews@harvest-lodge.demon.co.uk>
     String Manipulation Help Required <hnews@harvest-lodge.demon.co.uk>
     String manipulation with Perl - Help Please <hnews@harvest-lodge.demon.co.uk>
     Sybperl dbuse closing STDOUT? dmorr@software.net
     Re: Year2000 problem with localtime(); <HARTLEH1@westatNOSPAM.com>
     Zipping files on a UNIX system, with a cgi Perl script <bjdweck@cloud9.net>
     Digest Administrivia (Last modified: 8 Mar 97) (Perl-Users-Digest Admin)

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

Date: Tue, 28 Oct 1997 12:00:00 -0800
From: Tom Phoenix <rootbeer@teleport.com>
To: bsd@pobox.com
Subject: Re: ADVANCED: Clearing a namespace/package?
Message-Id: <Pine.GSO.3.96.971028114835.23246F-100000@usertest.teleport.com>

On Tue, 28 Oct 1997, Brad Daugherty wrote:

>     Does anybody know how I can clear an entire namespace/package
> without knowing the variables.  In theory I want to "undef($Q::*)".

(My third eye seems to see that you're trying to use cgi-lib.pl. Unless I
put in the wrong contact lens this morning, you should use CGI.pm instead,
and ignore the rest of this message. :-)

This is tricky. If you do simply this:

    $foo::bar = "some value\n";
    undef %foo:: ;		# wipe the foo:: symbol table
    print $foo::bar;

 ...the value is printed. The reason that happens is that the compiler is
too smart! :-)  It compiles the first and third lines to go directly to
the variable, skipping the symbol table - so even though the second line
"worked", clearing the foo:: symbol table, the variable may still be
accessed. Yikes! 

The attached code should show you the right way to wipe out a symbol
table whose name may not be known until runtime. Enjoy!

-- 
Tom Phoenix           http://www.teleport.com/~rootbeer/
rootbeer@teleport.com  PGP   Skribu al mi per Esperanto!
Randal Schwartz Case:  http://www.rahul.net/jeffrey/ovs/
              Ask me about Perl trainings!

    #!/usr/bin/perl -w

    use strict;

    # We'll put something into package foo, for testing.
    # The eval is needed because we don't want the
    # compiler to "see" that we've used this variable.
    # (Same for other evals here.)
    eval q{ $foo::bar = "I'm alive!\n" } ;
    die $@ if $@;

    # $Q is the package name
    my $Q = 'foo';

    # To prove that this works, let's test it here.
    eval q{ print $foo::bar };
    die $@ if $@;

    # Now we'll delete the package named in $Q
    # Since this is a soft reference, we'll need to
    # relax the stricture.
    {
	no strict 'refs';
	undef %{ $Q . '::' };
    }

    # And now, when we print this, we should get a
    # warning about using an undefined value.
    eval q{ print $foo::bar };
    die $@ if $@;

__END__



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

Date: Tue, 28 Oct 1997 15:30:39 -0500
From: comdog@computerdog.com (brian d foy)
Subject: Re: ADVANCED: Clearing a namespace/package?
Message-Id: <comdog-ya02408000R2810971530390001@news.panix.com>

In article <Pine.GSO.3.96.971028114835.23246F-100000@usertest.teleport.com>, Tom Phoenix <rootbeer@teleport.com> wrote:

>On Tue, 28 Oct 1997, Brad Daugherty wrote:
>
>>     Does anybody know how I can clear an entire namespace/package
>> without knowing the variables.  In theory I want to "undef($Q::*)".
>
>(My third eye seems to see that you're trying to use cgi-lib.pl. Unless I
>put in the wrong contact lens this morning, you should use CGI.pm instead,
>and ignore the rest of this message. :-)

the CGI.pm POD also uses the $Q:: namespace when discussing the 
import_names method:

     IMPORTING ALL PARAMETERS INTO A NAMESPACE:

        $query->import_names('R');

     This creates a series of variables in the 'R' namespace.
     For example, $R::foo, @R:foo.  For keyword lists, a variable
     @R::keywords will appear.  If no namespace is given, this
     method will assume 'Q'.  WARNING:  don't import anything
     into 'main'; this is a major security risk!!!!

-- 
brian d foy                                  <comdog@computerdog.com>
NY.pm - New York Perl M((o|u)ngers|aniacs)*  <URL:http://ny.pm.org/>
CGI Meta FAQ <URL:http://computerdog.com/CGI_MetaFAQ.html>


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

Date: Tue, 28 Oct 1997 19:17:47 GMT
From: ced@bcstec.ca.boeing.com (Charles DeRykus)
Subject: Re: ADVANCED: Clearing a namespace/package?
Message-Id: <EIs09p.3tt@bcstec.ca.boeing.com>

In article <34560B44.B1B4A8DF@ameritech.net>,
Brad Daugherty  <bsd@pobox.com> wrote:
>Hello,
>
>    Does anybody know how I can clear an entire namespace/package
>without knowing the variables.  In theory I want to "undef($Q::*)".
>
>Some of the leads I have had that don't work are:
>
>undef %{$Q::};
>


undef %{"${Q}::"}; 



HTH,
--
Charles DeRykus


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

Date: Tue, 28 Oct 1997 15:54:31 -0500
From: Matt Silvia <silvia@mathworks.com>
Subject: anyone familiar with the extract_links() method?
Message-Id: <34565107.E5E5D831@mathworks.com>

Hi there...

I'm having trouble getting the extract_links() method of
HTML::TreeBuilder to work.

More specifically, I use a UserAgent to execute a request and return a
response object, and then use HTML::Parse::parse_html to create a tree
object.

I try to run the extract links method of this tree, but it seems as if
it's not extracting anything from the tree.

Does anyone know what I'm doing wrong?

Thanks,

    Matt

----
example code, comments and declarations removed:


$ua = new LWP::UserAgent;
$ua->agent("AgentName/0.1 " . $ua->agent);

$URL = 'http://www.somethin.com/';

my $req = new HTTP::Request POST => $URL;
$req->content_type('application/x-www-form-urlencoded');
$req->content('');

my $response = $ua->request($req);
$html = $response->content();
$tree = HTML::Parse::parse_html($html);

    for (@{ $tree->extract_links( qw(a) ) }) {
        $link = $_->[0];
        print "$link\n";
   }

--

=================================================
 Matt Silvia  silvia@mathworks.com
 The MathWorks, Inc. http://www.mathworks.com
=================================================




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

Date: Tue, 28 Oct 1997 13:41:45 -0600
From: Dan Harkless <dan_oct97@unitech.com>
To: evangelo@endcontsw.com
Subject: Re: Children only inherit redirects if use system "perl": should be NT FAQ!
Message-Id: <878066743.14475@dejanews.com>

In article <62m44m$nbp$1@speedx1.speed.net>, I wrote:
>
> I am using Gurusamy Sarathy's binary distribution of 5.004_02 on NT.  I was
> trying to get a pair of scripts to work where a parent script writes some
> output to a LOG file then redirects STDOUT and STDERR to the LOG and calls
> another perl script with system().
>
> This absolutely fails to work if you call the second script using its name:
>
>     system("callee.pl arguments");
>
> The output of the callee just disappears!  It doesn't go to the log file,
> the terminal, or anywhere.
>
> I tried various workarounds including doing a ">" in the system string and
> tying STDERR to STDOUT in the callee -- everything I tried failed -- except
> for one thing:
>
>     system("perl -S callee.pl arguments");
>
> Calling the perl interpreter directly appears to be the only way to get the
> callee to respect output redirections.  The -S causes perl to search the
> path for callee.pl rather than just looking for it in the current directory.
>
> This should certainly be in the Perl for Win32 FAQ -- I'm sure it burns a
> lot of people.

Actually, I'll now follow up my post to say that even doing what I say
above doesn't completely work.	It works the first time you redirect
output, but if you come back through the code a second time the output
disappears.

I guess what should be a FAQ is that you can't expect output redirection
to work properly with versions of the standard Perl distribution built
under Windows. The ActiveWare port, on the other hand, works properly.

Mentioning this in the FAQ could save newbies like myself a lot of time. 
I burned half a day wrestling with what turned out to be the wrong
version of perl.  I naturally assumed a version built from the latest
version of the main distribution would offer superior compatibility to a
Windows-only version that's a few revisions out-of-date.  This turns out
not to be the case.

-- Dan Harkless  Unitech Research, Inc.  <dan_oct97@unitech.com>

NOTE:  This is a monthly mail alias used to post to the Usenet without
conSPAMinating my real address.  If you are replying after October 1997,
your mail may bounce.  If so, replace 'oct' with the current month's
abbrev.

-------------------==== Posted via Deja News ====-----------------------
      http://www.dejanews.com/     Search, Read, Post to Usenet


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

Date: Tue, 28 Oct 1997 14:51:42 -0600
From: zingbust@montana.com
Subject: Client/server problems with understanding sockets
Message-Id: <878071270.19514@dejanews.com>

Hi,  I am modifying a perl script I found somewhere on the Net.  It is
part of a client program that connects to a server on a different
machine.  The TCP connection part of it uses a Socket S and works fine. 
Here is the part of it that I don't understand. Comments are the original
author's....

# Force our socket to flush output immediately after a print
select(S);
$| = 1;

# Make standard output the default again
select(STDOUT);

# The interaction we want is to type lines of input and have them echoed
# back by the server.  But how can we both wait for input AND be #
receptive to the server's output?  Answer:  By forking a process to  #
accept	input from standard input (the keyboard) and send it to the
server # and using our current process to receive and display input from
the server.

if ($child = fork) {
# We're the parent.  Read lines of input from the standard input and
# send them to the server until end of file is seen.
  while (<STDIN>) {
    print S ;
  }
  # Sleep for 3 seconds then...
  sleep 3;
    #...then kill ourselves and the child
  do dokill();
}
else {
    # We're the child.  Read lines of input from the server over the
    # socket S and output them.   Stop if end of file is seen.
    while (<S>) {
        print "Server: $_";
    }
}


Earlier in the program, there is this...

$SIG{'INT'} = 'dokill';

sub dokill {
   kill 9, $child if $child;
}

What I need to do is not to have the interaction at the keyboard that
this program does, but to modify the code in such a way that once the
connection is established, the client sends a small stream of data
(always no more than about 500k) to the server via the socket, then
pauses and waits for a response from the server.  It may have to wait 5
minutes or more.  When the server responds (with an even smaller stream
of data), the client must open a file for writing that data to it and
only then close the connection.  I have tried all kinds of things.  I
guess the problem is that I don't understand exactly what is happening
with the code above.  Specifically...

if ($child = fork) { What this says to me is that we are asking for a new
process and returing the PID and storing it in $child.	If successful,
then execute this block.

do dokill(); Say what?	If this really kills both the parent and the
child process, then the program is all done, isn't it?	But if that were
true, then it should only be able to write once to the socket, then be
done.  But that isn't what happens.

else { Following my line of reasoning from above after if ($child = fork)
{ then the code in this else block would only execute if we were
unsuccessful in spawning a child process.  But that isn't what happens
either.  So can anyone explain to me what is happening here and maybe
suggest what I should be doing with the code to acieve my purpose?

-------------------==== Posted via Deja News ====-----------------------
      http://www.dejanews.com/     Search, Read, Post to Usenet


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

Date: 28 Oct 1997 11:48:50 -0700
From: lmulcahy@nyx.net (Larry Mulcahy)
Subject: DBD-Oracle-0.47.tar.gz corrupted?
Message-Id: <635c2i$7b5$1@nyx10.nyx.net>

I've tried to download this half a dozen times and each time I wind up
with something that (gnu) zcat doesn't recognize.  Yes, I know about
setting FTP to binary mode, though I've mostly been trying to do this
from Netscape.

Did a bad file get into the CPAN distribution?

-- 
Larry Mulcahy		bofh@ecentral.com	lmulcahy@nyx.net
http://www.nyx.net/~lmulcahy/   http://www.geocities.com/Area51/Zone/9653/
GEEK CODE (v3.1) GCS d s a C++$ UL++++$ P+++$ L++ E+ W+++$ N+ K w--- 
    M-- V- PS+++ PE+ Y+ PGP+ t* 5++ X++ R tv b+++ DI++ D+++ G e+++ h+ r* y-


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

Date: Tue, 28 Oct 1997 20:33:20 GMT
From: me@no-spam.com (Mike Rambour)
Subject: detecting reload
Message-Id: <635i4u$sbl@daffy.sb.west.net>

I have a script that outputs data to a data file and creates a web
page on the fly.  Its all working but if the user presses the reload
button on his browser it reloads the thing and I end up with duplicate
data in my data file since the data is passed as hidden text fields.

 Is there a way to detect a reload, I tried looking at REQUEST_METHOD
but it shows a POST not a reload...

	mike
	mikey at inline-tech dot com  
      soon to be mikey at singercars dot com (anyday now)
(replace at with @ and replace dot with . to reply)

And for you automated email spammers out there, here's the email addresses 
of the current board of the Federal Communications Commission:
Chairman Reed Hundt: rhundt@fcc.gov 
Commissioner James Quello: jquello@fcc.gov 
Commissioner Susan Ness: sness@fcc.gov 
Commissioner Rachelle Chong: rchong@fcc.gov

And let's help you send some spam to the USPS, too:
customer@email.usps.gov



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

Date: Tue, 28 Oct 1997 15:51:33 -0600
From: jason@cimedia.com (Jason Bodnar)
Subject: Exception.pm?
Message-Id: <878074981.23522@dejanews.com>

Exception.pm is mentioned in Advanced Perl Programming but is not listed
in the module index on CPAN. I found Exceptions.pm (note the 's') by
PSEIBEL. It requires Class/MethodMaker. I installed v0.92 of it without a
problem. All tests passed. I then tried to install Exceptions 0.01. No
problem with make but make test failed due to an error in MethodMaker:

Taz:$ make test
PERL_DL_NONLAZY=1 /usr/local/bin/perl -I./blib/arch -I./blib/lib
-I/usr/local/lib/perl5/sun4-solaris/5.00401 -I/usr/local/lib/
perl5 test.pl
1..1
Not an ARRAY reference at
/usr/local/lib/perl5/site_perl/Class/MethodMaker.pm line 132.
BEGIN failed--compilation aborted at blib/lib/Exceptions.pm line 123.
BEGIN failed--compilation aborted at test.pl line 11.
not ok 1
*** Error code 2
make: Fatal error: Command failed for target `test_dynamic'

Is there a working version of either MethodMaker or Exceptions?

Thanks.

Jason Bodnar

-------------------==== Posted via Deja News ====-----------------------
      http://www.dejanews.com/     Search, Read, Post to Usenet


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

Date: 28 Oct 1997 21:39:31 GMT
From: jgloudon@bbn.remove.com (Jason Gloudon)
Subject: Re: filehandle storage in class?
Message-Id: <635m2j$e$1@daily.bbnplanet.com>

Clinton Wong (clintdw@netcom.com) wrote:
: Anyone know of a good way for a class (package) to internally keep a
: filehandle?  For now, I do this:
  
: There's gotta be a better way...  The Sockets.pm module seemed to
: handle this nicely but I didn't find much when I went poking
: around in there.  Ideas?

Did you try perldoc IO::Handle and IO::File ?

Jason Gloudon


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

Date: Tue, 28 Oct 1997 13:08:53 -0600
From: Kermit Tensmeyer <kermit@ticnet.com>
Subject: Re: Filehandles and nested-if-loops
Message-Id: <34563845.B259FEEA@ticnet.com>

Joseph June wrote:
> 
> Hello,
> 
> If anyone can help me solve this problem, it will be GREATLY appreciated.
> 
> Currently I'm reading in a file to an filehandle via
> 
> while ($rulefile_line = <RULEFILE> ...

 Rather than re-invent the wheel, why not use an existing module?
 
 Try the Data::Locations module It will let you define the use of
 text in one place, and then generate the text later. The order of
 the text generation does not need to match the order of the
 text usage. (you can reuse the same section of text in many
 places)(or generate entries for the table of contents as you
 are generating the block contents.)




-- 
-------
  Kermit Tensmeyer    (E & T - Networking)
  Kermit@ticnet.com     Dallas


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

Date: Tue, 28 Oct 1997 19:17:33 GMT
From: theresa@nytimes.com
Subject: help for perl NT4.0
Message-Id: <345639d6.20809158@newsgate.nytimes.com>

Hi:
	Where can I download the perl that can run on NY4.0 from
command line. Thanks in advance.


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

Date: Tue, 28 Oct 1997 16:24:32 -0500
From: Berny Gordon <berny@nortel.com>
Subject: ingperl's connect command problem
Message-Id: <34565810.8A065288@nortel.com>

Good day,

I hope somebody could help me out with the following...

I have a problem using the "connect" command:

&sql("connect $database -Rglobal_admin -u$userid");

where $database is the database I'm trying to connect to, and the
$userid is the
user I'm trying to connect as.

The problem I constantly get is that no matter what first delimited
argument I pass in,
it takes everything that follows the argument as a string.
    Ex: connect $database -Rglobal_admin -u$userid
    Contents of -R is: "global_admin -u$userid"
          and the user is not set.

    Ex: connect $database -u$userid -Rglobal_admin
    Contents of -u is: "$userid -Rglobal_admin"
           and the role is not set.

I would really appreciate it if somebody could lead me in the right
direction with this
problem.

    Thanks




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

Date: Tue, 28 Oct 1997 15:25:42 -0500
From: John P Reber <John.P.Reber@mail.tju.edu>
Subject: Installing on SGI Irix 6.2 Hangs
Message-Id: <34564A46.5B1E19ED@mail.tju.edu>

This is a multi-part message in MIME format.
--------------1C3221A0A9AADE1DC6539688
Content-Type: text/plain; charset=us-ascii
Content-Transfer-Encoding: 7bit

While trying to install perl 5.004_01 on an Irix 6.2 system, the
installation hangs. The last line displayed is:

'What is the type for the 2nd, 3rd, and 4th arguments to select? [fd_set
*]'

output of 'uname -a':

IRIX64 zug 6.2 06101031 IP28

I'm compiling using the defaults

'sh Configure -des'



--------------1C3221A0A9AADE1DC6539688
Content-Type: text/x-vcard; charset=us-ascii; name="vcard.vcf"
Content-Transfer-Encoding: 7bit
Content-Description: Card for John Reber
Content-Disposition: attachment; filename="vcard.vcf"

begin:          vcard
fn:             John Reber
n:              Reber;John
org:            Kimmel Cancer Center
adr:            233 South 10th St;;Room 812 BLSB;Philadelphia;PA;19107;USA
email;internet: John.P.Reber@mail.tju.edu
title:          System Design Manager
tel;work:       215/503-4174
tel;fax:        215/923-2117
x-mozilla-cpt:  ;0
x-mozilla-html: FALSE
version:        2.1
end:            vcard


--------------1C3221A0A9AADE1DC6539688--



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

Date: Tue, 28 Oct 1997 19:57:30 GMT
From: Joseph June <jjune@midway.uchicago.edu>
Subject: Multiple filehandles
Message-Id: <Pine.GSO.3.95.971028134955.28217B-100000@harper.uchicago.edu>

Hello... 

Another quick question for the perl experts..
Is there a way to have multiple filehandles?
let me make that more clear.. :)

i create a filehandle by

open(RULEFILE, "FILENAME")

and i start a while loop that goes something like

while ($rulefile_line = <RULEFILE> ) {

 ...

I need an another filehandle that will "move" with <RULEFILE> in the while
loop.  So for exameple... i can create another filehandle <BUFFER> by

open(BUFFER, "FILENAME")

but... i can't do 

while ($rulefile_line = <RULEFILE> && $rulefile_buffer = <BUFFER>) {

HOw can i do something of equivalence?

Thanks for all the help!

Regards,
Joseph June
 





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

Date: Tue, 28 Oct 1997 12:04:27 -0800
From: Tom Phoenix <rootbeer@teleport.com>
To: Aaron Addison <Aaron@landru.com>
Subject: Re: Please Help getting keystrokes.
Message-Id: <Pine.GSO.3.96.971028120054.23246G-100000@usertest.teleport.com>

On Tue, 28 Oct 1997, Aaron Addison wrote:

> Newsgroups: comp.lang.perl, comp.lang.perl.misc

If your news administrator still carries comp.lang.perl, please let him
or her know that that newsgroup has not existed since 1995. If you
have such an outdated newsgroup listing, you are probably missing out
on many other valid newsgroups as well. You'll be doing yourself and
many others a favor to use only comp.lang.perl.misc (and other valid
Perl newsgroups) instead.

> I need to from within perl, check to see
> if there is a keystroke waiting, 

If you've tried the methods in the FAQ, you've tried the best methods out
there. The next step is to ask your local experts, your vendor, or to
search for a newsgroup or users' group for your machine, to see whether
anyone else has good ideas. And, if you find a way to do what you want
beyond the FAQ's answer, please send it to the FAQ maintainers. We all
want the FAQ to be as complete and useful as possible. Good luck!

-- 
Tom Phoenix           http://www.teleport.com/~rootbeer/
rootbeer@teleport.com  PGP   Skribu al mi per Esperanto!
Randal Schwartz Case:  http://www.rahul.net/jeffrey/ovs/
              Ask me about Perl trainings!




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

Date: 28 Oct 1997 19:19:26 GMT
From: kcarroll@halcyon.com (Kris Carroll)
Subject: shtlm problem though perl works
Message-Id: <635dru$42n$1@brokaw.wa.com>

At http://www.horse-country.com/ridindex.shtml

I have the script working (images plus links) but the two images - a gif and 
the ramdom image  - don't sit side by side as they should. The shtml says:

<P align=center><A
HREF="http://206.63.62.61/htbin/imagemap/maps/hcbuttons.map"><IMG
SRC="media/hcbuttons.gif" alt="HC List" BORDER=0 ISMAP></A><!--#exec
cgi="/cgi-bin/kcarroll/hc_random2.pl"--> </a></p>

Please, could anyone tell me what I did wrong?

Kris Carroll
kcarroll@horse-country.com


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

Date: Tue, 28 Oct 1997 14:00:38 -0600
From: "Valentin C. Briones" <valentin@cssdomain.com>
Subject: Simulating ${parm:-$parm2}
Message-Id: <34564465.477973C8@cssdomain.com>


--------------884B0A35E0F0618969F02477
Content-Type: text/plain; charset=us-ascii
Content-Transfer-Encoding: 7bit

In Perl, what is a short, elegant, legible way of simulating ksh's

    var=${parm:-$parm2}

functionality.   I have come up with:

   $var = (defined $parm||$parm) ? $parm : $parm2;

but I am wondering whether there is anything shorter and more elegant
than this.

TIA,
  VCB

--------------884B0A35E0F0618969F02477
Content-Type: text/html; charset=us-ascii
Content-Transfer-Encoding: 7bit

<HTML>
<TT>In Perl, what is a short, elegant, legible way of simulating ksh's</TT><TT></TT>

<P><TT>&nbsp;&nbsp;&nbsp; var=${parm:-$parm2}</TT><TT></TT>

<P><TT>functionality.&nbsp;&nbsp; I have come up with:</TT><TT></TT>

<P><TT>&nbsp;&nbsp; $var = (defined $parm||$parm) ? $parm : $parm2;</TT><TT></TT>

<P><TT>but I am wondering whether there is anything shorter and more elegant</TT>
<BR><TT>than this.</TT><TT></TT>

<P><TT>TIA,</TT>
<BR><TT>&nbsp; VCB</TT></HTML>

--------------884B0A35E0F0618969F02477--



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

Date: Tue, 28 Oct 1997 07:15:17 -0000
From: "Hugh" <hnews@harvest-lodge.demon.co.uk>
Subject: String manipulation - Help Required
Message-Id: <878071013.18908.1.nnrp-02.c2de48f0@news.demon.co.uk>

I am trying to read data from a web page form using post, this bit works
fine
and I get a long string $FORM{'items'} which I want to process.
items contains a long string comprising a csv file ie.
aa=123,bb=123,cc=ede,dd=2342,ee=ededw,ff=efef,aa=1233,bb=erec, etc.etc.
I want to be abel to take each group of values aa-ff in turn and process
them,
My attempt is below, problem is the incoming data does not appear to have
linebreaks
between lines. How can I get round this?

read(STDIN, $buffer, $ENV{'CONTENT_LENGTH'});
@pairs = split(/&/, $buffer);
foreach $pair (@pairs)
{
    ($name, $value) = split(/=/, $pair);
    $value =~ tr/+/ /;
    $value =~ s/%([a-fA-F0-9][a-fA-F0-9])/pack("C", hex($1))/eg;
    $FORM{$name} = $value;
}
# FORM{$items} now contains 1 string of all submissions
$dat = $FORM{'items'};
@pairs = split(/,/, $dat);
foreach $line ($dat)
{
 ($aa, $bb, $cc, $dd, $ee, $ff) = split(',',$line);
 print "<TR><TD><font size=2>Sign=$sg</TD></TR>";
}





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

Date: Tue, 28 Oct 1997 07:14:02 -0000
From: "Hugh" <hnews@harvest-lodge.demon.co.uk>
Subject: String Manipulation Help Required
Message-Id: <878070934.18867.1.nnrp-02.c2de48f0@news.demon.co.uk>

I am trying to read data from a web page form using post, this bit works
fine
and I get a long string $FORM{'items'} which I want to process.
items contains a long string comprising a csv file ie.
aa=123,bb=123,cc=ede,dd=2342,ee=ededw,ff=efef,aa=1233,bb=erec, etc.etc.
I want to be abel to take each group of values aa-ff in turn and process
them,
My attempt is below, problem is the incoming data does not appear to have
linebreaks
between lines. How can I get round this?

read(STDIN, $buffer, $ENV{'CONTENT_LENGTH'});
@pairs = split(/&/, $buffer);
foreach $pair (@pairs)
{
    ($name, $value) = split(/=/, $pair);
    $value =~ tr/+/ /;
    $value =~ s/%([a-fA-F0-9][a-fA-F0-9])/pack("C", hex($1))/eg;
    $FORM{$name} = $value;
}
# FORM{$items} now contains 1 string of all submissions
$dat = $FORM{'items'};
@pairs = split(/,/, $dat);
foreach $line ($dat)
{
 ($aa, $bb, $cc, $dd, $ee, $ff) = split(',',$line);
 print "<TR><TD><font size=2>Sign=$sg</TD></TR>";
}





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

Date: Tue, 28 Oct 1997 21:24:08 -0000
From: "Hugh" <hnews@harvest-lodge.demon.co.uk>
Subject: String manipulation with Perl - Help Please
Message-Id: <878073773.19682.0.nnrp-09.c2de48f0@news.demon.co.uk>

I am trying to read data from a web page form using post, this bit works
fine
and I get a long string $FORM{'items'} which I want to process.
items contains a long string comprising a csv file ie.
aa=123,bb=123,cc=ede,dd=2342,ee=ededw,ff=efef,aa=1233,bb=erec, etc.etc.
I want to be abel to take each group of values aa-ff in turn and process
them,
My attempt is below, problem is the incoming data does not appear to have
linebreaks
between lines. How can I get round this?

read(STDIN, $buffer, $ENV{'CONTENT_LENGTH'});
@pairs = split(/&/, $buffer);
foreach $pair (@pairs)
{
    ($name, $value) = split(/=/, $pair);
    $value =~ tr/+/ /;
    $value =~ s/%([a-fA-F0-9][a-fA-F0-9])/pack("C", hex($1))/eg;
    $FORM{$name} = $value;
}
# FORM{$items} now contains 1 string of all submissions
$dat = $FORM{'items'};
@pairs = split(/,/, $dat);
foreach $line ($dat)
{
($aa, $bb, $cc, $dd, $ee, $ff) = split(',',$line);
print "<TR><TD><font size=2>Sign=$sg</TD></TR>";
}







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

Date: Tue, 28 Oct 1997 13:37:53 -0600
From: dmorr@software.net
To: dmorr@software.net
Subject: Sybperl dbuse closing STDOUT?
Message-Id: <878066434.14023@dejanews.com>

I'm experiencing this strange intermittent problem with dbuse.
I have a script which is hitting a Sybase database repeatedly
throughout the life of the script.  At each iteration, it is
calling $dbh->dbuse('database');  Occasionally, all output from
the script stops after the last dbuse call.

Or, I should say, all output to STDOUT does not make it to a web
browser.  Printing to a log file still works fine, and the script
continues on its merry way as long as there are no print statements.

I can't duplicate this on the command line; it also doesn't happen
every time through a browser.  I *can* reliably duplicate it if
it happens once by reloading the form, but the same series of
steps will not always produce the error.

I saw a post recently about this in this groupd, but the responses
had to do with the SYBASE environment variable, which is set before
and after the dbuse command.  Anybody have any other ideas about what's
going on?  I'm pretty puzzled by this one.

I'm running perl 5.003, and Sybperl 2.07.

Thanks,
Dave

-------------------==== Posted via Deja News ====-----------------------
      http://www.dejanews.com/     Search, Read, Post to Usenet


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

Date: Tue, 28 Oct 1997 16:40:30 -0500
From: Henry Hartley <HARTLEH1@westatNOSPAM.com>
Subject: Re: Year2000 problem with localtime();
Message-Id: <34565BCE.CDCAD6AE@westatNOSPAM.com>

True.  My understanding, however, is that the range for dates in perl is 2038.
Is that not true?  Try running this code:

#!/usr/local/bin/perl -w
print "Content-type: text/html\n\n";
for ($x==0; $x<43; $x++) {
  $y = $x * (24*60*60*365.24);
  ($sec, $min, $hour, $mday, $mon, $year, $wday, $yday, $isdst) =
localtime(time+$y);
  $mon = $mon +1;
  $year = $year+1900;
  print "$mon, $mday, $year, $wday, $yday, $isdst, $hour, $min, $sec \n";
}

and notice what happens in 2038.  I understand this is not the same as the year
2000 problem but I can see where it might be a problem.

Henry



I R A Aggie wrote:

>      Declarations of all the functions and externals, and the tm structure,
>      are in the time.h header file.  The structure declaration is:
>
>           struct    tm {
>                int  tm_sec;   /* seconds after the minute - [0, 61] */
>                                    /* for leap seconds */
>                int  tm_min;   /* minutes after the hour - [0, 59] */
>                int  tm_hour;  /* hour since midnight - [0, 23] */
>                int  tm_mday;  /* day of the month - [1, 31] */
>                int  tm_mon;   /* months since January - [0, 11] */
>                int  tm_year;  /* years since 1900 */
>
> Hmmm...years since 1900...hmmm...and no range like [0-99]...hmmm...
>
>                int  tm_wday;  /* days since Sunday - [0, 6] */
>                int  tm_yday;  /* days since January 1 - [0, 365] */
>                int  tm_isdst; /* flag for alternate daylight */
>                                    /* savings time */
>           };





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

Date: Tue, 28 Oct 1997 14:57:10 -0500
From: "B.J. Dweck" <bjdweck@cloud9.net>
Subject: Zipping files on a UNIX system, with a cgi Perl script
Message-Id: <34564396.853524D7@cloud9.net>

I wrote a Perl script on my UNIX WWW account, which, when called via
WWW, zip's a bunch of files, sends the location of the zip file to the
user's browser to initiate download, and deletes the file afterwards. 
It is meant as a means of backing up my data files on the server, via
the web.  When I run the program from the shell, while logged on to my
account, it works fine.  When I run it through the web, however, the
program doesn't create the zip file, leading to an error message from
the browser, that it can't find the file.  Figuring that the problem had
to do with permissions, I tried turning on the set-uid bit, for the file
which contains the program.  This would give the user of the program, my
uid, and therefore, access to anything that I would have access to,
while logged in to my UNIX shell account.  This didn't work.

I used the following lines to zip the files:
	open(CMD,'|zip -r9 backup.zip ../data.bjd ../data.bjd.log');
	close(CMD);

The following is a copy of the program (with various parts omitted):
------------------------------------------------------------------------------
#!/usr/local/bin/perl5

require("../data-cgi.pl");	# Include various subroutines

&ReadParse;		# Reads and Parses the any variables submitted with a form

if ($in{'BackupType'} eq "Data") {
	&DataBackup;
} elsif ($in{'BackupType'} eq "Full") {
	&FullBackup;
} else {
	print &PrintHeader;	# Prints a message to the browser that an HTML
				# Document is coming.
	&BackupMenu;		# Displays a backup menu
}

sub BackupMenu {
	# Displays a menu in HTML, for what files to backup.
	# A new form is created for each option.
	# Each option (or form) has a hidden field, in which it assigns a value
to BackupType,
	# and it's own submit button, containing the description of the backup.
}

sub DataBackup {
	open(CMD,'|zip -r9 backup.zip ../data.bjd ../data.bjd.log');
	close(CMD);
	print "Location: ./backup.zip\n\n";
}

sub FullBackup {
	# Same as DataBackup, but with different files to zip.
}
------------------------------------------------------------------------------

Perhaps you could give my some advice on how to remedy the problem, or
an alternative means of zipping the files with Perl.

Many thanks in advance!!
B.J. Dweck


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

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


Administrivia:

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

	subscribe perl-users
or:
	unsubscribe perl-users

to almanac@ruby.oce.orst.edu.  

To submit articles to comp.lang.perl.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 1240
**************************************

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