[23002] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 5222 Volume: 10

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Mon Jul 14 18:06:04 2003

Date: Mon, 14 Jul 2003 15:05:11 -0700 (PDT)
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)

Perl-Users Digest           Mon, 14 Jul 2003     Volume: 10 Number: 5222

Today's topics:
        assigning alternativ value if a regular expression has  <Rocco.Melzian@TU-Berlin.de>
    Re: assigning alternativ value if a regular expression  <go@away.spam>
    Re: assigning alternativ value if a regular expression  <mpapec@yahoo.com>
    Re: assigning alternativ value if a regular expression  <REMOVEsdnCAPS@comcast.net>
    Re: Big hash question (Ingo Fellner)
        building C DLL  for calling from Perl using (*.XS) (Kenjis Kaan)
    Re: building C DLL  for calling from Perl using (*.XS) <tassilo.parseval@rwth-aachen.de>
    Re: duplicate removal (Helgi Briem)
        Error during compile of 5.8.1-RC2 (Eric Kidder)
    Re: flock() and W95 <noreply@gunnar.cc>
        Help with Fileman V-1, File Manager <angel2@ShirT.com>
    Re: Help with Fileman V-1, File Manager <emschwar@pobox.com>
    Re: multi-part forms in CGI.pm <info@wienerlibrary.co.uk>
    Re: Need help with posting to CGI from javascript  <_sodamnmad_@_hotmail_._com_>
    Re: Need help with posting to CGI from javascript <emschwar@pobox.com>
    Re: Perl and telnet <syscjm@gwu.edu>
        Problem executing a BAT file (or EXE file) using Perl a <salzo@yahoo.com>
        Regex question... (Math55)
    Re: Regex question... (Greg Bacon)
    Re: safe cgi programming in perl? (Tad McClellan)
    Re: safe cgi programming in perl? (Tad McClellan)
        Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)

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

Date: Mon, 14 Jul 2003 18:53:58 +0200
From: Rocco Melzian <Rocco.Melzian@TU-Berlin.de>
Subject: assigning alternativ value if a regular expression has failed
Message-Id: <beumvk$jcp$1@mamenchi.zrz.TU-Berlin.DE>

Hello,

I am using regular expressions to filter words and numbers from $_ and 
assign them to $1 and $2 for further use

$_ =~ m/(.*?)(-{0,1}\d+)$/;

How can I assign an alternative value to $1 and $2 if the regular 
expression failed? (sometimes no there is no input, so I want to record 
a failure message)

Problem is: the digit "0" is a possible value in $1 or $2

I was trying

if(!$1){
   $var="alternativ values";
}
else{
   $var=$1;
}

or

if($1 eq undef){
   $var="alternativ values";
}
 ...

How cann I check whether a $scalar exists or not? Is there something 
like the "hash exists-function"? Thanks for helping me.

Rocco



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

Date: Mon, 14 Jul 2003 13:42:34 -0400
From: "LaDainian Tomlinson" <go@away.spam>
Subject: Re: assigning alternativ value if a regular expression has failed
Message-Id: <FTBQa.10843$b03.8556@lakeread03>

"Rocco Melzian" wrote:
> I am using regular expressions to filter words and numbers from $_ and
> assign them to $1 and $2 for further use
>
> $_ =~ m/(.*?)(-{0,1}\d+)$/;

To make things a little simpler, the m// operator operates on $_ by default,
the 'm' is not required if you are using forward slashes as delimiters, and
the {0,1} construct is exactly the same as '?' in that context.  So your
line is equivalent to:

/(.*?)(-?\d+)$/;

Check up on perlop under "Regexp Quote-Like Operators" for info on m// and
perlre for info on regular expressions.

> How can I assign an alternative value to $1 and $2 if the regular
> expression failed? (sometimes no there is no input, so I want to record
> a failure message)

In scalar context, m// also returns true if the match succeeds and false if
it doesn't.

if (/(.*?)(-?\d+)$/){
    $word = $1;
    $number = $2;
} else {
    print "Match failed.";
}

> How cann I check whether a $scalar exists or not? Is there something
> like the "hash exists-function"? Thanks for helping me.

You can try defined().  But most of the regexp operators will give you an
easy way to check if (or how many times) the match succeeded, so you
shouldn't really need to check whether the $n variables are defined, since
that may also give you unexpected results based on an earlier match.

Hope that helps,

Brandan L.
--
bclennox AT eos DOT ncsu DOT edu




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

Date: Mon, 14 Jul 2003 19:36:03 +0200
From: Matija Papec <mpapec@yahoo.com>
Subject: Re: assigning alternativ value if a regular expression has failed
Message-Id: <obq5hv0pk992pedmrh8oron98eevmag02n@4ax.com>

X-Ftn-To: Rocco Melzian 

Rocco Melzian <Rocco.Melzian@TU-Berlin.de> wrote:
>if($1 eq undef){
>   $var="alternativ values";
>}
>...
>
>How cann I check whether a $scalar exists or not? Is there something 
>like the "hash exists-function"? Thanks for helping me.

You can put the regex in 'if' condition,

if (m/(.*?)(-{0,1}\d+)$/) {
 ...
}

hope this helps,


-- 
Matija


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

Date: Mon, 14 Jul 2003 16:27:56 -0500
From: "Eric J. Roode" <REMOVEsdnCAPS@comcast.net>
Subject: Re: assigning alternativ value if a regular expression has failed
Message-Id: <Xns93B8B1BE95A1Csdn.comcast@206.127.4.25>

-----BEGIN xxx SIGNED MESSAGE-----
Hash: SHA1

Rocco Melzian <Rocco.Melzian@TU-Berlin.de> wrote in news:beumvk$jcp$1
@mamenchi.zrz.TU-Berlin.DE:

> Hello,
> 
> I am using regular expressions to filter words and numbers from $_ and 
> assign them to $1 and $2 for further use
> 
> $_ =~ m/(.*?)(-{0,1}\d+)$/;
> 
> How can I assign an alternative value to $1 and $2 if the regular 
> expression failed? (sometimes no there is no input, so I want to record 
> a failure message)

unless ( ($thing1, $thing2) = /(.*?)(-{0,1}\d+)$/ )
{
    $thing1 = 'default thing one';
    $thing2 = 'default thing two';
    print LOG "Had to use default values\n";
}

- -- 
Eric
$_ =  reverse sort qw p ekca lre Js reh ts
p, $/.r, map $_.$", qw e p h tona e; print

-----BEGIN xxx SIGNATURE-----
Version: PGPfreeware 7.0.3 for non-commercial use <http://www.pgp.com>

iQA/AwUBPxMgdGPeouIeTNHoEQLGUQCg6zymsS2tXujPesK43sG/2EU1NUQAniuE
FSpfwtQI08YAznTZ1S4aRgLs
=Rx/s
-----END PGP SIGNATURE-----


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

Date: 14 Jul 2003 10:37:32 -0700
From: i.fellner@puz.de (Ingo Fellner)
Subject: Re: Big hash question
Message-Id: <89e91023.0307140438.475ec580@posting.google.com>

"S. Heiling" <newsreadermail@charter.net> wrote in message news:<vgu39at0610747@corp.supernews.com>...
> I have a very large hash inside a script.
> The $values of the $keys can be very large.
> 
> When the script runs, it takes a long time to load the hash.
> And this eats up memory...really fast!
> At least I'm assuming that's what it's doing.
> 
> My question is, is there a way to stop this?
> How can I keep the whole hash from loading at startup?
> 
> while ( ($key, $value) = each %hash) {
> 
> # This is what I'm using for the hash
> 
> }
> 

foreach $key (keys %hash) {

	$hash{$key} = "blabla";
	# or:
	print "$hash{$key}\n";

}


Rgds

Ingo ;-))


> Thanks.


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

Date: 14 Jul 2003 11:27:52 -0700
From: tivolinewbie@canada.com (Kenjis Kaan)
Subject: building C DLL  for calling from Perl using (*.XS)
Message-Id: <6a8ba9f8.0307141027.189502d7@posting.google.com>

Have anyone tried hooking perl to external C libraries?  I am trying
to port some code in C  into a module (ie. DLL) which can then be
called from Perl.
I did the usual stuffs with h2xs to generate the Mytest.xs/Mytest.pm
and support environment.

As a Test wanted to see how Mytest.xs file works so I proceed to
modify.  I wanted first to see that it can pull in the headers ok.
so I added to Mytest.xs
#ifdef __cplusplus
extern "C" {
#endif
#include "EXTERN.h"
#include "perl.h"
#include "XSUB.h"
#include <stdio.h>
#include <stdlib.h>
#include <malloc.h>
#ifdef __cplusplus
}
#endif
---------------------------------------------------------------
Then of course the perl Makefile.pl to generate *.c etc
Then tried to use MSVC6 to compile it, everything is ok except for
malloc.h
Here is what came out from NMAKE

E:\var\h2xs\Mytest>nmake

Microsoft (R) Program Maintenance Utility   Version 1.50
Copyright (c) Microsoft Corp 1988-94. All rights reserved.

cp Mytest.pm blib\lib\Mytest.pm
cp mytest.pl blib\lib\mytest.pl
        C:\Perl\bin\perl.exe -IC:\Perl\lib -IC:\Perl\lib
C:\Perl\lib\ExtUtils/xs
ubpp  -typemap C:\Perl\lib\ExtUtils\typemap Mytest.xs > Mytest.xsc &&
C:\Perl\bi
n\perl.exe -IC:\Perl\lib -IC:\Perl\lib -MExtUtils::Command -e mv
Mytest.xsc Myte
st.c
Please specify prototyping behavior for Mytest.xs (see perlxs manual)
        cl -c  -nologo -O1 -MD -Zi -DNDEBUG -DWIN32 -D_CONSOLE
-DNO_STRICT -DHAV
E_DES_FCRYPT -DPERL_IMPLICIT_CONTEXT -DPERL_IMPLICIT_SYS
-DPERL_MSVCRT_READFIX -
O1 -MD -Zi -DNDEBUG    -DVERSION=\"0.01\"  -DXS_VERSION=\"0.01\" 
-IC:\Perl\lib\
CORE  Mytest.c
Mytest.c
C:\VC\VC98\INCLUDE\malloc.h(106) : error C2059: syntax error : '('
C:\VC\VC98\INCLUDE\malloc.h(107) : error C2059: syntax error : '('
C:\VC\VC98\INCLUDE\malloc.h(108) : error C2059: syntax error : '('
NMAKE : fatal error U1077: 'C:\WINNT\system32\cmd.exe' : return code
'0x2'
Stop.

-------------------------------------------------------------------------------
I opened up malloc.h in an editor and this is what I see at those 3
lines (106,107,108)

_CRTIMP void    __cdecl free(void *);
_CRTIMP void *  __cdecl malloc(size_t);
_CRTIMP void *  __cdecl realloc(void *, size_t);
-------------------------------------------------------------------------------


Surely someone musta have had to use malloc.h before for whatever
reason.  I have no idea how to fix it.  Can someone help??


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

Date: 14 Jul 2003 21:51:09 GMT
From: "Tassilo v. Parseval" <tassilo.parseval@rwth-aachen.de>
Subject: Re: building C DLL  for calling from Perl using (*.XS)
Message-Id: <bev8kd$kij$1@nets3.rz.RWTH-Aachen.DE>

Also sprach Kenjis Kaan:

> Have anyone tried hooking perl to external C libraries?  I am trying
> to port some code in C  into a module (ie. DLL) which can then be
> called from Perl.
> I did the usual stuffs with h2xs to generate the Mytest.xs/Mytest.pm
> and support environment.
> 
> As a Test wanted to see how Mytest.xs file works so I proceed to
> modify.  I wanted first to see that it can pull in the headers ok.
> so I added to Mytest.xs
> #ifdef __cplusplus
> extern "C" {
> #endif
> #include "EXTERN.h"
> #include "perl.h"
> #include "XSUB.h"
> #include <stdio.h>
> #include <stdlib.h>
> #include <malloc.h>
> #ifdef __cplusplus
> }
> #endif
> ---------------------------------------------------------------
> Then of course the perl Makefile.pl to generate *.c etc
> Then tried to use MSVC6 to compile it, everything is ok except for
> malloc.h

You don't have to include malloc.h. Usually the *alloc/free family of
functions is provided by stdlib.h.

In case of XS code, you shouldn't be using your libc's malloc anyways.
Instead use the macros provided by perl.h: safemalloc, safefree,
saferealloc etc. They aren't listed in perlapi.pod, though. I wonder
why not.

Tassilo
-- 
$_=q#",}])!JAPH!qq(tsuJ[{@"tnirp}3..0}_$;//::niam/s~=)]3[))_$-3(rellac(=_$({
pam{rekcahbus})(rekcah{lrePbus})(lreP{rehtonabus})!JAPH!qq(rehtona{tsuJbus#;
$_=reverse,s+(?<=sub).+q#q!'"qq.\t$&."'!#+sexisexiixesixeseg;y~\n~~dddd;eval


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

Date: Mon, 14 Jul 2003 14:45:46 GMT
From: helgi@decode.is (Helgi Briem)
Subject: Re: duplicate removal
Message-Id: <3f12c1e7.357421828@news.cis.dfn.de>

On Sun, 13 Jul 2003 01:46:23 GMT, Bob Walton
<bwalton@rochester.rr.com> wrote:

>john62@electronmail.com wrote:
>
>> ok, this is probably another easy question.  does anyone 
>> know how to remove duplicates in a list of strings?  
>
>
>This is a FAQ:
>
>    perldoc -q dupicate

Except that he might want to spell that "duplicate".

Like the denizens of comp.lang.perl.misc, computers
are notoriously picky about spelling things properly.

;-)


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

Date: 14 Jul 2003 11:28:44 -0700
From: ejkidder@hotmail.com (Eric Kidder)
Subject: Error during compile of 5.8.1-RC2
Message-Id: <d7134847.0307140633.24cf023e@posting.google.com>

I tried to send this as an email to perlbug@perl.org, but it kept bouncing.
This is a compile-time error, so I can't use perlbug to report it.

My configuration is as follows:
Summary of my perl5 (revision 5.0 version 8 subversion 1) configuration:
  Platform:
    osname=hpux, osvers=11.00, archname=PA-RISC2.0
    uname='hp-ux xxxx b.11.00 e 9000800 22704576 8-user license '
    config_args='-Dcc=gcc'
    hint=recommended, useposix=true, d_sigaction=define
    usethreads=undef use5005threads=undef useithreads=undef
usemultiplicity=undef
    useperlio=define d_sfio=undef uselargefiles=define usesocks=undef
    use64bitint=undef use64bitall=undef uselongdouble=undef
    usemymalloc=n, bincompat5005=undef
  Compiler:
    cc='gcc', ccflags ='-fPIC -D_HPUX_SOURCE -mpa-risc-2-0
-fno-strict-aliasing -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64',
    optimize='-O',
    cppflags='-D_HPUX_SOURCE -fPIC -D_HPUX_SOURCE -mpa-risc-2-0
-fno-strict-aliasing'
    ccversion='', gccversion='3.2', gccosandvers='hpux11.00'
    intsize=4, longsize=4, ptrsize=4, doublesize=8, byteorder=4321
    d_longlong=define, longlongsize=8, d_longdbl=define, longdblsize=16
    ivtype='long', ivsize=4, nvtype='double', nvsize=8, Off_t='off_t',
lseeksize=8
    alignbytes=8, prototype=define
  Linker and Libraries:
    ld='/usr/bin/ld', ldflags ='-L/home/cpcusers/ek9635/lib -L/appl/cpc/lib
-L/usr/local/lib'
    libpth=/home/cpcusers/ek9635/lib /appl/cpc/lib /usr/local/lib /lib
/usr/lib /usr/ccs/lib
    libs=-lcl -lpthread -lnsl -lnm -lndbm -lgdbm -ldb -lmalloc -ldld -lm
-lcrypt -lsec -lc
    perllibs=-lcl -lpthread -lnsl -lnm -lmalloc -ldld -lm -lcrypt -lsec -lc
    libc=/lib/libc.sl, so=sl, useshrplib=true, libperl=libperl.sl
    gnulibc_version=''
  Dynamic Linking:
    dlsrc=dl_hpux.xs, dlext=sl, d_dlsymun=undef, ccdlflags='-Wl,-E
-Wl,-B,deferred '
    cccdlflags='-fPIC', lddlflags='-b -L/home/cpcusers/ek9635/lib
-L/appl/cpc/lib -L/usr/local/lib'

I am receiving the following error when compiling pp_sys.c:
`sh  cflags "optimize='-O'" pp_sys.o` -fPIC pp_sys.c
          CCCMD =  gcc -DPERL_CORE -c -fPIC -D_HPUX_SOURCE -mpa-risc-2-0
-fno-strict-aliasing -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64 -O  -Wall
In file included from /usr/include/shadow.h:9,
                 from pp_sys.c:36:
/usr/include/prot.h:600: conflicting types for `Perl_get_seed'
proto.h:817: previous declaration of `Perl_get_seed'
make: *** [pp_sys.o] Error 1

This is because this #define from embed.h:
#define get_seed                Perl_get_seed

is conflicting with this function prototype from /usr/include/prot.h:
extern int get_seed __((struct pr_passwd *));

When pp_sys.c is run through the pre-processor, it is turning all of the
get_seed()s into Perl_get_seed()s, resulting in the following: (excerpted
from gcc -E)
 UV Perl_get_seed(void);                        <-- from perl
 ...
extern int Perl_get_seed (struct pr_passwd *);  <-- from /usr/include/prot.h


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

Date: Mon, 14 Jul 2003 18:23:05 +0200
From: Gunnar Hjalmarsson <noreply@gunnar.cc>
Subject: Re: flock() and W95
Message-Id: <beulbb$9a3q0$1@ID-184292.news.uni-berlin.de>

Mark Jason Dominus wrote:
> In article <berd9f$7n05r$1@ID-184292.news.uni-berlin.de>, Gunnar
> Hjalmarsson  <noreply@gunnar.cc> wrote:
> 
>> I'm not using 'subs' since, as I mentioned in a reply to Tassilo,
>> I want the solution to cover also occurrences of flock() in
>> modules like Tie::File that don't use or require anything from my
>> program.
> 
> While this isn't directly germane to your problem (of overridding 
> flock() globally) if you wanted to deal with Tie::File, the easy
> way would be just to subclass it and override the Tie::File::flock
> method, which is the only place that Tie::File uses flock.

Hmm.. It means that it _would_ have been an option to not change
flock() globally, after all. Thanks for mentioning it to somebody who
have not yet started to explore OOP. :)  But defining
CORE::GLOBAL::flock still seems to be a more convenient solution to
this particular problem, i.e. making the whole program disregard
"flock() unimplemented" errors, wouldn't you agree?

-- 
Gunnar Hjalmarsson
Email: http://www.gunnar.cc/cgi-bin/contact.pl



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

Date: 14 Jul 2003 21:06:07 GMT
From: Angel <angel2@ShirT.com>
Subject: Help with Fileman V-1, File Manager
Message-Id: <Xns93B8ADF8612DDsmakyou33msnhardhitt@129.250.170.100>

Hello. First,I know next to nothing about perl. That being said...

I uploaded and changed permissions for the file manager mentioned on the 
subject line. The FM showed a width of 630 pixels on my 1024 screen. I 
edited the script tables and changed the width to 100%. The FM now shows 
as nearly full screen, except for the sub-directories which load at 630 
pixels. And after any action is done, even the root directory will then 
show as 630 pixels. 

I have poured over this script and cannot see why this is happening, but 
as already stated, I know nothing about perl scripts beyond a little 
tinkering.

If someone is interested in taking a look I will post script.

Thank you. Angel 

Remove "ShirT" to reply.
-- 
Archives for the Walrus Contest
http://WeeklyWalrus.com

Weekly Walrus Contest entries and rules
http://web.newsguy.com/evilsideshowbob/index.html


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

Date: 14 Jul 2003 15:48:41 -0600
From: Eric Schwartz <emschwar@pobox.com>
Subject: Re: Help with Fileman V-1, File Manager
Message-Id: <etoptkcg4p2.fsf@wormtongue.emschwar>

Angel <angel2@ShirT.com> writes:
> I uploaded and changed permissions for the file manager mentioned on the 
> subject line.

I've never heard of it.  Is it GTK-based?  Qt?  Curses?  *gack* *spit* 
CGI?  How can you expect anyone to comment on something that's
brand-new to them?  ESR has a fairly helpful page on How To Ask
Questions the Smart Way at his website:

<URL:http://www.catb.org/~esr/faqs/smart-questions.html>

I strongly urge you to read it over.

> I have poured over this script and cannot see why this is happening, but 
> as already stated, I know nothing about perl scripts beyond a little 
> tinkering.

We are happy to discuss specific Perl questions here, but we're not a
free helpdesk.  You'll get the best results if you show you've spent
some time and effort of your own on the problem.

> If someone is interested in taking a look I will post script.

If anyone is interested, they'll only be interested in a very small
script (on the order of 10-20 lines) that reproduces the problem.
Very often, just the act of trying to reduce a large script to the
smallest program that reproduces the problem you're seeing is enough
to show you where the trouble is.  It also has the benefit of showing
that you've invested some effort yourself-- nobody likes being used as
free support, but most people don't mind helping someone who is trying
hard.

-=Eric
-- 
Come to think of it, there are already a million monkeys on a million
typewriters, and Usenet is NOTHING like Shakespeare.
		-- Blair Houghton.


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

Date: Mon, 14 Jul 2003 16:50:10 +0100
From: Rod <info@wienerlibrary.co.uk>
Subject: Re: multi-part forms in CGI.pm
Message-Id: <n7k5hvs09pi487uokkbc0265rp1kd7o87g@4ax.com>



this is,partly anyway, an HTML question - in order to create a
'read-only' input field pre-filled with prior data you simply add the
'disabled attribute for that input field in the form definition.
something like.

<input name="textfield" type="text" value="textcheck" disabled >

You'll have to check out the latest documentation on CGI.pm to see if
caters for this - I also have a feeling it doesn't. also I have only
checked the above snippet on post IE4 browsers.

You should also check that any 'disabled fields' actually return form
data - in the spec. I've read they don't - (ie they really are
disabled) - this may not make a difference to you, but it's good to
know anyway.

Good luck
>Hi,
> I am a new comer to CGI.pm and find it extremely useful. I have created
>multi-form pages and with little struggle have succesfully been able to save
>states from one form to another (from one page to another).  Two groups of
>people will be using the mutli-form pages to fill out the fields.

personal replies to info@wienerlibrary.co.uk


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

Date: Mon, 14 Jul 2003 17:26:58 GMT
From: "Miguel De Anda" <_sodamnmad_@_hotmail_._com_>
Subject: Re: Need help with posting to CGI from javascript 
Message-Id: <CJBQa.2895$C64.655@newssvr16.news.prodigy.com>

> >
> > I create a hidden frame, be it an iframe or from a frameset. Have a form
> in
> > there that will receive data from the dragDone(x,y) function. Submit the
> > form to your cgi. This will prevent the main window from submiting the
data
> > (and prevent the user from doing more things). From what I'm guessing,
you
> > may need some way to buffer the input and send larger packets of input
> > together.
> >
> >
>
>


"Stacey" <stacye@optonline.net> wrote in message
news:aGNPa.23618$hY1.7299696@news4.srv.hcvlny.cv.net...
> Thanks for your help.  For your last suggestion, are there any examples of
> such on the net?  I am a bit of a newbie and would not know how to go
about
> it.
>
> Thanks again
>


I don't have anything that I can show you (since the project that I've used
it on can't be made public), but just learn each step of the process bit by
bit. For example, first figure out framesets, then the javascript to use to
send messages from one frame to the other, then the script to be able to set
form values and to submit the form, and so on.

I haven't look at Ron Savage's post, but it looks promising as well.




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

Date: 14 Jul 2003 11:47:52 -0600
From: Eric Schwartz <emschwar@pobox.com>
Subject: Re: Need help with posting to CGI from javascript
Message-Id: <eto3ch9gfuf.fsf@wormtongue.emschwar>

"Miguel De Anda" <_sodamnmad_@_hotmail_._com_> writes:
> I don't have anything that I can show you (since the project that
> I've used it on can't be made public), but just learn each step of
> the process bit by bit.

For instance, you could learn that questions about CGI and Javascript
aren't appropriate on perl newsgroups.

Followups set.

-=Eric
-- 
Come to think of it, there are already a million monkeys on a million
typewriters, and Usenet is NOTHING like Shakespeare.
		-- Blair Houghton.


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

Date: Mon, 14 Jul 2003 12:40:01 -0400
From: Chris Mattern <syscjm@gwu.edu>
Subject: Re: Perl and telnet
Message-Id: <3F12DCE1.2050601@gwu.edu>

JS Bangs wrote:
> Wolfgang Fischer sikyal:
> 
> 
>>You don't need to check for users and CPU usage. Instead, you should give
>>your program a low priority (nice -19 program).
>>For security reasons you should use ssh.
> 
> 
> You mean `nice 19 program`. Using -19 gives your program an exceptionally
> high priority and will probably cripple your system, if it's a
> processor-intensive program.
> 
> 
Fortunately, you can't negative nice stuff unless you're root, proving
once again that, "To err is human, to really screw things up requires
the root password."

                        Chris Mattern



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

Date: Mon, 14 Jul 2003 15:56:49 -0400
From: "Tom Salzmann" <salzo@yahoo.com>
Subject: Problem executing a BAT file (or EXE file) using Perl as CGI script under Apache.
Message-Id: <EUDQa.401$x16.16473@eagle.america.net>

I have developed some perl code to run as a script under Windows 2000
running apache.  This works GREAT on Win2k but on WinNT, perl is simply
unable to launch the program.  The program works fine from the command line.

Here's the code:

    $fred=time . ".out" ;
   open(OUTPUT, "|imon.bat " . $fred . " " . $ENV{'REMOTE_ADDR'} . " " .
$IMCommand . " " . $IMFile );
   close OUTPUT;
   open(FILE, $fred );
   @htmlLines = <FILE>;
   close FILE   ;
   unlink($fred);
   unlink($IMFile);

As a test to make sure I wasn't nuts, I put the following in the bat file:

    ECHO >> echo.out

And sure enough, I get "ECHO IS ON" in the file every time I run from
command line.  But when I run from Apache, I get NOTHING.  It's as if Apache
is unable to launch the thing.

Again, this works FINE under Win2k but fails on WinNT - Any ideas?  I tried
system() but I get the same thing.


Thanks,

Tom




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

Date: 14 Jul 2003 12:39:44 -0700
From: magelord@t-online.de (Math55)
Subject: Regex question...
Message-Id: <a2b8188a.0307140124.1343aeb6@posting.google.com>

hi, i have this regex:


\.(?!.png|.log)[^.]*$


how can i replace the .before png and log with nothing? the problem
is, the alternation can be longer, like that:

\.(?!.png|.log|.txt|.c|.cpp and so on )[^.]*$

how could i do that?

THANKS:-)


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

Date: Mon, 14 Jul 2003 20:27:21 -0000
From: gbacon@hiwaay.net (Greg Bacon)
Subject: Re: Regex question...
Message-Id: <vh64h9mhgifv6d@corp.supernews.com>

In article <a2b8188a.0307140124.1343aeb6@posting.google.com>,
    Math55 <magelord@t-online.de> wrote:

: hi, i have this regex:
: 
: \.(?!.png|.log)[^.]*$
: 
: how can i replace the .before png and log with nothing? the problem
: is, the alternation can be longer, like that:
: 
: \.(?!.png|.log|.txt|.c|.cpp and so on )[^.]*$

Is the code below what you're after?

    #! /usr/local/bin/perl

    use warnings;
    use strict;

    my $extensions = qr/^(png|log)$/;

    while (<DATA>) {
        chomp;

        if (/^(.+)\.([^.]*)$/) {
            $_ = $1 unless $2 =~ $extensions;
        }

        print $_, "\n";
    }

    __DATA__
    foo.png
    bar.log
    baz.txt
    quux.c
    blurfl.cpp

It produces this output:

    foo.png
    bar.log
    baz
    quux
    blurfl

Sorry if I misunderstood your question.  Can you provide example inputs
and the corresponding outputs you expect?

Greg
-- 
The more corrupt the state, the more numerous the laws.
    -- Tacitus 


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

Date: Mon, 14 Jul 2003 08:52:42 -0500
From: tadmc@augustmail.com (Tad McClellan)
Subject: Re: safe cgi programming in perl?
Message-Id: <slrnbh5dda.2st.tadmc@magna.augustmail.com>

Steve <me@home.com> wrote:

> My main concern is with untainting data and
> using backtics for system commands.

> I'm only using mkdir, 


Is that the shell's mkdir(1) or Perl's mkdir() function?


> open 


_That_ must be Perl's open(), I don't think there is a shell "open".


> and rm with user input.


And that is clearly the shell's rm(1).


> most of my commands to create directories, files and to remove files
> are with backtics,


You can do all three of those things in native Perl rather than
"shelling out" to external programs.

   perldoc -f mkdir
   perldoc -f open
   perldoc -f unlink


Avoiding a shell goes a long way toward peace of mind, so you
should avoid it whenever possible.

As an added bonus, you could then move your program unchanged
to some other operating system.


-- 
    Tad McClellan                          SGML consulting
    tadmc@augustmail.com                   Perl programming
    Fort Worth, Texas


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

Date: Mon, 14 Jul 2003 08:58:27 -0500
From: tadmc@augustmail.com (Tad McClellan)
Subject: Re: safe cgi programming in perl?
Message-Id: <slrnbh5do3.2st.tadmc@magna.augustmail.com>

Steve <me@home.com> wrote:

> My main concern is with untainting data and
> using backtics for system commands.


> if ($pairs{affilate_ID} =~ /^([-_\w.\s]+)$/) { $pairs{affilate_ID} =
> $1 }


Allowing dot may be dangerous, as it can have meta-meaning in a path.

What if 

   $pairs{affilate_ID} = '../etc/passwd';
   $pairs{affilate_ID} = '../../etc/passwd';
   $pairs{affilate_ID} = '../../../etc/passwd';

etc.

Do you allow users to enter relative paths?


-- 
    Tad McClellan                          SGML consulting
    tadmc@augustmail.com                   Perl programming
    Fort Worth, Texas


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

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


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