[19694] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 1889 Volume: 10

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Mon Oct 8 09:05:30 2001

Date: Mon, 8 Oct 2001 06:05:08 -0700 (PDT)
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)
Message-Id: <1002546308-v10-i1889@ruby.oce.orst.edu>
Content-Type: text

Perl-Users Digest           Mon, 8 Oct 2001     Volume: 10 Number: 1889

Today's topics:
        Any help with this program? <jonathan@unique.com>
    Re: binmode with "perl -p" doesn't work (Mark Jason Dominus)
    Re: Bug in s/\B.//g and s/\b.//g (was: Re: Goedel JAPH) <bart.lateur@skynet.be>
    Re: How to have portable email script? <JPFauvelle@Colt-Telecom.fr>
    Re: How to interpret ?? (Phanidhar)
    Re: How to interpret ?? <josef.moellers@fujitsu-siemens.com>
    Re: How to interpret ?? <andrew@erlenstar.demon.co.uk>
    Re: How to interpret ?? <bart.lateur@skynet.be>
        How to run perl under bash not sh <invalid@nowhere.com>
    Re: How to run perl under bash not sh nobull@mail.com
    Re: Multiplexing strings (Anno Siegel)
    Re: Multiplexing strings <JPFauvelle@Colt-Telecom.fr>
    Re: Multiplexing strings <krahnj@acm.org>
    Re: pattern matching (Rafael Garcia-Suarez)
    Re: pattern matching <usenet@diefenba.ch>
    Re: pattern matching <Graham.T.Wood@oracle.com>
    Re: Perl 5.6.0 chmod bug? (Mark Jason Dominus)
        Q: How to use LWP behind a Microsoft ISA-server firewal <terpstra@smrREMOVE.nl>
    Re: SelfLoader and 'open(FH, "-|")' <mcnuttj@nin.iats.missouri.edu>
    Re: SelfLoader and 'open(FH, "-|")' <andrew@erlenstar.demon.co.uk>
    Re: unix comm perl style (Mark Jason Dominus)
    Re: unix comm perl style (Mark Jason Dominus)
        Useless use of numeric eq in void context (Tobias Wolff)
    Re: Useless use of numeric eq in void context (Anno Siegel)
        Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)

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

Date: Mon, 8 Oct 2001 13:58:08 +0100
From: "Jon Fanti" <jonathan@unique.com>
Subject: Any help with this program?
Message-Id: <Mphw7.968$t97.10746@news.uk.colt.net>

Hi,

Sorry, it would help if the clock on this PC was correct (D'oh!).

I'm still a Perl newbie(ish) and am trying to write a script that runs
through a dir and emails me with a list of any files that look like *.xml,
*.xml.lock (upper and lowercase). As well as print this on screen. The major
problems I have are:

a. I can't work out how to get this to search sub directories.
b. how to email me all found files in one email. At the moment it sends a
separate email for each file found.

Here is my script:

--- BEGIN search.pl ---

#!/usr/bin/perl -w

$mailto = "asdf\@somedomain.com";

opendir(DIRHANDLE,"/data/users/")|| die "Error: can not read current
directory\n";
foreach (grep { /\.xml(\.lock)?$/i } readdir(DIRHANDLE))
{
        print "found $_";
        system( "echo found $_ | sendmail $mailto" );
}
closedir DIRHANDLE;

--- END search.pl ---


Thanks in advance.

Jon.






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

Date: Mon, 08 Oct 2001 07:33:32 GMT
From: mjd@plover.com (Mark Jason Dominus)
Subject: Re: binmode with "perl -p" doesn't work
Message-Id: <3bc156cb.6d84$3bf@news.op.net>

In article <a73bcad1.0110071923.280bb9b@posting.google.com>,
John Lin <johnlin@chttl.com.tw> wrote:
>In addition, I would also propose a "perl -g" switch for "glob
>pre-processing".  For example, in UNIX platforms:
>
>perl -e "print @ARGV" *.pl *.txt *.cpp
>
>The OS will do globbing first then pass the list to perl.
>But some platforms (such as Win32) won't.  On Windows, people have to write
>
>perl -e "BEGIN { @ARGV = map {glob} @ARGV } print @ARGV" *.pl *.txt *.cpp
>
>If we have "-g" option, which is a short hand for
>
>BEGIN { @ARGV = map {glob} @ARGV }
>
>then the orginal script can still apply
>
>perl -ge "print @ARGV" *.pl *.txt *.cpp

It seems to me you could write a module that would do this.  Then you
would say

        perl -MGPP -e "print @ARGV" *.pl *.txt *.cpp

or you could put 'use GPP;' at the top of your program.

GPP.pm would be about two lines long.

-- 
@P=split//,".URRUU\c8R";@d=split//,"\nrekcah xinU / lreP rehtona tsuJ";sub p{
@p{"r$p","u$p"}=(P,P);pipe"r$p","u$p";++$p;($q*=2)+=$f=!fork;map{$P=$P[$f^ord
($p{$_})&6];$p{$_}=/ ^$P/ix?$P:close$_}keys%p}p;p;p;p;p;map{$p{$_}=~/^[P.]/&&
close$_}%p;wait until$?;map{/^r/&&<$_>}%p;$_=$d[$q];sleep rand(2)if/\S/;print


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

Date: Mon, 08 Oct 2001 11:54:41 GMT
From: Bart Lateur <bart.lateur@skynet.be>
Subject: Re: Bug in s/\B.//g and s/\b.//g (was: Re: Goedel JAPH)
Message-Id: <c743st0552t3alra3inc4hc55dbbvdaq30@4ax.com>

Ilya Zakharevich wrote:

>Bart Lateur 
><bart.lateur@skynet.be>], who wrote in article <833vrtcabs7mh9d8v9hqlkhdpn28p8ohg0@4ax.com>:
>> substitution. Hmm... Would /\b/ exhibit the same behaviour?
>> 
>> 	$_ = 'A+B+C+D+E+F';
>> 	s/\b(.)/X/g;
>> 	print;
>> -->
>> 	X+X+X+X+X+X
>
>This may be a *very different* problem.  This guy is optimized (the
>string is modified "in place"), *and* the boundaries change during the
>substitution.

No they don't. Replacing a "A" or a "B" with an "X" does not change the
word boundaries. Just in case, I took care of that in my example.

Plus: my earlier experiences with regexes (i.e. in perls prior to 5.6)
indicate that s///g always works on the *original*, unmodifed string.
Two examples:

	$_ = "A\tB\tC\tD\n";
	s/\t/" " x (8-length($`)%8)/ge;
	print;

If your assesment is right, this should porperly detabify the string. It
doesn't. The further to the right, the shorter the distance between the
letters become.

This one does work properly:

	while(s/\t/" " x (8-length($`)%8)/e) {}

Example two:

	$_ = "ABBC\n";
	s/(?<=B)./X/g;
	print;

This prints (on 5.6.1): 

	ABXX

If your assesment is true, how can that C possibly be replaced? After
all, after replacement of the second "B", the "C" no longer follows a
"B", and according to you, it ought not to be replaced.

My conclusion is: lookbehind works on the original, unmodified string.
That's find by me. But as /\b/ and /\B/ are a form of lookbehind too, so
these should act in the same way.

-- 
	Bart.


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

Date: Mon, 08 Oct 2001 11:38:42 +0200
From: Jean-Philippe Fauvelle <JPFauvelle@Colt-Telecom.fr>
Subject: Re: How to have portable email script?
Message-Id: <n0t2stc67sq8ud7sl1trl0l3d9827mqvjp@4ax.com>

Le Fri, 05 Oct 2001 17:16:48 -0700, BCC <a@b.c> écrit:

Use the libnet set of modules.
The following axample works on both Unix and Windows.

Jean-Philippe Fauvelle


use Net::SMTP;

$SMTP_HOST = 'smtp-out.domain.net'; # the SMTP server of your provider / employer

$smtp = Net::SMTP->new($SMTP_HOST,Timeout=>30) or die 'Server unreachable';
$smtp->mail('sender@domain.com');
$smtp->recipient('recipient@domain.com');
$smtp->data;
$smtp->datasend(<<END_OF_MESSAGE);
From: <visible_sender\@domain.com>
To: <visible_recipient\@domain.com>
Subject: a test

This is
a test
END_OF_MESSAGE

$smtp->dataend;
$smtp->quit;


>Hi,
>
>I need to write a simple cgi script that takes form elements and then
>emails them to one address.
>
>Easy!  In -unix-.  But how to do this in windows?  The client who wants
>this needs to temporarily have the script running on an NT machine, but
>then moved to a unix machine, which is my home environment.  Far as I
>know, windows doesnt have sendmail, and has some nasty windows objects
>that are normally used.
>
>Can someone offer some suggestions or docs or code on how to send email
>in perl on a windows machine?  
>
>Thanks,
>Bryan



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

Date: 8 Oct 2001 01:40:22 -0700
From: dkphani@yahoo.com (Phanidhar)
Subject: Re: How to interpret ??
Message-Id: <605e0b10.0110080040.2677bf2d@posting.google.com>

thanks for ur reply.but still i don't get what '@@' is supposed to do
in that code.can u please throw some light on it.

Benjamin Goldberg <goldbb2@earthlink.net> wrote in message news:<3BBEA6E4.B645213E@earthlink.net>...
> Phanidhar wrote:
> > 
> > Hi All,
> >  i have the following perl code.can someone help me out in
> > interpreting the third and fourth line of the following code.
> > 
> > $dirName = $ARGV[0];
> > $fileName = $ARGV[0];
> > $dirName =~ s@[^\\/]*$@@;
> 
> The expression [^\\/]* matches any number of NON forward- and back-
> slashes.  The expression $ matches the end of the line.
> 
> So, [^\\/]*$ matches all the NON forward- and back- slashes which occur
> just before the end of the line.  As this is used as the patterm in
> EXPR=~s/pattern/replace/, it results in whatever's matches it in
> $dirname getting replaced with the empty string.
> 
> > $fileName =~ s@.*[\\/]@@;
> 
> .* matches as much as it can.  [\\/] matches a single forward- or back-
> slash.  So .*[\\/] matches as much as it can, up to the last slash in
> the string.  It's in a s/expr/replace/, with an empty replace part, so
> it removes everything up to and including the last slash from $fileName.


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

Date: Mon, 08 Oct 2001 11:10:29 +0200
From: Josef =?iso-8859-1?Q?M=F6llers?= <josef.moellers@fujitsu-siemens.com>
Subject: Re: How to interpret ??
Message-Id: <3BC16D85.86E5382B@fujitsu-siemens.com>

Phanidhar wrote:
> =

> thanks for ur reply.but still i don't get what '@@' is supposed to do
> in that code.can u please throw some light on it.

> > > $fileName =3D~ s@.*[\\/]@@;

The "s" command allows you to use (almost) any non-alphanumeric
character as a separator instead of the usual /. This allows you to use
/ in the pattern and replacement strings.
So the above could also be written as

$fileNwme =3D~ s/.*[\\\/]//;

if that would be more readable for you.

Josef
-- =

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


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

Date: 08 Oct 2001 10:14:42 +0100
From: Andrew Gierth <andrew@erlenstar.demon.co.uk>
Subject: Re: How to interpret ??
Message-Id: <87y9mmo5ml.fsf@erlenstar.demon.co.uk>

>>>>> "Phanidhar" == Phanidhar  <dkphani@yahoo.com> writes:

 Phanidhar> thanks for ur reply.but still i don't get what '@@' is
 Phanidhar> supposed to do in that code.can u please throw some light
 Phanidhar> on it.

The s/foo/bar/ construct can use other characters than / as the delimiter;
s@foo@bar@ is just an example of that. This is useful if the pattern you're
matching happens to use / a lot.

It could equally have been written

  s/[^\\\/]*$//;

or

  s:[^\\/]*$::;

or even

  s{[^\\/]*$}{};

(note that for bracket-like characters the format is slightly different,
e.g. s{foo}{bar} rather than s/foo/bar/)

-- 
Andrew.


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

Date: Mon, 08 Oct 2001 10:32:25 GMT
From: Bart Lateur <bart.lateur@skynet.be>
Subject: Re: How to interpret ??
Message-Id: <djv2st4tn1qu6buhjcitef427abdu3gfao@4ax.com>

Phanidhar wrote:

>thanks for ur reply.but still i don't get what '@@' is supposed to do
>in that code.can u please throw some light on it.

You mean in 

	 s@[^\\/]*$@@;

? Ooh, that may look confusing, but it's just alternative delimiters for
s///. Notice that there's a "@" right after the "s", too. So all these
do the same:

	 s/[^\\\/]*$//;
	 s@[^\\/]*$@@;
	 s![^\\/]*$!!;
	 s#[^\\/]*$##;

 ... etc., I'm sure you get the gist by now, and with pairs:

	 s([^\\/]*$)();
	 s<[^\\/]*$><>;
	 s{[^\\/]*$}{};
	 s[[^\\/]*$][];	# nested brackets

Oh, when using pairs, the second pair needn't be the same as the first
one:

	 s<[^\\/]*$>[];

You can find the official docs on this in perlop, under the heading
"Quote and Quote-like Operators".

-- 
	Bart.


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

Date: Mon, 08 Oct 2001 11:02:42 GMT
From: Larry Alkoff <invalid@nowhere.com>
Subject: How to run perl under bash not sh
Message-Id: <i713st0d9r35vabqsbg3cmu233fassggi7@4ax.com>

I have a small perl script that "paginates" output from any program
that would scroll output off the screen.  It's called "so" for "scrolled
output"/.

However, many of my programs are aliased and my perl script complains.
For example dir is aliased and the command "so dir" gives the error message
"sh: dir: command not found.

Apparently perl starts up under sh.  How can I get it to start under bash so
perl can use my aliases?

Thanks for any help,
Larry Alkoff

-- 
Larry Alkoff N2LA
My address is:  larryalk is_at mindspring dot com


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

Date: 08 Oct 2001 13:25:40 +0100
From: nobull@mail.com
Subject: Re: How to run perl under bash not sh
Message-Id: <u9vghqtj23.fsf@wcl-l.bham.ac.uk>

Larry Alkoff <invalid@nowhere.com> writes a lot of stuff, the essense
of which is "How do I define aliases in bash such that they are
available in shells other than an interactive login shell?".  

This, of course, has nothing to do with Perl even if there is a Perl
process in the process tree between the login shell and the
non-interactive subshell.

I suggest using exported shell functions.

For further information I suggest you read the bash documentation or
try a newgroup where bash questions are on-topic.  When you RTFM take
particular note of the distictions between the various initialisation
files and see the sections on aliases and functions.

-- 
     \\   ( )
  .  _\\__[oo
 .__/  \\ /\@
 .  l___\\
  # ll  l\\
 ###LL  LL\\


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

Date: 8 Oct 2001 07:39:56 GMT
From: anno4000@lublin.zrz.tu-berlin.de (Anno Siegel)
Subject: Re: Multiplexing strings
Message-Id: <9prl8c$1r9$1@mamenchi.zrz.TU-Berlin.DE>

According to Bart Lateur  <bart.lateur@skynet.be>:
> Anno Siegel wrote:
> 
> >    $str1 =~ s/(..)/$1\0\0\0\0/g;
> >    $str2 =~ s/(..)/\0\0$1\0\0/g;
> >    $str3 =~ s/(..)/\0\0\0\0$1/g;
> >    $out = $str1 ^ $str2 ^ $str3;
> >
> >No, it isn't fast.
> 
> And why are you using xor instead of or?

I like xor.  Together with and, it makes {true, false} a field.

Anno


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

Date: Mon, 08 Oct 2001 11:27:34 +0200
From: Jean-Philippe Fauvelle <JPFauvelle@Colt-Telecom.fr>
Subject: Re: Multiplexing strings
Message-Id: <72s2stku820t7sa2jmn4q3bhs6i7p2d7db@4ax.com>

Le Fri, 05 Oct 2001 22:56:09 GMT, Dave Tweed <dtweed@acm.org> écrit:

Hi,

Because i start to find this kinf of game interesting, 
i wrote a new one this week-end, entirely based on a REGEXP !
Of course, if you intend to benchmark it, i suggest not to include
the regexp construction into the benchmark...

I suppose this version could be surprisingly fast if the benchmark
was run on the second line only...

Jean-Philippe Fauvelle


@W   = @WORDS           = qw/aabbccddeeff AABBCCDDEEFF 001122334455/;
$W   = $WORDS           = @WORDS;
$TL  = $TOKEN_LENGTH    = 2;
$WL  = $WORD_LENGTH     = length($WORDS[0]);
$TPW = $TOKENS_PER_WORD = $WORD_LENGTH / $TOKEN_LENGTH;

$regexp = sprintf "(.{$TL})(?=%s)", sprintf( ".{%d}(.{$TL})", $WL-$TL ) x ($W-1);
$result = join '', join('',@W) =~ /$regexp/go;

print $result,"\n";



>Jean-Philippe Fauvelle wrote:
>> Can you add my version into your benchmark, please ?
>> I tested it and it works.
>> I'd like to know how fast is the probably most ugly version :-)
>
>~/temp/perl>perl mux.pl
>           Rate oneline   split  swrite  substr  inline
>oneline  7304/s      --    -34%    -73%    -78%    -80%
>split   11072/s     52%      --    -59%    -66%    -70%
>swrite  27163/s    272%    145%      --    -17%    -27%
>substr  32603/s    346%    194%     20%      --    -13%
>inline  37395/s    412%    238%     38%     15%      --
>
>~/temp/perl>perl mux.pl 100
>          Rate oneline   split  substr  swrite  inline
>oneline 77.5/s      --    -33%    -79%    -88%    -88%
>split    116/s     50%      --    -68%    -82%    -83%
>substr   368/s    374%    216%      --    -45%    -45%
>swrite   662/s    755%    470%     80%      --     -1%
>inline   672/s    767%    478%     83%      1%      --
>
>Definitely the slowest of the lot, but it gets a little better
>on long strings.
>
>-- Dave Tweed



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

Date: Mon, 08 Oct 2001 11:27:36 GMT
From: "John W. Krahn" <krahnj@acm.org>
Subject: Re: Multiplexing strings
Message-Id: <3BC18E2E.13D77B3@acm.org>

Jean-Philippe Fauvelle wrote:
> 
> Le Fri, 05 Oct 2001 22:56:09 GMT, Dave Tweed <dtweed@acm.org> écrit:
> 
> Hi,
> 
> Because i start to find this kinf of game interesting,
> i wrote a new one this week-end, entirely based on a REGEXP !
> Of course, if you intend to benchmark it, i suggest not to include
> the regexp construction into the benchmark...
> 
> I suppose this version could be surprisingly fast if the benchmark
> was run on the second line only...
> 
> Jean-Philippe Fauvelle
> 
> @W   = @WORDS           = qw/aabbccddeeff AABBCCDDEEFF 001122334455/;
> $W   = $WORDS           = @WORDS;
> $TL  = $TOKEN_LENGTH    = 2;
> $WL  = $WORD_LENGTH     = length($WORDS[0]);
> $TPW = $TOKENS_PER_WORD = $WORD_LENGTH / $TOKEN_LENGTH;
> 
> $regexp = sprintf "(.{$TL})(?=%s)", sprintf( ".{%d}(.{$TL})", $WL-$TL ) x ($W-1);
> $result = join '', join('',@W) =~ /$regexp/go;
> 
> print $result,"\n";


Or to simplify it a bit:

my @W   = qw/aabbccddeeff AABBCCDDEEFF 001122334455/;
my $TL  = 2;
my $WL  = length $W[0];

my $regexp = "(.{$TL})(?=" . ".{@{[$WL - $TL]}}(.{$TL})" x (@W - 1) .
')';
$" = '';
my $result = qq(@{[ "@W" =~ /$regexp/g ]});

print "$result\n";



John
-- 
use Perl;
program
fulfillment


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

Date: 8 Oct 2001 07:07:03 GMT
From: rgarciasuarez@free.fr (Rafael Garcia-Suarez)
Subject: Re: pattern matching
Message-Id: <slrn9s2k4f.79d.rgarciasuarez@rafael.kazibao.net>

Tony wrote in comp.lang.perl.misc:
} 
} Need a little nudge in the right direction please (NEWBIE). I am
} trying to build a list of groups that a user is a member of, however
} the bright sparks have logins like fred,fred1,fred2 etc so if I use
} 
} if ($memberList =~ /$LoginId/)
} 
} and I'm lookin for fred, and fred is not a member of group test, but
} fred1 is then I end up with fred listed as being in test group.

You didn't explain what $memberList is. If it's as simple as a
comma-separated list, you can use split() (described in the perlfunc
doc) to get an array of members.

Alternatively you can use \b in your regexp. This matches a word
boundary (see the perlre section of the docs) :

    if ($memberList =~ /\b$LoginId\b/) {...}

Also, it's a good habit to protect the regexp against funny characters
(e.g. if $LoginId contains a '*') :

    if ($memberList =~ /\b\Q$LoginId\E\b/) {...}

-- 
Rafael Garcia-Suarez / http://rgarciasuarez.free.fr/


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

Date: 08 Oct 2001 10:57:59 +0200
From: Kai Diefenbach <usenet@diefenba.ch>
Subject: Re: pattern matching
Message-Id: <bwitdqtso8.fsf@diefenba.ch>


Hi, 

>>>>> "Tony" == Tony  <tadermann@hotmail.com> writes:

 Tony> if ($memberList =~ /$LoginId/)
 
 Tony> and I'm lookin for fred, and fred is not a member of group test, but
 Tony> fred1 is then I end up with fred listed as being in test group.
	
	/^$LoginId$/  resp.  /\b$LoginId\b/
	 ^        ^           ^^        ^^				
 Tony> Any suggestions would be appreciated, and yes I have read FAQ's and
 Tony> look through the list but need a little prompting in the right
 Tony> direction.

	perldoc perlre /zero-width assertions
	perldoc perlre /metacharacters

Regards Kai


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

Date: Mon, 08 Oct 2001 13:43:14 +0100
From: Graham Wood <Graham.T.Wood@oracle.com>
Subject: Re: pattern matching
Message-Id: <3BC19F62.96787EF4@oracle.com>

This is a multi-part message in MIME format.
--------------C34F1885669C94C46FB63346
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 7bit

Tony wrote:

> if ($memberList =~ /$LoginId/)
>
> and I'm lookin for fred, and fred is not a member of group test, but
> fred1 is then I end up with fred listed as being in test group.

Try splitting the member list into individual names then either using eq
to compare the name (case sensitively) or /^$LoginId$/i (case
insensitively) to match the entire string.  You won't match "fred" for
"fred1" that way.

Graham Wood

--------------C34F1885669C94C46FB63346
Content-Type: text/x-vcard; charset=UTF-8;
 name="Graham.T.Wood.vcf"
Content-Transfer-Encoding: 7bit
Content-Description: Card for Graham Wood
Content-Disposition: attachment;
 filename="Graham.T.Wood.vcf"

begin:vcard 
n:Wood;Graham
x-mozilla-html:FALSE
org:;Worldwide Product Translation Group
adr:;;;;;;
version:2.1
email;internet:Graham.T.Wood@oracle.com
title:Senior QA Engineer
fn:Graham Wood
end:vcard

--------------C34F1885669C94C46FB63346--



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

Date: Mon, 08 Oct 2001 07:12:34 GMT
From: mjd@plover.com (Mark Jason Dominus)
Subject: Re: Perl 5.6.0 chmod bug?
Message-Id: <3bc151e1.6cff$171@news.op.net>

In article <3bc1d249.388248@news.m.iinet.net.au>,
Doug <linderd@ses.curtin.edu.au> wrote:
>No no. My thanks. That greatly clarified things for me.

Glad to be of service.
-- 
@P=split//,".URRUU\c8R";@d=split//,"\nrekcah xinU / lreP rehtona tsuJ";sub p{
@p{"r$p","u$p"}=(P,P);pipe"r$p","u$p";++$p;($q*=2)+=$f=!fork;map{$P=$P[$f^ord
($p{$_})&6];$p{$_}=/ ^$P/ix?$P:close$_}keys%p}p;p;p;p;p;map{$p{$_}=~/^[P.]/&&
close$_}%p;wait until$?;map{/^r/&&<$_>}%p;$_=$d[$q];sleep rand(2)if/\S/;print


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

Date: Mon, 08 Oct 2001 13:00:57 GMT
From: "Peter Terpstra" <terpstra@smrREMOVE.nl>
Subject: Q: How to use LWP behind a Microsoft ISA-server firewall
Message-Id: <dshw7.2881$pN3.36820@amsnews03.chello.com>
Keywords: perl isa-server lwp firewall


Hi,
I'm trying to use the LWP modules to download urls from my perl programs.
Our company uses the Microsoft ISA server as a firewall.
This firewall denies our http:get requests. (we also do not succeed in
downloading with the TelePort-Pro sitemapper tool)
Does someone know how to configure the ISA server to permit this?

Peter






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

Date: 7 Oct 2001 14:27:12 GMT
From: <mcnuttj@nin.iats.missouri.edu>
Subject: Re: SelfLoader and 'open(FH, "-|")'
Message-Id: <9ppoo0$d9f$1@dipsy.missouri.edu>

Was just wondering if anyone had thought about this any and come up with
any ideas...

For now, I'm probably going to have to remove all of the SelfLoader
references and interpret everything at runtime.  :-(

--J

mcnuttj@nin.iats.missouri.edu wrote:
> A guess:  The SelfLoader module has a hash named (surprise) %Cache, in
> which it appears to store the previously-SelfLoad-ed modules.  Is it
> possible that this cache is the source of the problem?

> If that's the case it would be awfully strange.  Consider:

> In the case of the macfind() function, the first process to call that
> subroutine is the first child fork()-ed.  That child runs successfully.
> However, the next child fork()-ed does not run successfully.  In theory,
> each child is a copy of the parent.  Fortunately, the first child has
> already shut down before the second child is spawned, so there shouldn't
> be any weird cross-communication there.

> So what is the first child doing to the parent or the Perl interpreter that
> is causing the next child to fail?  If this were C, it would smell like
> stale pointers to me.

> Suggestions on where to look next?  This is the kind of problem that I'm not
> exactly sure how to diagnose.  I more or less know what's going on, but I
> haven't been doing this quite long enough to know how to debug it when it
> gets whacked.

> --J

> mcnuttj@nin.iats.missouri.edu wrote: > More information:

>> 1)  I am running perl version 5.6.1 on Linux (Slackware 8.0).

>> 2)  I found the following in 'man perldelta':

>>> Spurious subroutine stubs after failed subroutine calls

>>> Perl could sometimes create empty subroutine stubs when a subroutine was 
>>> not found in the package. Such cases stopped later method lookups from 
>>> progressing into base packages. This has been corrected.

>> Could it be that this problem was not truly solved in all cases?

>> 3)  This problem - AFAIK - does not occer with all SelfLoad-ed modules.  
>> It does happen with other modules besides 'jscanmacfind.pm', but not every 
>> module referenced from the top-level module.

>> Anyway, if someone knows the answer to this, great!  If not, what's the 
>> best place to look next?  I'm completely confused by the particular syntax 
>> error that I'm getting.

>> --J

>> mcnuttj@nin.iats.missouri.edu wrote:
>>> Hey all,

>>> I have a weird problem.  I maintain an application that I wrote that uses 
>>> the Net-SNMP SNMP.pm module (version 4.1.2).  The app has a lot of 
>>> different functions, so I make heavy use of 'use SelfLoader' to keep the 
>>> runtime short.

>>> Example:

>>> jscan bs450custom 10.1.1.0/22 sysDescr

>>> That will query all Nortel BayStack 450 switches in the subnet specified 
>>> for 'sysDescr'.

>>> One of the more commonly-used functions of the script is 'ipfind'.  This 
>>> function, given an IP address, will search through the switches in our 
>>> network and return the IP address and port number of the switch where the 
>>> given IP host is found.

>>> Example:

>>> jscan ipfind 10.1.5.3

>>> Our security people make great use of this.  Since they do, they recently 
>>> asked me if I could make the script accept multiple IP targets at once.  
>>> The command-line parsing part was pretty simple (comma-separated), but due 
>>> to the internals of the top-level package, it became simplest to do 
>>> something like this:

>>> while ( $#{$args{iplist}} ) {
>>> 	open (README, "-|");
>>> 	if ( $pid ) {
>>> 		while ( <README> ) {
>>> 			print $_;
>>> 		}
>>> 		close(README) || warn "child exited $?";
>>> 		shift @{$args{iplist}};
>>> 	} else {
>>> 		last;
>>> 	}
>>> }

>>> The parent itself then processes the last item in the list.

>>> Now here's the problem.  I have a bunch of different functions that are 
>>> called from the top-level package.  Each function is in it's own module, 
>>> since I use these same functions in other apps.  So above the while loop 
>>> somewhere will be, say:

>>> use jscanmacfind;

>>> ...and then later on will be:

>>> macfind(args, moreargs, otherargs);

>>> The jscanmacfind package has "use SelfLoader;" at the top.  The macfind() 
>>> forward declaration is the only thing between the BEGIN and END blocks, so 
>>> the package winds up looking like this:

>>> package jscanmacfind;

>>> use (some packages);
>>> use SelfLoader;

>>> BEGIN { .... }

>>> sub macfind($$$);

>>> END { }

>>> 1;

>>> __DATA__

>>> sub macfind($$$) {
>>> 	...code...
>>> }


>>> Now when I run my script with multiple IP addresses (thus children are 
>>> created), the first child executes successfully, but each subsequent 
>>> child, and the parent (the last iteration) all fail like this:

>>> Missing right curly or square bracketsyntax error at (eval 26) line 113, 
>>> at EOF
>>>  at /usr/local/bin/jscan line 390
>>> child exited 65280 at /usr/local/bin/jscan line 153.

>>> Line 390 of /usr/local/bin/jscan is where macfind() is called.  Line 153 
>>> is the "close(README) || warn..." line in the parent.

>>> Here's the kicker:  If I move the END block, the 1; statement, and the 
>>> __DATA__ token to the bottom of the module, the script executes 
>>> successfully, even if 'use SelfLoader;' is still invoked.

>>> I have 'use strict;' in every module, including the top-level package.

>>> I'd really rather not remove all of the SelfLoader stuff from my modules, 
>>> since they do speed things up quite a bit for this and other scripts, and 
>>> using the named pipe saves me from having to rewrite a bunch of other code 
>>> in the top-level package just to get a foreach loop.

>>> So what does the SelfLoader do that breaks subsequent calls to a 
>>> self-loaded function by child processes?

>>> --J


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

Date: 08 Oct 2001 09:31:24 +0100
From: Andrew Gierth <andrew@erlenstar.demon.co.uk>
Subject: Re: SelfLoader and 'open(FH, "-|")'
Message-Id: <87vghqpm77.fsf@erlenstar.demon.co.uk>

[bogus group comp.lang.perl removed]

>>>>> "mcnuttj" ==   <mcnuttj@nin.iats.missouri.edu> writes:

 mcnuttj> Was just wondering if anyone had thought about this any and
 mcnuttj> come up with any ideas...

(didn't see this before, I only read the perl groups intermittently)

I think your problem is that the child processes are messing up each
other's reading of the DATA filehandle. Without looking at how DATA is
implemented internally I can't be certain, but my guess is that it
actually leaves the original source FH open at that point. All the
child processes will end up sharing that FH, which means that only one
of them will be able to read it successfully.

The fix is actually very simple; force the data to be read immediately
(but not compiled, it's the compilation that takes the time) rather
than waiting for the first function call:

package jscanmacfind;

use (some packages);
use SelfLoader;

BEGIN { .... }

SelfLoader->load_stubs();

END { }

1;

__DATA__

sub macfind($$$) {
	...code...
}

By calling load_stubs, you make SelfLoader read from DATA and locate
the subroutines in it (and declare them for you, saving you the bother
of doing it for yourself).

-- 
Andrew.


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

Date: Mon, 08 Oct 2001 07:14:59 GMT
From: mjd@plover.com (Mark Jason Dominus)
Subject: Re: unix comm perl style
Message-Id: <3bc15273.6d11$3ae@news.op.net>
Keywords: Montclair, Teutonic, float, gantlet


In article <ts251tr5d685f7@corp.supernews.com>,
 <blah@blah.blah.invalid> wrote:
>vbrammer <vbrammer@home.com> wrote:
>> hi,
>> 
>> Im trying to do with perl what the unix comm command can do.
>[ cut ]
>
>You might check out mjd's effort for the defunct(?) perl power tools
>project:
>  http://language.perl.com/ppt/src/comm/comm.mjd

Or you could check out the code I posted here on Friday 
in the thread 'Finding the difference between arrays...'

<3bbdd875.558$28a@news.op.net>

Sometimes it's funny how these things clump.
-- 
@P=split//,".URRUU\c8R";@d=split//,"\nrekcah xinU / lreP rehtona tsuJ";sub p{
@p{"r$p","u$p"}=(P,P);pipe"r$p","u$p";++$p;($q*=2)+=$f=!fork;map{$P=$P[$f^ord
($p{$_})&6];$p{$_}=/ ^$P/ix?$P:close$_}keys%p}p;p;p;p;p;map{$p{$_}=~/^[P.]/&&
close$_}%p;wait until$?;map{/^r/&&<$_>}%p;$_=$d[$q];sleep rand(2)if/\S/;print


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

Date: Mon, 08 Oct 2001 07:29:44 GMT
From: mjd@plover.com (Mark Jason Dominus)
Subject: Re: unix comm perl style
Message-Id: <3bc155e8.6d70$c@news.op.net>

In article <Aa3w7.129607$Xz1.15829310@news1.rdc1.md.home.com>,
vbrammer <vbrammer@home.com> wrote:
>Im trying to do with perl what the unix comm command can do.

Code follows.

>this is what i have, and it works :

No way, man.  Try @log = (1,2,3) and @post=(2,3).  It should produce
@diff=(1), but it produces (1,2,3) instead.

>can this be written simpler? or quicker? 

Quicker, I couldn't say.  It's really easy to write fast code that
doesn't work.

Simpler, definitely.  For example, I found this deeply confusing:

        shift @post if ($true eq 1) || push @diff , $_;

I might have written this:

        push @diff, $_ unless $true;
        shift @post;

which does exactly the same thing.  Although I don't know why you
think you're doing it, it would be a simpler way toi do the same
thing, whatever it is.

If you want it to work, you might try something like this:

        while (@log && @post) {
          if    ($log[0] lt $post[0]) { push @diff, shift @log }
          elsif ($log[0] gt $post[0]) { push @diff, shift @post }
          else                        { push @same, shift @post; shift @log }
        }
        push @diff, @log, @post;

If you want to be more like the real 'comm', use:

        while (@a && @b) {
          if    ($a[0] lt $b[0]) { push @a_not_b, shift @a }
          elsif ($a[0] gt $b[0]) { push @b_not_a, shift @b }
          else                   { push @a_and_b, shift @a; shift @b }
        }
        push @a_not_b, @a;
        push @b_not_a, @b;

Now you have three arrays, @a_not_b, @b_not_a, and @a_and_b, which
correspond to columns 1, 2, and 3 of comm's output.

-- 
@P=split//,".URRUU\c8R";@d=split//,"\nrekcah xinU / lreP rehtona tsuJ";sub p{
@p{"r$p","u$p"}=(P,P);pipe"r$p","u$p";++$p;($q*=2)+=$f=!fork;map{$P=$P[$f^ord
($p{$_})&6];$p{$_}=/ ^$P/ix?$P:close$_}keys%p}p;p;p;p;p;map{$p{$_}=~/^[P.]/&&
close$_}%p;wait until$?;map{/^r/&&<$_>}%p;$_=$d[$q];sleep rand(2)if/\S/;print


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

Date: 8 Oct 2001 03:40:40 -0700
From: wolff@falkag.de (Tobias Wolff)
Subject: Useless use of numeric eq in void context
Message-Id: <46872b23.0110080240.749241de@posting.google.com>

Hi,
I can't relate the following error message to my code:

    Useless use of numeric eq in void context at ./interface.pl line
3124

Lines 3123-3124 read:

    $intResult = &myFunction();
    if($intResult >= 0)
    {
    }

The function "myFunction" has two return statements. The first

    return ERROR_DATABASE;

where ERROR_DATABASE is defined as a constant using the code:

    use constant ERROR_DATABASE      => -1;

The second statement (which is the one I am bothering about) reads:

    return $hshRefRow->{"Position"};

where $hshRefRow is a resulting line of a mysql database query. At
first glance, I thought that $hshRefRow->{"Position"} returned a
string. So I changed the line in

    return $hshRefRow->{"Position"} + 0;

to definitely return an integer. But this didn't work. Can anyone
enligthen me why this warning occurs? I am running Perl 5.00503 on a
Linux Redhat with "-w" option.

Thanks,
Tobias.


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

Date: 8 Oct 2001 11:27:37 GMT
From: anno4000@lublin.zrz.tu-berlin.de (Anno Siegel)
Subject: Re: Useless use of numeric eq in void context
Message-Id: <9ps2j9$h4q$1@mamenchi.zrz.TU-Berlin.DE>

According to Tobias Wolff <wolff@falkag.de>:
> Hi,
> I can't relate the following error message to my code:
> 
>     Useless use of numeric eq in void context at ./interface.pl line
> 3124
> 
> Lines 3123-3124 read:
> 
>     $intResult = &myFunction();
>     if($intResult >= 0)
>     {
>     }

It is very likely that the actual error is within the if-block,
which you don't show.

Anno


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

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


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