[25474] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 7719 Volume: 10

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Tue Feb 1 03:05:51 2005

Date: Tue, 1 Feb 2005 00:05:12 -0800 (PST)
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, 1 Feb 2005     Volume: 10 Number: 7719

Today's topics:
    Re: [perl-python] find & replace strings for all files  <yyusenet@yahoo.com>
        cgi and cgi-bin <home@home.net>
    Re: cgi and cgi-bin <yyusenet@yahoo.com>
    Re: cgi and cgi-bin <spamtrap@dot-app.org>
    Re: cgi and cgi-bin <nospam@bigpond.com>
        compacting '..' path segments using File::Spec ofer@netapt.com
    Re: compacting '..' path segments using File::Spec <josef.moellers@fujitsu-siemens.com>
        file locking module ofer@netapt.com
    Re: How bad is $'? (Was: "Get substring of line") <jl_post@hotmail.com>
        HTTP::Request::Form - Can't submit a form with  input t <sborruso@austin.rr.com>
        localtime question <yshtil@synopsys.com>
    Re: localtime question <noreply@gunnar.cc>
        Newbie Hash question. <dbent@comcast.net>
    Re: Newbie Hash question. <news@chaos-net.de>
    Re: Newbie Hash question. ioneabu@yahoo.com
        Obfuscating mod_perl code <Deke@nospam.com>
    Re: Obfuscating mod_perl code ioneabu@yahoo.com
        Send Parameter to SQL <chastaib@hotmail.com>
    Re: Send Parameter to SQL <tadmc@augustmail.com>
    Re: Send Parameter to SQL <yyusenet@yahoo.com>
        Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)

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

Date: Mon, 31 Jan 2005 16:10:20 -0700
From: YYusenet <yyusenet@yahoo.com>
Subject: Re: [perl-python] find & replace strings for all files in a dir
Message-Id: <ctmdsq$in3$1@news.xmission.com>

Xah Lee wrote:
> suppose you want to do find & replace of string of all files in a
> directory.
> here's the code:
  [snip]
> Xah
>  xah@xahlee.org
>  http://xahlee.org/PageTwo_dir/more.html
> 

When are you going to take the hint (from everybody in 
comp.lang.perl.misc and comp.lang.python) to stop posting!  Your posts 
do not help anybody and will only hurt a beginner.  *PLEASE STOP POSTING*!

-- 
k g a b e r t (@at@) x m i s s i o n (.dot.) c o m

* 	After "extensive" research, I noticed
*	that yyusenet@yahoo.com received 12
*	spam e-mail messages after just two
*	posts on usenet groups.  If you want
*	to email me, use the "encrypted"
*	email address at the beggining of my
*	signature.


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

Date: Tue, 01 Feb 2005 02:55:18 GMT
From: "zippy" <home@home.net>
Subject: cgi and cgi-bin
Message-Id: <qcCLd.1475$Kj4.111@trnddc09>

Hi,
I hope this is the correct group to post this question. I have set up a cgi
bin /var/www/website/cgi-bin with some perl scripts that worked on a similar
server before we took it down. Transferring the files to the new server
didn't work untill we put the files in /var/www/website/cgi.

For our forms to work (unless we want to rewrite every one of them) they
need to be in /var/www/website/cgi-bin. Where is the configuration script to
change it from cgi to cgi-bin? I am running fedora c1, apache 2 and using
the cgi bin in the virtual host area of httpd.conf.

Thanks,
--zip




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

Date: Mon, 31 Jan 2005 20:49:50 -0700
From: "YYusenet" <yyusenet@yahoo.com>
Subject: Re: cgi and cgi-bin
Message-Id: <ctmu82$vgc$1@news.xmission.com>


"zippy" <home@home.net> wrote in message news:qcCLd.1475$Kj4.111@trnddc09...
> Hi,
> I hope this is the correct group to post this question. I have set up a 
> cgi
> bin /var/www/website/cgi-bin with some perl scripts that worked on a 
> similar
> server before we took it down. Transferring the files to the new server
> didn't work untill we put the files in /var/www/website/cgi.
>
> For our forms to work (unless we want to rewrite every one of them) they
> need to be in /var/www/website/cgi-bin. Where is the configuration script 
> to
> change it from cgi to cgi-bin? I am running fedora c1, apache 2 and using
> the cgi bin in the virtual host area of httpd.conf.
>
> Thanks,
> --zip
>
>

This is completely off subject.  Before you make a post like this, think
about what exactly does it have to do with Perl.  But...
You will find where the cgi-bin or cgi is inside of the apache2.conf file
normally found inside of /etc/apache2 (at least on mine.)
-- 
k g a b e r t (@at@) x m i s s i o n (.dot.) c o m




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

Date: Mon, 31 Jan 2005 22:53:34 -0500
From: Sherm Pendley <spamtrap@dot-app.org>
Subject: Re: cgi and cgi-bin
Message-Id: <B_WdnZJiedzdYGPcRVn-gQ@adelphia.com>

zippy wrote:

> I hope this is the correct group to post this question.

It's not. Sorry. This group is about writing Perl code. Your question is
about how to configure Apache's CGI support; the answer would be the same
if your CGIs were written in Python, C, or any other language. Hence, your
question isn't a Perl question.

Searching the group list for "apache" or "servers" turned up several hits.
The "comp.infosystems.www.servers" and "alt.apache.configuration" groups
appear to be relevant, but I don't frequent those groups so I can't say for
sure. Your best bet is to check the apache site at <http://www.apache.org>,
to see what groups, lists, or other resources they recommend.

sherm--

-- 
Cocoa programming in Perl: http://camelbones.sourceforge.net
Hire me! My resume: http://www.dot-app.org


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

Date: Tue, 01 Feb 2005 14:23:33 +1000
From: Gregory Toomey <nospam@bigpond.com>
Subject: Re: cgi and cgi-bin
Message-Id: <368ei5F4uhm3kU1@individual.net>

zippy wrote:

> Hi,
> I hope this is the correct group to post this question. I have set up a
> cgi bin /var/www/website/cgi-bin with some perl scripts that worked on a
> similar server before we took it down. Transferring the files to the new
> server didn't work untill we put the files in /var/www/website/cgi.
> 
> For our forms to work (unless we want to rewrite every one of them)
Why not? 

> they 
> need to be in /var/www/website/cgi-bin. Where is the configuration script
> to change it from cgi to cgi-bin?
Since you're the only person to need this, there isn't one.

> I am running fedora c1, apache 2 and 
> using the cgi bin in the virtual host area of httpd.conf.
> 
> Thanks,
> --zip

Make a symbolic link from cgi-bin to scgi-bin, or move cgi-bin to scgi-bin.
Any system admin with 1/4 of a brain could work this out.

gtoomey



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

Date: 31 Jan 2005 23:29:27 -0800
From: ofer@netapt.com
Subject: compacting '..' path segments using File::Spec
Message-Id: <1107242967.693202.188450@c13g2000cwb.googlegroups.com>

Here's the scenario:

I am given a path to a file, which is actually a relative symlink.
Example:

/foo/bar/somelink -> ../somefile

I tried the following code to follow the symlink and then elegantly
combine the two into a final absolute path to the real file:

use File::Spec;
my $symlink = '/foo/bar/somelink';
my $realfile = readlink( $symlink );
unless ( File::Spec->file_name_is_absolute( $realfile ) ) {
my ( $volume, $directories, $file ) = File::Spec->splitpath( $symlink
);
$realfile = File::Spec->rel2abs( $realfile, $directories );
}

It works... but instead of producing '/foo/somefile', which is what I
want, it produces '/foo/bar/../somefile'.  It is technically correct,
but not as elegant as I would like, and makes the final result
unnecessarily depend on the continued existance of the 'bar'
subdirectory in order for the path to remain valid (this data is going
into a long-term database).

Any ideas?

-ofer



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

Date: Tue, 01 Feb 2005 08:56:51 +0100
From: Josef Moellers <josef.moellers@fujitsu-siemens.com>
Subject: Re: compacting '..' path segments using File::Spec
Message-Id: <ctncm2$til$1@nntp.fujitsu-siemens.com>

ofer@netapt.com wrote:
> Here's the scenario:
>=20
> I am given a path to a file, which is actually a relative symlink.
> Example:
>=20
> /foo/bar/somelink -> ../somefile
>=20
> I tried the following code to follow the symlink and then elegantly
> combine the two into a final absolute path to the real file:
>=20
> use File::Spec;
> my $symlink =3D '/foo/bar/somelink';
> my $realfile =3D readlink( $symlink );
> unless ( File::Spec->file_name_is_absolute( $realfile ) ) {
> my ( $volume, $directories, $file ) =3D File::Spec->splitpath( $symlink=

> );
> $realfile =3D File::Spec->rel2abs( $realfile, $directories );
> }
>=20
> It works... but instead of producing '/foo/somefile', which is what I
> want, it produces '/foo/bar/../somefile'.  It is technically correct,
> but not as elegant as I would like, and makes the final result
> unnecessarily depend on the continued existance of the 'bar'
> subdirectory in order for the path to remain valid (this data is going
> into a long-term database).
>=20
> Any ideas?

Well, since you haven't shown us what you have tried to canonizise the=20
path name, we have few ideas.

1. You could try a regex which replaces /./s by /s and /<anyname>/../s=20
by /s.
2. You could split the pathname and work on the components.

There's even a CPAN module iirc.

--=20
Josef M=F6llers (Pinguinpfleger bei FSC)
	If failure had no penalty success would not be a prize
						-- T.  Pratchett



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

Date: 31 Jan 2005 23:22:55 -0800
From: ofer@netapt.com
Subject: file locking module
Message-Id: <1107242575.595479.164370@c13g2000cwb.googlegroups.com>

I'm writing a script that requires locking a file before writing to it,

and I decided to check CPAN to see if there are any goodies to take
care
of this for me.  A search for 'flock' yielded:

module                 ( dist                   updated     )
-------------------------------------------------------------
IO::File::flock        ( IO-File-flock-0.10     26 Apr 2004 )
IO::File::flock        ( IO-File-Lockable-0.31  16 Jul 2004 )
IO::LockedFile::Flock  ( IO-LockedFile-0.23     20 Feb 2003 )
File::Flock            ( File-Flock-104.111901  19 Nov 2004 )


Anyone have any experience with any of the above, and want to recommend
one?  Incidentally, this is why I think a CPAN wiki would be neat.  :)



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

Date: 31 Jan 2005 21:20:28 -0800
From: "jl_post@hotmail.com" <jl_post@hotmail.com>
Subject: Re: How bad is $'? (Was: "Get substring of line")
Message-Id: <1107235228.611771.163810@f14g2000cwb.googlegroups.com>

(Okay, so I know that Michele will probably not read this post, but
I've decided to answer his reply anyway, for the benefit of anybody who
might be interested in this thread.)


> On 18 Jan 2005 07:29:11 -0800, jl_post@hotmail.com (J. Romano) wrote:
>
> >   Okay, I'll take you up on that offer.
> >
> >   (But be warned!  Expect a "tome".  :)

Michele Dondi replied:
>
> Indeed: as a personal cmt to you, I have the impression you
> tend to be overly verbose. I mean verboseness is not so bad
> per se, but the actual impression, gathered from other posts
> of yours, is that the actual content in them that may have
> been of some interest could have been expressed much more
> concisely, thus making it easier for it to reach a wider
> audience.

Could be, could be... But that's the way I tend to be.  One reason for
that is that I like to explain things.

Another reason for that is that the people in this newsgroup tend to
point out things that I missed mentioning, whether I'm aware of them or
not.  (That's not necessarily a bad thing.)  For instance, if I mention
$' in my code without assigning it to a variable, someone may point out
that the Perl compiler may optimize $' out, making some think that my
benchmark is invalid (whether it really is or not).  They may have a
valid point, which is why I often include extra explanations to cover
concerns that I anticipate that others may have.

> In this particular case I couldn't go beyond the first
> few paragraphs and I'm not willing to.

Well, if time is an issue, you might consider reading the "CONCLUSION"
section of this thread's original post.  It discusses when it's best to
avoid using the MATCH variables, as well as when it's acceptable to use
them.


> >The first benchmark program I came up with was this one:
> >
> >#!/usr/bin/perl
> >use strict;
> >use warnings;
> >use Benchmark;
> >
> >my $count = 1e7;
> >my $prefix = q!$a = $'  if "a" =~ m/a/;!;
> >my $line = '$a = 1  if "abc=xyz" =~ m/=/;';
>
> Why are you (running under strict and) using as a
> generic variable the predefined global variable $a?

I used strict because I make it a habit of using it in my own code (and
I see no reason not to use it here).  I assigned to $a because, well,
it's there to use and I don't have to declare it.  I mean, I suppose I
could declare a variable, but I didn't see any reason to put a
declaration in my benchmark when it doesn't have to be there.  I don't
think it really makes a difference either way.

> I mean, this post of yours has some flavour of a tutorial: so why
> exposing to potential newbies something we usually warn them against?

Good question.  I'll give three answers:

First, I didn't mean this post to be a tutorial.  I meant it to be easy
to follow and understand.  If that makes it easy for potential newbies
to understand, then that's just a side-effect that I didn't plan.

Second, I don't think there's much harm in teaching potential newbies
about $', $&, and $`, as long as the obligatory warning is given (as it
almost always is).

And third, if we're not supposed to expose potential newbies to these
match variables, then I have to point out that Randal Schwartz and Tom
Phoenix already broke this rule in their book "Learning Perl," as they
use the match variables rather liberally in their examples.  (I even
included a quote from their book in the CONCLUSION section of my
original post, in case you want to read some of their thoughts about
the match variables.)


> >my $badProgram = "$prefix $line";
> >
> >timethese($count, {good => $line});
> >timethese($count, {bad => $badProgram, prefix => $prefix});
> >__END__
>
> What is the point of benchmarking two completely
> different snippets, one of which just does something
> more than the other?

They're not two completely different snippets; they both have the code
in the $line variable in common.  The "bad" program has an extra line
of code, which is used to "taint" the rest of the program (due to the
$' variable).  Of course, it's not fair to compare the times of "good"
with "bad," as the "bad" code runs an extra line of code (which happens
to be the taint line).  Therefore, I also benchmark that line of code
so that it can be subtracted from the "bad" code time.  This difference
is what is compared to the "good" code time.

> Also, indeed lines of code benchmarked as strings are
> (string-)eval()ed which means that they are parsed and
> executed as stand-alone perl programs, but (as of the
> docs => see!) _in the lexical context_ of the current
> program, which means that the interpreter they're executed
> with is not a total stranger to the current one.

I'm not quite sure if I understand you perfectly here.  It sounds like
you're saying that even if I use $' once in my code, it "spoils" all
the regular expressions (even the ones that have no need for $').  If
this is what you mean, I have to point out that I'm eval()ing the "bad"
code (the code with $') AFTER the "good" code is eval()ed.  In other
words, the "good" code finishes executing before the Perl interpreter
ever gets a chance to eval() the "bad" code and discover that the $'
variable is being used at all.  As a result, the $' taint in the "bad"
code shouldn't get a chance to spoil the "good" code.


> PS: FWIW I _partly_ agree with you that the general habit
> of frowning upon the use of $`, $&, $' a priori is to some
> extent exaggerated.

Thanks for the comment.  Of course, there are times when it's bad to
use them, and other times when it's really no big deal.  By making
benchmarks on several real programs I've found that the penalty of
using the match variables is almost always negligible.  I wouldn't mind
feedback from other people who have benchmarked real, useful programs
(with and without the match variables) to see if they discover a
significant penalty.  To be honest, I had to go out of my way to create
unrealistic data in order to create a non-negligible penalty.  (That
doesn't mean that the penalty will never be measurable in real code;
that just means that, under some (but not all) conditions, there are
times when the penalty exists in some measurable manner.)

And thanks for your feedback, Michele.  It was appreciated.
Good luck in your studies!

-- Jean-Luc



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

Date: 31 Jan 2005 22:42:42 -0800
From: "fochie" <sborruso@austin.rr.com>
Subject: HTTP::Request::Form - Can't submit a form with  input type=image button
Message-Id: <1107240162.105962.163300@f14g2000cwb.googlegroups.com>

Greetings,

I'm having trouble "pressing" a Form button of type=image using
HTTP::Request:Form and HTML::Treebuilder. I can retrieve, parse a
document and fill in fileds fine in the form, but I'm confused on the
syntax of the press method when the input object is type=image and has
no name associated with it.

All attempts so far indicate that I am specifying the image to press
incorrectly.

The HTTP::Request:Form doc states the following related to pressing a
form button -

"press([$name [, $coord ] [, $number]])
 .
 .
The "coord" parameter comes in handy if you have an image button. If
this is the case, the button press will simulate a press at coordinates
[2,2] unless you provide an anonymous array with different
coordinates."

A dump of the form I need to submit shows the following -

FORM METHOD=POST
ACTION=/exec/varzea/ae-nickname-search/

BASE=http://s1.amazon.com/exec/varzea/subst/search/auction-search.html/ref=a_h_tn_as/104-8399919-2455160
FIELD{input/hidden} exchange-type=auction
FIELD{input/text} seller=mysellername
BUTTON image=[image]
image={image}

Any assistance on how to specify the proper syntax to submit this form
is most appreciated.

Thanks !
Steve



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

Date: Mon, 31 Jan 2005 17:20:08 -0800
From: "Yuri Shtil" <yshtil@synopsys.com>
Subject: localtime question
Message-Id: <10vtma9jtnh0gf3@corp.supernews.com>

the localtime function converts the system time from seconds to an array
($sec,$min,$hour,$mday,$mon,$year,$wday,$yday,$isdst).

How do I accomplish a reverse conversion?




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

Date: Tue, 01 Feb 2005 02:26:39 +0100
From: Gunnar Hjalmarsson <noreply@gunnar.cc>
Subject: Re: localtime question
Message-Id: <368460F4u54gkU1@individual.net>

Yuri Shtil wrote:
> the localtime function converts the system time from seconds to an array
> ($sec,$min,$hour,$mday,$mon,$year,$wday,$yday,$isdst).
> 
> How do I accomplish a reverse conversion?

     perldoc Time::Local

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


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

Date: 31 Jan 2005 21:19:18 -0800
From: "Wondering" <dbent@comcast.net>
Subject: Newbie Hash question.
Message-Id: <1107235158.046510.158720@f14g2000cwb.googlegroups.com>

I'm teaching myslf Perl using the Camel book. I'm trying to load some
data, and I think a hash is a good solution for mapping values. I did
one simple hash in the program, and it worked as expected. Now I have a
larger lookup table, and rather than write it into the program, I'd
prefer to store the lookup table in a text file, and load it at
runtime. I've tried a couple of different methods, and I thought I had
it working at one point. Then, a couple of days went by, and now I
can't get what I want at all. I separated the code for that hash into a
separate Perl script so I could test it, and nothing I've tried (book
in hand) has given the result I would like. I expect it's something
simple a newbie like me would miss.

Here's an abbreviated version of the table from the text file (filename
is "sufhash"):

'149' => ' x'
'150' => ' y'
'151' => ' z'
'152' => 'AA'

I've also written this file with commas at the end of each line, but
this is the current iteration.

Here's the Perl script I'm using to test:
#!/usr/contrib/bin/perl

%sufmap = (`cat /"full path"/sufhash`) ;
$hashcnt = (keys(%sufmap)) ;
# @keys = keys %sufmap ;
# @val = values %sufmap ;
# while (@keys) {
#    print pop(@keys),  '=',  pop(@val), "\n" ;
# }
# foreach $key (sort keys %sufmap) {
#    print $key. '='. $sufmap{$key}, "\n";
#   $sleep = (`sleep 2`) ;
# }
while (($key,$value) = each %sufmap) {
print "$key = $value\n" ;
}

You can see that I've tried (and commented out) several ways of
displaying the contents of the hash. As near as I can tell, each method
of displaying works about as well as any other, so I suspect the
problem is in the way I've written the text file the hash is loaded
from. What I get is a key/value pair on a line, followed by a "=" sign,
and another key/value pair on the next line. What I expect is a key,
the "=" sign, and the corresponding value all on one line. I'm not so
particular about the output of the test script, if I can get the hash
to work in the program.

Thanks to all who take the time to read all this, and a bigger thanks
to those who respond. I'll be happy to provide additional info as
requested.



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

Date: Tue, 1 Feb 2005 07:15:36 +0100
From: Martin Kissner <news@chaos-net.de>
Subject: Re: Newbie Hash question.
Message-Id: <slrncvu7k8.4mh.news@maki.homeunix.net>

Wondering wrote :
> [...]
> What I get is a key/value pair on a line, followed by a "=" sign,
> and another key/value pair on the next line. What I expect is a key,
> the "=" sign, and the corresponding value all on one line. I'm not so
> particular about the output of the test script, if I can get the hash
> to work in the program.
>
I'm a newbie, too and I have written a script last week which also has
to populate a hash from a simple file.

I'll provide a snipped of it here in order to give you a hint to a
possible solution and also to ask the regulars to take a look on it
whether it can be optimized.

The text file is formated like this:

name1:url1
name2:url2

--- snip ---
#!/usr/bin/perl

use warnings;
use strict;
use HTML::Template;

my $file = "/path/file";

# [...]

my (%row, $row, $name, $url);
open  LINKS, "<", $file or die "Can not open $file: $!";
while ($line = <LINKS>)
{
    my @line = split (":", $line);
    $name = $line[0];
    $url = $line[1];

# this is how I get the hash populated with key/value pairs
    $row{$name} = $url;  
}

# [...]

--- snap ---

HTH
Martin

-- 
perl -e 'print 7.74.117.115.116.11.32.13.97.110.111.116.104.101.114.11
 .32.13.112.101.114.108.11.32.13.104.97.99.107.101.114.10.7'


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

Date: 31 Jan 2005 22:47:18 -0800
From: ioneabu@yahoo.com
Subject: Re: Newbie Hash question.
Message-Id: <1107240438.534670.27540@c13g2000cwb.googlegroups.com>

> Here's an abbreviated version of the table from the text file
(filename
> is "sufhash"):
>
> '149' => ' x'
> '150' => ' y'
> '151' => ' z'
> '152' => 'AA'
>
> I've also written this file with commas at the end of each line, but
> this is the current iteration.
>
> Here's the Perl script I'm using to test:
> #!/usr/contrib/bin/perl
>
> %sufmap = (`cat /"full path"/sufhash`) ;
> $hashcnt = (keys(%sufmap)) ;
> # @keys = keys %sufmap ;
> # @val = values %sufmap ;
> # while (@keys) {
> #    print pop(@keys),  '=',  pop(@val), "\n" ;
> # }
> # foreach $key (sort keys %sufmap) {
> #    print $key. '='. $sufmap{$key}, "\n";
> #   $sleep = (`sleep 2`) ;
> # }
> while (($key,$value) = each %sufmap) {
> print "$key = $value\n" ;
> }

I named my data file test.dat.  Here is my first program which attempts
to do it using cat as in your example.  I am on a Windows machine now,
so I had to run it under Cygwin.

#!/usr/bin/perl

use strict;
use warnings;

my $a =  `cat ./test.dat` ;
$a =~ s/'\s*'/','/g;
my %sufmap;
$a =  '%sufmap = ('.$a.')';
eval($a);
while ((my $key,my $value) = each %sufmap) {
print "$key = $value\n" ;
}

Probably most people here would not like this way of solving the
problem, so I did it another way:

#!/usr/bin/perl

use strict;
use warnings;

open my $file, './test.dat' or die "cannot open: $!";
my @a =  <$file> ;
my %sufmap = map{split '=>', $_} @a;
print "$_ = ", $sufmap{$_} for keys %sufmap;

You could probably simplify the program if your data was stored in a
more sensible format, maybe:

149
x
150
y
151
z
152
AA

I recommend 'Learning Perl' to pick up the basics.

wana



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

Date: Tue, 01 Feb 2005 00:33:43 -0500
From: Deke <Deke@nospam.com>
Subject: Obfuscating mod_perl code
Message-Id: <10vu55pfut4oh7f@news.supernews.com>

Is there a way to obfuscate perl code that runs in apache and mod_perl 
and mason etc..?

Thanks!


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

Date: 31 Jan 2005 22:52:44 -0800
From: ioneabu@yahoo.com
Subject: Re: Obfuscating mod_perl code
Message-Id: <1107240764.120583.91140@z14g2000cwz.googlegroups.com>

Just put all of your secret code in modules and keep them out of the
path that might be exposed to the web.  Are you afraid that maybe the
root user of a server that you do not own might steal your ideas?  You
could wait for Perl6 where you can compile your code to byte code which
will be harder to read.  Or, just re-use other people's publicly
available code in modules so you don't have anything to be stolen.

Just be happy you are not writing complex, valuable javascript.  You
really can't hide it at all.

wana



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

Date: 31 Jan 2005 15:37:22 -0800
From: "Gomer" <chastaib@hotmail.com>
Subject: Send Parameter to SQL
Message-Id: <1107214642.334737.47960@f14g2000cwb.googlegroups.com>

How can I send a parameter I read inside of a PERL script to a SQL
script.
For example, I have the following:

chomp ($login_name = uc(<STDIN>));

Now, I want to send that $login_name to a SQL script.  I'm doing
something like the following:

$sql = "declare \n";
$sql .= " v_new_pswd varchar2(20); \n";
$sql .= "begin \n";
$sql .= " v_new_pswd := db_login.crypt_passwd('NEW_PASSWORD'); \n";
$sql .= " update table set pswd = v_new_pswd where user_id =
'$login_name'; \n";
$sql .= "end; \n";
$sql .= "/ \n";
$sql .= "commit; \n";
@output = run_sql_query ($login,$password,$sql);

I'm using some libraries that came with my system so I know that
everything is working correctly except that the login_name isn't being
passed.
How can I format the login_name so it's correctly interpreted in
my SQL script?

Thanks,
Gomer



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

Date: Mon, 31 Jan 2005 18:48:39 -0600
From: Tad McClellan <tadmc@augustmail.com>
Subject: Re: Send Parameter to SQL
Message-Id: <slrncvtkf7.pjm.tadmc@magna.augustmail.com>

Gomer <chastaib@hotmail.com> wrote:
> How can I send a parameter I read inside of a PERL script to a SQL
> script.
> For example, I have the following:
> 
> chomp ($login_name = uc(<STDIN>));
> 
> Now, I want to send that $login_name to a SQL script.  I'm doing
> something like the following:
> 
> $sql = "declare \n";
> $sql .= " v_new_pswd varchar2(20); \n";
> $sql .= "begin \n";
> $sql .= " v_new_pswd := db_login.crypt_passwd('NEW_PASSWORD'); \n";
> $sql .= " update table set pswd = v_new_pswd where user_id =
> '$login_name'; \n";
> $sql .= "end; \n";
> $sql .= "/ \n";
> $sql .= "commit; \n";


Did you try adding this statement at this point?

   print $sql;

You should use a "here-document" if you want to see what
you are writing:

my $sql =<<ENDSQL;
declare
 v_new_pswd varchar2(20);
begin
 v_new_pswd := db_login.crypt_passwd('NEW_PASSWORD');
 update table set pswd = v_new_pswd where user_id = '$login_name';
end;
/
commit;
ENDSQL


Does the same thing as your code, but *looks like* what
you are constructing.


> @output = run_sql_query ($login,$password,$sql);
> 
> I'm using some libraries that came with my system so I know that
> everything is working correctly except that the login_name isn't being
> passed.


How does run_sql_query() indicate errors?

No Perl there.


> How can I format the login_name so it's correctly interpreted in
> my SQL script?


That depends on how an "SQL script" wants it formatted. Looks OK to me...

No Perl there either.


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


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

Date: Mon, 31 Jan 2005 18:23:51 -0700
From: YYusenet <yyusenet@yahoo.com>
Subject: Re: Send Parameter to SQL
Message-Id: <ctmln8$p4j$1@news.xmission.com>

Gomer wrote:
> How can I send a parameter I read inside of a PERL script to a SQL
> script.
> For example, I have the following:
> 
> chomp ($login_name = uc(<STDIN>));
          ^^^^^^^^^^^
> 
> Now, I want to send that $login_name to a SQL script.  I'm doing
> something like the following:
  [snip]
> Thanks,
> Gomer
> 

Do you possibly need to use:
--------------
chomp (my $login_name = uc(<STDIN>));
--------------
I'm not sure if that will help seeing that the full script is not 
provided so I cannot debug it properly.
-- 
k g a b e r t (@at@) x m i s s i o n (.dot.) c o m

* 	After "extensive" research, I noticed
*	that yyusenet@yahoo.com received 12
*	spam e-mail messages after just two
*	posts on usenet groups.  If you want
*	to email me, use the "encrypted"
*	email address at the beggining of my
*	signature.


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

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.  

NOTE: due to the current flood of worm email banging on ruby, the smtp
server on ruby has been shut off until further notice. 

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


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