[19724] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 1919 Volume: 10

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Fri Oct 12 18:05:43 2001

Date: Fri, 12 Oct 2001 15:05:12 -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: <1002924311-v10-i1919@ruby.oce.orst.edu>
Content-Type: text

Perl-Users Digest           Fri, 12 Oct 2001     Volume: 10 Number: 1919

Today's topics:
    Re: $5  -> 7 back issues of "The Perl Journal" <jurgenex@hotmail.com>
    Re: 20-line webserver in perl ? (Lawrence Foard)
    Re: 20-line webserver in perl ? (Randal L. Schwartz)
    Re: CGI Authorization module? <khera@kcilink.com>
    Re: changing a submit button to a link <jurgenex@hotmail.com>
    Re: changing a submit button to a link <noname@nowhere.com>
    Re: counting substrings in strings <jurgenex@hotmail.com>
        creating primary key using dbd::odbc <matthew.garrish@sympatico.ca>
    Re: DBI ODBCD MS-Access Error <jraff@home.com>
        Doing cyclic log files <peterhi@shake.demon.co.uk>
    Re: Doing cyclic log files <ilya@martynov.org>
    Re: executing batch file from script <goldbb2@earthlink.net>
    Re: FTP mirror script <anders.floderus@swipnet.se>
    Re: Getting a list of running programs under Windows200 (Malcolm Dew-Jones)
    Re: Hashe keys and references? <jeff@vpservices.com>
        How do you get paid for Perl work over the Internet?? <aperlprogrammer@yahoo.com>
        How to make a script put itself into background? <Tassilo.Parseval@post.rwth-aachen.de>
    Re: How to make a script put itself into background? <ilya@martynov.org>
    Re: How to make a script put itself into background? <Tassilo.Parseval@post.rwth-aachen.de>
    Re: How to print out uninitialized variables (a field i <goldbb2@earthlink.net>
    Re: How to stop File Upload (CGI) <real@earthling.net>
    Re: Keeping an escape code in a line <goldbb2@earthlink.net>
    Re: Mailing list subscription script <Thomas@Baetzler.de>
        matching something in $a, dumping into $b? <Mark.Drummond@Sun.COM>
    Re: matching something in $a, dumping into $b? <ilya@martynov.org>
        Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)

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

Date: Fri, 12 Oct 2001 09:07:57 -0700
From: "Jürgen Exner" <jurgenex@hotmail.com>
Subject: Re: $5  -> 7 back issues of "The Perl Journal"
Message-Id: <3bc7155d$1@news.microsoft.com>

"lbecker" <lwbecker2@hotmail.com> wrote in message
news:imkcstkpakq4ape0e9rveok8cn8aaliksq@4ax.com...
> 7 mint issues of The Perl Journal, if interested go to:
>
> http://cgi.ebay.com/aw-cgi/eBayISAPI.dll?ViewItem&item=[xxxxxx]

See http://pages.ebay.com/help/usenet_policy.html

<QUOTE>
eBay users may not post on Usenet groups (Internet newsgroups) to advertise
eBay or an eBay listing [...]
We have no tolerance for UseNet abuse and will take action as appropriate.
<END QUOTE>

jue




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

Date: 12 Oct 2001 11:26:40 -0700
From: entropy@farviolet.com (Lawrence Foard)
Subject: Re: 20-line webserver in perl ?
Message-Id: <9q7cl0$pv8$1@farviolet.com>

In article <m1g08q2bcl.fsf@halfdome.holdit.com>,
Randal L. Schwartz <merlyn@stonehenge.com> wrote:
>>>>>> "Uri" == Uri Guttman <uri@sysarch.com> writes:
>
>ML> All work was done in 20 lines without modules. Of course it isn't
>ML> complete web server, but it works.
>
>Uri> i think randal did that one. i am sure he will pop in here with the
>Uri> answer either way.
>
>Uri> it was an extremely minimal server but it did use modules for the socket
>Uri> and related stuff. 
>
>No, I've not written a webserver that didn't use HTTP::Daemon.
>
>Why?  BECAUSE I REFUSE TO REINVENT A WORKING WHEEL.
>
>{sigh}
>
>This "without modules" thing keeps getting me irritated.
>
>Part of Perl culture is the ability to install modules and reuse the
>CPAN.  Without that, I argue you don't have *true* access to Perl.  So
>if you're getting so-called "perl" from a webhost service, but they
>don't let you install modules (or they don't install CPAN modules for
>you), YOU ARE NOT GETTING perl!

In the original message he explained that it was to be educational. There
are a number of valid reasons to reinvent the wheel (after all if you may
have noticed there isn't just one standard tire out there for sale...).

1) Education - If you really want to understand something doing it from the
               ground up is the best way. This doesn't mean you necessarily
               use the code in production, but the exercise means that you
               really understand whats going on.

2) Efficiency - An off the shelf wheel is great to get something up and
                going quickly. But at some point the fact that its not 
                an exact fit may become an issue.

3) Coding time - Sometimes the preexisting wheel is a really bad fit to 
                 start with. You can spend more time working around the
                 bad fit than it would take to start from scratch.

Don't reinvent the wheel if you don't need to, but don't take the "Don't
reinvent the wheel" mantra as the only factor in your decision making
process. All rules of thumbs have exceptions. I've seen and been involved in
both extremes, reinventing too much, and/or trying to make an existing
library fit where it really shouldn't be.
-- 
      Be a counter terrorist perpetrate random senseless acts of kindness
     Rave: Immanentization of the Eschaton in a Temporary Autonomous Zone.
     I'm looking for computer hardware donations for charities, E-mail me.
   Available for contracting http://www.farviolet.com/~entropy/resume2001.txt


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

Date: 12 Oct 2001 14:51:56 -0700
From: merlyn@stonehenge.com (Randal L. Schwartz)
Subject: Re: 20-line webserver in perl ?
Message-Id: <m1lmigsf0j.fsf@halfdome.holdit.com>

>>>>> "Lawrence" == Lawrence Foard <entropy@farviolet.com> writes:

Lawrence> In the original message he explained that it was to be
Lawrence> educational. There are a number of valid reasons to reinvent
Lawrence> the wheel (after all if you may have noticed there isn't
Lawrence> just one standard tire out there for sale...).

Lawrence> 1) Education - If you really want to understand something
Lawrence> doing it from the ground up is the best way. This doesn't
Lawrence> mean you necessarily use the code in production, but the
Lawrence> exercise means that you really understand whats going on.

Part of education is that you also study existing art.  He didn't
mention that he had already studied the source of HTTP::Daemon.  So,
first, write it (or look at it) using HTTP::Daemon, *then* reinvent
HTTP::Daemon.

print "Just another Perl hacker,"

-- 
Randal L. Schwartz - Stonehenge Consulting Services, Inc. - +1 503 777 0095
<merlyn@stonehenge.com> <URL:http://www.stonehenge.com/merlyn/>
Perl/Unix/security consulting, Technical writing, Comedy, etc. etc.
See PerlTraining.Stonehenge.com for onsite and open-enrollment Perl training!


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

Date: 12 Oct 2001 15:02:15 -0400
From: Vivek Khera <khera@kcilink.com>
Subject: Re: CGI Authorization module?
Message-Id: <x7itdkbs20.fsf@onceler.kciLink.com>

>>>>> "c" == cybertoast  <sundar> writes:

c> I've been using some code for authorizing my users against a MySQL
c> database for my CGI code (using File::Cache and cookies).
c> I was wondering if there was anyone working on something like a

Check out Apache::AuthCookie perhaps.  You can make it authenticate
however you like to whatever database you like.

-- 
=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
Vivek Khera, Ph.D.                Khera Communications, Inc.
Internet: khera@kciLink.com       Rockville, MD       +1-240-453-8497
AIM: vivekkhera Y!: vivek_khera   http://www.khera.org/~vivek/


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

Date: Fri, 12 Oct 2001 09:10:36 -0700
From: "Jürgen Exner" <jurgenex@hotmail.com>
Subject: Re: changing a submit button to a link
Message-Id: <3bc715fc$1@news.microsoft.com>

"wildphir" <noname@nowhere.com> wrote in message
news:9q6rot$5v9$1@bob.news.rcn.net...
> This is a cgi poll file which has a "View Results" button and I want to
> change that to a link. What do I change the input type to?  and how do I
> make that a link?  thanks
>
>    print "<input type=submit value=\"View
Results\"></form></center><p>\n";
>   }
>   print "<center>\n";
>   print "</font></td></tr></table>\n";
>   exit;

Well, as far as Perl is concerned you would still use a "print" statement
(although personally I would recommend to use a here document instead).
As far as the HMTL is concerned you may want to ask in an HTML or
webauthoring NG.

jue




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

Date: Fri, 12 Oct 2001 15:41:05 -0400
From: "wildphir" <noname@nowhere.com>
Subject: Re: changing a submit button to a link
Message-Id: <9q7gqa$ar5$1@bob.news.rcn.net>


"Jürgen Exner" <jurgenex@hotmail.com> wrote in message
news:3bc715fc$1@news.microsoft.com...
> "wildphir" <noname@nowhere.com> wrote in message
> news:9q6rot$5v9$1@bob.news.rcn.net...
> > This is a cgi poll file which has a "View Results" button and I want to
> > change that to a link. What do I change the input type to?  and how do I
> > make that a link?  thanks
> >
> >    print "<input type=submit value=\"View
> Results\"></form></center><p>\n";
> >   }
> >   print "<center>\n";
> >   print "</font></td></tr></table>\n";
> >   exit;
>
> Well, as far as Perl is concerned you would still use a "print" statement
> (although personally I would recommend to use a here document instead).
> As far as the HMTL is concerned you may want to ask in an HTML or
> webauthoring NG.
>
> jue

Thanks for your polite reply.  I know this is a perl script and I found out
I need more than just html to make it work.  I did email the author of the
script but it is a free script and he didn't have the time to help.  I
thought someone may help here.  I did ask at
alt.comp.infosystems.www.authorizing.cgi and they referred me to this group
for answers.

The script itself has to refer to the VIEW RESULTS page and I don't know how
to do that.

I will look for another script.





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

Date: Fri, 12 Oct 2001 09:36:39 -0700
From: "Jürgen Exner" <jurgenex@hotmail.com>
Subject: Re: counting substrings in strings
Message-Id: <3bc71c17$1@news.microsoft.com>

"shaz" <ssa1701@yahoo.co.uk> wrote in message
news:23e71812.0110111316.33ad8f63@posting.google.com...
> I want to count the number of times that a substring appears within a
> longer string.

In list context the m operator returns a list of all matches found. Just
take the length of this list. I'm sure this can be written nicer, but
anyway:
    $_ = "the end of these words";
    my @a = m/the/g;
    print "The substring 'the' appears " . scalar @a . " times in '$_'\n";

which produces the expected output
    The substring 'the' appears 2 times in 'the end of these words'

jue




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

Date: Fri, 12 Oct 2001 16:58:36 -0400
From: "Matt Garrish" <matthew.garrish@sympatico.ca>
Subject: creating primary key using dbd::odbc
Message-Id: <ZLIx7.33729$xy1.3281448@news20.bellglobal.com>

Hello,

I'm at my wits end with this one. I'm trying to set the primary key for the
new blank MS Access databases that can be added by the script, but every
command I've tried has come back with an unable to execute on undefined
value. I know that the table is defined, because it gets created despite the
script failing, which also means that the column bno exists as well. I've
tried everything from specifying the primary key in the create table command
to disconnecting and reconnecting to the database to blindly changing the
statement order around knowing how stupid MS can be about these things. I've
also tried adding data to the table before trying to specify the primary
key, but nothing works. I would therefore be eternally grateful to whoever
can tell me what's wrong with this statement that's causing the script to
fail:


my $nsk_sth = $ns_dbh->prepare("ALTER TABLE $nstable ADD PRIMARY KEY
(bno)");

Thanks in advance,

Matt





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

Date: Fri, 12 Oct 2001 20:43:12 GMT
From: "jlr" <jraff@home.com>
Subject: Re: DBI ODBCD MS-Access Error
Message-Id: <ABIx7.1908$s9.321157@news1.rdc1.nj.home.com>

MS Access likes parens.
I have had to put them in 2 and 3 deep to keep Access happy.
"Scott Davis" <scott_k_davis@yahoo.com> wrote in message
news:c3075022.0110100927.2319631b@posting.google.com...
> I am trying to insert records into a MS-Access Database (Access 97 or
> 2000).  I have downloaded all the latest perl modules and am able to
> connect to the database, however when I try to insert records I get
> the following error :
>
> DBD::ODBC::st execute failed: [Microsoft][ODBC Microsoft Access
> Driver] Too few parameters. Expected 2. (SQL-07001)(DBD:
> st_execute/SQLExecute err=-1) at D:\DBD-ODBC-0




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

Date: Fri, 12 Oct 2001 22:08:36 +0100
From: "Peter Hickman" <peterhi@shake.demon.co.uk>
Subject: Doing cyclic log files
Message-Id: <1002920851.11061.0.nnrp-10.9e980a61@news.demon.co.uk>

Is there a module for doing log files that change daily / weekly / monthly /
whatever. Or is there a need for one?




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

Date: 13 Oct 2001 01:16:23 +0400
From: Ilya Martynov <ilya@martynov.org>
Subject: Re: Doing cyclic log files
Message-Id: <87k7y0v9so.fsf@abra.ru>

>>>>> On Fri, 12 Oct 2001 22:08:36 +0100, "Peter Hickman" <peterhi@shake.demon.co.uk> said:

PH> Is there a module for doing log files that change daily / weekly /
PH> monthly / whatever. Or is there a need for one?

Quick search on CPAN reveals one such module: Logfile::Rotate

-- 
 -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
| Ilya Martynov (http://martynov.org/)                                    |
| GnuPG 1024D/323BDEE6 D7F7 561E 4C1D 8A15 8E80  E4AE BE1A 53EB 323B DEE6 |
| AGAVA Software Company (http://www.agava.com/)                          |
 -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-


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

Date: Fri, 12 Oct 2001 16:42:55 -0400
From: Benjamin Goldberg <goldbb2@earthlink.net>
Subject: Re: executing batch file from script
Message-Id: <3BC755CF.B35EB795@earthlink.net>

Jessica Bull wrote:
> 
> I am on windows NT.  I am trying to call a batch file to run from the
> script.  I am not able to get the script to call it correctly.  I am
> getting the error:  Directory or Filename does not exist or is not an
> operable batch program.  Can someone help me out?  This is what I
> have.
[snip]
> The code above calls a subroutine (edited below)...this is where I am
> trying to call the batch file.  The correct value is being passed in,
> but the OS doesn't seem to like the command.  Can someone help me out?
> Thanks so much!!!
> 
> sub Cpy_snd_chk {
>  my ($path, $batch) = @_;
>  `$batch` or die "Batch file open failed: $batch : $! \n";
> }

The value of `` is the captured results of the command.  So if $batch
doesn't produce any output, `$batch` will be an empty string... And in
perl, an empty string has a false value.  You should be using system if
what you want to know is whether or not the command succeeded.
sub Cpy_snd_chk {
    my ($path, $batch) = @_;
    my $rc = system($batch)
    die "Couldn't run $batch: $!" if $rc == -1;
    my ($sig, $ret) = ($rc&255, $rc>>8);
    die "$batch died from signal $sig" if $sig;
    die "$batch exited with code $ret" if $ret;
    # ok, no error.
}

-- 
    "Just how stupid are you Kuno?"
    "Verily, Tatewaki Kuno knows no limits."


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

Date: Fri, 12 Oct 2001 18:50:47 +0200
From: "ANDERS FLODERUS" <anders.floderus@swipnet.se>
Subject: Re: FTP mirror script
Message-Id: <5%Ex7.4184$Ad3.14805@nntpserver.swip.net>


Thomas Bätzler <Thomas@Baetzler.de> wrote in message
news:q88dst43t7kcgfjbgvc0jgvvg5f5k3tao1@4ax.com...
> On Thu, 11 Oct 2001, "ANDERS FLODERUS" <anders.floderus@swipnet.se>
> wrote:
>
 ...

I just want to say thank you, it was wonderful of you going
so much into details.

Anders



> HTH,
> --
> use strict;my($i,$t,@r)=(0,'5 -.@BHJPT4acd6e2hk2lmn2o4r2s3tuz',map{ord}
> split//,unpack('u*','L#`T&)QD5#0`#!!`#%1D)#08`#P05!!(3``$$"``#"0L&``('.
> '"`P<!`````0$`'));$t=~s/(\d)(.)/$2x$1/eg;map{$t.=substr$t,$i,1,''while
> $_--;$i++}@r;print"$t\n";# Thomas@Baetzler.de - http://baetzler.de/perl




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

Date: 12 Oct 2001 13:11:22 -0800
From: yf110@vtn1.victoria.tc.ca (Malcolm Dew-Jones)
Subject: Re: Getting a list of running programs under Windows2000
Message-Id: <3bc74e6a@news.victoria.tc.ca>

peter pilsl (pilsl_@goldfisch.at) wrote:
: Greg Webster wrote:

: > Heya all,
: > 
: > I'm a unix guy so doing perl under Win2k is a bit weird for me.
: > 
: > In Unix, I'd just grep 'ps ax' for what I needed and if a program
: > wasn't running I'd start it, but I wonder if there is a way for me to
: > do this under Win2k.
: > 
: > I've got a program that does some funky terminal emulation for an
: > external program to print to a local printer, and that program keeps
: > crashing. So what I'd like to do is have a perl script running on this
: > Win2k box that runs (via some freeware scheduler) once a minute,
: > checks to see if the terminal emulation program is running and if not,
: > starts it.
: > 

: There is no tool coming with win by default, but 

I do not think that is correct.  Windows comes with a .DLL, the name of
which I now forget but it probably includes "tool" in its name.  That dll
provides standard ways to scan through the task list. 

There is also a standard windows function to scan through all the windows,
and another to get information about each such window, and this is just as
good for the majority of purposes (such as finding a running program). 

All you need is a way to access these things from perl.  I've never done
that, but I've read of various windows modules that look like they may
well provide that sort of access, or at least provide examples of how to
acces them.

As for running a scheduled program, once you can access windows functions,
then your program should be able to go into a normal windows event loop
and therefore be able to wait for wakeup calls from windows, and therefore
perform its task on any schedule you desire. 
	e.g. (totally pseudo) 
	use Win32::API ; # made up name
	send_event(WM_TIMER,10);
	while (wait_for_event(WM_TIMER))
	{	do_our_task();
		send_event(WM_TIMER,10);
	}
	sub do_our_task
	{	$window = find_the_apps_window("emulator-app-name");
		system("start emulator-app-name") unless $window;
	}



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

Date: Fri, 12 Oct 2001 08:34:34 -0700
From: Jeff Zucker <jeff@vpservices.com>
Subject: Re: Hashe keys and references?
Message-Id: <3BC70D8A.CC6C8AD4@vpservices.com>

Dimitri wrote:
> 
> Can the key of a hash table element be a reference? Would the
> following work?
> 
> $key = [1, 2, 3];       ## reference to anonymous array (1, 2, 3)
> $val = "bla";

If you really need to do something like this, you'll have to use a tied
hash, either Tie::RefHash, or something you roll on your own.  For
example in AnyData I use hashrefs as keys to a reference to a tied hash:

    print $table->{ {field1=>'foo',field2=>'bar'} };

Ugly but useful, it prints the rows in the table that match the hashref
key's key/value pairs.

-- 
Jeff



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

Date: Fri, 12 Oct 2001 17:27:29 GMT
From: Carlos C. Gonzalez <aperlprogrammer@yahoo.com>
Subject: How do you get paid for Perl work over the Internet??
Message-Id: <MPG.1630d611c8f908329897ab@news.edmonton.telusplanet.net>

Hi everyone,

I am looking at marketing my services over the Internet to do some very 
basic Perl and other type of work but I was wondering how one would get 
paid for doing this?  

If this is not appropriate for this newsgroup can someone point me to one 
where I could ask questions related to this?  

The problem is that I could do the work and not be paid.  Is there some 
kind of an account where money could be put by a client but not released 
until the client and the programmer are satisfied as to the work 
performed?  Where the client could not take out the money either (as in 
not paying for work done) without the programmer's okay?

How do you all do it?  

Feel free to email me at miscellaneousemail@yahoo.com with any advice or 
insight on this that you might want to pass along (if you don't feel it 
appropriate to this newsgroup to discuss how to make an income 
programming in Perl over the Internet).  

As a side note would anyone be willing to pay me a commission in return 
for finding additional work for you?  I can market your services but 
would want to have some kind of return for my efforts.  Tied to the work 
that you get to be sure but a return nevertheless. I would probably want 
to work with newer programmers whose fees would not be very high yet.  So 
if you are a new Perl programmer I would like to hear from you.  I can 
only take on so much work myself timewise.  

Not that I am against working with more experienced programmers mind you.  
Only that more experienced programmers tend to charge high fees and most 
of my clients will want to be saving money.  

Again the same question would apply.  Namely how could I be re-assured of 
getting paid some commission for work I funnel your way?  Given that I 
live in Canada I'm unlikely to be willing to pursue legal recource in 
another country where you might live.  If it came down to not being paid 
the commission.

Thanks.

---
Carlos 
www.internetsuccess.ca (not operational yet)


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

Date: Fri, 12 Oct 2001 18:52:01 +0200
From: Tassilo von Parseval <Tassilo.Parseval@post.rwth-aachen.de>
Subject: How to make a script put itself into background?
Message-Id: <3BC71FB1.2050401@post.rwth-aachen.de>

Hi there,

Lately I have been working on a script excessively using Term::ReadKey. 
Basically the main-loop is in raw-mode and subsequently any control 
sequences like Ctrl+c and Ctrl+z aren't recognized.
So, I did something like this:

#! /usr/bin/perl -w

use strict;
use Term::ReadKey;

 ...

# constants taken from 'man ascii'
# any module exporting them already?
use constant => KEY_ETX => 3;
use constant => KEY_SUB => 26;

# readkey-loop
ReadMode 'raw';
while () {

	my $k;
	while (not defined ($k = ReadLine(-1)) ) {
		# wait
	}
	...
	if (ord($k) == KEY_ETX) { ReadMode 'restore'; exit }
	if (ord($k) == KEY_SUB) { # and now? }

}

How could I possibly make this script conform to standard UNIX behaviour 
in a sense that Ctrl+z (KEY_SUB) suspends the executing of the script 
temporarily? Is that possible at all?

Thanks to anyone who could give me a hint,
Tassilo

-- 
$a=[(74,116)];$b=[($a->[1]-1,$a->[1]++,0x20)];$c=[(97,110)];$d=[($c->
[1]+1,$b->[1],"her")];for(@{[$a,$b,$c,$d]}){for(@{$_}){$_=~/\d+/?print
(chr($_)):print;}}$c=sub{$l=shift;[(0x20+$l-1,0x50,0x65,0x73-0x01,108
),(0x20,0x68,0x61,)]};print(map{chr($_)}@{($c->(1))});$h={a=>33*3,b=>
10**2+7,c=>"1"."0"."1",d=>0162};@h=sort(keys(%$h));for(@h){print(chr(
ord(chr($h->{$_}))))};



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

Date: 12 Oct 2001 21:44:18 +0400
From: Ilya Martynov <ilya@martynov.org>
Subject: Re: How to make a script put itself into background?
Message-Id: <87itdkwy6l.fsf@abra.ru>

>>>>> On Fri, 12 Oct 2001 18:52:01 +0200, Tassilo von Parseval <Tassilo.Parseval@post.rwth-aachen.de> said:

TvP> Hi there,
TvP> Lately I have been working on a script excessively using
TvP> Term::ReadKey. Basically the main-loop is in raw-mode and subsequently
TvP> any control sequences like Ctrl+c and Ctrl+z aren't recognized.
TvP> So, I did something like this:

TvP> #! /usr/bin/perl -w

TvP> use strict;
TvP> use Term::ReadKey;

TvP> ...

TvP> # constants taken from 'man ascii'
TvP> # any module exporting them already?
TvP> use constant => KEY_ETX => 3;
TvP> use constant => KEY_SUB => 26;

TvP> # readkey-loop
TvP> ReadMode 'raw';
TvP> while () {

TvP> 	my $k;
TvP> 	while (not defined ($k = ReadLine(-1)) ) {
TvP> 		# wait
TvP> 	}
TvP> 	...
TvP> 	if (ord($k) == KEY_ETX) { ReadMode 'restore'; exit }
TvP> 	if (ord($k) == KEY_SUB) { # and now? }

And now

    use POSIX qw/SIGSTOP/;
    kill SIGSTOP, $$;

TvP> }


-- 
 -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
| Ilya Martynov (http://martynov.org/)                                    |
| GnuPG 1024D/323BDEE6 D7F7 561E 4C1D 8A15 8E80  E4AE BE1A 53EB 323B DEE6 |
| AGAVA Software Company (http://www.agava.com/)                          |
 -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-


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

Date: Fri, 12 Oct 2001 22:53:00 +0200
From: Tassilo von Parseval <Tassilo.Parseval@post.rwth-aachen.de>
Subject: Re: How to make a script put itself into background?
Message-Id: <3BC7582C.4030408@post.rwth-aachen.de>

Ilya Martynov wrote:

> And now
> 
>     use POSIX qw/SIGSTOP/;
>     kill SIGSTOP, $$;


Ah, thanks a lot! I knew it would be POSIX if any. Works splendidly.


Tassilo


-- 
$a=[(74,116)];$b=[($a->[1]-1,$a->[1]++,0x20)];$c=[(97,110)];$d=[($c->
[1]+1,$b->[1],"her")];for(@{[$a,$b,$c,$d]}){for(@{$_}){$_=~/\d+/?print
(chr($_)):print;}}$c=sub{$l=shift;[(0x20+$l-1,0x50,0x65,0x73-0x01,108
),(0x20,0x68,0x61,)]};print(map{chr($_)}@{($c->(1))});$h={a=>33*3,b=>
10**2+7,c=>"1"."0"."1",d=>0162};@h=sort(keys(%$h));for(@h){print(chr(
ord(chr($h->{$_}))))};



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

Date: Fri, 12 Oct 2001 17:19:02 -0400
From: Benjamin Goldberg <goldbb2@earthlink.net>
Subject: Re: How to print out uninitialized variables (a field in db is empty)?
Message-Id: <3BC75E46.F0A69DAC@earthlink.net>

Alex wrote:
> 
> Hi,
> 
> I'm a little confused about how to make Perl stop complaining about
> uninitialized variables when printing out fields from an Access
> database.
> For example, I have a table user with the following fields:
> Username
> Password
> Firstname
> Lastname
> Phone
> Fax
> Email
> 
> Then, on in website I have a page where all this information is
> displayed. I get record data using fetchrow_hashref() method from DBI
> module. So when I try to print out $hashref->{Fax} and the field "Fax"
> happens to be empty in the database I get this warning written in my
> mycgi-log.txt file: "Use of uninitialized value in concatenation (.)
> or string at..."

Happens to be empty?  As in, it has [in database parlance], a NULL
value?  Or did you possibly get the case confused between the fields
fetched in your select statement and the key used in the hashref?

eg, if you did:
my $sth = $dbi->prepare(q[SELECT username, fax FROM tablename]);
$sth->execute;
while( my $hashref = $sth->fetchrow_hashref ) {
    print $hashref->{Fax} . " " . $hashref->{UserName} . "\n";
}

Then the case of "fax" and "Fax" do no agree... so the hash element will
be empty [and thus undef].

> How do I avoid these warnings? It seems like it's too much of a pain
> in the tail to do something like if( exists($hashref->{field}) ){
> blah; blah; } each time I want to print out the content of a field.

There's a number of ways.  One is to make the strings not be
uninitialized.  You can do this in the database, or in the data fetched
from it:

Fix it in the database:
my $unnull = $dbi->prepare(q[
    UPDATE tablename
    SET ? = ''
    WHERE ? IS NULL
]);

foreach( qw/Username Password Firstname Lastname Phone Fax Email/ ) {
    $unnull->execute( $_, $_ );
}

Or fix it in the data fetched:
while( my $hashref = $sth->fetchrow_hashref ) {
    $_ = "" if !defined $_ foreach(@$hashref{keys %$hashref});
    # do stuff
}

If you fix it in the database, you only need to do the fix once -- if
nothing ever adds stuff to or changes stuff in the database.  If your
database contents are not static, you also need make sure not to add new
NULLs, which may involve changing code elsewhere.

If you fix it in the data feched, you have to do it every time.

A third way of course is to disable the warnings for the block:

while( my $hashref = $sth->fetchrow_hashref ) {
    no warnings 'uninitialized';
    # do stuff
}

or:
while( my $hashref = $sth->fetchrow_hashref ) {
    local $^W = 0;
    # do stuff
}

-- 
    "Just how stupid are you Kuno?"
    "Verily, Tatewaki Kuno knows no limits."


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

Date: Fri, 12 Oct 2001 17:48:16 +0200
From: "Real" <real@earthling.net>
Subject: Re: How to stop File Upload (CGI)
Message-Id: <9q73c1$ns0$1@news.surfnet.nl>

"Petar Markovic" <petar.markovic@uniserv.de> wrote in message
news:57c6q9.ti2.ln@news.uniserv.de...
> Hi,
>
> I an making CGI scripts for uploading files.
> It is designed for business clients and some of them need to upload
> large files.
>
> If a client pushes the Stop button on the browser I want the upload to
> stop and delete the part of file already copied to Server.
>
> my $error;
> while ($bytes_count = read($file_query,$buff,1024))
> {
>         $size += $bytes_count;
>         $bytes_loaded = $size;
>         $buff =~ s/\r//g;
>         print FILE $buff;
>         $error = $query->cgi_error();
>         if($error) {
>                 close(FILE);
>                 unlink("$upload_dir/$file_name");
>                 &Error("Upload interrupted, error: $error", 1);
>         }
> }
>
> When Stop button is pressed $query->cgi_error() function does not detect
> that signal.
>
> I don't know what to do in order to Cancel uploading in progress. It
> cannot be allowed because a file can be very large and should be
> deleted.
>
> Anybody has an idea how to fix this?

Just ideas ... but perhaps it can help you a bit. This is "general Perl"
since I don't program CGI (often).

Anyways, what you can try is checking if the stop-button results in a
signal. I've read somewhere that especialy NPH (non parsed headers) scripts
receive a PIPE signal when the stop-button is pressed. You probably known
how to code such a signal-handler aborting the upload.

Another method I can think of is using a seperate "Abort Upload" button in
your page. Take care; as far as I know, clicking a link/botton will start
another instance of your script. The tricky part is figuring out which
process must be aborted. Sending a user-defined signal to that process is a
way which enables you to cleanup partial uploads. And you can recycle the
code needed for the 1st option :)

Good luck,
Real





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

Date: Fri, 12 Oct 2001 16:29:33 -0400
From: Benjamin Goldberg <goldbb2@earthlink.net>
Subject: Re: Keeping an escape code in a line
Message-Id: <3BC752AD.D5E5A10F@earthlink.net>

Greg Thorne wrote:
[snip]
> After messing around with this statement some, I came up with:
> s/\\([nrt])/eval qq("\\$1")/eg;
> 
> Which doesn't do as much as your code snippet, but suits my needs just
> fine.

This could be simplified a bit, to:
    s/(\\[nrt])/"$1"/eeg;

-- 
    "Just how stupid are you Kuno?"
    "Verily, Tatewaki Kuno knows no limits."


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

Date: Fri, 12 Oct 2001 17:07:54 +0200
From: =?ISO-8859-1?Q?Thomas_B=E4tzler?= <Thomas@Baetzler.de>
Subject: Re: Mailing list subscription script
Message-Id: <3n1est4g3ftk8sq0ang3ch46ti0ud9lt1i@4ax.com>

On 12 Oct 2001, jeremyreynolds@yahoo.com (Jeremy Reynolds) wrote:

>Hoping that someone can point me in the right direction for a script

Wrong group. Try comp.infosystems.www.authoring.cgi

>jeremyreynolds_NOSPAM@yahoo.com (Remove '_NOSPAM' when replying)

This is not really effective against spammers if you have your real mail
address in the From: header.

HTH,
-- 
use strict;my($i,$t,@r)=(0,'5 -.@BHJPT4acd6e2hk2lmn2o4r2s3tuz',map{ord}
split//,unpack('u*','L#`T&)QD5#0`#!!`#%1D)#08`#P05!!(3``$$"``#"0L&``('.
'"`P<!`````0$`'));$t=~s/(\d)(.)/$2x$1/eg;map{$t.=substr$t,$i,1,''while
$_--;$i++}@r;print"$t\n";# Thomas@Baetzler.de - http://baetzler.de/perl


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

Date: Fri, 12 Oct 2001 14:57:19 -0400
From: Mark Drummond <Mark.Drummond@Sun.COM>
Subject: matching something in $a, dumping into $b?
Message-Id: <3BC73D0F.E5013466@Sun.COM>

Hi all. I think this should be simple. I have a scalar $a, and I want
to match part of $a with a regex, putting the result into $b. Like $b
= regex(/.*/,$a) if such a function existed.

- Mark


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

Date: 12 Oct 2001 23:19:06 +0400
From: Ilya Martynov <ilya@martynov.org>
Subject: Re: matching something in $a, dumping into $b?
Message-Id: <87sncovf85.fsf@abra.ru>

>>>>> On Fri, 12 Oct 2001 14:57:19 -0400, Mark Drummond <Mark.Drummond@Sun.COM> said:

MD> Hi all. I think this should be simple. I have a scalar $a, and I want
MD> to match part of $a with a regex, putting the result into $b. Like $b
MD> = regex(/.*/,$a) if such a function existed.

Something like

    ($b) = $a =~ /(PATTERN)/

?

-- 
 -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
| Ilya Martynov (http://martynov.org/)                                    |
| GnuPG 1024D/323BDEE6 D7F7 561E 4C1D 8A15 8E80  E4AE BE1A 53EB 323B DEE6 |
| AGAVA Software Company (http://www.agava.com/)                          |
 -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-


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

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


Administrivia:

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

	subscribe perl-users
or:
	unsubscribe perl-users

to almanac@ruby.oce.orst.edu.  

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

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

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


------------------------------
End of Perl-Users Digest V10 Issue 1919
***************************************


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