[19341] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 1536 Volume: 10

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Wed Aug 15 21:05:31 2001

Date: Wed, 15 Aug 2001 18:05:10 -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: <997923909-v10-i1536@ruby.oce.orst.edu>
Content-Type: text

Perl-Users Digest           Wed, 15 Aug 2001     Volume: 10 Number: 1536

Today's topics:
        "shifting" values of the @_ array?? <miscellaneousemail@yahoo.com>
    Re: accessing multiple hashes and regex <gnarinn@hotmail.com>
        ActivePerl, IIS5, Windows2000 (Tony)
    Re: Any way of detecting running in eval? (Abigail)
        Avoiding symbolic references. <goldbb2@earthlink.net>
    Re: Comma's at end of list can break program?? (Logan Shaw)
    Re: Crypt::RSA, does that exist?  I just want to decode (Torsten Mohr)
    Re: Crypt::RSA, does that exist?  I just want to decode (Torsten Mohr)
        DOS Colorizer <godzilla@stomp.stomp.tokyo>
        Dropping array duplicate values <pschnell@touchpowder.com>
    Re: Dropping array duplicate values <comdog@panix.com>
    Re: Evaluation order of object methods <uri@sysarch.com>
        FAQ: How can I read in an entire file all at once? <faq@denver.pm.org>
    Re: GnuPG::Tie::Encrypt Issue <gnarinn@hotmail.com>
    Re: Ignoring The First Line <ilya@martynov.org>
    Re: Is $! a number or a string? (Abigail)
    Re: Is $! a number or a string? (Abigail)
    Re: Not inserting duplicate elements into an array <godzilla@stomp.stomp.tokyo>
    Re: perldoc is like Greek to a beginner?? <miscellaneousemail@yahoo.com>
    Re: perldoc is like Greek to a beginner?? (Tad McClellan)
    Re: perldoc is like Greek to a beginner?? <miscellaneousemail@yahoo.com>
    Re: print HTML lines - Newbie question <jurgenex@hotmail.com>
    Re: substitution - Linux v Win32 <wyzelli@yahoo.com>
        tutorial for perl/ldap/web (todd)
    Re: tutorial for perl/ldap/web (Chris Fedde)
    Re: Using a fake name on this newsgroup and in places l <noway@nohow.com>
        Why no spaces show up in print of array - sometimes?? <miscellaneousemail@yahoo.com>
    Re: Why no spaces show up in print of array - sometimes (Tad McClellan)
    Re: Why no spaces show up in print of array - sometimes <krahnj@acm.org>
        Win32:EventLog - Security Log <ds@ss.com>
        Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)

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

Date: Thu, 16 Aug 2001 00:19:58 GMT
From: Carlos C. Gonzalez <miscellaneousemail@yahoo.com>
Subject: "shifting" values of the @_ array??
Message-Id: <MPG.15e4bf0bb5a0b96f98975f@news.edmonton.telusplanet.net>

Hi everyone,

I have been studying and playing with the shift operator and was 
wondering...

The following methodX subs all output the same thing.  Is there any 
reason to use one method as opposed to another other than personal 
preference or that one method is used more often than another just 
because?  

Code snippets:

#!/usr/bin/perl -w

use CGI::Carp qw(carpout fatalsToBrowser);
use diagnostics;
use strict;

my @a = qw(Tom Mary Jack);
method1(@a);
method2(@a);
method3(@a);	

sub method1
{
  my $a = shift;
  print " Method - shift: $a\n";
}  

sub method2
{
  my $a = $_[0];
  print " Method - \$_[0]: $a\n";
}  

sub method3
{
  my ($a) = @_;
  print "    Method - \@_: $a\n";
}  

Thanks for any insight on this.

---
Carlos 
www.internetsuccess.ca
*NOTE*: Internet Success is NOT yet fully operational so although you are 
welcomed to visit and take a look, trying to subscribe will only be a 
frustration for you as your data will not be saved at this time.


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

Date: Wed, 15 Aug 2001 21:38:36 +0000
From: gnari <gnarinn@hotmail.com>
Subject: Re: accessing multiple hashes and regex
Message-Id: <997911516.706167051568627.gnarinn@hotmail.com>

In article <cKwe7.690$0M1.9303@e3500-atl1.usenetserver.com>,
Leary <leary@foad.NOSPAM.org> wrote:
>I have 2 hashes, built from seperate sources, that I need to get at. The
>keys should be the same in both hashes. In one hash the keys are integers
>without leading zero's, in the other hash what should be the same keys have
>leading zero's, padded to 5 digits. I was trying to use the code below to
>get at the data. The $aact_names hash has the "non-leading zero" keys.
>
>foreach $key (keys (%acct_tot)) {
>    printf "%10d %30s %15.2f\n", $key, $acct_names{/$key/}, $acct_tot{$key};

do you know what /$key/ is here?

what you want is:
     printf "%10d %30s %15.2f\n", $key, $acct_names{0+$key}, $acct_tot{$key};

>}
>

gnari


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

Date: 15 Aug 2001 17:27:44 -0700
From: theskunk@excite.com (Tony)
Subject: ActivePerl, IIS5, Windows2000
Message-Id: <74f7bcf4.0108151627.62ef1887@posting.google.com>

Has any one else noticed the BIG change in IIS5 and Windows2000 for
configuring Perl?
Instead of the Exclusions (PUT, DELETE) in the App Mappings page they
changed the term to Verbs and they use the exact opposite values (GET,
HEAD, POST). I don't know why they did this...

All I know is that it screwed me up for 3 hours when trying to
configure Perl!

Anyways, hopefully this posting will help another poor soul out there.

T


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

Date: 15 Aug 2001 22:50:54 GMT
From: abigail@foad.org (Abigail)
Subject: Re: Any way of detecting running in eval?
Message-Id: <slrn9nlv72.9sn.abigail@alexandra.xs4all.nl>

lapplisa-no-spam@cotse.com (lapplisa-no-spam@cotse.com) wrote on MMCMVI
September MCMXCIII in <URL:news:bGFwcGxpc2E=.908dfd276d5c102e8ea0b3f2e8b490f7@997893029.cotse.com>:
|| Hi!
|| 
|| Is there any way to detect that code is running in an 
|| eval context? I've tried caller, but that doesn't seem
|| to work.

Well, it's so sad that you cannot bring yourself to tell us anymore
than this. Because caller should work, as the manual page will tell
you. Perhaps you did it wrong. Perhaps your expectations were wrong.
Perhaps there is a bug in Perl.

But you will never find out if you don't share with us what you
did, and what the result was. "doesn't work" is toddler talk.



Abigail
-- 
   my $qr =  qr/^.+?(;).+?\1|;Just another Perl Hacker;|;.+$/;
      $qr =~  s/$qr//g;
print $qr, "\n";


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

Date: Wed, 15 Aug 2001 20:50:43 -0400
From: Benjamin Goldberg <goldbb2@earthlink.net>
Subject: Avoiding symbolic references.
Message-Id: <3B7B18E3.324DB05B@earthlink.net>

I have in a module a for loop which creates a number of subroutines from
a closure.  Normally, one would do something like:

while( my ($name,$args) = each %whatever ) {
	no strict 'refs';
	*{"Package::$name"} = sub { .... };
}

I'm trying to replace this with something like:
while( my ($name,$args) = each %whatever ) {
	$Package::{$name} = sub { .... };
}

Which *should* do what I want, but doesn't seem to work.

Calls to those functions result in errors like "Undefined subroutine
&Package::whatever called at blah.pl line XX"

Anyone want to tell me what's going wrong?

PS: these subs are invoked as methods... which means that if they
weren't getting defined at all, I should be getting an error of the form
'Can't locate object method "whatever" via package "Package" at ...'

-- 
I'm not a programmer but I play one on TV...


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

Date: 15 Aug 2001 17:26:20 -0500
From: logan@cs.utexas.edu (Logan Shaw)
Subject: Re: Comma's at end of list can break program??
Message-Id: <9lesuc$9cf$1@charity.cs.utexas.edu>

In article <slrn9nlq47.9sn.abigail@alexandra.xs4all.nl>,
Abigail <abigail@foad.org> wrote:
>Logan Shaw (logan@cs.utexas.edu) wrote on MMCMIV September MCMXCIII in
>?? few simple syntactic rules?"  Or at least I would, because if "you must
>?? make sure the thing you added at the end has a comma before it" is too
>?? hard a rule to remember and follow, how are you *ever* going to get
>
>I guess you never decide to change the order of things in a list.
>I do. Swapping two lines in vi takes just three characters: ddp.
>And if you swap the last and the one before, you need to add a comma
>if it wasn't already there. I tend to forget those things.

I guess I don't mind typing '$xkp' in the 100/(n-1) percent of the cases
where I have to do that (where n is the number of items in the list).

That'd probably be the difference.  I'm a very visual person, and
unless I'm doing something unfamiliar I usually catch syntax errors
quite easily.  Not that I don't miss them sometimes.  Plus, it is just
automatic at this point to check whether the commas are correct after
doing anything to a list.

>Also, if you do not what that comma there, you need to do extra work if
>you would delete the last item; remove the comma on the line before.

Yes, but it's just there keystrokes ('$x'), and if I forget, it's not a
problem.  :-)

  - Logan
-- 
"Our grandkids love that we get Roadrunner and digital cable."
(Advertisement for Time Warner cable TV and internet access, July 2001)


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

Date: 15 Aug 2001 23:54:51 GMT
From: tmohr@schleim.qwe.de (Torsten Mohr)
Subject: Re: Crypt::RSA, does that exist?  I just want to decode...
Message-Id: <9lf24b$65f$1@schleim.qwe.de>

>> Sadly, c and d (also n) are 1024 bit BigInt numbers.
> 
> So?  Overloading makes things easy:
> 
>     use Math::BigInt ':constant'; # so numbers are born as BigInt's
> 
>     my ( $c, $d, $n) = ( 298, 101, 100);
>     my $m = $c ** $d % $n;
Ok, you use it with 9 bit numbers, i'd like 1024 bit numbers
which really breaks the simple power-mod calculation (time).

> There are simple algorithms, and I'm sure "Applied Kryptography"
> deals with them, or points to sources that do.

You're right i totally overread it, it is on page 285, chapter
11.3.


Thanks,
Torsten.


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

Date: 16 Aug 2001 01:08:58 GMT
From: tmohr@schleim.qwe.de (Torsten Mohr)
Subject: Re: Crypt::RSA, does that exist?  I just want to decode...
Message-Id: <9lf6fa$75d$1@schleim.qwe.de>

> You're right i totally overread it, it is on page 285, chapter
> 11.3.

Ok, here's the algorithm, it results in "+123", as it should
but it's damn slow, did i mess it up?

#! /usr/bin/perl -w

use Math::BigInt;

$n = Math::BigInt->new(
	"227966640524899936815469125349396042386053664575091404379046" .
	"815424060833551474255748000035945380714132391947295315364765" .
	"323409688354743346743152619226085304857261009385201411063108" .
	"763134345918977737199113655937838553792158674260397955708523" .
	"902171848085132050340489604666911179121973619573405510862007" .
	"063383580963015743585394733635239111868091866199201177210773" .
	"456439234520921136819061119613672824558825398521618156809409" .
	"831089673845131322525755190226573904917546668198979349998844" .
	"395319272700792859638267284479561872026489727981628797895729" .
	"442002289476937826278250217391683461907437804687461821317520" .
	"54725431473140843"
);

$d = Math::BigInt->new(
	"210086904013143079026020566498463019453814161471162666780690" .
	"202449624689743515490591294150773193991455341598487839649881" .
	"768632457895547790135846531443647241731201322374597378822864" .
	"938574789376312816634477290766243373102577601769386351339227" .
	"909844644313749144431431596457741674877112943528432529617928" .
	"078020160035225175217504177443254394362886207033446767024578" .
	"644798118541019931677362862948926696678443377863601370904499" .
	"092659431216845569923810770604108317404077723604715870794849" .
	"630557987484792444424408559983569874507347409313614134437834" .
	"571685520239701157254917910337705417512481536295607089515669" .
	"90749167485856667"
);

$c = Math::BigInt->new(
	"384734102417491492310836306336253037213130263862801025922706" .
	"39656218338329902155223714848428224067621714627"
);


$o = modPow(\$c, \$d, \$n);
print "decode :$o\n";

sub modPow {
	my ($x, $y, $nn) = @_;
	my ($s, $t, $u, $n, $tmp);

	$s = Math::BigInt->new("1");
	$t = $$x;
	$u = $$y;
	$n = $$nn;

	while($u) {
		if(substr($u, -1) & 1) {
			$tmp = Math::BigInt->new($s->bmul($t));
			$s = Math::BigInt->new($tmp->bmod($n));
		}
		$u = Math::BigInt->new($u->brsft(1));
		print "u $u\n";
		$tmp = Math::BigInt->new($t->bmul($t));
		$t = Math::BigInt->new($tmp->bmod($n));
	}

	return $s;
}


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

Date: Wed, 15 Aug 2001 15:12:59 -0700
From: "Godzilla!" <godzilla@stomp.stomp.tokyo>
Subject: DOS Colorizer
Message-Id: <3B7AF3EB.2A1CEC65@stomp.stomp.tokyo>


A question came about on changing foreground and
background colors in DOS for running Perl scripts.


* slowly and softly begins singing Donovan's Mellow Yellow *


Add this line to your Win32 Win3.x Win9.x Win.me config.sys
file for boot:

DEVICEHIGH=c:\windows\command\ansi.sys

This will load the ansi driver into high DOS Memory.
Add this line AFTER himem.sys and AFTER emm386.exe
in your config.sys file. Approximately four kilobytes
of DOS high memory will be used.

Be sure ansi.sys is located in c:\windows\command
before adding this line. This is a common location.
Adjust your path as needed. For Win 3.x, it will be
in c:\dos directory. However, what are you doing
running Perl on Win3.x ???


Example:

DEVICE=C:\WINDOWS\HIMEM.SYS
DEVICE=C:\WINDOWS\EMM386.EXE
DEVICEHIGH=c:\windows\command\ansi.sys
DEVICE=c:\windows\setver.exe
[COMMON]
DEVICE=C:\DELL\RTC.CLK +R


You will need to reboot to load the ansi system.


Copy this and name it, godzilla.bat

@ECHO OFF
IF %1!==! GOTO MENU
ECHO ON
ECHO 
GOTO %1
:FOREBLACK
ECHO 
GOTO TOKYO
:FOREBLUE
ECHO 
GOTO TOKYO
:BRIGHTBLUE
ECHO 
GOTO TOKYO
:FORECYAN
ECHO 
GOTO TOKYO
:BRIGHTCYAN
ECHO 
GOTO TOKYO
:FOREGREEN
ECHO 
GOTO TOKYO
:BRIGHTGREEN
ECHO 
GOTO TOKYO
:FOREMAGENTA
ECHO 
GOTO TOKYO
:BRIGHTMAGENTA
ECHO 
GOTO TOKYO
:FORERED
ECHO 
GOTO TOKYO
:BRIGHTRED
ECHO 
GOTO TOKYO
:FOREYELLOW
ECHO 
GOTO TOKYO
:BRIGHTYELLOW
ECHO 
GOTO TOKYO
:FOREWHITE
ECHO 
GOTO TOKYO
:BRIGHTWHITE
ECHO
GOTO TOKYO
:TOKYO
SHIFT
ECHO OFF
GOTO %1
ECHO ON
:BACKBLACK
ECHO 
GOTO STOMPSTOMP
:BACKBLUE
ECHO 
GOTO STOMPSTOMP
:BACKCYAN
ECHO 
GOTO STOMPSTOMP
:BACKGREEN
ECHO 
GOTO STOMPSTOMP
:BACKMAGENTA
ECHO 
GOTO STOMPSTOMP
:BACKRED
ECHO 
GOTO STOMPSTOMP
:BACKYELLOW
ECHO 
GOTO STOMPSTOMP
:BACKWHITE
ECHO 
GOTO STOMPSTOMP
:MENU
ECHO.
ECHO 
ECHO.
ECHO  Godzilla DOS Colorizer!
ECHO  Actual Colors Depend On Your System!
ECHO.
ECHO  Syntax:
ECHO.
ECHO     GODZILLA BrightForeground Background
ECHO.
ECHO     GODZILLA Foreground Background
ECHO.
ECHO  Bright Foreground    Normal Foreground        Background
ECHO  ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ    ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ        ÄÄÄÄÄÄÄÄÄÄ
ECHO   (no black)           FOREBLACK                BACKBLACK
ECHO   BRIGHTBLUE           FOREBLUE                 BACKBLUE
ECHO   BRIGHTCYAN           FORECYAN                 BACKCYAN
ECHO   BRIGHTGREEN          FOREGREEN                BACKGREEN
ECHO   BRIGHTMAGENTA        FOREMAGENTA              BACKMAGENTA
ECHO   BRIGHTRED            FORERED                  BACKRED
ECHO   BRIGHTYELLOW         FOREYELLOW               BACKYELLOW
ECHO   BRIGHTWHITE          FOREWHITE                BACKWHITE
ECHO.
GOTO FINISH
:STOMPSTOMP
CLS
:FINISH


Install godzilla.bat in your root C:\ directory.
Open a DOS box, change to your C:\ directory
and type in,

godzilla

If you cannot figure out what to do from there,
you probably should not be doing this.

For those of you running non-industry standard
browsers and operating systems, such as MSIE,
Opera, Lynx and the such, either upgrade to
an acceptable industry standard compatible
system enabled for eight bit or, download my
batch file as a binary zip file, here:

http://la.znet.com/~callgirl/bat.html


Godzilla!  Queen Of Sunshine Supermen.


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

Date: Thu, 16 Aug 2001 00:34:00 +0100
From: "Paul Schnell" <pschnell@touchpowder.com>
Subject: Dropping array duplicate values
Message-Id: <8GDe7.13846$LN3.3461048@monolith.news.easynet.net>

Hi, The following sub takes input via a post from an
HTML form using CGI.pm, picks up all params whose
keys start with 'band_' and maps the values to @new,
drops any duplicates and then saves results. It works
fine but I was wondering if there is a way of checking
for duplicates without the %seen and grep line.

 ...just out of interest.

my $cgi = new CGI;

sub update {

    my @new = map { $cgi->param($_) if /^band_/ } $cgi->param;

    # drop duplicates [Perl Cookbook]
    my %seen;
    @new = grep { !$seen{$_}++ } @new;
    save_bands( \@new );
 }

Thanks,
Paul




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

Date: Wed, 15 Aug 2001 20:47:54 -0400
From: brian d foy <comdog@panix.com>
Subject: Re: Dropping array duplicate values
Message-Id: <comdog-24CD5A.20475415082001@news.panix.com>

In article <8GDe7.13846$LN3.3461048@monolith.news.easynet.net>, "Paul 
Schnell" <pschnell@touchpowder.com> wrote:

> Hi, The following sub takes input via a post from an
> HTML form using CGI.pm, picks up all params whose
> keys start with 'band_' and maps the values to @new,
> drops any duplicates and then saves results. It works
> fine but I was wondering if there is a way of checking
> for duplicates without the %seen and grep line.

> sub update {
> 
>     my @new = map { $cgi->param($_) if /^band_/ } $cgi->param;

my %new = map { ( $cgi->param($_), 1 ) if /^band_/ } $cgi-param;
@new = keys %new;

-- 
brian d foy <comdog@panix.com>
CGI Meta FAQ - http://www.perl.org/CGI_MetaFAQ.html
Troubleshooting CGI scripts - http://www.perl.org/troubleshooting_CGI.html



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

Date: Wed, 15 Aug 2001 22:21:34 GMT
From: Uri Guttman <uri@sysarch.com>
Subject: Re: Evaluation order of object methods
Message-Id: <x7n151j768.fsf@home.sysarch.com>

>>>>> "S" == Sunblade  <djberge@uswest.com> writes:

  S> I didn't mean for this to become the focus of the critique.  The
  S> point is to eventually create Ruby-like arrays - i.e. arrays as
  S> objects so that I can do something like:

  S> my $sa = Some::Object->new(1,2,3,4,5,2,3,4);
  S> print $sa->unique()->length();

you can still do that. just always return the object from the call to
unique. it then becomes a side effect method and all it does is uniquify
@array.

but even so, using a single global @array for the object's data is not a
good idea either. you can make the object itself the array that holds
the data and that makes life much cleaner:

package Array ;

sub new {
	my( $class, @array ) = @_ ;
	return bless \@array, $class ;
}

sub length {
	my( $self ) = @_ ;
	return scalar @{$self} ;
}

sub unique {

	my( $self ) = @_ ;

	@{$self} = keys %{ map { $_, 1 } @{$self} } ;

	return $self ;
}

think in perlish ways, not rubyish.

uri

-- 
Uri Guttman  ---------  uri@sysarch.com  ----------  http://www.sysarch.com
SYStems ARCHitecture and Stem Development ------ http://www.stemsystems.com
Search or Offer Perl Jobs  --------------------------  http://jobs.perl.org


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

Date: Thu, 16 Aug 2001 00:17:05 GMT
From: PerlFAQ Server <faq@denver.pm.org>
Subject: FAQ: How can I read in an entire file all at once?
Message-Id: <5iEe7.135$V3.170984960@news.frii.net>

This message is one of several periodic postings to comp.lang.perl.misc
intended to make it easier for perl programmers to find answers to
common questions. The core of this message represents an excerpt
from the documentation provided with every Standard Distribution of
Perl.

+
  How can I read in an entire file all at once?

    The customary Perl approach for processing all the lines in a file is to
    do so one line at a time:

        open (INPUT, $file)         || die "can't open $file: $!";
        while (<INPUT>) {
            chomp;
            # do something with $_
        } 
        close(INPUT)                || die "can't close $file: $!";

    This is tremendously more efficient than reading the entire file into
    memory as an array of lines and then processing it one element at a
    time, which is often--if not almost always--the wrong approach. Whenever
    you see someone do this:

        @lines = <INPUT>;

    you should think long and hard about why you need everything loaded at
    once. It's just not a scalable solution. You might also find it more fun
    to use the standard DB_File module's $DB_RECNO bindings, which allow you
    to tie an array to a file so that accessing an element the array
    actually accesses the corresponding line in the file.

    On very rare occasion, you may have an algorithm that demands that the
    entire file be in memory at once as one scalar. The simplest solution to
    that is

        $var = `cat $file`;

    Being in scalar context, you get the whole thing. In list context, you'd
    get a list of all the lines:

        @lines = `cat $file`;

    This tiny but expedient solution is neat, clean, and portable to all
    systems on which decent tools have been installed. For those who prefer
    not to use the toolbox, you can of course read the file manually,
    although this makes for more complicated code.

        {
            local(*INPUT, $/);
            open (INPUT, $file)     || die "can't open $file: $!";
            $var = <INPUT>;
        }

    That temporarily undefs your record separator, and will automatically
    close the file at block exit. If the file is already open, just use
    this:

        $var = do { local $/; <INPUT> };

- 

Documents such as this have been called "Answers to Frequently
Asked Questions" or FAQ for short.  They represent an important
part of the Usenet tradition.  They serve to reduce the volume of
redundant traffic on a news group by providing quality answers to
questions that keep coming up.

If you are some how irritated by seeing these postings you are free
to ignore them or add the sender to your killfile.  If you find
errors or other problems with these postings please send corrections
or comments to the posting email address or to the maintainers as
directed in the perlfaq manual page.

Answers to questions about LOTS of stuff, mostly not related to
Perl, can be found by pointing your news client to

    news:news.answers

or to the many thousands of other useful Usenet news groups.

Note that the FAQ text posted by this server may have been modified
from that distributed in the stable Perl release.  It may have been
edited to reflect the additions, changes and corrections provided
by respondents, reviewers, and critics to previous postings of
these FAQ. Complete text of these FAQ are available on request.

The perlfaq manual page contains the following copyright notice.

  AUTHOR AND COPYRIGHT

    Copyright (c) 1997-1999 Tom Christiansen and Nathan
    Torkington.  All rights reserved.

This posting is provided in the hope that it will be useful but
does not represent a commitment or contract of any kind on the part
of the contributers, authors or their agents.

                                                           05.24
-- 
    This space intentionally left blank


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

Date: Wed, 15 Aug 2001 21:52:39 +0000
From: gnari <gnarinn@hotmail.com>
Subject: Re: GnuPG::Tie::Encrypt Issue
Message-Id: <997912359.164522782433778.gnarinn@hotmail.com>

In article <c36b2f02.0108150834.5c15fbd4@posting.google.com>,
Blixa Bargeld <taviny@hotmail.com> wrote:
>Hi. I'm having a problem with this Perl module. I have a cgi script
>that takes data from a form, encrypts it & sends it along in an email
>message. When executed from a browser my script is crashing & I've
>pinpointed it to be at the point where I try to encrypt the data.

what do you mean 'crash' ?
are you using CGI::Carp qw(fatalsToBrowser); ?
what is the errormessage then?
else what do the logs say?


> The
>code I'm using to encrypt is similar to this:
>

careful about the 'similar' thing. that is useless for locating
typoes.

(snipped 'similar' code)

>The funny thing is this works fine from the command line (when I'm
>logged in with my userid). I know that the web server executes as
>'nobody' so is this possibly a permissions issue? If so, how do I get
>around this?

if it is a permissions issue, it could be a question of a tempfile.
try to find out whether a temp file is created, and if so where
it is put. make sure 'nobody' has write permissions to that directory.

the other possibility is environment. does the module need any
environment variables?

gnari


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

Date: 16 Aug 2001 02:11:54 +0400
From: Ilya Martynov <ilya@martynov.org>
Subject: Re: Ignoring The First Line
Message-Id: <87ae11km6t.fsf@abra.ru>

PL> I've got the "reverse" problem in that my 1st line is ignored!!
PL> As a beginner, I did a "quick & dirty" to remove the "\000" that
PL> was passed into my resolv.conf; the "\000" is in ascii readable/printable
PL> mode.  I have since did a shell script that just executes
PL> "/usr/bin/perl -pe ......etc" which works but still wonder why my perl
PL> script loosed the 1st line.  The code is as follows:
PL>   =================================================================

PL> #!/usr/bin/perl
PL> #
PL> #
PL> # to remove the '\000' created by /sbin/dhclient-script
PL> #  
PL> #
PL> print "running /usr/local/sbin/resolvchg................"
PL> #
PL> open (OLDFILE, "/etc/resolv.conf");
PL> open (NEWFILE, ">/etc/resolv.conf.new");
PL> while (<OLDFILE>)    {
PL>       s/'\000'//;

Should not it be s/\000//;?

PL>       print NEWFILE <OLDFILE>;
                        ^^^^^^^^^

It should be

    print NEWFILE $_;

PL>                      }
PL> close OLDFILE;
PL> close NEWFILE;
PL> rename ('/etc/resolv.conf.new', '/etc/resolv.conf');
PL> #

You script will pass only even lines

while(<OLDFILE>) reads odd line
print NEWFILE <OLDFILE> reads even line and prints its

BTW instead of your script you can use this one-liner:

perl -i -pe 's/\000//' /etc/resolv.conf

See 'perldoc perlrun' for description of -i, -p and -e switches.

-- 
 -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
| Ilya Martynov (http://martynov.org/)                                    |
| GnuPG 1024D/323BDEE6 D7F7 561E 4C1D 8A15 8E80  E4AE BE1A 53EB 323B DEE6 |
| AGAVA Software Company (http://www.agava.com/)                          |
 -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-


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

Date: 15 Aug 2001 22:21:08 GMT
From: abigail@foad.org (Abigail)
Subject: Re: Is $! a number or a string?
Message-Id: <slrn9nltf6.9sn.abigail@alexandra.xs4all.nl>

Philip Newton (pne-news-20010815@newton.digitalspace.net) wrote on MMCMVI
September MCMXCIII in <URL:news:ns4kntcvqi3apie87d64cj2hksq3r5qqu0@4ax.com>:
'' On 14 Aug 2001 19:18:38 -0700, johnlin@chttl.com.tw (John Lin) wrote:
'' 
'' > I guess there is a kind of variable that keeps a numeric value but
'' > display differently when stringified.  This explains #1: #2: and #3:.
'' 
'' Precisely. It's even documented in the documentation, surprise surprise:
'' 
'' :  $OS_ERROR
'' :  $ERRNO
'' :  $!      If used in a numeric context, yields the current value of
'' :          errno, with all the usual caveats. (This means that you
'' :          shouldn't depend on the value of `$!' to be anything in
'' :          particular unless you've gotten a specific error return
'' :          indicating a system error.) If used in a string context,
'' :          yields the corresponding system error string.
'' 
'' > My questions are:
'' > 
'' > How many "this kind" of variables exist in Perl (built-in)?
'' 
'' I only know of $! having this dual nature.
'' 
'' > Can I make this magic of my own?  (I believe the answer is "Yes".)
'' 
'' Correct. You need XS code, however; you can't do it in pure Perl.

Of course you can. Just use a combination of overload and tie.



Abigail
-- 
               split // => '"';
${"@_"} = "/"; split // => eval join "+" => 1 .. 7;
*{"@_"} = sub {foreach (sort keys %_)  {print "$_ $_{$_} "}};
%{"@_"} = %_ = (Just => another => Perl => Hacker); &{%{%_}};


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

Date: 15 Aug 2001 22:45:56 GMT
From: abigail@foad.org (Abigail)
Subject: Re: Is $! a number or a string?
Message-Id: <slrn9nlutp.9sn.abigail@alexandra.xs4all.nl>

Philip Newton (pne-news-20010815@newton.digitalspace.net) wrote on MMCMVI
September MCMXCIII in <URL:news:ns4kntcvqi3apie87d64cj2hksq3r5qqu0@4ax.com>:
** On 14 Aug 2001 19:18:38 -0700, johnlin@chttl.com.tw (John Lin) wrote:
** 
** I only know of $! having this dual nature.
** 
** > Can I make this magic of my own?  (I believe the answer is "Yes".)
** 
** Correct. You need XS code, however; you can't do it in pure Perl. The

Pure Perl:


#!/opt/perl/bin/perl

use strict;
use warnings 'all';

package Dual;

use overload  '0+'     => \&numify,
              '""'     => \&stringify,
              fallback =>  1,
;

sub new {
    my $proto = shift;
    my $class = ref $proto || $proto;

    bless \(my $foo = shift) => $class;
}


sub numify {
    ${$_ [0]}
}

my @R = ([M => 1000], [CM => 900], [D => 500], [CD => 400],
         [C =>  100], [XC =>  90], [L =>  50], [XL =>  40],
         [X =>   10], [IX =>   9], [V =>   5], [IV =>   4],
         [I =>    1]);
sub stringify {
    my $d = ${$_[0]};
    my $o = "";
    my $i = 0;
    while ($i < @R) {
        while ($d >= $R [$i] -> [1]) {
               $o .= $R [$i] -> [0];
               $d -= $R [$i] -> [1]
        }
        $i ++;
    }
    $o;
}

package Roman;

sub TIESCALAR {
    my $proto = shift;
    my $class = ref $proto || $proto;

    bless \(my $foo) => $class;
}

sub FETCH {${$_ [0]}}
sub STORE {${$_ [0]} = Dual -> new ($_ [1])}

package main;

tie my ($romeral) => "Roman";

foreach my $num (12, 100, 99, 54, 63, 997, 2113) {
    $romeral = $num;
    print "The number ", 0 + $romeral, " is $romeral as a Roman number.\n";
}


__END__
The number 12 is XII as a Roman number.
The number 100 is C as a Roman number.
The number 99 is XCIX as a Roman number.
The number 54 is LIV as a Roman number.
The number 63 is LXIII as a Roman number.
The number 997 is CMXCVII as a Roman number.
The number 2113 is MMCXIII as a Roman number.



Abigail
-- 
perl -wle 'print sub {} -> ("Just another Perl Hacker")'
#    A woodpecker flies
#    over the river. A beetle
#    in a maple.


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

Date: Wed, 15 Aug 2001 15:19:20 -0700
From: "Godzilla!" <godzilla@stomp.stomp.tokyo>
Subject: Re: Not inserting duplicate elements into an array
Message-Id: <3B7AF568.8B406ED5@stomp.stomp.tokyo>

Yves Orton blathered, drooled and told lies:
 
> Godzilla! wrote:
> > Jasper McCrea aka Yves Orton aka The CLPM Troll aka Ad Nauseam trolled:
> > > Godzilla! wrote

 (snipped)


There is no doubt about your enjoying being the
loving mouthpiece for geekster boys around here.


Godzilla!


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

Date: Wed, 15 Aug 2001 23:08:28 GMT
From: Carlos C. Gonzalez <miscellaneousemail@yahoo.com>
Subject: Re: perldoc is like Greek to a beginner??
Message-Id: <MPG.15e4ae9bf7a7b3898975c@news.edmonton.telusplanet.net>

In article <slrn9nlrlb.9sn.abigail@alexandra.xs4all.nl>, Abigail at 
abigail@foad.org says...

Hi Abigail. I was just wondering what the following lines at the bottom 
of your post mean?  I take it it is some kind of fancy signature in Perl 
or something similar? 

sub J::FETCH{Just   }$_.='print+"@{[map';sub J::TIESCALAR{bless\my$J,J}
sub A::FETCH{Another}$_.='{tie my($x),$';sub A::TIESCALAR{bless\my$A,A}
sub P::FETCH{Perl   }$_.='_;$x}qw/J A P';sub P::TIESCALAR{bless\my$P,P}
sub H::FETCH{Hacker }$_.=' H/]}\n"';eval;sub H::TIESCALAR{bless\my$H,H}

Just curious...

---
Carlos 
www.internetsuccess.ca
*NOTE*: Internet Success is NOT yet fully operational so although you are 
welcomed to visit and take a look, trying to subscribe will only be a 
frustration for you as your data will not be saved at this time.


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

Date: Wed, 15 Aug 2001 19:05:59 -0400
From: tadmc@augustmail.com (Tad McClellan)
Subject: Re: perldoc is like Greek to a beginner??
Message-Id: <slrn9nm02n.312.tadmc@tadmc26.august.net>

Carlos C. Gonzalez <miscellaneousemail@yahoo.com> wrote:
>In article <slrn9nlrlb.9sn.abigail@alexandra.xs4all.nl>, Abigail at 
>abigail@foad.org says...
>
>Hi Abigail. I was just wondering what the following lines at the bottom 
>of your post mean?  I take it it is some kind of fancy signature in Perl 
>or something similar? 
>
>sub J::FETCH{Just   }$_.='print+"@{[map';sub J::TIESCALAR{bless\my$J,J}
>sub A::FETCH{Another}$_.='{tie my($x),$';sub A::TIESCALAR{bless\my$A,A}
>sub P::FETCH{Perl   }$_.='_;$x}qw/J A P';sub P::TIESCALAR{bless\my$P,P}
>sub H::FETCH{Hacker }$_.=' H/]}\n"';eval;sub H::TIESCALAR{bless\my$H,H}


Put it in a file. Execute it. See what it does.


>Just curious...


Here are some more JAPHs:

   http://www.perl.com/CPAN-local/misc/japh


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


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

Date: Thu, 16 Aug 2001 00:33:01 GMT
From: Carlos C. Gonzalez <miscellaneousemail@yahoo.com>
Subject: Re: perldoc is like Greek to a beginner??
Message-Id: <MPG.15e4c2b54f0a7df989760@news.edmonton.telusplanet.net>

In article <slrn9nm02n.312.tadmc@tadmc26.august.net>, Tad McClellan at 
tadmc@augustmail.com says...

> Put it in a file. Execute it. See what it does.

> Here are some more JAPHs:
> 
>    http://www.perl.com/CPAN-local/misc/japh

Boy.  Just when you think that you are starting to understand Perl you 
see something like that.  Good golly gee!  You all must actually think in 
Perl like some people think in a foreign language.  

Makes me feel like I am still in diapers. Wah! Wah! =:).

---
Carlos 
www.internetsuccess.ca
*NOTE*: Internet Success is NOT yet fully operational so although you are 
welcomed to visit and take a look, trying to subscribe will only be a 
frustration for you as your data will not be saved at this time.


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

Date: Wed, 15 Aug 2001 15:25:10 -0700
From: "Jürgen Exner" <jurgenex@hotmail.com>
Subject: Re: print HTML lines - Newbie question
Message-Id: <3b7af6c7$1@news.microsoft.com>

"leo white" <leowhite@btinternet.com> wrote in message
news:3e5e52b3.0108151400.56f8ec38@posting.google.com...
> Am I right in thinking that such a module has to be installed on the
> server?
> I am hosting with easyspace.com and I dont have access permission to
> install stuff other than in my cgi bin - is there a way to use
> templates with such a setup or any tutorials that may help?

See PerlFAQ8: "How do I keep my own module/library directory".
It's the first answer for "perldoc -q library"

jue




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

Date: Thu, 16 Aug 2001 10:07:27 +0930
From: "Wyzelli" <wyzelli@yahoo.com>
Subject: Re: substitution - Linux v Win32
Message-Id: <%vEe7.33$wg1.72954@wa.nnrp.telstra.net>

"gnari" <gnarinn@hotmail.com> wrote in message
news:997896530.55457221576944.gnarinn@hotmail.com...
> In article <nfne7.73$1T.191471@wa.nnrp.telstra.net>,
> Wyzelli <wyzelli@yahoo.com> wrote:
> >
> >I have a squid log file on my Linux server, which I want to copy onto my
> >local drive (win2k) before processing.
> >
<snip>
> >
> >perl -p -i*.bak -e "s/\r\n/\n/g" filename
>
> maybe i am missing something, but i understood that you want to
> move a unix test file to win for processing there.
> unix text files have \012 (LF), and win files have \015\012 (CRLF)
>
> so you want co convert LF to CRLF, not the other way around

Well I'm a goose, I was doing it bass ackwards!  <blush in shame>.

Wierd thing is that it was working (for some definition of 'working' meaning
notepad could read the file properly) on the Win32 command line, so that
didn't help me see the error of my ways.

Thanks for the pointer.  (Yes, works fine now....)

Wyzelli
--
push@x,$_ for(a..z);push@x,' ';
@z='092018192600131419070417261504171126070002100417'=~/(..)/g;
foreach $y(@z){$_.=$x[$y]}y/jp/JP/;print;




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

Date: 15 Aug 2001 17:39:10 -0700
From: todd_sargent@mentor.com (todd)
Subject: tutorial for perl/ldap/web
Message-Id: <53626290.0108151639.3609e470@posting.google.com>

Could anyone kindly suggest a good tutorial on creating the
server-side perl code and web interface to hook into an ldap server?

Thank you for any assistance.


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

Date: Thu, 16 Aug 2001 00:49:43 GMT
From: cfedde@fedde.littleton.co.us (Chris Fedde)
Subject: Re: tutorial for perl/ldap/web
Message-Id: <HMEe7.136$V3.191999488@news.frii.net>

In article <53626290.0108151639.3609e470@posting.google.com>,
todd <todd_sargent@mentor.com> wrote:
>Could anyone kindly suggest a good tutorial on creating the
>server-side perl code and web interface to hook into an ldap server?
>
>Thank you for any assistance.

You mean something more than the article in the recent perl journal?

good luck
-- 
    This space intentionally left blank


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

Date: Thu, 16 Aug 2001 00:14:25 GMT
From: "Buck Turgidson" <noway@nohow.com>
Subject: Re: Using a fake name on this newsgroup and in places like perlmonks??
Message-Id: <BfEe7.122512$J37.30235116@typhoon.southeast.rr.com>

When I run for the Senate 20 years from now, I don't want my enemies
dredging up any unseemly ranting and ravings that I've posted.

Buck




"Carlos C. Gonzalez" <miscellaneousemail@yahoo.com> wrote in message
news:MPG.15e396a698e576af989748@news.edmonton.telusplanet.net...
> Hi everyone,
>
> I've been looking around at www.perlmonks.org and noticed that
everyone
> there goes by fake names such as reptile, ChemBoy, and others.
Sometimes
> I see some usenet messages from others that way too.  I've even
gotten
> some usenet messages that have real sounding names only to learn
later
> when the authors email me that they are called by some other name.
>
> Maybe I am being naive about the Internet or something but I was
> wondering why people use fake names so much?  Especially when
discussing
> something as acceptable as Perl?
>
> I could understand it if say one was the President and wanted to
remain
> anonymous in order to be able to speak freely without having the
press
> blow everything out of proportion but for the average Perl
programmer is
> there a reason to hide one's identity?
>
> I don't know.  I am asking sincerely.  Maybe I am missing something
and
> should start hiding my real name too but it would seem that using a
fake
> name would open the door for me to not be accountable for what I say
> (since it wouldn't be me saying it sort of thing).
>
> Any thoughts on this?
>
> ---
> Carlos
> www.internetsuccess.ca
> *NOTE*: Internet Success is NOT yet fully operational so although
you are
> welcomed to visit and take a look, trying to subscribe will only be
a
> frustration for you as your data will not be saved at this time.




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

Date: Wed, 15 Aug 2001 23:33:59 GMT
From: Carlos C. Gonzalez <miscellaneousemail@yahoo.com>
Subject: Why no spaces show up in print of array - sometimes??
Message-Id: <MPG.15e4b4eb10d53c2398975d@news.edmonton.telusplanet.net>

Hi everyone,

Can someone explain to me why the second print (after the call to the 
temp sub) prints out without any spaces between the names in the 
following code?  Or for that matter why there are spaces in the first 
print?  I was working on trying to understand the shift function and was 
curious as to the output produced. 

If I print "@a\n" the second print, the output results in spaces between 
all names.

#!/usr/bin/perl -w

use CGI::Carp qw(carpout fatalsToBrowser);
use diagnostics;
use strict;

my @a = qw(Tom Mary Jack);
temp(@a);
print @a;

sub temp
{
  my (@a) = @_;
  my $b = shift; # shift occurs on @_ array in sub context.
  print "@a\n";
  print "$b\n";
}

=pod 
Output is:

Tom Mary Jack
Tom
TomMaryJack
=cut

Thanks.

---
Carlos 
www.internetsuccess.ca
*NOTE*: Internet Success is NOT yet fully operational so although you are 
welcomed to visit and take a look, trying to subscribe will only be a 
frustration for you as your data will not be saved at this time.


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

Date: Wed, 15 Aug 2001 19:08:36 -0400
From: tadmc@augustmail.com (Tad McClellan)
Subject: Re: Why no spaces show up in print of array - sometimes??
Message-Id: <slrn9nm07k.312.tadmc@tadmc26.august.net>

Carlos C. Gonzalez <miscellaneousemail@yahoo.com> wrote:

>Can someone explain to me why the second print (after the call to the 
>temp sub) prints out without any spaces between the names in the 
>following code?  


Because

  $, = '';


>Or for that matter why there are spaces in the first 
>print?  


Because

  $" = ' ';


>I was working on trying to understand the shift function and was 
>curious as to the output produced. 


   perldoc perlvar


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


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

Date: Wed, 15 Aug 2001 23:56:36 GMT
From: "John W. Krahn" <krahnj@acm.org>
Subject: Re: Why no spaces show up in print of array - sometimes??
Message-Id: <3B7B0C32.6F9162D2@acm.org>

"Carlos C. Gonzalez" wrote:
> 
> Can someone explain to me why the second print (after the call to the
> temp sub) prints out without any spaces between the names in the
> following code?  Or for that matter why there are spaces in the first
> print?  I was working on trying to understand the shift function and was
> curious as to the output produced.
> 
> If I print "@a\n" the second print, the output results in spaces between
> all names.

perldoc perlvar

[snip]
       $LIST_SEPARATOR

       $"      This is like `$,' except that it applies to array
               and slice values interpolated into a double-quoted
               string (or similar interpreted string).  Default
               is a space.  (Mnemonic: obvious, I think.)


Also have a look at $, and $\



John
-- 
use Perl;
program
fulfillment


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

Date: Wed, 15 Aug 2001 23:49:06 GMT
From: GunneR <ds@ss.com>
Subject: Win32:EventLog - Security Log
Message-Id: <ntmont8ovc37bu4hkddqqttd9tvqp3vn5b@4ax.com>

I can write to the application and system logs but no dice on the
security log (says file not found when I use the Report function). I
can clear and read the security event log but I just cant seem to
write to it. Any ideas or is this simply impossible due to WinNT?


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

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


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