[21950] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 4172 Volume: 10

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Mon Nov 25 09:05:45 2002

Date: Mon, 25 Nov 2002 06:05:09 -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           Mon, 25 Nov 2002     Volume: 10 Number: 4172

Today's topics:
    Re: @INC, use, $LD_LIBRARY_PATH, & modules <dave@dave.org.uk>
    Re: @INC, use, $LD_LIBRARY_PATH, & modules <shirsch@adelphia.net>
    Re: @INC, use, $LD_LIBRARY_PATH, & modules (Tad McClellan)
    Re: Binary vs ascii ??? news@roaima.freeserve.co.uk
    Re: comment on 2 or 4 spaces indentation <cingram@pjocsNOSPAMORHAM.demon.co.uk>
    Re: Help with grep + hash value <bart.lateur@pandora.be>
        Help with reg.exp. (Rune)
    Re: Help with reg.exp. <graham@wellho.net>
    Re: Help with reg.exp. (Philip Lees)
    Re: Help with reg.exp. (Gilgames)
    Re: Perl debugger? (Helgi Briem)
    Re: Perl debugger? <kaushal.mehta@sbcglobal.net>
    Re: removing elements from an array <dave@dave.org.uk>
    Re: removing elements from an array <bart.lateur@pandora.be>
    Re: Unpacking MHTML files on upload news@roaima.freeserve.co.uk
    Re: Urgent request for help -- posting to a FORM from a <bart.lateur@pandora.be>
    Re: Winnt Authentication <simon.andrews@bbsrc.ac.uk>
        Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)

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

Date: Mon, 25 Nov 2002 08:46:19 +0000
From: "Dave Cross" <dave@dave.org.uk>
Subject: Re: @INC, use, $LD_LIBRARY_PATH, & modules
Message-Id: <pan.2002.11.25.08.46.18.999923@dave.org.uk>

On Sun, 24 Nov 2002 20:36:59 +0000, Abernathey Family wrote:

> Benjamin Goldberg wrote:
>> 
>> Dave Cross wrote:
>> [snip]
>> > use lib /path/to/perl/modules;
>> 
>> This needs quotes:
>> 
>> use lib "/path/to/perl/modules";
> --snip--
> 
> Single or double quotes?

Usual rules about single and double quotes apply. Variables are expanded
in double quotes, not in single quotes.

Of course, because the "use" statement happens at compile time, there are
a couple of caveats. Code like this won't work:

$home = '/path/to/dir';
use lib "$home/some/other/dir";

You'd need to do:

BEGIN { $home = '/path/to/dir'; }
use lib "$home/some/other/dir";

Dave...

-- 
  ...she opened strange doors that we'd never close again



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

Date: Mon, 25 Nov 2002 13:04:20 GMT
From: "Steven N. Hirsch" <shirsch@adelphia.net>
Subject: Re: @INC, use, $LD_LIBRARY_PATH, & modules
Message-Id: <3DE21F5A.2040308@adelphia.net>

Dave Cross wrote:


>>I'm in a multi-national company with access via afs to groups with their
>>own builds/installations of Perl.
>>By the way, some of modules have c-libraries with them. "use lib
>>"pathname" works for getting the path into the @INC array but I still
>>get an error from Linux Dyna-loader that it can't find them. The error
>>goes away when I set my LD_LIBRARY_PATH variable to point at the
>>c-libraries. But this variable has to be set "outside" of my Perl
>>script. Modifying my script's local copy of this variable
>>$ENV{LD_LIBRARY_PATH} doesn't work.
> 
> 
> Have you tried setting $ENV{LD_LIBRARY_PATH} in a BEGIN block?
> 
> BEGIN {
>   $ENV{LD_LIBRARY_PATH} = '/path/to/shared/objects';
> }
> 
> use lib /path/to/perl/modules;
> 
> use Some::Wierd::Module;

I'm in the same boat at work as the original poster (we probably work at 
different sites together).  We've developed some rather ugly workarounds 
involving creative use of the "pound-bang" header to run setup scripts. 
  That aside, setting the LD_LIBRARY_PATH in BEGIN{} does not work on 
some architectures (security issues, I suppose), and it's often 
necessary to condition it before starting perl.

Steve




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

Date: Mon, 25 Nov 2002 06:58:56 -0600
From: tadmc@augustmail.com (Tad McClellan)
Subject: Re: @INC, use, $LD_LIBRARY_PATH, & modules
Message-Id: <slrnau47kg.29v.tadmc@magna.augustmail.com>

Abernathey Family <family2@aracnet.com> wrote:
> Benjamin Goldberg wrote:
>> Dave Cross wrote:
>> [snip]
>> > use lib /path/to/perl/modules;
>> 
>> This needs quotes:
>> 
>> use lib "/path/to/perl/modules";
> --snip--
> 
> Single or double quotes?


Yes.


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


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

Date: Mon, 25 Nov 2002 09:58:52 +0000
From: news@roaima.freeserve.co.uk
Subject: Re: Binary vs ascii ???
Message-Id: <s8ssra.49e.ln@moldev.cmagroup.co.uk>

Noerd wrote:
>I'm using Macintosh OS9 for my home computer.

Bart Lateur <bart.lateur@pandora.be> wrote:
> Oops. Not compatible. Unix uses *only* a chr(10) as a line end marker,
> MacOS uses *only* a chr(13). Not compatible.

> I think the invisible characters, in particular the chr(13) and chr(10)
> I mentioned earlier, maybe got substituted. 

In ASCII mode, the FTP client and server ensure that a line remains a
line, so the trailing end-of-line marker (i.e. CR, LF, CR/LF,...) will
be translated automatically.

In BINARY mode, the file is treated as a single untouchable unit, and no
conversions of any kind (including that relating to end-of-line markers)
will be made.


The correct approach is to transfer binary data files (e.g. images, tar
files, ZIP files, Stuff-it files) in BINARY, and everything else in ASCII.

Chris
-- 
@s=split(//,"Je,\nhn ersloak rcet thuarP");$k=$l=@s;for(;$k;$k--){$i=($i+1)%$l
until$s[$i];$c=$s[$i];print$c;undef$s[$i];$i=($i+(ord$c))%$l}


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

Date: Mon, 25 Nov 2002 13:18:40 -0000
From: "Clyde Ingram" <cingram@pjocsNOSPAMORHAM.demon.co.uk>
Subject: Re: comment on 2 or 4 spaces indentation
Message-Id: <art7sr$se1$1$8302bc10@news.demon.co.uk>


"Jeff 'japhy' Pinyan" <pinyaj@rpi.edu> wrote in message
news:Pine.A41.3.96.1021122101054.104578A-100000@cortez.sss.rpi.edu...
<SNIP>
> I use two-space indents, because I don't want my code to run off the edge
> of the screen. ;)

What?  You write code that indents around ten times?
IMHO It'd be a lot easier on your readers if you broke it into functions -
especially if your deeply nested blocks exceed one screenful. ;-)




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

Date: Mon, 25 Nov 2002 08:39:04 GMT
From: Bart Lateur <bart.lateur@pandora.be>
Subject: Re: Help with grep + hash value
Message-Id: <hon3uu07mh7s4edav4529un53i8p1bk6eh@4ax.com>

Trent Hare wrote:

>So, when the hash value = "12345C.jpg" how do I get it to allow
>12345C_2.jpg as well using this type of array matching?

I think you'd want to use the basename, '12345C', as a hash key. You can
extract that bare name by only allowing letters and digits, no
underscores:

	$_ = '12345C_2.jpg';
	my ($basename) = /^([^\W_]+)/;
	$h{$barename}++;

That, IMO, is the easy (and likely fast) route. I think I've seen a
module on CPAN to do regex matching on hash keys... Yeah:
Tie::Hash::Regex. And you can always do grep on the hash keys:

	$_ = '12345C_2.jpg';
	$h{'12345C.jpg'}++;
	@pictures = ('12345C_2.jpg', '54321A.jpg');

	@filtered = grep { my($base) = /^([^\W_]+)/;
		!grep /^$base(?=[_.])/, keys %h } @pictures;

But don't go that route.

-- 
	Bart.


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

Date: 25 Nov 2002 00:21:20 -0800
From: hoplah@hotmail.com (Rune)
Subject: Help with reg.exp.
Message-Id: <6b0f1981.0211250021.23021d5b@posting.google.com>

Hi all,
I have a regular expression to find a special substring within a
string. The substring consists of 2 chars (capital) followed by 11
digits. The substring can be located anywhere within the string. I'm
using the following code to extract the substring:

($number) = $line =~ m{ ( [A-Z]{2}\d{9} ) }ix;

My problem is now that there can be multible instances of the
substring within the string, but my code only gets the first instance.
Does anyone know how to extend the code to grep all the instances of
the substring into an array so that $number would be @number
containing one instance per element?

Thanks in advance,
Rune


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

Date: Mon, 25 Nov 2002 08:38:45 +0000
From: Graham Ellis <graham@wellho.net>
Subject: Re: Help with reg.exp.
Message-Id: <3DE1E195.650DEB6@wellho.net>

Rune wrote:
> 
> Hi all,
> I have a regular expression to find a special substring within a
> string. The substring consists of 2 chars (capital) followed by 11
> digits. The substring can be located anywhere within the string. I'm
> using the following code to extract the substring:
> 
> ($number) = $line =~ m{ ( [A-Z]{2}\d{9} ) }ix;
> 
> My problem is now that there can be multible instances of the
> substring within the string, but my code only gets the first instance.
> Does anyone know how to extend the code to grep all the instances of
> the substring into an array so that $number would be @number
> containing one instance per element?
> 
> Thanks in advance,
> Rune

@number = $line =~ m{ ([A-Z]{2}\d{9}) }gx;

The g switch requests a global match and will return you a list of all
matches within $line.   I have removed your i switch which is "ignore case",
since you say that you need two capital letters.

Graham

-- 
Graham Ellis, Well House Consultants
Melksham, Wiltshire, UK.
http://www.wellho.net


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

Date: Mon, 25 Nov 2002 09:23:34 GMT
From: pjlees@ics.forthcomingevents.gr (Philip Lees)
Subject: Re: Help with reg.exp.
Message-Id: <3de1ebf6.244093734@news.grnet.gr>

On 25 Nov 2002 00:21:20 -0800, hoplah@hotmail.com (Rune) wrote:

>I have a regular expression to find a special substring within a
>string. The substring consists of 2 chars (capital) followed by 11
>digits. The substring can be located anywhere within the string. I'm
>using the following code to extract the substring:
>
>($number) = $line =~ m{ ( [A-Z]{2}\d{9} ) }ix;
>
>My problem is now that there can be multible instances of the
>substring within the string, but my code only gets the first instance.
>Does anyone know how to extend the code to grep all the instances of
>the substring into an array so that $number would be @number
>containing one instance per element?

Replace the ix with g.

Phil
-- 
Ignore coming events if you wish to send me e-mail


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

Date: 25 Nov 2002 13:32:48 GMT
From: gilgames@aol.coma (Gilgames)
Subject: Re: Help with reg.exp.
Message-Id: <20021125083248.11546.00000071@mb-fg.aol.com>

<<

My problem is now that there can be multible instances of the
substring within the string, but my code only gets the first instance.
Does anyone know how to extend the code to grep all the instances of
the substring into an array so that $number would be @number
containing one instance per element?
>>

put the g parameter to the end, and run it in a loop which builds up an array. 


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

Date: Mon, 25 Nov 2002 11:40:40 GMT
From: helgi@decode.is (Helgi Briem)
Subject: Re: Perl debugger?
Message-Id: <3de20bea.3486687591@news.cis.dfn.de>

On 24 Nov 2002 09:09:52 -0800, therobs@n2net.net (Rob
Richardson) wrote:

>I am entering the Perl world from the worlds of Visual C++ and Visual
>Basic.  In both of those worlds, I have at my disposal a powerful
>debugger that allows me to set breakpoints in code, to execute my code
>one step at a time, to enter or skip over subroutines, and to watch
>variables as they change.  Most imporantly, the debugger can execute
>code in exactly the same environment in which the production version
>will run.  Presumably, other Perl programmers also have experience
>with these or other IDEs with similar capabilities.  So, since Perl is
>largely used for Web programming, I would presume that there exist
>IDEs for Perl that can act as web servers, accepting connections from
>browsers, generating web pages and responding to events from those
>pages by running the requested Perl scripts, stopping at breakpoints,
>displaying variable values, and all the rest of it.  If that is indeed
>the case, what do people recommend that I try to persuade the
>non-profit organization I'm volunteering to do web programming for to
>spend money on?

I have used and liked Perl Builder for a long time.
http://www.solutionsoft.com/perl.htm
-- 
Regards, Helgi Briem
helgi AT decode DOT is

                           A: Top posting
                           Q: What is the most irritating thing on Usenet?
                                           - "Gordon" on apihna


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

Date: Mon, 25 Nov 2002 11:59:22 GMT
From: "KM" <kaushal.mehta@sbcglobal.net>
Subject: Re: Perl debugger?
Message-Id: <ugoE9.4369$S15.1978202273@newssvr12.news.prodigy.com>

I've used the graphical debugger @ http://world.std.com/~aep/ptkdb/
It is pretty basic when compared to the VB and VC++ IDEs, but it does the
job.


"Rob Richardson" <therobs@n2net.net> wrote in message
news:f79bc007.0211240909.21296104@posting.google.com...
> Greetings!
>
> I am entering the Perl world from the worlds of Visual C++ and Visual
> Basic.  In both of those worlds, I have at my disposal a powerful
> debugger that allows me to set breakpoints in code, to execute my code
> one step at a time, to enter or skip over subroutines, and to watch
> variables as they change.  Most imporantly, the debugger can execute
> code in exactly the same environment in which the production version
> will run.  Presumably, other Perl programmers also have experience
> with these or other IDEs with similar capabilities.  So, since Perl is
> largely used for Web programming, I would presume that there exist
> IDEs for Perl that can act as web servers, accepting connections from
> browsers, generating web pages and responding to events from those
> pages by running the requested Perl scripts, stopping at breakpoints,
> displaying variable values, and all the rest of it.  If that is indeed
> the case, what do people recommend that I try to persuade the
> non-profit organization I'm volunteering to do web programming for to
> spend money on?
>
> I've seen tantalizing hints in posts on this group, but I don't know
> where to start.
>
> Thanks!
>
> Rob




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

Date: Mon, 25 Nov 2002 08:42:01 +0000
From: "Dave Cross" <dave@dave.org.uk>
Subject: Re: removing elements from an array
Message-Id: <pan.2002.11.25.08.41.21.129952@dave.org.uk>

On Sun, 24 Nov 2002 19:02:07 +0000, Nick Tipper wrote:

> Hi can anybody please tell me how i can remove an element from an array thus
> 
> foreach (@arr) {
>     if (some condition) {
>          # remove $_ from @arr
>      }
> }
> 
> i know i could
> 
> for  $i  (0 .. $#arr) {
>     if(some condition) {
>         splice @arr, $i, 1;
>     }
> }
> 
> but i really want to use the 'foreach' method because i am trying to use
> this in a recursive fashion and i keep getting unitialised variable problems
> with 'for'

Your "uninitialised" error is probably caused by falling off the end of
the array in the for loop. The value of $#arr is only evaluated as you
enter the loop for the first time anf as you're removing elements, that
value will be too large by the time to get to the end of the array.

If you know for sure that you will only be removing _one_ item from the
array, then you can add a call to "last" to jump out of the loop before
you get to the dangerous waters at the end of the array, but if your
condition will possibly remove more than one element then you can't use
that approach and you'll be better off using "grep".

hth,

Dave...

-- 
  Love is a fire of flaming brandy
  Upon a crepe suzette



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

Date: Mon, 25 Nov 2002 08:42:38 GMT
From: Bart Lateur <bart.lateur@pandora.be>
Subject: Re: removing elements from an array
Message-Id: <peo3uug5gubm54t6minqvn0ddlb7btv3p7@4ax.com>

Nick Tipper wrote:

>i know i could
>
>for  $i  (0 .. $#arr) {
>    if(some condition) {
>        splice @arr, $i, 1;
>    }
>}
>
>but i really want to use the 'foreach' method because i am trying to use
>this in a recursive fashion and i keep getting unitialised variable problems
>with 'for'

The reason is because you still increment the array index after you
modified the array index. Or: the array item $arr[5] is not the same
item it was if you do splice(@arr, 4, 1).

Either don't increment your index if you do a splice, or, a lot easier,
loop through the array backwards.

	for  (my $i = $#arr; $i--; $i>=0) {
	    if(some condition) {
	        splice @arr, $i, 1;
	    }
	}

Only items that come after the splice point got moved, not the ones in
front of it.

-- 
	Bart.


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

Date: Mon, 25 Nov 2002 09:54:21 +0000
From: news@roaima.freeserve.co.uk
Subject: Re: Unpacking MHTML files on upload
Message-Id: <d0ssra.49e.ln@moldev.cmagroup.co.uk>

Barry King <barry_king@hotmail.com> wrote:
> Hi.  I want to have a form that allows users to upload an MHTML file
> (via <input type=file>) which is then unpacked on the server by the
> CGI (Perl) that received the POST.  Is there a Perl module out there
> that can enable my CGI to easily unpack the MHTML?

I don't know what MHTML is, but if you need to process data received by
a POST operation you should be looking at the CGI module

	perldoc CGI

Chris
-- 
@s=split(//,"Je,\nhn ersloak rcet thuarP");$k=$l=@s;for(;$k;$k--){$i=($i+1)%$l
until$s[$i];$c=$s[$i];print$c;undef$s[$i];$i=($i+(ord$c))%$l}


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

Date: Mon, 25 Nov 2002 08:25:34 GMT
From: Bart Lateur <bart.lateur@pandora.be>
Subject: Re: Urgent request for help -- posting to a FORM from a Perl Script
Message-Id: <7in3uu82vpgtmp9rdg743bnfs1u61h0ei5@4ax.com>

RK wrote:

>However, after posting the form from my Perl script, the results of
>$body above are "The object has been moved." and a reference to
>"welcome.asp".

That's what happens when the other side outputs a Location header.

>Any idea how I can then get the contents of "welcome.asp" from
>www.domain.com? If I just try to simply "get()" it from the Perl
>script, I get the logon screen again, so I'm not sure what to do.

I think you must have overlooked a cookie, sent at the same time as the
above.

-- 
	Bart.


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

Date: Mon, 25 Nov 2002 12:30:09 +0000
From: Simon Andrews <simon.andrews@bbsrc.ac.uk>
Subject: Re: Winnt Authentication
Message-Id: <3DE217D1.E2C758D3@bbsrc.ac.uk>

Ravi wrote:
> 
> Hi
> Is there any way I can use winnt (PDC--BDC) authentication instead of
> .htaccess. Since I have more than 200 users who wants to access the
> web server.
> 
> Configuation
> WINNT Server
> Apache 1.3.20

Just a general point here, there is a module included with the
ActiveState Perl distribution which allows you to authenticate against a
PDC, it's called Win32::AuthenticateUser.  We've used it as an
authentication mechanism within scripts and it works fine.  You have to
be careful using this in normal CGI though as unless you're using a
secure server then your usernames / passwords will be passed over the
network in clear text.

I'm not sure how easy it would be to use this module as a part
replacement for .htaccess authentication - might be a question for an
Apache group.

Simon.


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

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


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