[30676] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 1921 Volume: 11

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Mon Oct 13 21:09:50 2008

Date: Mon, 13 Oct 2008 18:09:13 -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, 13 Oct 2008     Volume: 11 Number: 1921

Today's topics:
    Re: 'extracting' from a string via regular expressions? sseelenluft@gmail.com
        access C++ modular functions <smcbutler@hotmail.com>
    Re: can't run "devenv" in Perl <bwalton@nospam.invalid>
    Re: can't run "devenv" in Perl sln@netherlands.com
    Re: can't run "devenv" in Perl <slick.users@gmail.com>
    Re: can't run "devenv" in Perl <jurgenex@hotmail.com>
    Re: FAQ 4.34 How do I extract selected columns from a s <john@castleamber.com>
    Re: finding newest file in a directory and removing the <rvtol+news@isolution.nl>
    Re: finding newest file in a directory and removing the <tadmc@seesig.invalid>
    Re: finding newest file in a directory and removing the <tadmc@seesig.invalid>
    Re: GETDATA to POSTDATA <ced@blv-sam-01.ca.boeing.com>
    Re: how to close STDIN <ced@blv-sam-01.ca.boeing.com>
    Re: how to close STDIN <ced@blv-sam-01.ca.boeing.com>
    Re: how to close STDIN (fidokomik\)
        mod_perl <jcarlock@127.0.0.1>
    Re: mod_perl <jcarlock@127.0.0.1>
    Re: mod_perl <No_4@dsl.pipex.com>
        Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)

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

Date: Mon, 13 Oct 2008 11:24:19 -0700 (PDT)
From: sseelenluft@gmail.com
Subject: Re: 'extracting' from a string via regular expressions?
Message-Id: <5247f7ad-ece7-4000-8ebe-9fb6db4aacf2@l64g2000hse.googlegroups.com>

On Oct 13, 6:08=A0pm, Tad J McClellan <ta...@seesig.invalid> wrote:
> sseelenl...@gmail.com <sseelenl...@gmail.com> wrote:
> > # Definition of variables
> > my $line;
> > my $file;
>
> You are not defining variables there.
>
> You are declaring variables there.
>
> "defining" in not the same thing as "declaring".
You are correct, the original code was written by an Italian speaking
person, and I as a German speaker was not apparently not bothered
enough by it to change it.


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

Date: Mon, 13 Oct 2008 17:47:16 -0700 (PDT)
From: si <smcbutler@hotmail.com>
Subject: access C++ modular functions
Message-Id: <0ff18619-728c-4fdf-a466-7c8b404cfe3f@k36g2000pri.googlegroups.com>

my coworker has written some C++ functions and i'd like to access them
from my perl code. how much work would be involved to make this work?
TIA


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

Date: Mon, 13 Oct 2008 17:10:05 -0400
From: Bob Walton <bwalton@nospam.invalid>
Subject: Re: can't run "devenv" in Perl
Message-Id: <48f380e1$0$30496$9a6e19ea@nhxl.newshosting.com>

Slickuser wrote:
 ...
> system("devenv /Build Debug \"ProjectABC.sln\" /out \"C:/log_out.txt
> \");
---------^
This quotation mark is not balanced by another, so it is unlikely that 
this even compiled.  Please copy/paste your real code.
 ...
-- 
Bob Walton
Email: http://bwalton.com/cgi-bin/emailbob.pl


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

Date: Mon, 13 Oct 2008 22:25:05 GMT
From: sln@netherlands.com
Subject: Re: can't run "devenv" in Perl
Message-Id: <6vb7f498rcnjooqdr9pa36t6coso611l7c@4ax.com>

On Mon, 13 Oct 2008 10:29:01 -0700 (PDT), Slickuser <slick.users@gmail.com> wrote:

>Hi,
>
>How can I fixed the error below so that I can run "devenv" in Perl?
>Thanks.
>
>setVSEnv();
>system("devenv /Build Debug \"ProjectABC.sln\" /out \"C:/log_out.txt
>\");
>
>Error:
>Setting environment for using Microsoft Visual Studio 2005 x86 tools.
>'devenv' is not recognized as an internal or external command,
>operable program or batch file.
>
>sub setVSEnv
>{
>	## VS 2005
>	my $VS_Path = $ENV{'VS80COMNTOOLS'};
>	if (defined($VS_Path))
>	{
>		system("call \"%vs80comntools%vsvars32.bat\" ");
>	}
>	else
>	{
>		## VS 2003
>		$VS_Path = $ENV{'VS71COMNTOOLS'};
>		if (!defined($VS_Path))
>		{
>			print STDERR "Visual Studio doesn't exist.\n";
>			exit(0);
>		}
>		system("call \"%vs71comntools%vsvars32.bat\" ");
>	}
>}

I think the 'system()' function forkes a new process. As soon as the process goes
away the @sets go away before you call the devenv. Try using exec(), it should work.

If that doesen't work you could dynamically create a batch file then run it with system().
Something like this:

	mybuild.bat
	------------------
	call "C:\Program Files\Microsoft Visual Studio 8\Common7\Tools\vsvars32.bat"
	devenv.exe "C:\(full path)\ProjectABC.sln" /rebuild "Release" /out log_out.txt

sln

=====================================
use strict;
use warnings;

open my $fh, '>', 'mybuild.bat' or die "can't create mybuild.bat...";
print $fh makeBatchFile('"(full path)\ProjectABC.sln" /rebuild "Release" /out log_out.txt');
close $fh;

system (" mybuild.bat ");

sub makeBatchFile
{
	my $solution = shift;
	my $str = '';

	 ## VS 2005
	my $VS_Path = $ENV{'VS80COMNTOOLS'};
	 ## VS 2003
	$VS_Path = $ENV{'VS71COMNTOOLS'} unless (defined $VS_Path);
	
	if (!defined($VS_Path))	{
		print STDERR "Visual Studio doesn't exist.\n";
		exit(0);
	}
	return "\@echo off\n\@cls\ncall \"".$VS_Path."vsvars32.bat\"\ndevenv $solution\n";
}

__END__

output:

Setting environment for using Microsoft Visual Studio 2005 x86 tools.

Microsoft (R) Visual Studio Version 8.0.50727.762.
Copyright (C) Microsoft Corp 1984-2005. All rights reserved.

The following files were specified on the command line:

        (full path)\ProjectABC.sln

These files could not be found and will not be loaded.

C:\temp>



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

Date: Mon, 13 Oct 2008 16:53:48 -0700 (PDT)
From: Slickuser <slick.users@gmail.com>
Subject: Re: can't run "devenv" in Perl
Message-Id: <d59db24d-169c-46d5-a6d6-4367c5a99a45@l33g2000pri.googlegroups.com>


>
> I think the 'system()' function forkes a new process. As soon as the process goes
> away the @sets go away before you call the devenv. Try using exec(), it should work.
>

It doesn't work so I am going with the calling absolute full path to
devenv.exe directly.


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

Date: Mon, 13 Oct 2008 17:38:57 -0700
From: Jürgen Exner <jurgenex@hotmail.com>
Subject: Re: can't run "devenv" in Perl
Message-Id: <9aq7f4lq3j27lqc5iteg5ph7247clp5926@4ax.com>

Slickuser <slick.users@gmail.com> wrote:
>> I think the 'system()' function forkes a new process. As soon as the process goes
>> away the @sets go away before you call the devenv. Try using exec(), it should work.
>
>It doesn't work so I am going with the calling absolute full path to
>devenv.exe directly.

Well, I don't know what problem the previous poster tried to solve by
using exec() instead of system() (his article doesn't show up). 
But whatever it is, I cannot fathom why replacing the Perl process with
another process would be an improvement over running the other process
while the Perl process is waiting.

jue


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

Date: 13 Oct 2008 19:14:15 GMT
From: John Bokma <john@castleamber.com>
Subject: Re: FAQ 4.34 How do I extract selected columns from a string?
Message-Id: <Xns9B3690D75968Fcastleamber@130.133.1.4>

PerlFAQ Server <brian@stonehenge.com> wrote:

>     modules that handle that fornat, such as "Text::CSV",
                                  ^ 

-- 
John    http://johnbokma.com/ - Hacking & Hiking in Mexico

Perl help in exchange for a gift:
http://johnbokma.com/perl/help-in-exchange-for-a-gift.html


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

Date: Mon, 13 Oct 2008 21:11:58 +0200
From: "Dr.Ruud" <rvtol+news@isolution.nl>
Subject: Re: finding newest file in a directory and removing the rest
Message-Id: <gd0djv.1r0.1@news.isolution.nl>

Stu schreef:

>> email: perl -le "print scalar reverse qq/moc.noitatibaher\100cmdat/"
> 
> Thanks for the response but I am not too sure I understand what this
> statement is doing.

It prints an address. 

-- 
Affijn, Ruud

"Gewoon is een tijger."


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

Date: Mon, 13 Oct 2008 17:46:46 -0500
From: Tad J McClellan <tadmc@seesig.invalid>
Subject: Re: finding newest file in a directory and removing the rest
Message-Id: <slrngf7jum.pgt.tadmc@tadmc30.sbcglobal.net>

Stu <beefstu350@hotmail.com> wrote:
> On Oct 13, 12:14 pm, Tad J McClellan <ta...@seesig.invalid> wrote:
>> Stu <beefstu...@hotmail.com> wrote:
>> > On Oct 10, 12:14 pm, Tad J McClellan <ta...@seesig.invalid> wrote:
>> >> Stu <beefstu...@hotmail.com> wrote:


[ snip 20 lines ]


>> >> --
>> >> Tad McClellan
>> >> email: perl -le "print scalar reverse qq/moc.noitatibaher\100cmdat/"
>>
>> It is bad form to quote .sigs. Please do not do that.
>>
>> You should also trim irrelevant text, and interleave your comments.


[ snip 20 lines ]


>> --
>> Tad McClellan
>> email: perl -le "print scalar reverse qq/moc.noitatibaher\100cmdat/"- Hide quoted text -
>>
>> - Show quoted text -
>
> Thanks for all your help.


Yeah, right.

Off to perpetual invisibility you go...


-- 
Tad McClellan
email: perl -le "print scalar reverse qq/moc.noitatibaher\100cmdat/"


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

Date: Mon, 13 Oct 2008 17:47:41 -0500
From: Tad J McClellan <tadmc@seesig.invalid>
Subject: Re: finding newest file in a directory and removing the rest
Message-Id: <slrngf7k0d.pgt.tadmc@tadmc30.sbcglobal.net>

Dr.Ruud <rvtol+news@isolution.nl> wrote:
> Stu schreef:
>
>>> email: perl -le "print scalar reverse qq/moc.noitatibaher\100cmdat/"
>> 
>> Thanks for the response but I am not too sure I understand what this
>> statement is doing.
>
> It prints an address. 


<grin>


-- 
Tad McClellan
email: perl -le "print scalar reverse qq/moc.noitatibaher\100cmdat/"


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

Date: Mon, 13 Oct 2008 16:39:08 -0700 (PDT)
From: "C.DeRykus" <ced@blv-sam-01.ca.boeing.com>
Subject: Re: GETDATA to POSTDATA
Message-Id: <743c7f29-4fc6-40f2-9183-3415f308b9bd@p10g2000prf.googlegroups.com>

On Oct 11, 9:28 am, "Daniel Kaplan" <NoS...@NoSpam.com> wrote:
> Hi,
>
> I have a page that the server redirects to incase of an SQL Inject attempt.
> The thing is, because of the rewrite rule (something beyond my
> understanding) the page won't work properly.  Call it directly, it works,
> call it via the rule, not so much.
>
> What does work is if in that new page, I redirect it to another copy of that
> page, and then it works.
>
> But here is my problem:
>
> I cannot redirect it with the same URL because that triggers the redirect
> rule (again, written in the server OS), and therefore my Perl redirect just
> loops.
>
> So my question is:
>
> Can I take that URL I have, and somehow pass it to my copy with the data in
> the URL now in POSTDATA format?  Because POSTDATA won't trigger the redirect
> rule.
>

Two modules that can help you
transform GET to POST:

URI
HTTP::Request::Common


--
Charles DeRykus


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

Date: Mon, 13 Oct 2008 15:13:10 -0700 (PDT)
From: "C.DeRykus" <ced@blv-sam-01.ca.boeing.com>
Subject: Re: how to close STDIN
Message-Id: <62bc44cc-fc4c-4cc9-9586-1411f0bbe1a9@40g2000prx.googlegroups.com>

On Oct 12, 5:57 am, Larry <dontmewit...@got.it> wrote:
> In article <slrngf1mrd.6fv.hjp-usen...@hrunkner.hjp.at>,
>  "Peter J. Holzer" <hjp-usen...@hjp.at> wrote:
>
> > You can't send it to the script, since the script is already dead.
>
> ok, so back to my question...is ok to close STDIN and exit in order to
> stop my script if a user fails to auth?
>

But if authentication fails, you could return a "401 Unauthorized"
before you even begin reading:

if ( $ENV{"HTTP_USER_PASS"} ne ... ) {
  print $q->header(
      -status="401 Unauthorized"), ...,
   "Wrong password....";
} else {
   if ( $io->fdopen(fileno(STDIN),"r") )
    {
      ...  # read
    }
}
exit;

--
Charles DeRykus


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

Date: Mon, 13 Oct 2008 15:18:56 -0700 (PDT)
From: "C.DeRykus" <ced@blv-sam-01.ca.boeing.com>
Subject: Re: how to close STDIN
Message-Id: <fc07a2f4-3ec0-48d4-bb4a-fb1ea267156a@r37g2000prr.googlegroups.com>

On Oct 13, 3:13 pm, "C.DeRykus" <c...@blv-sam-01.ca.boeing.com> wrote:
> On Oct 12, 5:57 am, Larry <dontmewit...@got.it> wrote:
>
> > In article <slrngf1mrd.6fv.hjp-usen...@hrunkner.hjp.at>,
> >  "Peter J. Holzer" <hjp-usen...@hjp.at> wrote:
>
> > > You can't send it to the script, since the script is already dead.
>
> > ok, so back to my question...is ok to close STDIN and exit in order to
> > stop my script if a user fails to auth?
>
> But if authentication fails, you could return a "401 Unauthorized"
> before you even begin reading:
>  ...

Of course, this won't alleviate the data push,
but at least you'll be failing gracefully with
the appropriate status.

--
Charles DeRykus



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

Date: Tue, 14 Oct 2008 01:47:11 +0200
From: "Petr Vileta \(fidokomik\)" <stoupa@practisoft.cz>
Subject: Re: how to close STDIN
Message-Id: <gd0n8o$6d1$2@aioe.org>

C.DeRykus wrote:
> On Oct 12, 5:57 am, Larry <dontmewit...@got.it> wrote:
> But if authentication fails, you could return a "401 Unauthorized"
> before you even begin reading:
> 
> if ( $ENV{"HTTP_USER_PASS"} ne ... ) {
>  print $q->header(
>      -status="401 Unauthorized"), ...,
>   "Wrong password....";

Or you can simply write

if ( $ENV{"HTTP_USER_PASS"} ne ... ) {
  print "Status: 401 Unauthorized\n\n");
  exit;
}


-- 
Petr Vileta, Czech republic
(My server rejects all messages from Yahoo and Hotmail.
Send me your mail from another non-spammer site please.)
Please reply to <petr AT practisoft DOT cz>



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

Date: Mon, 13 Oct 2008 15:18:55 -0400
From: "Jim Carlock" <jcarlock@127.0.0.1>
Subject: mod_perl
Message-Id: <48f39f23$0$5475$9a6e19ea@unlimited.newshosting.com>

: The first method, which I did not document at the following link,
: involves setting some keys to use the Perl.exe (executable) to
: run all .pl files and it requires a line inside ALL .pl documents
: to point where to the executable Perl.exe. And I did get that to
: work, but that's not the route I took as I'm more into getting
: mod_perl to run ALL files with the appropriate extension. And I
: believe I'm successful in this regards. But the PerlTaintCheck
: I've not quite figured out yet. Any suggestions?
: 
: http://www.microcosmotalk.com/tech/mod_perl/

I'm prepared to state that mod_perl does NOT use and can NOT use
PertTaintCheck. I need some comfirmation from others before I make
this claim. It appears that Apache uses PerlTaintCheck to call
Perl.exe with specific parameters. But before I claim that to be
true, does anyone know what's going on? Is anyone else here
interested in this topic? I'm just going to crosspost this.

mod_perl is installed as follows in my httpd.conf file...

<snip file="httpd.conf">
# mod_perl 5.8 build
# LoadFile "C:/Program Files/ActiveState/Perl/bin/perl58.dll"

# mod_perl 5.10 build
LoadFile "C:/Program Files/ActiveState/Perl/bin/perl510.dll"
LoadModule perl_module modules/mod_perl.so

# ...
# ...
# other Apache directives
# ...
# ...

<IfModule alias_module>
 <IfModule mime_module>
  # ...
  # ...
  # ...
  
  <Files ~ "\.(pl|plx)$">
   # DefaultType text/html # This DOES NOT work/commented out
   SetHandler perl-script
   Options ExecCGI
   PerlHandler ModPerl::Registry
   PerlSendHeader On
   # PerlTaintCheck On     # This does NOT work/commented out
   # PerlWarn On           # This does NOT work/commented out
  </Files>
 </IfModule>
</IfModule>

# ...
# ...
# ...
</snip>

-- 
Jim Carlock
Vote Ralph Nader
(George Bush Groupies: Sarah Palin And John McCain Say So)
http://www.votenader.org/



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

Date: Mon, 13 Oct 2008 14:13:52 -0400
From: "Jim Carlock" <jcarlock@127.0.0.1>
Subject: Re: mod_perl
Message-Id: <48f38fe5$0$5478$9a6e19ea@unlimited.newshosting.com>

> Now back to mod_perl. mod_perl is installed as follows in my
> httpd.conf file.

"J. Gleixner" wrote...
: Again, it's not 'installed' by your httpd.conf file. It should
: already be 'installed' on your machine before you can use it.
: 
: What is your question?

I guess my understanding of install comes into question here.

The Perl executables and other files reside inside a subset of
folders on a computer. mod_perl gets loaded and run via the
Apache httpd.conf. There is NO OTHER INSTALL involved. Apache
knows where to find the two files involved with mod_perl and
that's all that's required. Is my understanding of this
installation faulty?

mod_perl is installed as follows in my httpd.conf file...

<snip file="httpd.conf">
# mod_perl 5.8 build
# LoadFile "C:/Program Files/ActiveState/Perl/bin/perl58.dll"

# mod_perl 5.10 build
LoadFile "C:/Program Files/ActiveState/Perl/bin/perl510.dll"
LoadModule perl_module modules/mod_perl.so

# ...
# ...
# other Apache directives
# ...
# ...

<IfModule alias_module>
 <IfModule mime_module>
  # ...
  # ...
  # ...
  
  <Files ~ "\.(pl|plx)$">
   # DefaultType text/html # This DOES NOT work/commented out
   SetHandler perl-script
   Options ExecCGI
   PerlHandler ModPerl::Registry
   PerlSendHeader On
   # PerlTaintCheck On     # This does NOT work/commented out
   # PerlWarn On           # This does NOT work/commented out
  </Files>
 </IfModule>
</IfModule>

# ...
# ...
# ...
</snip>

On to another question: To get PerlTainCheck to work, do you know
what might be involved in getting that to work? I know that more
than one way exists in getting Perl going configured inside of an
Apache httpd.conf file, as I've established two means, I decided
I did not want to put deal with the Windows registry and so I do
not mess with the Windows registry in getting things going.

The first method, which I did not document at the following link,
involves setting some keys to use the Perl.exe (executable) to
run all .pl files and it requires a line inside ALL .pl documents
to point where to the executable Perl.exe. And I did get that to
work, but that's not the route I took as I'm more into getting
mod_perl to run ALL files with the appropriate extension. And I
believe I'm successful in this regards. But the PerlTaintCheck
I've not quite figured out yet. Any suggestions?

http://www.microcosmotalk.com/tech/mod_perl/

Thanks.

-- 
Jim Carlock
Ralph Nader Only Has A Chance If YOU Vote For Him
http://www.votenader.org/




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

Date: Tue, 14 Oct 2008 00:22:28 +0100
From: Big and Blue <No_4@dsl.pipex.com>
Subject: Re: mod_perl
Message-Id: <Cc-dnTvTHLuoRW7VnZ2dnUVZ8qfinZ2d@pipex.net>

Jim Carlock wrote:

> 
> I'm prepared to state that mod_perl does NOT use and can NOT use
> PertTaintCheck.

Should be fairly easy to confirm.  Just write some code that would fail 
taint checking and load it into mod_perl at Apache startup.  Then look 
for errors.  If there are some it works, if there aren't it doesn't.

>              It appears that Apache uses PerlTaintCheck to call
> Perl.exe with specific parameters.

???  I only ever use Unix/Linux with mod_perl so may be barking up the 
wrong tree here, but why would perl.exe be involved?  I'd expect it to 
be using the shared library (perl*.dll) rather then any executable.




-- 
              Just because I've written it doesn't mean that
                   either you or I have to believe it.


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

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 V11 Issue 1921
***************************************


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