[23969] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 6170 Volume: 10

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Fri Feb 20 18:05:41 2004

Date: Fri, 20 Feb 2004 15:05:07 -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           Fri, 20 Feb 2004     Volume: 10 Number: 6170

Today's topics:
    Re: commandline version of this script. (NNTP)
    Re: Compatibility of perl on different HPUX-Versions (Anno Siegel)
    Re: Example of web application done right? thumb_42@yahoo.com
        help on hash of hashes (Stephen Moon)
    Re: help on hash of hashes <ittyspam@yahoo.com>
    Re: help on hash of hashes (Anno Siegel)
    Re: I wish buy Perl book <toylet@mail.hongkong.com>
    Re: I wish buy Perl book <uri@stemsystems.com>
    Re: I wish buy Perl book <jwillmore@remove.adelphia.net>
        Installation Problem with XML::Parser perl module (HarishN)
    Re: IO::Socket::INET: Address already in use <jwillmore@remove.adelphia.net>
    Re: moving a file to a different name (Gary E. Ansok)
    Re: Multiple substitution in a complex RE (SqlSlinger)
    Re: Multiple substitution in a complex RE <tadmc@augustmail.com>
    Re: Newbe Unicode question (Scottie)
    Re: Newbie question on use <glex_nospam@qwest.invalid>
    Re: Newbie question on use <noreply@gunnar.cc>
    Re: Newbie question on use <beable+unsenet@beable.com.invalid>
    Re: Newbie question on use (Anno Siegel)
    Re: Newbie question on use <jwkenne@attglobal.net>
    Re: Newbie question on use <jimicarlo@ntlworld.com>
    Re: perl controlling samba permissions? (Anthony Boyd)
    Re: Protecting Source code of a perl script <jimicarlo@ntlworld.com>
    Re: Protecting Source code of a perl script <bobx@linuxmail.org>
    Re: Really unbuffered reads... (Anno Siegel)
    Re: Really unbuffered reads... <uri@stemsystems.com>
    Re: regex newbie <jgibson@mail.arc.nasa.gov>
    Re: Replacing a text in multiple files with regular exp <dwall@fastmail.fm>
    Re: Search and replace problem <as@hotmail.com>
        Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)

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

Date: 20 Feb 2004 09:17:30 -0800
From: news8080@yahoo.com (NNTP)
Subject: Re: commandline version of this script.
Message-Id: <110fc16.0402200917.6f042bd5@posting.google.com>

That worked great. my bad.

Thanks

Ben Morrow <usenet@morrow.me.uk> wrote in message news:<c13b7r$aiv$1@wisteria.csv.warwick.ac.uk>...
> [don't top-post]
> [wrap your posts at 72 chars or so]
> 
> news8080@yahoo.com (NNTP) wrote:
> > Ben Morrow <usenet@morrow.me.uk> wrote in message
> > news:<c10dev$a0u$9@wisteria.csv.warwick.ac.uk>...
> > > news8080@yahoo.com (NNTP) wrote:
> > > >
> > > > #!/usr/bin/perl
> > > > use Validate::Net;
> > > > if ( Validate::Net->ip($ARGV[0]))
> > > > {
> > > > print "valid";
> > > > exit 0;
> > > > }
> > > > print "invalid";
> > > > #--done
> > > > 
> > > > is it even doable?
> > > 
> > > err... (untested)
> > > 
> > > perl -MValidate::Net -le'print !Validate::Net->ip(shift) && "in", "valid"'
> >  
> > perl -MValidate::Net -le'print \!Validate::Net->ip(shift) && "in",
> > "valid"'
> > doesn't work
> > 
> > sh-2.05a# perl -MValidate::Net -le'print \!Validate::Net->ip(1.1.1.1)
> > && "in", "valid"'
> > invalid
> > sh-2.05a# perl -MValidate::Net -le'print \!Validate::Net->ip(1.1.11.)
> > && "in", "valid"'
> > syntax error at -e line 1, near ".) "
> > Execution of -e aborted due to compilation errors.
> > sh-2.05a# perl -MValidate::Net -le'print
> > \!Validate::Net->ip(1.1.1.1asdfdasf) && "in", "valid"'
> > Bareword found where operator expected at -e line 1, near
> > "1.1.1.1asdfdasf"
> >         (Missing operator before asdfdasf?)
> > syntax error at -e line 1, near "1.1.1.1asdfdasf"
> > Execution of -e aborted due to compilation errors.
> 
> Try using it right:
> 
> ~% perl -MValidate::Net -le'print !Validate::Net->ip("1.1.1.1") 
>     && "in", "valid"'
> valid
> ~% perl -MValidate::Net -le'print !Validate::Net->ip("1.1.1.1adad") 
>     && "in", "valid"'
> invalid
> ~% perl -MValidate::Net -le'print !Validate::Net->ip("1.1.11.") 
>     && "in", "valid"'
> invalid
> 
> or, better,
> 
> #!/bin/sh
> 
> VALID_IP=$(<<CMD
> perl -MValidate::Net -le'print !Validate::Net->ip(shift) && "in", "valid"'
> CMD
> )
> 
> eval $VALID_IP 1.1.1.1
> eval $VALID_IP 1.1.11.
> eval $VALID_IP 1.1.1.1adsf
> 
> Ben


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

Date: 20 Feb 2004 19:25:08 GMT
From: anno4000@lublin.zrz.tu-berlin.de (Anno Siegel)
Subject: Re: Compatibility of perl on different HPUX-Versions
Message-Id: <c15muk$l05$3@mamenchi.zrz.TU-Berlin.DE>

Alex F. <v2af@yahoo.de> wrote in comp.lang.perl.misc:
> Hi folks,
> 
> is it possible to call perl running on HPUX11.xy from a
> HPUX10.xy-machine - don´t care which perl-version and which modules,
> just the perl-exe itself...

That would be better asked in a HPUX group.  The perl binary isn't special,
I'd expect it to behave like other binaries.

Anno


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

Date: Fri, 20 Feb 2004 16:33:48 GMT
From: thumb_42@yahoo.com
Subject: Re: Example of web application done right?
Message-Id: <MFqZb.352401$I06.3752467@attbi_s01>

Steven N. Hirsch <shirsch@adelphia.net> wrote:
 
> There have been other comments on the net alluding to memory leaks with 
> certain versions of DBD::DB2.  Did you report it to DB2 support?  IIRC, 
> the DBI driver is a supported application.

Yea, I noticed. :-)

Actually, I was kind of thankful for the bug, because stripping out DBI from
the web front turned out to be one of the best moves. Whether you use
mod_perl OR php for web interface, I'd recommend avoiding any database
connection from the web interface. (Only reason I tried it was that it
seemed convenient for simple reports and the like)

When I left, it looked something that looks like this: 
(standard n-tier I guess)

Apache[] <------> Backend[] <------> Database
|                   |
+-------------------+--> Directory[] services, SMTP[], etc..

The []'s mean "more than 1 of", with DNS giving revolving IP's to Apache.
 
(with Database[] if you can manage it, we couldn't justify it, $$$)

Isolating any database access to the backends means we could replace them
with backends that only support queries and queued inserts if for some
reason we had to take down the database. (To swap to another vendor for
example)

Storing core business logic in a backend is easier to change because the
backends are completely transparent to the users. With dynamic, directory
based configuration we were able to easily take them in and out of the loop.
(Directory could have been an rsync'd conf file, in our case it just
happened to be LDAP, we needed authentication anyway.)

The backends spoke to the front ends using custom XML, (the "schema" was
specifically designed to parse fast, avoiding cdata and using attributes
make parsing XML trivial and FAST with XML::Parser, using xml meant we could
easily add functionality to a backend w/out disrupting existing
functionality and we could 'boxcar' several business-logic functions
together)

Obviously these services reside on physically different machines.

Had I left the DBI code in the web interface, this would not have been
practical, maintenance would have been harder. In a way I was glad for
that bug. :-) 

Jamie


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

Date: 20 Feb 2004 09:00:38 -0800
From: vibfft@yahoo.com (Stephen Moon)
Subject: help on hash of hashes
Message-Id: <9feadd98.0402200900.2ebbb9a7@posting.google.com>

Hi,

Can you help me with the below error?  Thanks in advance.

-Steve



input file:
====================================================
flintstones: lead=fred pal=barney 
jetsons: lead=george wife=jane boy=elroy
simpsons: lead=homer wife=marge kid=bart

perl source code:
====================================================

#!/usr/bin/perl -w

use strict;

my %HoH; #hash table for the data structure
my $rfwho;
if($#ARGV != 1) {
	die("Invalid number of arguments\nUsage: perl test.pl <input_file>
<output_file>\n");
}

my $infile = $ARGV[0];
my $outfile = $ARGV[1];

open(DATA_IN,"$infile") || die("could not open $infile\n");
open(DATA_OUT,">$outfile") || die("could not open $outfile\n");

while ( my $line = <DATA_IN> ) {
    chomp($line);
    if($line =~ /^(.*?):\s*/){
    	my $who = $1;
	$rfwho = \$who;
    	my $rfrec = {};
    	$HoH{$who} = $rfrec;
    	for my $field ( split /\s+/, $line) {
        	my ($key, $value) = split /=/,$field;
        	$rfrec->{$key} = $value;
    	}
    }
}

foreach my $family ( keys %HoH ) {
    print "$family: ";
    foreach my $role ( keys %{ $HoH{$family} } ) {
         printf(DATA_OUT "$role=$HoH{$family}{$role}"); <= error here
    }
    printf(DATA_OUT "\n");
}

output error:
====================================================

Use of uninitialized value in concatenation (.) or string at test.pl
line 34, <DATA_IN> line 3.
Use of uninitialized value in concatenation (.) or string at test.pl
line 34, <DATA_IN> line 3.
Use of uninitialized value in concatenation (.) or string at test.pl
line 34, <DATA_IN> line 3.


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

Date: Fri, 20 Feb 2004 12:14:27 -0500
From: Paul Lalli <ittyspam@yahoo.com>
Subject: Re: help on hash of hashes
Message-Id: <20040220121201.I5358@dishwasher.cs.rpi.edu>

On Fri, 20 Feb 2004, Stephen Moon wrote:

> Hi,
>
> Can you help me with the below error?  Thanks in advance.
>
> -Steve
>
>
>
> input file:
> ====================================================
> flintstones: lead=fred pal=barney
> jetsons: lead=george wife=jane boy=elroy
> simpsons: lead=homer wife=marge kid=bart
>
> perl source code:
> ====================================================
>
> #!/usr/bin/perl -w
>
> use strict;
>
> my %HoH; #hash table for the data structure
> my $rfwho;
> if($#ARGV != 1) {
> 	die("Invalid number of arguments\nUsage: perl test.pl <input_file>
> <output_file>\n");
> }
>
> my $infile = $ARGV[0];
> my $outfile = $ARGV[1];
>
> open(DATA_IN,"$infile") || die("could not open $infile\n");
> open(DATA_OUT,">$outfile") || die("could not open $outfile\n");
>
> while ( my $line = <DATA_IN> ) {
>     chomp($line);
>     if($line =~ /^(.*?):\s*/){
>     	my $who = $1;
> 	$rfwho = \$who;
>     	my $rfrec = {};
>     	$HoH{$who} = $rfrec;
>     	for my $field ( split /\s+/, $line) {
	                             ^^^^^^

$line still contains the entire line, including (for example)
"flintsones:".  THerefore, "flinstones:" becomes one of  your fields

>         	my ($key, $value) = split /=/,$field;

There is no = found in "flinstones:", so $key gets that whole string, and
$value is left as undef.



>         	$rfrec->{$key} = $value;

You've just assigned a new position in the hash to be undef.

>     	}
>     }
> }
>
> foreach my $family ( keys %HoH ) {
>     print "$family: ";
>     foreach my $role ( keys %{ $HoH{$family} } ) {
>          printf(DATA_OUT "$role=$HoH{$family}{$role}"); <= error here


Now you try to print out that undef value, and Perl correctly warns you.


Hope this helps,
Paul Lalli


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

Date: 20 Feb 2004 18:57:37 GMT
From: anno4000@lublin.zrz.tu-berlin.de (Anno Siegel)
Subject: Re: help on hash of hashes
Message-Id: <c15lb1$l05$1@mamenchi.zrz.TU-Berlin.DE>

Stephen Moon <vibfft@yahoo.com> wrote in comp.lang.perl.misc:
> Hi,
> 
> Can you help me with the below error?  Thanks in advance.

[lots of code snipped]

Do not dump your problem as is to the newsgroup, make an attempt to
solve it yourself first.

The code I snipped contained things like checking the number of parameters
in @ARGV.  Why should hundreds of people have to read that code,
understand what it does, and ignore it?  It's your job to do that.

> foreach my $family ( keys %HoH ) {
>     print "$family: ";
>     foreach my $role ( keys %{ $HoH{$family} } ) {
>          printf(DATA_OUT "$role=$HoH{$family}{$role}"); <= error here

Don't say "printf" when you mean "print".  There's a difference, and
some day it will bite you.  Also, I suppose you want to print a line
feed inside the loop too.

>     }
>     printf(DATA_OUT "\n");
> }
> 
> output error:
> ====================================================
> 
> Use of uninitialized value in concatenation (.) or string at test.pl
> line 34, <DATA_IN> line 3.

That's not an error but a warning, so the program should have printed
something to the output file.  It would be interesting to know what
it was, but you didn't supply it.

In any case, you have not exhausted your own means by a long shot.

The warning tells you there's an undefined value in a string, so
at least one of "$role" or "$hoh{$family}{$role}" is undefined.

To find out which, change the code to tell you:

foreach my $family ( keys %HoH ) {
    print "$family: ";
    foreach my $role ( keys %{ $HoH{$family} } ) {
         die '$role' unless defined $role;
         die '$HoH{$family}{$role}' unless defined $HoH{$family}{$role};
         print "$role=$HoH{$family}{$role}";
    }
    print "\n";
}

I bet you'll find that "$role" is defined but "$HoH{$family}{$role}" isn't.

Ask yourself why you think it should have a value.  Then go back through 
your code and verify that it does what you think it does.

In other words, learn to debug a program.  It's a skill as necessary as
writing it in the first place.

Anno


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

Date: Sat, 21 Feb 2004 00:29:29 +0800
From: toylet <toylet@mail.hongkong.com>
Subject: Re: I wish buy Perl book
Message-Id: <403635e1_3@rain.i-cable.com>

read them online. :)

http://iis1.cps.unizar.es/Oreilly/perl/

PHP2 wrote:

>> I wish buy Perl book tomorrow by Amazon.. I am new in Perl development..


-- 
   .~.    Might, Courage, Vision. In Linux We Trust.
  / v \   http://www.linux-sxs.org
/( _ )\  Linux 2.4.22-xfs
   ^ ^    12:28am up 48 min 1 user 0.01 0.03


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

Date: Fri, 20 Feb 2004 17:59:03 GMT
From: Uri Guttman <uri@stemsystems.com>
Subject: Re: I wish buy Perl book
Message-Id: <x7wu6hiqe0.fsf@mail.sysarch.com>

>>>>> "t" == toylet  <toylet@mail.hongkong.com> writes:

  t> read them online. :)
  t> http://iis1.cps.unizar.es/Oreilly/perl/

you are supporting and promoting thieves.

i am sure this will get you killfiled by many here. you won't get help
from me anymore.

uri

-- 
Uri Guttman  ------  uri@stemsystems.com  -------- http://www.stemsystems.com
--Perl Consulting, Stem Development, Systems Architecture, Design and Coding-
Search or Offer Perl Jobs  ----------------------------  http://jobs.perl.org


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

Date: Fri, 20 Feb 2004 13:11:19 -0500
From: James Willmore <jwillmore@remove.adelphia.net>
Subject: Re: I wish buy Perl book
Message-Id: <pan.2004.02.20.18.11.18.656322@remove.adelphia.net>

On Sat, 21 Feb 2004 00:29:29 +0800, toylet wrote:

> read them online. :)
> 
> http://iis1.cps.unizar.es/Oreilly/perl/

I wouldn't - this is probably an *illegal* copy of the CD Bookshelf.

I'm thinking O'Reilly will thank you for posting this web address on the
'Net.  Too bad the best you'll get out of this is good karma :-)

-- 
Jim

Copyright notice: all code written by the author in this post is
 released under the GPL. http://www.gnu.org/licenses/gpl.txt 
for more information.

a fortune quote ...
What the world *really* needs is a good Automatic Bicycle
<Sharpener. 



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

Date: 20 Feb 2004 14:31:30 -0800
From: harish_ng@yahoo.com (HarishN)
Subject: Installation Problem with XML::Parser perl module
Message-Id: <15c5a3c6.0402201431.4555468d@posting.google.com>

I just installed the XML::Parser and when I tried to run a test I see
this following error.
Parser.pm and Expat.pm versions don't match at
/my/local/harishn/perl-modules/lib/5.6.1/sun4-solaris/XML/Parser.pm
line 16.
 
I looked at the source code in these 2 modules.
 
package XML::Parser;
 
use Carp;
 
BEGIN {
  require XML::Parser::Expat;
  $VERSION = '2.34';
  die "Parser.pm and Expat.pm versions don't match"
    unless $VERSION eq $XML::Parser::Expat::VERSION;
}
 
package XML::Parser::Expat;
 
require 5.004;
 
use strict;
use vars qw($VERSION @ISA %Handler_Setters %Encoding_Table
@Encoding_Path
            $have_File_Spec);
use Carp;
 
require DynaLoader;
 
@ISA = qw(DynaLoader);
$VERSION = "2.34" ;

 
I see both versions match but I still get the error. Can you anyone
help in resolving this ?
 
 
Thank you very much,
Harish


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

Date: Fri, 20 Feb 2004 11:12:53 -0500
From: James Willmore <jwillmore@remove.adelphia.net>
Subject: Re: IO::Socket::INET: Address already in use
Message-Id: <pan.2004.02.20.16.12.51.501193@remove.adelphia.net>

On Fri, 20 Feb 2004 16:42:03 +0100, chatiman wrote: [Don't top post - it's
rude]
[re-ordered to proper format]

> "hagen" <h.muench@substring.ch> a écrit dans le message de news:
> 1ff2226.0402200735.1f26e6e4@posting.google.com...
>> I try to write a dhcp-client to get user defined dhcp option.I'm
>> stranding already with this reduced script:
>>
>> #!/usr/bin/perl
>>
>> use IO::Socket::INET;
>>
>> $sock = IO::Socket::INET->new(ReuseAddr => '1',
>>                               LocalPort => '68',
>>                               Proto     => 'udp') or die "can't bind:
>> $@\n";
>>
>>

Are you using BOOTP on the client?  If so, disable it or use another
port - because port 68 may be in use on your box :-)

>> this dies with: "IO::Socket::INET: Address already in use"
> If i remember when you close a socket, it stays open for a certain
> amount of time (a few minutes or seconds).
> So you have to wait a bit before you open the socket for a second time.

This isn't a true statement.  First, the OP is using UDP.  The statement
you made *may* be true if the OP was trying to use TCP instead.  UDP is
connectionless - so, once the packets leaves the client, it's done.  Plus,
the port being used is a reserved port (below 1024).  Depending upon
what's running on the client box, the port may actually be in use.  The
same applies to,say, port 123 (which is the port typically used for NTP). 
If the client was using NTP to sync time, then the above script would fail
- because the client was, in fact, using port 123 (meaning, it's running
ntpd or xntpd).

HTH

-- 
Jim

Copyright notice: all code written by the author in this post is
 released under the GPL. http://www.gnu.org/licenses/gpl.txt 
for more information.

a fortune quote ...
!07/11 PDP a ni deppart m'I  !pleH 




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

Date: Fri, 20 Feb 2004 19:58:26 +0000 (UTC)
From: ansok@alumni.caltech.edu (Gary E. Ansok)
Subject: Re: moving a file to a different name
Message-Id: <c15ot2$1h4$1@naig.caltech.edu>

In article <SsSYb.84$LH3.38303@news.uswest.net>,
Shawn <spedwards@qwest.net> wrote:
>I'm trying to move a file to different directory, filename (with a date
>stamp within the name).
>
>The file starts out as: report.txt
>and I want to move it so it comes out as: gl_user_rept_021804.txt
>
>So, I have been trying different versions of this command:
>system("mv /var/shawn/report.txt /var/fred/gl_sys_rept_$date.txt");
>
>I set date = `date +m+d+y`
>
>And I can get it close but not quite what I want:
>
>-rw-rw-r--   1 gp22     pnpsup         5 Feb 18 10:06 gl_user_rept.021804
>-rw-rw-r--   1 gp22     pnpsup         5 Feb 18 10:37 gl_user_rept..txt
>
>Any suggestions would be greatly appreciated.

Other posts have discussed how to get the date and do the file renaming
in Perl (which I also highly recommend), but if you want to understand 
what went wrong with your original code, print out $date like this:
print "Date is >>>$date<<<" and then look up the chomp() function.

Gary Ansok
-- 
Any attempt to brew coffee with a teapot should result in the error code
"418 I'm a teapot". The resulting entity body MAY be short and stout. 
    -- RFC 2324, Hyper Text Coffee Pot Control Protocol (HTCPCP)/1.0


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

Date: 20 Feb 2004 12:05:51 -0800
From: vince.iacoboni@db.com (SqlSlinger)
Subject: Re: Multiple substitution in a complex RE
Message-Id: <b74d9c54.0402201205.381df300@posting.google.com>

fifo <fifo@despammed.com> wrote in message news:<20040219143341.GA14410@fleece>...
> At 2004-02-19 05:37 -0800, SqlSlinger wrote:
> > Now here's the rest of what I should have told you.  I use Perl every
> > chance I get, but in this case I'm hoping to program a macro in
> > TextPad to perform this kind of substitution.  TextPad REs support
> > most of the Perl RE features, but not the g (global) modifier and not
> > loops.  This is why I was attempting to get it all done in the s///
> > statement.  If it won't work, of course, I can program a quick perl
> > script to do it using any of your suggestions, but that's slightly
> > more inconvenient than the TextPad macro.
> > 
> 
> If you need a single substitution to work over the entire file, how
> about doing something like
> 
>   s/                   ([a-zA-Z0-9])([a-zA-Z0-9]*)(?=_[a-zA-Z0-9_])
>    | (?<=[a-zA-Z0-9_]_)([a-zA-Z0-9])([a-zA-Z0-9]*)
>  /\U$1$3\L$2$4/xg

Prints A_Really_Long_Variable_Name.  Can we lose the underscores?  I'm
not familiar with the RE directives you've used to be able to work up
an adjusted version, but I'll look into it.  Doesn't seem to affect
text without the underscore, which is nice.

Thanks!


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

Date: Fri, 20 Feb 2004 16:05:54 -0600
From: Tad McClellan <tadmc@augustmail.com>
Subject: Re: Multiple substitution in a complex RE
Message-Id: <slrnc3d162.3il.tadmc@magna.augustmail.com>

SqlSlinger <vince.iacoboni@db.com> wrote:

> Can we lose the underscores? 


Yes (but I think it is a horrid idea...).


   tr/_//d;


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


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

Date: 20 Feb 2004 13:48:48 -0800
From: Scott_Starker@sil.org (Scottie)
Subject: Re: Newbe Unicode question
Message-Id: <899d28b2.0402201348.48faa624@posting.google.com>

Ben,

> ... (what you posted wasn't complete, right?).

It wasn't nearly all of it!
 
> Now, I can't really see what this is supposed to do, so what do you want
> it to do, and what is it in fact doing?

Well, the zapotecUnicode.txt is a file the contains a "dictionary" of
Zapotec word (spoken in Mexico) and it's Spanish words as it's
definitions. It's almost a database type-of-thing. The program is
called Shoebox. There are different lines for each record. They all
start with "\lx" (lexicon). Then the definition(s) (\gn) follows.
There might at least one subentry (\se) along with it's definition(s)
(\sgn). There's more than these fields. (The Perl line "print "**";
was for testing purposes.) Thus, I therefor I need a @Fld = split(" ",
$_, 9999); that takes an array like this. Can you help me out? I need
to know how to get the line into @Fld.

Scott


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

Date: Fri, 20 Feb 2004 10:06:15 -0600
From: "J. Gleixner" <glex_nospam@qwest.invalid>
Subject: Re: Newbie question on use
Message-Id: <XfqZb.96$uJ.17230@news.uswest.net>

chatiman wrote:
> Hello again,
> 
> If i have 2 modules :
> 
> -------------------------
> package A;
> 
> use lib "/path";
> --------------------------
> package B;
> 
> use A;
> --------------------------
> 
> Will the package B search have "/path" in @INC ?
> 
> 
> 

Instead of asking, why not print it to see?


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

Date: Fri, 20 Feb 2004 17:07:26 +0100
From: Gunnar Hjalmarsson <noreply@gunnar.cc>
Subject: Re: Newbie question on use
Message-Id: <c15be4$1fc6qb$1@ID-184292.news.uni-berlin.de>

chatiman wrote:
> If i have 2 modules :
> 
> -------------------------
> package A;
> 
> use lib "/path";
> --------------------------
> package B;
> 
> use A;
> --------------------------
> 
> Will the package B search have "/path" in @INC ?

What happened when you tried it?

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



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

Date: Fri, 20 Feb 2004 16:11:33 GMT
From: Beable van Polasm <beable+unsenet@beable.com.invalid>
Subject: Re: Newbie question on use
Message-Id: <1ollmxpwa0.fsf@dingo.beable.com>

"chatiman" <chatiman@free.fr> writes:

> Hello again,
> 
> If i have 2 modules :
> 
> -------------------------
> package A;
> 
> use lib "/path";

print("in package A, INC = @INC\n");

> --------------------------
> package B;
> 
> use A;

print("in package B, INC = @INC\n");

> --------------------------
> 
> Will the package B search have "/path" in @INC ?

Get the computer to tell you.


-- 
   


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

Date: 20 Feb 2004 19:03:42 GMT
From: anno4000@lublin.zrz.tu-berlin.de (Anno Siegel)
Subject: Re: Newbie question on use
Message-Id: <c15lme$l05$2@mamenchi.zrz.TU-Berlin.DE>

chatiman <chatiman@free.fr> wrote in comp.lang.perl.misc:
> Hello again,
> 
> If i have 2 modules :
> 
> -------------------------
> package A;
> 
> use lib "/path";
> --------------------------
> package B;
> 
> use A;
> --------------------------
> 
> Will the package B search have "/path" in @INC ?

What is the "package B search"?

Never mind, you decide, and when it happens, print @INC.

Anno


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

Date: Fri, 20 Feb 2004 22:45:13 GMT
From: "John W. Kennedy" <jwkenne@attglobal.net>
Subject: Re: Newbie question on use
Message-Id: <Z5wZb.21598$ac.2296244@news4.srv.hcvlny.cv.net>

Anno Siegel wrote:

> chatiman <chatiman@free.fr> wrote in comp.lang.perl.misc:
> 
>>Hello again,
>>
>>If i have 2 modules :
>>
>>-------------------------
>>package A;
>>
>>use lib "/path";
>>--------------------------
>>package B;
>>
>>use A;
>>--------------------------
>>
>>Will the package B search have "/path" in @INC ?
> 
> 
> What is the "package B search"?
> 
> Never mind, you decide, and when it happens, print @INC.

That doesn't tell whether it's defined behavior, you know.

-- 
John W. Kennedy
"But now is a new thing which is very old--
that the rich make themselves richer and not poorer,
which is the true Gospel, for the poor's sake."
   -- Charles Williams.  "Judgement at Chelmsford"


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

Date: Fri, 20 Feb 2004 23:00:41 +0000
From: Jimi-Carlo Bukowski-Wills <jimicarlo@ntlworld.com>
Subject: Re: Newbie question on use
Message-Id: <bkwZb.135$xx3.62@newsfe1-win>

Since @INC is global, you should see /path in @INC in any script using 
module A directly or indirectly.  I've tested it and it works:
package A;

-------------------------
package A;
use lib "/path";
--------------------------
package B;
use A;
--------------------------
$ perl B.pl
/path
/usr/lib/perl5/5.8.1/i386-linux-thread-multi
/usr/lib/perl5/5.8.1
/usr/lib/perl5/site_perl/5.8.1/i386-linux-thread-multi
/usr/lib/perl5/site_perl/5.8.1
 ....

Jimi



John W. Kennedy wrote:
> Anno Siegel wrote:
> 
>> chatiman <chatiman@free.fr> wrote in comp.lang.perl.misc:
>>
>>> Hello again,
>>>
>>> If i have 2 modules :
>>>
>>> -------------------------
>>> package A;
>>>
>>> use lib "/path";
>>> --------------------------
>>> package B;
>>>
>>> use A;
>>> --------------------------
>>>
>>> Will the package B search have "/path" in @INC ?
>>
>>
>>
>> What is the "package B search"?
>>
>> Never mind, you decide, and when it happens, print @INC.
> 
> 
> That doesn't tell whether it's defined behavior, you know.
> 



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

Date: 20 Feb 2004 10:32:21 -0800
From: usenet@outshine.com (Anthony Boyd)
Subject: Re: perl controlling samba permissions?
Message-Id: <cebfe83a.0402201032.1359edd4@posting.google.com>

Ben Morrow <usenet@morrow.me.uk> wrote:

> The samba docs I have (for version 2.2.8a) clearly say that the only
> permissions you will in fact be able to set through that dialog are
> those corresponding to user, group and world Unix permissions. The
> relevant document is full_docs/htmldocs/NT_Security.html (wherever
> you've got the samba docs installed).

Thanks for the link to the NT_Security.html file.  I had tried google
and man pages, but that file was really what I needed.

-Anthony


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

Date: Fri, 20 Feb 2004 21:21:24 +0000
From: Jimi-Carlo Bukowski-Wills <jimicarlo@ntlworld.com>
Subject: Re: Protecting Source code of a perl script
Message-Id: <6TuZb.102$xx3.73@newsfe1-win>

Hi there, I'm Jimi

Why don't you consider downloading the free version of Perl2Exe from 
http://www.indigostar.com/perl2exe.htm

It'll turn your .pl file into a binary executable... available for 
Windows, Linux, Unix.

This makes it a bit difficult for people to read your data in a text 
editor.

Alternatively you could use one of the Acme modules that obscures your 
source code... or maybe you could try both.

You could also try one or a combination of the many data encryption 
modules available.

If you did all of these things, I'm sure that your data would be pretty 
safe, but the best way is probably not to put sensitive data into an 
insecure environment.

Hope this helps

Jimi

ctcgag@hotmail.com wrote:
> Rafael Garcia-Suarez <rgarciasuarez@free.fr> wrote:
> 
>>ctcgag@hotmail.com wrote in comp.lang.perl.misc :
>>
>>>>That is not what is meant by "security by obscurity".
>>>
>>>I just think it's kind of cheating to coerce the language into making
>>>your argument for you.  When something you think should be open is not,
>>>that is labelled obscurity, while when something you think should not
>>>be open is not, that is labelled security.   So then when you say not
>>>to do security by obscurity, it's really just saying "don't do that
>>>which you shouldn't do."
>>
>>You don't seem to perceive the difference between data and algorithms.
>>
>>Obscuring data and obscuring algorithms that operate on data are two
>>very different things.
> 
> 
> How do you protect the portion of the perl source code which is the
> data (rather than the portion of the perl source code which is the
> algorithm) from an untrusted administrator?
> 
> Xho
> 



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

Date: Fri, 20 Feb 2004 17:41:42 -0500
From: Robert <bobx@linuxmail.org>
Subject: Re: Protecting Source code of a perl script
Message-Id: <Vp6dnf_uyPm7EKvdRVn-gQ@adelphia.com>

Jimi-Carlo Bukowski-Wills wrote:

> Hi there, I'm Jimi
> 
> Why don't you consider downloading the free version of Perl2Exe from 
> http://www.indigostar.com/perl2exe.htm
> 
> It'll turn your .pl file into a binary executable... available for 
> Windows, Linux, Unix.
> 
> This makes it a bit difficult for people to read your data in a text 
> editor.
> 
> Alternatively you could use one of the Acme modules that obscures your 
> source code... or maybe you could try both.
> 
> You could also try one or a combination of the many data encryption 
> modules available.
> 
> If you did all of these things, I'm sure that your data would be pretty 
> safe, but the best way is probably not to put sensitive data into an 
> insecure environment.
> 
> Hope this helps
> 
> Jimi
> 
> ctcgag@hotmail.com wrote:
> 
>> Rafael Garcia-Suarez <rgarciasuarez@free.fr> wrote:
>>
>>> ctcgag@hotmail.com wrote in comp.lang.perl.misc :
>>>
>>>>> That is not what is meant by "security by obscurity".
>>>>
>>>>
>>>> I just think it's kind of cheating to coerce the language into making
>>>> your argument for you.  When something you think should be open is not,
>>>> that is labelled obscurity, while when something you think should not
>>>> be open is not, that is labelled security.   So then when you say not
>>>> to do security by obscurity, it's really just saying "don't do that
>>>> which you shouldn't do."
>>>
>>>
>>> You don't seem to perceive the difference between data and algorithms.
>>>
>>> Obscuring data and obscuring algorithms that operate on data are two
>>> very different things.
>>
>>
>>
>> How do you protect the portion of the perl source code which is the
>> data (rather than the portion of the perl source code which is the
>> algorithm) from an untrusted administrator?
>>
>> Xho
>>
> 
use PAR;



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

Date: 20 Feb 2004 20:27:37 GMT
From: anno4000@lublin.zrz.tu-berlin.de (Anno Siegel)
Subject: Re: Really unbuffered reads...
Message-Id: <c15qjp$ntf$1@mamenchi.zrz.TU-Berlin.DE>

Matthew Braid  <mb@uq.net.au.invalid> wrote in comp.lang.perl.misc:
> Hi all,
> 
> I'm using GnuPG::Interface to verify some PGP signed data, and for the 
> most part it all seems to be working nicely.
> 
> I have come across a small problem though. Sometimes (not always, which 
> makes this nicely annoying) the function I use to read through the 
> output blocks indefinitely.
> 
> The segment of code that causes the problem is:
> 
> # $fh is a filehandle passed in to the function -
> # its an IO::Handle object that's been used as the
> # stderr handle to GnuPG::Interface::verify
> my ($buffer, $ok) = ('', undef);
> while (1) {
> 	if (not sysread($fh, $buffer, 1024, length($buffer)) {
> 		last if not length $buffer;

"last unless ..." reads better here.

> 		$ok = [1, $1] if $buffer =~ PGP_SIGOK;
                                            ^^^^^^^^^
Uh... I suppose that's a constant that returns a regex.

> 		last;
> 	}
> 	# Do some stuff with buffer to look for individual lines...
> }
> 
> This _almost_ always works fine. Rarely, that sysread hangs. If i'm 

Use select() or IO::Select to see if the filehandle is ready for reading.
You could also make it non-blocking, but I don't know how well that works
with sysread().

In both cases you'll have to decide what to do if the handle never
becomes ready, and how long "never" is.

Anno


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

Date: Fri, 20 Feb 2004 20:37:57 GMT
From: Uri Guttman <uri@stemsystems.com>
Subject: Re: Really unbuffered reads...
Message-Id: <x7fzd5ij1a.fsf@mail.sysarch.com>

>>>>> "AS" == Anno Siegel <anno4000@lublin.zrz.tu-berlin.de> writes:

  AS> Use select() or IO::Select to see if the filehandle is ready for reading.
  AS> You could also make it non-blocking, but I don't know how well that works
  AS> with sysread().

sysread/write work fine with non-blocking as long as you handle the buffering
yourself. in fact they usually required for non-blocking sockets as you
could do a large print to such a socket and not all of the data will be
written and the rest will sit in the buffer forever until you flush
it. and you have no control then over how much gets written each time.

uri

-- 
Uri Guttman  ------  uri@stemsystems.com  -------- http://www.stemsystems.com
--Perl Consulting, Stem Development, Systems Architecture, Design and Coding-
Search or Offer Perl Jobs  ----------------------------  http://jobs.perl.org


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

Date: Fri, 20 Feb 2004 13:00:03 -0800
From: Jim Gibson <jgibson@mail.arc.nasa.gov>
Subject: Re: regex newbie
Message-Id: <200220041300031833%jgibson@mail.arc.nasa.gov>

In article <SLYYb.3492$AQ4.1071225@newsfep2-win.server.ntli.net>, Dave
Cardwell <dcspam@ntlworld.com> wrote:

> "Greg Carlson" <gregfcarlson@hotmail.com> wrote:
> > I've looked through a number of books and faq's and such and haven't been
> > able to solve my regex conundrum. I need to find the first match before
> > another match. For example, with the string 'abcdefgabcdefgfooabcdefg', I
> > need to match 'foo' and the 'a' previous to but nearest 'foo' (not the one
> > at the beginning of the string). Also, there's an unknown number of
> > characters between the 'a' and the 'foo'. Any help would be greatly
> > appreciated.
> >
> > Greg Carlson
> >
> >
> 
> Normally a regular expression tries to gobble up as much as it can, in this
> case it will try to match the 'a' furthest away from 'foo'.
> 
> To get round this, you can do:
>     /a[^a]*foo/
> which will match an 'a', any number of anything-but-a, then foo.
> 
> Alternatively you can do:
>     /a.*?foo/
> Here the ? makes the regexp 'not greedy'.  That is, it will try to match
> across the minimum amount of characters (hence the closest 'a' to 'foo').

No, you can't! Perl will match the FIRST string that matches,
regardless of the greediness of the pattern. Try it first before
posting incorrect advice (we can't all be as infallible as Tad).

#!/usr/local/bin/perl

use strict;
use warnings;

my $s = 'cbabcdcbabcdefoopqrstuv';

if( $s =~ /a.*?foo/ ) {
  print "matches: <$&>\n";
}else{
  print "nomatch\n";
}

Output:
matches: <abcdcbabcdefoo>


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

Date: Fri, 20 Feb 2004 18:05:46 -0000
From: "David K. Wall" <dwall@fastmail.fm>
Subject: Re: Replacing a text in multiple files with regular expressions
Message-Id: <Xns949585388D283dkwwashere@216.168.3.30>

Tad McClellan <tadmc@augustmail.com> wrote:

> Angel <anichin@vip.bg> wrote:
> 
>> The problem is that wildcards does not work with my 
>> perl on Windows XP.
> 
> 
> But you can make "wildcards" work yourself by using:
> 
>    perldoc -f glob

Good thing the OP is using winXP and not win98.

A friend of mine recently wanted a copy of a little utility program I had 
written. He didn't have Perl (and didn't want or need it), so I packaged 
the program with PAR under winXP and sent him the executable. When he ran 
the exe on his win98 system, all he got from glob() was "Bad command or 
filename", so I had to rewrite that portion of the program to use readdir() 
and 'next unless ...'. What a PITA. 

Maybe if I'd had a win98 system with which to create the exe it might have 
worked?

-- 
David Wall


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

Date: Fri, 20 Feb 2004 16:14:50 GMT
From: Devop <as@hotmail.com>
Subject: Re: Search and replace problem
Message-Id: <403632D3.ED4BD1F6@hotmail.com>

Thanks a lot. you showed me my mistake



Beable van Polasm wrote:

> Devop <as@hotmail.com> writes:
> >
> > This error is coming :
> > Use of uninitialized value in substitution (s///)
> >
> > Is there any other way to solve this problem. Thanks.
> >
> >
> > #!/usr/bin/perl -w
> > #use strict;
>
> Please don't comment out use strict. It is your friend.
>
> > use warnings;
>
> Good!
>
> > my $infile = 'first.xml';
> > my $outfile = 'second.xml';
> >
> >
> > my $text1 = 'this is it =';
> > my $text2 = '{and this is a new} OK '';
>                                       ^^
>                                   This is wrong, surely.
>
> > undef $/;
> > open IN, $infile or  die "couldn't open the file!";
>
> This should be;
> open IN, $infile or  die "couldn't open the file: $!";
>                                                   ^^
>                                      Tells you what the error was
>
> > my $intext = <IN>;
> > close IN;
> >
> > $intext =s/$text1/$text2/gi;
>
> Should be:
> $intext =~ s/$text1/$text2/gi;
>         ^^
>       Note typo.
>
> > open OUT, ">$outfile" or die $!;
> > print OUT $intext;
> > close OUT;
>
> Also, you might like to use one of the XML modules like XML::Simple
> to deal with XML files, rather than using regular expressions.
>
> --
>



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

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


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