[16110] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 3522 Volume: 9

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Fri Jun 30 09:05:26 2000

Date: Fri, 30 Jun 2000 06:05:13 -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: <962370313-v9-i3522@ruby.oce.orst.edu>
Content-Type: text

Perl-Users Digest           Fri, 30 Jun 2000     Volume: 9 Number: 3522

Today's topics:
    Re: $_ and @_ use? (Bart Lateur)
        +<< operator - cant find string delimiter <mike@cyborg-group.com>
        [Perl] How to find the Perl FAQ <rootbeer&pfaq*finding*@redcat.com>
    Re: a large amount of unique numbers in an efficient wa (Bernard El-Hagin)
    Re: cgi.pm & parsing question (Bart Lateur)
    Re: change in precedence from 5.00503 -> 5.6.0 ? (Rafael Garcia-Suarez)
    Re: Changing .htpasswd on the fly.. <mark@markcain.com>
    Re: check for valid e-mail address <news@fido.workone.com>
    Re: check for valid e-mail address <mike.solomon@eps.ltd.uk>
    Re: check for valid e-mail address <news@fido.workone.com>
    Re: check for valid e-mail address <gellyfish@gellyfish.com>
    Re: check for valid e-mail address (brian d foy)
    Re: check for valid e-mail address <mike.solomon@eps.ltd.uk>
        correct name space eastking@my-deja.com
    Re: DANGEROUS CODE ABOVE (was Re: Perl Help Please!) <Magic@mattnet.freeserve.co.uk>
    Re: deleting entries in a hash <abe@ztreet.demon.nl>
    Re: Dereferencing a two dimensional array? (Eric Bohlman)
    Re: Finding out free disk space ??? <Roger.Tillmann@extern.rwso.de>
    Re: how do i create an array of hashes? <TheEx0rcist@fanclub.org>
    Re: Message Board Problem <gellyfish@gellyfish.com>
        PPM not work on ActivePerl 5.6 for NT ? <a.bruno.SII@ifrance.com>
        Printing background images? <nhiller@san.rr.com>
    Re: Problems installing perl on PC (Eric Bohlman)
    Re: sending a password to a server. <andrew.g.bacchi@hitchcock.org>
        STDOUT and IIS <mikihasa@att.net>
    Re: STDOUT and IIS <mikihasa@att.net>
        Still stuck: "converting rel. HTML paths into abs. path <j.bessels@quicknet.nl>
    Re: Strange behaviour in upper case conversion (Philip Lees)
    Re: Strange behaviour in upper case conversion (Philip Lees)
    Re: Teen Volenteers WANTED (Bart Lateur)
    Re: User's details (Csaba Raduly)
    Re: where did the email my perl script sent go? <Peter.Dintelmann@dresdner-bank.com>
        Win32 .htpasswd MD5 vs. Perl Digest::MD5 encryption <steven.van-poeck@SPAM.wanadoo.com>
        Digest Administrivia (Last modified: 16 Sep 99) (Perl-Users-Digest Admin)

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

Date: Fri, 30 Jun 2000 10:43:54 GMT
From: bart.lateur@skynet.be (Bart Lateur)
Subject: Re: $_ and @_ use?
Message-Id: <395f718d.3258645@news.skynet.be>

Alun Moon wrote:

>I've been trying to learn more about using $_ and @_ as default parameters and
>returns from functions.
>
>Largely trial and error so far.
>
>Do they work with things like
>
>while(shift){
>  # do something
>}

@_ and $_ are unrelated ... apart from the fact that they share the same
name.

shift() behaves differently in a sub, than in top level code: at the top
level, shift defaults to using @ARGV, the command line arguments (usuall
file names), while in a sub, it uses @_, the sub parameters array.

@_ used to be used as a target for split(), when not called in a list
context, but that is deprecated. Otherwise, there are NO functions that
default to using it.

$_ is the default scalar operand, the "accumulator" to use some Assembly
notion. Your code should not depend on it keeping it's value for too
long. Many operators/function use this as a default parameter, but
rarely as a destination (tr/// and s/// are exceptions). shift() is not
among them. So:

	while(shift) {
	    ...
	}

will try to get (and remove) the first item from either @ARGV or @_, and
throw the value away. $_ is NOT affected. The loop will abort if the
array was empty (shift() returning undef), or if it contained a false
value, such as undef, 0, "" or "0".

	
	$_ = "not affected\n";
	@ARGV = (1, 2, 3, 0, 4, 5); # not in sub
	while(shift) {
	    print;
	}
	print "Remains: @ARGV\n";

-->
	not affected
	not affected
	not affected
	Remains: 4 5

-- 
	Bart.


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

Date: Fri, 30 Jun 2000 13:58:14 +0000
From: redtux <mike@cyborg-group.com>
Subject: +<< operator - cant find string delimiter
Message-Id: <962369895.3970.0.nnrp-10.9e986064@news.demon.co.uk>

I have the following peice of code of code which I am trying to use in
smtp procedure

use Net::SMTP ();
              use Carp qw(carp verbose);
              
              #
              # Sends email by using the SMTP Server
              #
              # The SMTP server as defined in Net::Config 
              # Alternatively you can hardcode it here, look for
              $smtp_server below 
              #
              sub send_mail{
                my ($from, $to, $subject, $body) = @_;



            
                carp "From missing" unless defined $from ; # Prefer to
                exit early if 
errors
                carp "To missing"   unless defined $to ;
              
                my $mail_message = <<__END_OF_MAIL__;
              To: $to From: $from Subject: $subject
              
              $body
              
              __END_OF_MAIL__
              
                  # Set this parameter if you don't have a valid
                  Net/Config.pm
                  # entry for SMTP host and uncomment it in the
                  Net::SMTP->new
                  # call
                # my $smtp_server = 'localhost';
              
                  # init the server
                my $smtp = Net::SMTP->new(
                                        # $smtp_server,
                                        Timeout => 60,  Debug   => 0,
                                       );
              
                $smtp->mail($from) or carp ("Failed to specify a sender
                [$from]\n");
                $smtp->to($to) or carp ("Failed to specify a recipient
                [$to]\n");
                $smtp->data([$mail_message]) or carp ("Failed to send a
                message\n");
              
                $smtp->quit or carp ("Failed to quit\n");
              
              } #  end of sub send_mail

This fails when at __END_OF_MAIL__ with debugging error of Can't find
string terminator "__END_OF_MAIL__" anywhere before EOF

Can anyone shed some light on this - is this depreciated?


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

Date: Fri, 30 Jun 2000 10:22:22 GMT
From: Tom Phoenix <rootbeer&pfaq*finding*@redcat.com>
Subject: [Perl] How to find the Perl FAQ
Message-Id: <pfaqmessage962360645.8484@news.teleport.com>

Archive-name: perl-faq/finding-perl-faq
Posting-Frequency: weekly
Last-modified: 29 Apr 2000

[ That "Last-modified:" date above refers to this document, not to the
Perl FAQ itself! The last _major_ update of the Perl FAQ was in Summer
of 1998; of course, ongoing updates are made as needed. ]

For most people, this URL should be all you need in order to find Perl's
Frequently Asked Questions (and answers).

    http://www.cpan.org/doc/FAQs/

Please look over (but never overlook!) the FAQ and related docs before
posting anything to the comp.lang.perl.* family of newsgroups.

For an alternative way to get answers, check out the Perlfaq website.

    http://www.perlfaq.com/

# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # 

Beginning with Perl version 5.004, the Perl distribution itself includes
the Perl FAQ. If everything is pro-Perl-y installed on your system, the
FAQ will be stored alongside the rest of Perl's documentation, and one
of these commands (or your local equivalents) should let you read the FAQ.

    perldoc perlfaq
    man perlfaq

If a recent version of Perl is not properly installed on your system,
you should ask your system administrator or local expert to help. If you
find that a recent Perl distribution is lacking the FAQ or other important
documentation, be sure to complain to that distribution's author.

If you have a web connection, the first and foremost source for all things
Perl, including the FAQ, is the Comprehensive Perl Archive Network (CPAN).
CPAN also includes the Perl source code, pre-compiled binaries for many
platforms, and a large collection of freely usable modules, among its
560_986_526 bytes (give or take a little) of super-cool (give or take
a little) Perl resources.

    http://www.cpan.org/
    http://www.perl.com/CPAN/
    http://www.cpan.org/doc/FAQs/FAQ/html/
    http://www.perl.com/CPAN/doc/FAQs/FAQ/html/

You may wish or need to access CPAN via anonymous FTP. (Within CPAN,
you will find the FAQ in the /doc/FAQs/FAQ directory. If none of these
selected FTP sites is especially good for you, a full list of CPAN sites
is in the SITES file within CPAN.)

    California     ftp://ftp.cdrom.com/pub/perl/CPAN/
    Texas          ftp://ftp.metronet.com/pub/perl/
    South Africa   ftp://ftp.is.co.za/programming/perl/CPAN/
    Japan          ftp://ftp.dti.ad.jp/pub/lang/CPAN/
    Australia      ftp://cpan.topend.com.au/pub/CPAN/
    Netherlands    ftp://ftp.cs.ruu.nl/pub/PERL/CPAN/
    Switzerland    ftp://sunsite.cnlab-switch.ch/mirror/CPAN/
    Chile          ftp://ftp.ing.puc.cl/pub/unix/perl/CPAN/

If you have no connection to the Internet at all (so sad!) you may wish
to purchase one of the commercial Perl distributions on CD-Rom or other
media. Your local bookstore should be able to help you to find one.

# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # 

Comments and suggestions on the contents of this document
are always welcome. Please send them to the author at
<pfaq&finding*comments*@redcat.com>. Of course, comments on
the docs and FAQs mentioned here should go to their respective
maintainers.

Have fun with Perl!

-- 
Tom Phoenix       Perl Training and Hacking       Esperanto
Randal Schwartz Case:     http://www.rahul.net/jeffrey/ovs/


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

Date: Fri, 30 Jun 2000 11:16:47 GMT
From: bernard.el-hagin@lido-tech.net (Bernard El-Hagin)
Subject: Re: a large amount of unique numbers in an efficient way?
Message-Id: <slrn8lp04d.mm6.bernard.el-hagin@gdndev25.lido-tech>

On Fri, 30 Jun 2000 08:39:04 GMT, Neil Kandalgaonkar <neil@brevity.org> wrote:
>In article <slrn8lofjh.mm6.bernard.el-hagin@gdndev25.lido-tech>,
>Bernard El-Hagin <bernard.el-hagin@lido-tech.net> wrote:
>>On 29 Jun 2000 22:14:46 EDT, Abigail <abigail@delanet.com> wrote:
>>>Abigail
>>>-- 
>>>perl -weprint\<\<EOT\; -eJust -eanother -ePerl -eHacker -eEOT
>>
>>Can someone please explain how this works?
>
>The -e commands don't have to be quoted, the shell will pass them on
>when properly escaped.
>
>Multiple -e commands build up a multi-line script. So the script is:
>
>print <<EOT;
>Just
>another
>Perl
>Hacker
>EOT
>
>which should not be mystifying, it's a heredoc. See man perldata.

The multiple -e switches confused me. Now I get it. Thanks.

>This one is a mere trifle by Abigail standards.

Definitely agreed, but it's very nice, none the less.

Bernard
--
perl -wle '$_=q badqm!qcb;for(split ??){++$_;s g1gqq+a+ge;print}'


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

Date: Fri, 30 Jun 2000 10:43:48 GMT
From: bart.lateur@skynet.be (Bart Lateur)
Subject: Re: cgi.pm & parsing question
Message-Id: <395d695f.1164904@news.skynet.be>

Malcolm Dew-Jones wrote:

>I forgot to mention the safe module. I don't remember the name

Er.... "Safe"?

-- 
	Bart.


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

Date: Fri, 30 Jun 2000 11:44:00 GMT
From: garcia_suarez@hotmail.com (Rafael Garcia-Suarez)
Subject: Re: change in precedence from 5.00503 -> 5.6.0 ?
Message-Id: <slrn8lp27u.q62.garcia_suarez@rafael.kazibao.net>

Neil Kandalgaonkar wrote in comp.lang.perl.misc:
>
>[ Sorry about the subject-less posting. My news config is messed up so
>I couldn't cancel that. ]
>
>
>In article <slrn8lopmr.poj.garcia_suarez@rafael.kazibao.net>,
>Rafael Garcia-Suarez <garcia_suarez@hotmail.com> wrote:
>
>>What is your perl version? It seems that the parser has evolved since
>>5.00503.
>
>I'm using 5.6.0. Funny, I had a sneaking suspicion about this, but I 
>thought there was no way operator precedence had changed.
>
>
>$ perl5.00503 -MO=Deparse,-p -e '  not($a) &&  not($b) ' 2>&-
>(not ($a && (!$b)));
>
>$ perl5.6.0   -MO=Deparse,-p -e '  not($a) &&  not($b) ' 2>&-
>((not $a) and (not $b));
>
>
>Shame on me for not checking.
>
>So, is this a bug or a feature? I don't see anything in perldelta.

In the Perl 5.6.0 announcement by G.Sarathy, posted in clp.announce some
time ago, I read the following:
    + C<not> followed by parentheses behaves like a list operator.  This
      allows C<grep not($_), @things> to work as expected, but also changes
      C<not (1,2,3)[0]> to mean C<(not(1,2,3))[0]> instead of
      C<not((1,2,3)[0])>.

This should anwer this question. This is a feature.

-- 
Rafael Garcia-Suarez


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

Date: Fri, 30 Jun 2000 12:55:43 GMT
From: "Mark Cain" <mark@markcain.com>
Subject: Re: Changing .htpasswd on the fly..
Message-Id: <jN075.5052$re.55543@news1>

I have used this code to CREATE htaccess on Apache systems.  I see that you
want to modify the file.  Just open the file for appending and stick the new
password on the end.

Here is the code to create.  This will need some modification to serve your
needs -- but should send you in the right direction.

#create the password file
$user = "foo";
$pass = "bar";
$pass = crypt($pass, $pass);
open(FILEA, "> ./path/.htpasswd") or die "Can not open htpasswd";
print FILEA "$user:$pass\n";
close(FILEA);

#create the accesss file
open(FILEB, "> ./path/.htaccess") or die "Can not open htaccess";
print FILEB "AuthUserFile path/.htpasswd\n";
print FILEB "AuthName Vital Stats\n";
print FILEB "AuthType Basic\n";
print FILEB "\n";
print FILEB "<Limit GET>\n";
print FILEB "require valid-user\n";
print FILEB "</Limit>\n";
close(FILEB);


You would need to open the file for appending like this:

open(FILEA, ">> ./path/.htpasswd") or die "Can not open htpasswd";


HTH,

Mark



"Hans" <hans@exonet.net> wrote in message
news:9qoolsgiqjos8flriou1b5ha7neo06cht1@4ax.com...
> Hi,
>
> Is there a way to change .htpasswd on the fly from a Perl script?
> I have users who must register on my site, and I want to be able to
> add a new line to .htpasswd so  the new user can login at once.
>
> Any suggestions?
>
> CU
> Hans.
>
> --
>  EVA <http://www.exonet.net>




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

Date: Fri, 30 Jun 2000 12:25:19 +0200
From: Kirill Miazine <news@fido.workone.com>
Subject: Re: check for valid e-mail address
Message-Id: <Pine.LNX.4.21.0006301217500.21113-100000@isolde.uio.no>

Hi,

You can make a suroutine to do email_ok checks: if OK return 1 else return
0.
like this :


foreach (@ADD99) {
    if (&email_ok($_) {
	$ADD_GOOD99 .= "$_ ";
    } else {
	push @ERROR99 => "INVALID ADDRESS $_";
    }
}
sub email_ok {
    if ($_[0] =~/^[a-z0-9\.\-\_]+@[a-z0-9][a-z0-9\-\.]*\.[a-z]+/i){
	return 1;
    } else {
        return 0
    }
}


Hope this helps

On Fri, 30 Jun 2000, mike solomon wrote:

# I have written a script to send e-mail from the Unix command line
# 
# I test if what looks like a valid address has been entered and if the format
# is incorrect I create an error
# 
# #test if addresses are valid
# #ADD99 is an array containing addresses
# for (@ADD99) {
#     @ADD_NO99 = split("@") ;
#     #test if address contains space or field2 does not contain a "."
#     if ( $ADD_NO99[0] =~ / / || length($ADD_NO99[0]) == 0 || $ADD_NO99[1] !~
# /\./ ) {
#          push @ERROR99 => "INVALID ADDRESS $_";
#     }
#     #set up valid addresses
#     else { $ADD_GOOD99 = "$ADD_GOOD99 $_"; }
# }
# 
# while it works, I am not overly happy with this test, has anyone written a
# better one or is there a module that checks that the format of an e-mail
# address is valid
# 
# Your help would be appreciated
# 
# Regards
# 
# Mike Solomon
# 
# 
# 
# 



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

Date: Fri, 30 Jun 2000 11:55:59 +0100
From: "mike solomon" <mike.solomon@eps.ltd.uk>
Subject: Re: check for valid e-mail address
Message-Id: <8jhues$kri4$1@ID-36965.news.cis.dfn.de>

Kirill

that's really helpful

I don't actually need the subroutine and have changed my code to:

for (@ADD99) {
    if ($_ =~/^[a-z0-9\.\-\_]+@[a-z0-9][a-z0-9\-\.]*\.[a-z]+/i){
        push @ERROR99 => "INVALID ADDRESS $_";
    }
    else { $ADD_GOOD99 = "$ADD_GOOD99 $_"; }
}

thanks


Kirill Miazine <news@fido.workone.com> wrote in message
news:Pine.LNX.4.21.0006301217500.21113-100000@isolde.uio.no...
> Hi,
>
> You can make a suroutine to do email_ok checks: if OK return 1 else return
> 0.
> like this :
>
>
> foreach (@ADD99) {
>     if (&email_ok($_) {
> $ADD_GOOD99 .= "$_ ";
>     } else {
> push @ERROR99 => "INVALID ADDRESS $_";
>     }
> }
> sub email_ok {
>     if ($_[0] =~/^[a-z0-9\.\-\_]+@[a-z0-9][a-z0-9\-\.]*\.[a-z]+/i){
> return 1;
>     } else {
>         return 0
>     }
> }
>
>
> Hope this helps
>





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

Date: Fri, 30 Jun 2000 13:14:50 +0200
From: Kirill Miazine <news@fido.workone.com>
Subject: Re: check for valid e-mail address
Message-Id: <Pine.LNX.4.21.0006301313520.30813-100000@isolde.uio.no>

OK, you can actually remove `$_ =~' from the if statement to make it even
easier :)

On Fri, 30 Jun 2000, mike solomon wrote:

# Kirill
# 
# that's really helpful
# 
# I don't actually need the subroutine and have changed my code to:
# 
# for (@ADD99) {
#     if ($_ =~/^[a-z0-9\.\-\_]+@[a-z0-9][a-z0-9\-\.]*\.[a-z]+/i){
#         push @ERROR99 => "INVALID ADDRESS $_";
#     }
#     else { $ADD_GOOD99 = "$ADD_GOOD99 $_"; }
# }
# 
# thanks
# 
# 
# Kirill Miazine <news@fido.workone.com> wrote in message
# news:Pine.LNX.4.21.0006301217500.21113-100000@isolde.uio.no...
# > Hi,
# >
# > You can make a suroutine to do email_ok checks: if OK return 1 else return
# > 0.
# > like this :
# >
# >
# > foreach (@ADD99) {
# >     if (&email_ok($_) {
# > $ADD_GOOD99 .= "$_ ";
# >     } else {
# > push @ERROR99 => "INVALID ADDRESS $_";
# >     }
# > }
# > sub email_ok {
# >     if ($_[0] =~/^[a-z0-9\.\-\_]+@[a-z0-9][a-z0-9\-\.]*\.[a-z]+/i){
# > return 1;
# >     } else {
# >         return 0
# >     }
# > }
# >
# >
# > Hope this helps
# >
# 
# 
# 
# 



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

Date: Fri, 30 Jun 2000 11:39:02 GMT
From: Jonathan Stowe <gellyfish@gellyfish.com>
Subject: Re: check for valid e-mail address
Message-Id: <qF%65.743$iP2.73114@news.dircon.co.uk>

On Fri, 30 Jun 2000 10:48:16 +0100, mike solomon Wrote:
> I have written a script to send e-mail from the Unix command line
> 
> I test if what looks like a valid address has been entered and if the format
> is incorrect I create an error
> 

I would see in the first the item in perlfaq9 about validating e-mail
addresses and then Search Deja news for the hundred of times this has been
discussed before .  Then I would take a look at Abigail's module
RFC::RFC822:Address <http://search.cpan.org/search?dist=RFC_RFC822_Address>


/J\


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

Date: Fri, 30 Jun 2000 08:20:33 -0400
From: brian@smithrenaud.com (brian d foy)
Subject: Re: check for valid e-mail address
Message-Id: <brian-ya02408000R3006000820330001@news.panix.com>

In article <8jhues$kri4$1@ID-36965.news.cis.dfn.de>, "mike solomon" <mike.solomon@eps.ltd.uk> posted:

> for (@ADD99) {
>     if ($_ =~/^[a-z0-9\.\-\_]+@[a-z0-9][a-z0-9\-\.]*\.[a-z]+/i){
>         push @ERROR99 => "INVALID ADDRESS $_";

      if it matches the regex it's a bad address?  furthermore,
      your regex is doomed to fail (like every other regex solution
      posted, for the same reasons listed in the faq and oft
      posted to this group).  see RFC::RFC822::Address.

      and, why prepend "INVALID ADDRESS " tp every address if it
      it already in an array that only holds bad addresses?

>     }
>     else { $ADD_GOOD99 = "$ADD_GOOD99 $_"; }
> }

      what's going on here?  perhaps you should use an array to
      hold the good addresses as well.  what's the point of 
      putting spaces inbetween them?

-- 
brian d foy                    
CGI Meta FAQ <URL:http://www.smithrenaud.com/public/CGI_MetaFAQ.html>
Perl Mongers <URL:http://www.perl.org/>


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

Date: Fri, 30 Jun 2000 13:32:35 +0100
From: "mike solomon" <mike.solomon@eps.ltd.uk>
Subject: Re: check for valid e-mail address
Message-Id: <8ji440$ktg0$1@ID-36965.news.cis.dfn.de>

yes I made a mistake when I put the code here

it should have read

for (@ADD99) {
     if ($_ =~/^[a-z0-9\.\-\_]+@[a-z0-9][a-z0-9\-\.]*\.[a-z]+/I){
         $ADD_GOOD99 = "$ADD_GOOD99 $_";
    }
     else

         push @ERROR99 => "INVALID ADDRESS $_";}
}

the reason I hold an array of bad addresses is that if there is a address
error, it mails me, and it will still mail to the good addresses if any

the reason I put spaces between the addresses rather than hold them in an
array is that is the format that MIME Lite expects the address to be in





brian d foy <brian@smithrenaud.com> wrote in message
news:brian-ya02408000R3006000820330001@news.panix.com...
> In article <8jhues$kri4$1@ID-36965.news.cis.dfn.de>, "mike solomon"
<mike.solomon@eps.ltd.uk> posted:
>
> > for (@ADD99) {
> >     if ($_ =~/^[a-z0-9\.\-\_]+@[a-z0-9][a-z0-9\-\.]*\.[a-z]+/i){
> >         push @ERROR99 => "INVALID ADDRESS $_";
>
>       if it matches the regex it's a bad address?  furthermore,
>       your regex is doomed to fail (like every other regex solution
>       posted, for the same reasons listed in the faq and oft
>       posted to this group).  see RFC::RFC822::Address.
>
>       and, why prepend "INVALID ADDRESS " tp every address if it
>       it already in an array that only holds bad addresses?
>
> >     }
> >     else { $ADD_GOOD99 = "$ADD_GOOD99 $_"; }
> > }
>
>       what's going on here?  perhaps you should use an array to
>       hold the good addresses as well.  what's the point of
>       putting spaces inbetween them?
>
> --
> brian d foy
> CGI Meta FAQ <URL:http://www.smithrenaud.com/public/CGI_MetaFAQ.html>
> Perl Mongers <URL:http://www.perl.org/>




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

Date: Fri, 30 Jun 2000 10:25:52 GMT
From: eastking@my-deja.com
Subject: correct name space
Message-Id: <8jhsj5$v1o$1@nnrp1.deja.com>

Hi ,every one here.

I have written a pm file and two pl script as following

commonuse.pl

	sub test(){
		# so sth here
	}
	1;

Init.pm

	package Init;

	require "commonuse.pl";

	sub new(){
		#do bless and others
		test();
		#do other things
	}
	1;


testscript.pl

	use Init;
	require "commonuse.pl";

	my $Init = Init->new();

	test();


when I run "perl test.pl", it said " Undefined subroutine &main::test
called at testscript.pl line 6."

Why does not Perl find correct name space? Thanks in advance.



Sent via Deja.com http://www.deja.com/
Before you buy.


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

Date: Fri, 30 Jun 2000 11:08:40 +0100
From: Magic <Magic@mattnet.freeserve.co.uk>
Subject: Re: DANGEROUS CODE ABOVE (was Re: Perl Help Please!)
Message-Id: <h9solsgku5q2cggn768cka1p3cbtdee5d4@4ax.com>

On 29 Jun 2000 07:11:59 -0700, merlyn@stonehenge.com (Randal L.
Schwartz) wrote:

> Paul> open PAGE, $page ;

Could I just added the line

$page = 'http://www.mydomain.co.uk/' + $page;

?

> So I just invoke
> 
>   http://www.your.server.org/yourscript?PAGE=rm+-rf+/+|
> 
> and you say bye bye to all your files.

Wouldn't that now try to open "http://www.mydomain.co.uk/rm+-rf+/+|"
and fail?


Magic        ==|:o)
-- 
Location : Portsmouth, England, UK
Homepage : http://www.mattnet.freeserve.co.uk
EMail : mailto:Magic@mattnet.freeserve.co.uk


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

Date: Fri, 30 Jun 2000 12:58:57 +0200
From: Abe Timmerman <abe@ztreet.demon.nl>
Subject: Re: deleting entries in a hash
Message-Id: <ejuolssse3c462put70v3qbv99osrbdg5i@4ax.com>

On Thu, 29 Jun 2000 20:47:12 -0700, Paulo Dutra <paulo@xilinx.com>
wrote:

> Thanks Bob,
> 
> 
> I reviewed it more, and actually I confused the issue. I delete
> elements from anonymous array that is clinged to from anonymous hash.
> 
> I provided an example. You'll that the copy of hash and it's values
> are modified. This in turn modifies the original. How do I avoid it?
> 
> 
> 
> #!/group/techsup/perl5.6/bin/perl

please use -w and 'use strict;'

> 
> #Written by:  Paulo Dutra (paulo@xilinx.com)
> 
> # Hash of assigned members listed 
> my($assign) = {
>               'Team1' => ['rui', 'eddie'],
>               'Team2' => ['frog', 'rui'],
> };
> 
> for (my $n = 1; $n <= 2; ++$n)
>   {
>   printf ("-- Starting iteration %d\n", $n);
>   my(%temp) = %$assign;
> 
 ...
>     @{ $temp{$grp} } = ();

This is where you go wrong. The references to the anonymous arrays are
the same in _both_ the original and the copy. By using the construct:

	@{ $array_ref } = @new_list;

you alter the contents of the anonymous array the reference is refering
to (which means the original data).
You want to assign a new reference to an empty list:

	$temp{$grp} = [];


-- 
Good luck,
Abe


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

Date: 30 Jun 2000 10:14:55 GMT
From: ebohlman@netcom.com (Eric Bohlman)
Subject: Re: Dereferencing a two dimensional array?
Message-Id: <8jhruv$rdc$1@slb7.atl.mindspring.net>

Shannon Jacobs (shanen@my-deja.com) wrote:
: My current feeling about Perl is that I'm using a trench mortar to kill
: flies. Direct pointing didn't work so well, so now I load it and lure

The correct term is "Swiss Army chainsaw."



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

Date: Fri, 30 Jun 2000 14:16:09 +0200
From: Roger Tillmann <Roger.Tillmann@extern.rwso.de>
Subject: Re: Finding out free disk space ???
Message-Id: <395C8F88.D13221A8@extern.rwso.de>

Ì downloaded the Admin-Part, tried it out and perl crashes. I have perl 5.6
and W2K. Is there some other way ??

;-((

Roger

jinrai@my-deja.com schrieb:

> In article <8jg7bq$p1s$1@nnrp1.deja.com>,
>   jinrai@my-deja.com wrote:
> > In article <395B702C.1A079D7C@extern.rwso.de>,
> >   Roger Tillmann <Roger.Tillmann@extern.rwso.de> wrote:
> > > How can I find out how large a disk is (harddisk or network drive)
> > and
> > > how can I find out how much space is free on that drive?
> > >
> > > I could live with a solution for Windows, but some more general
> > solution
> > > would be better.
> > >
> > > can someone help me? PLEASE (begging)..
> > >
> > > TIA
> > >
> > > Roger
> > >
> > >
> > ummm within the win32::AdminMisc, ext there is a function called
> > GetDriveSpace($Drive), which returns an array of total drive capacity
> and actually it does work i tried, sample code could be
> use Win32::AdminMisc;
> ($Total, $Free) = Win32::AdminMisc::GetDriveSpace("c:\\");
> print "$Total \n";
> print $Free;
>
> > and the available space on a specified drive. i havent been able to
> get
> > it to work but you can try your luck...
> >
> > Sent via Deja.com http://www.deja.com/
> > Before you buy.
> >
>
> Sent via Deja.com http://www.deja.com/
> Before you buy.



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

Date: Fri, 30 Jun 2000 14:55:07 +0200
From: "TheEx0rcist" <TheEx0rcist@fanclub.org>
Subject: Re: how do i create an array of hashes?
Message-Id: <8ji6cg$hcn$1@reader1.fr.uu.net>

> ------------------
> #!/usr/bin/perl -w
> use strict;
> use Data::Dumper;
>
> my $ref_to_LoH = [ { } ];
>
> print Dumper $ref_to_LoH;
> ------------------



??????????????




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

Date: Fri, 30 Jun 2000 11:42:43 GMT
From: Jonathan Stowe <gellyfish@gellyfish.com>
Subject: Re: Message Board Problem
Message-Id: <TI%65.744$iP2.73114@news.dircon.co.uk>

On 29 Jun 2000 22:22:33 GMT, Kar Yan Mak Wrote:
> Hi, there's a problem with my message board and I'm not sure where to start
> correcting it.  I got the script from Matt's Script Archive.
> 

Search Deja News for 101 reasons not to use that program.

/J\


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

Date: Fri, 30 Jun 2000 14:38:07 +0200
From: "Aurélien BRUNO" <a.bruno.SII@ifrance.com>
Subject: PPM not work on ActivePerl 5.6 for NT ?
Message-Id: <8ji4a7$1i36$1@news2atm.raleigh.ibm.com>

Good Afternoon,

I have the following problem under NT when I use PPM:

PPM> verify /upgrade
Error verifying HTML-Parser: Could not locate a PPM binary of 'HTML-Parser'
for this platform
Package 'URI' is up to date.
Package 'Compress-Zlib' is up to date.
Package 'XML-Element' is up to date.
Package 'PPM' is up to date.
Error verifying libwww-perl: Could not locate a PPM binary of 'libwww-perl'
for this platform
Package 'MIME-Base64' is up to date.
Package 'Archive-Tar' is up to date.
Package 'libwin32' is up to date.
Cannot forceunlink D:\Perl\site\lib\auto\XML\Parser\Expat\Expat.dll:
Permission denied at D:/Perl/site/lib/PPM
 .pm line 617
Error verifying XML-Parser: Could not locate a PPM binary of 'XML-Parser'
for this platform

after exit I can't restart ppm : the next message appears :

Can't locate HTML/HeadParser.pm in @INC (@INC contains: D:/Perl/lib
D:/Perl/site/lib .) at D:/Perl/site/lib/LW
P/Protocol.pm line 47.
Compilation failed in require at D:/Perl/site/lib/LWP/UserAgent.pm line 103.
BEGIN failed--compilation aborted at D:/Perl/site/lib/LWP/UserAgent.pm line
103.
Compilation failed in require at D:/Perl/site/lib/PPM.pm line 8.
BEGIN failed--compilation aborted at D:/Perl/site/lib/PPM.pm line 8.
Compilation failed in require at D:\Perl\bin\ppm.bat line 21.
BEGIN failed--compilation aborted at D:\Perl\bin\ppm.bat line 21.

All files under HTML/ directory are removed :

What the problem ?

--
A. BRUNO




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

Date: Fri, 30 Jun 2000 10:22:38 GMT
From: "Nathan D Hiller" <nhiller@san.rr.com>
Subject: Printing background images?
Message-Id: <Ox_65.16661$bt1.163040@typhoon1.san.rr.com>



How can I get background images to print for users who print my web page?

I have a web page that contains several background images. When internet
users print this page I want the background images to print as well. If I
have a print button on this web page for users to click on when they need to
print, how can I send a print command to the user's printer so that the
background images are printed?

Please send me an email in case I miss the reply post.

Thanks,

Nathan

nhiller@san.rr.com





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

Date: 30 Jun 2000 12:24:22 GMT
From: ebohlman@netcom.com (Eric Bohlman)
Subject: Re: Problems installing perl on PC
Message-Id: <8ji3hm$rdc$2@slb7.atl.mindspring.net>

Neil Jones (Neil@nwjones.demon.co.uk) wrote:
: I have a real problem installing perl on my laptop.
: It is active Perl from a file APi522e.exe
: It installed fine on my desktop machine some while ago but when I went to
: install it on the laptop today I ran into problems.
: The first time I ran out of space on the hard disk which 
: is probably the cause of my current problems.
: I currently have 37,502,976 bytes free after removing the failed
: installation.
: 
: My current problem is that it goes through the installation but
: fails at 80% giving a message that it can not install the 
: Perl Interpreter and that it is aborting the installation.

That's caused by the installer choking on leftovers from your previous 
attempt to install it.  Make sure you've removed *all* files and 
directories from the previous attempt.



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

Date: Fri, 30 Jun 2000 06:08:20 -0400
From: "Andrew G. Bacchi" <andrew.g.bacchi@hitchcock.org>
Subject: Re: sending a password to a server.
Message-Id: <395C7194.A6C2725C@hitchcock.org>

OK, I am stopping my Apache httpd server from a Perl script, changing the
access log file and then restarting the server using ssl.  ssl requires a
password to be entered at the prompt.  How can I make my script aware of the
password prompt and submit the password when needed?  I hope I have explained
it fully.  Thanks.

Jonathan Stowe wrote:

> On Thu, 29 Jun 2000 14:08:07 -0400 Andrew Bacchi wrote:
> > I have to send a password to a server to restart it from a Perl script.
> > Can someone tell me where to look to do this?  A hint would be helpful.
>
> A hint as to what you mean by 'send' and 'server' might be of use.
>
> /J\
> --
> ** This space reserved for venue sponsor for yapc::Europe **
>               <http://www.yapc.org/Europe/>





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

Date: Fri, 30 Jun 2000 11:22:03 GMT
From: "Michael R. Harper" <mikihasa@att.net>
Subject: STDOUT and IIS
Message-Id: <395C838F.CF0E221F@att.net>

Perl Experts:

Does anyone know how to get around this under NT?

Problem:
You are unable to use standard programming I/O methods to pass arguments

and/or data to and from external command or separate PERL Scripts that
are spawned from a parent script.

Cause:
When you spawn a script or external command from a CGI application, it
is created in a separate process. By default Microsoft Internet
Information Server (IIS) 2.0 does not create a console and does not
support standard I/O redirection between processes.

I got that verbiage from Microsoft's site...

Basically, I am trying to do something like this:

open(IN, "program.exe < tempfile.txt|");
@response = <IN>;
close(IN);

or:

@response = `program.exe < tempfile.txt`;

and I get nothing back in the response variable.  Microsoft says to edit

the registry, but I am wondering if that is really necessary or if
something else can be done.

Sincerely,

Michael R. Harper



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

Date: Fri, 30 Jun 2000 12:36:51 GMT
From: "Michael R. Harper" <mikihasa@att.net>
Subject: Re: STDOUT and IIS
Message-Id: <395C9516.97FE3CB8@att.net>

Perl Experts:

Well, since system uses the same STDOUT, I see that this works:

system("program.exe < tempfile.txt > tempfile.out");
open(RESULT, "tempfile.out");
@result = <RESULT>;
close(RESULT);

But that is yucky.  Anyone have something that doesn't require the extra
file operation?

Michael

"Michael R. Harper" wrote:

> Perl Experts:
>
> Does anyone know how to get around this under NT?
>
> Problem:
> You are unable to use standard programming I/O methods to pass arguments
>
> and/or data to and from external command or separate PERL Scripts that
> are spawned from a parent script.
>
> Cause:
> When you spawn a script or external command from a CGI application, it
> is created in a separate process. By default Microsoft Internet
> Information Server (IIS) 2.0 does not create a console and does not
> support standard I/O redirection between processes.
>
> I got that verbiage from Microsoft's site...
>
> Basically, I am trying to do something like this:
>
> open(IN, "program.exe < tempfile.txt|");
> @response = <IN>;
> close(IN);
>
> or:
>
> @response = `program.exe < tempfile.txt`;
>
> and I get nothing back in the response variable.  Microsoft says to edit
>
> the registry, but I am wondering if that is really necessary or if
> something else can be done.
>
> Sincerely,
>
> Michael R. Harper



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

Date: Fri, 30 Jun 2000 15:01:51 +0200
From: Jan Bessels <j.bessels@quicknet.nl>
Subject: Still stuck: "converting rel. HTML paths into abs. paths
Message-Id: <395C9A3F.D7DD34D7@quicknet.nl>

A few days ago I did post.titled "Help: regex for changing NON-absolute
urls in a html file". I've used the comments/ppl mentioned but I'm still
stuck. Basically what I want is to retrieve using LWP:: (or read in a
HTML file from disk) some HTML. I need to tranform relative paths into
absolute ones. This can be done using regexes (got code for it) but the
best solution and most flexible one for my needs seems to be using
standard web modules. I've read (perldoc) about everything there is to
know about  URI:: , LWP, HTTP:: HTML::  (among which are HTTP::Request,
HTML::Parser, HTML::LinkExtor, HTML::TreeBuilder) . Still stuck.

For my needs HTML::LinkExtor (subclass of HTML::Parser) seems ideal. By
setting an option abs. paths are generated. I can also manualy convert
rel. to abs with constructions like. url($_, $base)->abs. With Parser
and LinkExtor I can set a callback function which is called when certain
tags are found so I can usefull things like setting up a datastructure
or print something. BUT what I really need is to be able change the
actual data I feed into parse or being able to put the changed html in a
new variable.
Basicaly what I have now is:
my $p = HTML::LinkExtor->new(\&callback);
# new(\callback,$url) gives absolue urls in returned matches..
my $res = $ua->request(HTTP::Request->new(GET => $url));
my $html =  $res->content;
$p->parse($html);
$p->eof;

I'm starting to feel very silly but for the live of me I can't figure
out how to get a $parsed_html which is the same as $html but with all
relative paths changed into absolute paths. Its probably very simple,
but I just don't see it.............. Any hints/tips/snippets of code
are VERY much appreciated. My boss starts breathing down my neck ;-(

PS Urls of good/related sites are appreciated.

Jan B.
When emailing, please use tux@planet.nl



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

Date: Fri, 30 Jun 2000 10:31:33 GMT
From: pjlees@ics.forthcomingevents.gr (Philip Lees)
Subject: Re: Strange behaviour in upper case conversion
Message-Id: <395c765e.2922882@news.grnet.gr>

On Thu, 29 Jun 2000 08:50:31 -0500, Tom Briles <sariq@texas.net>
wrote:

>Errr, you know that this is equivalent to:
>
>$name =~ tr/a-z/A-Z/;
>
>right?  Because you read the documentation in the perlop page of the
>manual for the bind operator, tr///, and s///, right?
>
><Snipped the evidence that you have *not* read the proper documentation,
>but would rather have someone else read it for you, and regurgitate.>
>
>Whoops...
> 
>> I'm sure this will seem quite simple to you gurus.
>
>It's quite simple for anyone who RTFM.

Reading and fully understanding the documentation are not the same
thing. I did the former, but obviously not the latter. That's why I
posted my question to this group.

Now why don't you take that artichoke out of your ass?

Phil
--
Philip Lees
ICS-FORTH, Heraklion, Crete, Greece
Ignore coming events if you wish to send me e-mail
'The aim of high technology should be to simplify, not complicate' - Hans Christian von Baeyer


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

Date: Fri, 30 Jun 2000 10:53:53 GMT
From: pjlees@ics.forthcomingevents.gr (Philip Lees)
Subject: Re: Strange behaviour in upper case conversion
Message-Id: <395c717a.1670472@news.grnet.gr>

Thanks to all who responded. I have a clearer idea now of what I was
doing wrong.

Thanks particularly for the pointer to perllocale, which I had
overlooked and will now study.

On Thu, 29 Jun 2000 10:14:06 -0400, tadmc@metronet.com (Tad McClellan)
wrote:

>What you don't see in perlop is any mention of regular
>expressions in connection with tr///

>No mention of regular expressions to be found...

Except that tr is listed under the section:

> Regexp Quote-Like Operators

which begins:

> Here are the quote-like operators that apply to pattern matching and related activities. 
> Most of this section is related to use of regular expressions from Perl. 

That's why I thought there was a connection between the two. Does that
seem unreasonable?

I also found under tr:

> If the SEARCHLIST is delimited by bracketing quotes, the 
> REPLACEMENTLIST has its own pair of quotes, which may 
> or may not be bracketing quotes, e.g., tr[A-Z][a-z] 

Which is how I got confused with the use of [A-Z] with s.

Phil
--
Philip Lees
ICS-FORTH, Heraklion, Crete, Greece
Ignore coming events if you wish to send me e-mail
'The aim of high technology should be to simplify, not complicate' - Hans Christian von Baeyer


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

Date: Fri, 30 Jun 2000 10:43:51 GMT
From: bart.lateur@skynet.be (Bart Lateur)
Subject: Re: Teen Volenteers WANTED
Message-Id: <395e6e56.2435868@news.skynet.be>

Abigail wrote:

>I wasn't claiming that HTML or XML were programming languages, or anything
>other than markup languages.
>
>But markup language is a subclass of language. Markup doesn't invalidate
>language.

>Stick to (sub)thread, please.

I'm pretty sure that the OPs ment "programming language" when they said
"computer language". But, that aside...

Then, what is the definition of "language"? Does it imply "grammar", or
does it indicate a typical means of processing it, e.g. using Lex and
Yacc?

Is the DXF format a language?

The scene description language of raytracers like POV is a language,
that I'm pretty sure. It is structured like a programming language, even
though it describes 3D structures, not a program.

OTOH, I think I've read somewhere that some people actually use XML to
describe programs. For example, a FOR loop could be constructed like:

	<FOR VAR="I" START="1" STOP="10" STEP="2">
	   .... <!-- contents of for loop block here -->
	</FOR>

which would be equivalent to the BASIC FOR loop:

	FOR I=1 to 10 step 2
	   ...
	NEXT I


So... where is the border? What makes a language, what makes a pure data
format but not a language?

-- 
	Bart.


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

Date: 30 Jun 2000 10:19:20 GMT
From: csaba_r@my-deja.com (Csaba Raduly)
Subject: Re: User's details
Message-Id: <8F6370CDFquuxi@193.82.145.131>

26 Jun 2000: A formal bug report was sent to Seti@Home, because the
following message originated from raphaelp@nr1webresource.com
(Raphael Pirker) was reported as containing signs of intelligence: 

>I'll be using this for educational purposes, so I don't want to use
>CGI.pm - I know I could, but the teacher doesn't like me doing stuff
>he doesn't understand... :-)
>
[snip]

In that case, you SHOULD use CGI.pm, to educate your teacher about the 
Right Way (tm) to do it :-)
-- 
Csaba Raduly, Software Developer (OS/2), Sophos Anti-Virus
mailto:csaba.raduly@sophos.com      http://www.sophos.com/
US Support +1 888 SOPHOS 9      UK Support +44 1235 559933
Life is complex, with real and imaginary parts.


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

Date: Fri, 30 Jun 2000 13:22:54 +0200
From: "Dr. Peter Dintelmann" <Peter.Dintelmann@dresdner-bank.com>
Subject: Re: where did the email my perl script sent go?
Message-Id: <8jhvt5$hu53@intranews.dresdnerbank.de>

    Hi Villy,

Villy Kruse schrieb in Nachricht ...
>No MTA is using the To: header line for any routing purpose whatsoever.
>The To: is of the benefit of the receiver and is compaired to the
>receiving addres you type at start of a paper letter.  The Postal service
>can't read that address but uses only the address typed on the envelope.

    you are right with this. I noticed this 5 min after my post.
    Well I should think a little bit longer in future ;-)

    Thanks for putting things right! Any hints for the original
    poster/problem?

        Peter





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

Date: Fri, 30 Jun 2000 12:16:11 +0200
From: "Steven Van Poeck" <steven.van-poeck@SPAM.wanadoo.com>
Subject: Win32 .htpasswd MD5 vs. Perl Digest::MD5 encryption
Message-Id: <8jhs1p$kto$1@wanadoo.fr>

Hello,

I'm tryig to figure out how to make an HTML interface to manage a .htpasswd
file on a Win32 system with Apache 1.3.9.

The htpasswd.exe generates MD5 encryption, which is perfectly understood by
the Apache server. It generates things like
"$apr1$zF4.....$PRSEsb.38HBZHJO4zHsgE/"

I did not find any Perl module that was able to encrypt having a similar
result. I tried Digest::MD5 and MD5 (use MD5), and downloaded
Crypt-PasswdMD5-1.0 but I don't know how to install that on my ActiveState
Perl without using PPM.

Anyone has a clue ? I'm getting desperate :(

Thx,

Steven
mailto:steven.van-poeck@wanadoo.com





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

Date: 16 Sep 99 21:33:47 GMT (Last modified)
From: Perl-Users-Request@ruby.oce.orst.edu (Perl-Users-Digest Admin) 
Subject: Digest Administrivia (Last modified: 16 Sep 99)
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: The mail to news gateway, and thus the ability to submit articles
| through this service to the newsgroup, has been removed. I do not have
| time to individually vet each article to make sure that someone isn't
| abusing the service, and I no longer have any desire to waste my time
| dealing with the campus admins when some fool complains to them about an
| article that has come through the gateway instead of complaining
| to the source.

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 V9 Issue 3522
**************************************


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