[8864] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 2481 Volume: 8

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Sun May 3 03:06:02 1998

Date: Sun, 3 May 98 00:00:33 -0700
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)

Perl-Users Digest           Sun, 3 May 1998     Volume: 8 Number: 2481

Today's topics:
    Re: 1701 days hath September (was: Re: rename funciton) <rjk@coos.dartmouth.edu>
    Re: A bug in localtime() (Alex Dong Li)
    Re: A bug in localtime() <rootbeer@teleport.com>
    Re: A bug in localtime() (Jonathan Stowe)
    Re: Apache Logfile Parser? (Gabor)
    Re: Can Perl execute a shell command? (Jonathan Stowe)
    Re: Converting COBOL Comp-3 field <btate@primary.net>
    Re: Converting COBOL Comp-3 field <rootbeer@teleport.com>
    Re: Converting COBOL Comp-3 field <btate@primary.net>
    Re: editor? (Gabor)
    Re: Encryption of perl scripts (Philosopher King)
    Re: Encryption of perl scripts (Jonathan Stowe)
    Re: Encryption of perl scripts <gurun@acc.umu.se>
    Re: extracting a sub-string (Hakan Hjelmstrom)
        HELP win32 perl (Taran)
    Re: looking for a little bit of help here. <rjk@coos.dartmouth.edu>
        Newbie config CGI question <qazmlp@ix.netcom.com>
    Re: QRe: == vs. eq <gurun@acc.umu.se>
    Re: randal stars in merlin! (David Adler)
    Re: Ref to an LVALUE???  I expected a simple SCALAR ref <eryq@zeegee.com>
    Re: regex help <rjk@coos.dartmouth.edu>
    Re: Style question: trouble with $_ ... <rootbeer@teleport.com>
        Use of Uninitialized Value rpearce@fastlane.net
    Re: Use of Uninitialized Value (Tad McClellan)
        Digest Administrivia (Last modified: 8 Mar 97) (Perl-Users-Digest Admin)

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

Date: Sun, 03 May 1998 01:25:25 -0400
From: Ronald J Kimball <rjk@coos.dartmouth.edu>
Subject: Re: 1701 days hath September (was: Re: rename funciton)
Message-Id: <354BFFC5.E2D597AA@coos.dartmouth.edu>

John Stanley wrote:
> 
> Yes, the words written are as you say. However, in this context, the
> issue is requiring spammable addresses, and some people cannot afford
> the cost of email spam just so they can post to USENET.  This means it
> is not really a choice, even though people keep wanting to couch it in
> those terms.

And there are people who can't afford the time to read and post to USENET, and
people who can't afford a computer to post to USENET, and people who...

Yes, it is a choice.  TANSTAAFL.  There are always costs.  It's your decision
whether you are willing to pay those costs.

No one would be prevented from using the moderated newsgroup.  Anyone who
doesn't has made a choice not to, for whatever reason.

-- 
 _ / '  _      /         - aka -             rjk@coos.dartmouth.edu
( /)//)//)(//)/(    Ronald J. Kimball           chipmunk@m-net.arbornet.org
    /                                   http://www.ziplink.net/~rjk/
        "It's funny 'cause it's true ... and vice versa."


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

Date: Sun, 03 May 1998 05:34:40 GMT
From: ali@genet.sickkids.on.ca (Alex Dong Li)
Subject: Re: A bug in localtime()
Message-Id: <6igkuq$lmm$1@resunix.sickkids.on.ca>

First, thank you all very much for your help and suggestion! I tried to thank 
you guys personally but somehow could not reach you via email.

Secondly, yes, I got 4 for May. I am just curious: if 0 is for January, but 
why not 0 for the first day of a month too? Why the second day is 2?, not 
offset to 1?

Regards,

Alex


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

Date: Sun, 03 May 1998 03:19:35 GMT
From: Tom Phoenix <rootbeer@teleport.com>
To: Alex Dong Li <ali@genet.sickkids.on.ca>
Subject: Re: A bug in localtime()
Message-Id: <Pine.GSO.3.96.980502201831.8809U-100000@user2.teleport.com>

On Sun, 3 May 1998, Alex Dong Li wrote:

> Secondly, yes, I got 4 for May. I am just curious: if 0 is for January, but 
> why not 0 for the first day of a month too? Why the second day is 2?, not 
> offset to 1?

Array indices start at zero, so numbers which will typically be used as
indices in arrays start at zero. Hope this helps!

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



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

Date: Fri, 01 May 1998 17:57:51 GMT
From: Gellyfish@btinternet.com (Jonathan Stowe)
Subject: Re: A bug in localtime()
Message-Id: <354a08f6.29149301@news.btinternet.com>

On Sun, 03 May 1998 05:34:40 GMT, Alex Dong Li wrote :

>First, thank you all very much for your help and suggestion! I tried to thank 
>you guys personally but somehow could not reach you via email.
>
>Secondly, yes, I got 4 for May. I am just curious: if 0 is for January, but 
>why not 0 for the first day of a month too? Why the second day is 2?, not 
>offset to 1?
>

Hey, the fat lady is in the bag and the cats about to sing (tm)

The thing is here that the day in the month dis nay get considered as
an array element.  There is no valuable information to be had with an
array indexed by $mday whereas $months[$mon] and $day[$wday] have a
value well known by all users of the western calendar.  The $yday also
runs 1 -> 36[56].

Clarissa,sister,mother !!

/J\
Jonathan Stowe
Some of your questions answered:
<URL:http://www.btinternet.com/~gellyfish/resources/wwwfaq.htm>



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

Date: 3 May 1998 04:35:09 GMT
From: gabor@vmunix.com (Gabor)
Subject: Re: Apache Logfile Parser?
Message-Id: <slrn6knt6q.onl.gabor@vnode.vmunix.com>

In comp.lang.perl.misc, jay <mocat@best.com> wrote :
# 
# I'm helping a friend of mine with a few scripts for his new server... 
# what he needs is an Apache logfile parser
# (/var/log/www/hostname/access.log)...
# Was wondering if there is a module to make this easier on myself, or do I
# have to do it manually?
# Either way, it's no problem.... just wondering.

I have written one.  Look at 
www.vmunix.com/~gabor/perl/logstats.pl
type 'logstats.pl -h' for help

I hope this is what you were looking for.


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

Date: Fri, 01 May 1998 16:32:29 GMT
From: Gellyfish@btinternet.com (Jonathan Stowe)
Subject: Re: Can Perl execute a shell command?
Message-Id: <3549ef30.23326372@news.btinternet.com>

On Sat, 2 May 1998 20:54:41 -0400, Rod Wintle wrote :

>Hi,
>
>Is it possible for me to use perl to collect variables and then have the
>perl script call a shell command?
>
Oh dear, of course it is.  If it were a full moon I might turn into
Tom Christiansen and flame you for using  "that paragon of
idiocy","the execrable Microsoft Outlook Express 4.72.2106.4"

(Dont get freaked out Tom I thought they were so funny I collected
them for a while )

But it isnt and I wont.

There are at least three methods for doing so elucidated in the Perl
documentation.  However I just grepped through the perlfaq with your
subject line and  didnt find anything I would find appropriate if I
didnt know what to look for, so here are they keywords to look for:
"backticks",system","fork","exec" in that order probably (Sorry I
forgot you were a POB, disregard the last two).

>Say I want to collect the name of a machine and then have the script ping
>the machine...
>

I would say use Net::Ping if thats what you want to do.   (pinging I
mean).  Try it out and if you have any further problems that are not
covered in the documentation and are to do with Perl please post a
small sample so we can see what the problem is.

/J\
Jonathan Stowe
Some of your questions answered:
<URL:http://www.btinternet.com/~gellyfish/resources/wwwfaq.htm>



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

Date: Sat, 2 May 1998 21:03:22 -0500
From: "Bob Tate" <btate@primary.net>
Subject: Re: Converting COBOL Comp-3 field
Message-Id: <354bd099.0@news.primary.net>

Tom,

Although I cannot show you the file with the field that I am trying to
convert due to the sensitive nature of the information that is in it I will
try to explain what I already know.

Here is one such number that is in this file.  It is a payroll number (PRN).

PRN = 97818

I know this because it is displayed elsewhere in the file.

The filed that I wish to use to identify the PRN is in a COMP-3 format.  Why
I wish to use this field and not one that is not encoded is simple.  The
coded field appears on every line in the same place while the unencoded PRN
info does not.  It is very important that PRN 97818 only be able to view his
pay record and not someone else's.

the comp-3 field is S9(7) COMP-3.

what this means, assuming that you are not completely familiar with COBOL,
is that a COMP-3 field is encoded to save space in the file.  "S" means
secured, "9" means that it is numeric only and "(7)" means that it is
7-numbers long.  COMP-3 means that it is the length of the field "7" plus
"1" divided by "2".  So, instead of taking up "8" bytes in the file it will
only occupy 4.

Now, remember that my PRN = 97818.  The file displays that the now 4 byte
field is in Hex (00 70 61 C6).
What the info needs to look like, after converting the HEX to COMP-3 is (00
97 81 8C).  If you noticed, the COMP-3 format displays the PRN.  The extra
bit at the end is the "sign" indicator.  "C" indicates a positive number,
"D" is a negative number, and "F" is an unsigned number.

As you can see, once I can get the HEX to convert/display in COMP-3 (BCD)
format then it is a snap for me to see what the PRN is.

I kinda of ran on and on here but I think you should see what I am looking
for.

Perl as an Unpack command and I have tried to make use of it but either the
commend is not the correct command for the job or I have simply not made use
of it in the correct way.



Tom Phoenix wrote in message ...
>On Sat, 2 May 1998, Bob Tate wrote:
>
>> I need some help with converting a COMP-3 field to normal decimal.  I am
>> using PERL 5 and understand the COMP-3 format, also called "packed
>> decimal"  or "Binary Coded Decimal (BCD)".  I know what the correct
>> answer should be once the field is decoded.  Even with all this info I
>> am still missing the critical element that will allow me to decode the
>> Comp-3 field.
>
>And that critical element is what? Could you post a small piece of code
>which shows what you're trying that isn't working? It would also help to
>see some sample data, and how it should be converted.
>
>I don't know what COBOL COMP-3 fields are, but you may be able to use
>unpack to get the data out. Then again, maybe not. :-)  Hope this helps!
>
>--
>Tom Phoenix       Perl Training and Hacking       Esperanto
>Randal Schwartz Case:     http://www.rahul.net/jeffrey/ovs/
>



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

Date: Sun, 03 May 1998 02:53:53 GMT
From: Tom Phoenix <rootbeer@teleport.com>
To: Bob Tate <btate@primary.net>
Subject: Re: Converting COBOL Comp-3 field
Message-Id: <Pine.GSO.3.96.980502193906.8809S-100000@user2.teleport.com>

On Sat, 2 May 1998, Bob Tate wrote:

> the comp-3 field is S9(7) COMP-3.
> 
> what this means, assuming that you are not completely familiar with
> COBOL,

I'm not at all familiar with COBOL. This is a feature, not a bug. :-) 

> is that a COMP-3 field is encoded to save space in the file.  "S" means
> secured, "9" means that it is numeric only and "(7)" means that it is
> 7-numbers long. 

Seven digits? 

> COMP-3 means that it is the length of the field "7" plus "1" divided by
> "2".  So, instead of taking up "8" bytes in the file it will only occupy
> 4.

Hmmm... That sounds like it may be "binary-coded decimal". (I use the
quotes because there's nothing "binary" about it, so I don't know why it's
called that. I'd call it "packed decimal", if it were my choice. But I
digress.) 

> Now, remember that my PRN = 97818.  The file displays that the now 4 byte
> field is in Hex (00 70 61 C6).

Is that hex value representing that five-digit number? I don't see how
that's encoded. 

> What the info needs to look like, after converting the HEX to COMP-3 is
> (00 97 81 8C). 

I can see the value in there, at least!

> The extra bit at the end is the "sign" indicator.  "C" indicates a
> positive number, "D" is a negative number, and "F" is an unsigned
> number. 

Okay, we're getting closer! So, are you trying to convert from 97818 to
('00', '97', '81', '8C'), or are you trying to do some other conversion?
If you use pack/unpack with a format of "H8", you can convert "0097818c"
to four bytes and vice-versa. Does that help any?

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



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

Date: Sat, 2 May 1998 23:15:33 -0500
From: "Bob Tate" <btate@primary.net>
Subject: Re: Converting COBOL Comp-3 field
Message-Id: <354bef92.0@news.primary.net>

Actually, In a nutshell, I believe that if I can convert HEX to BCD that
would give me the desired results.  And no, the unpack command does not work
in the way that you or I feel that it should.  using either the "H8" or the
"h8" seems to unpack the number but with a result that is not what I am
looking for.  Also, COMP-3 in COBOL is very much like BCD or Packed decimal.





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

Date: 3 May 1998 04:45:54 GMT
From: gabor@vmunix.com (Gabor)
Subject: Re: editor?
Message-Id: <slrn6kntqv.onl.gabor@vnode.vmunix.com>

In comp.lang.perl.misc, Philipp <Philipp999@gmx.net> wrote :
# Hi there!
# 
# Does anybody know of a nice perl editor fin win95?

gvim!


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

Date: Sun, 03 May 1998 01:43:16 GMT
From: holcojh5@REMOVEMEwfu.edu (Philosopher King)
Subject: Re: Encryption of perl scripts
Message-Id: <354bc657.20329702@enews.newsguy.com>

On Sat, 02 May 1998 18:35:30 +0200, Hans Ophuels <hophuels@koan.de>
wrote:

>I have to write a perl/CGI script. It will be distributed on several
>computers. How can I achive that nobody changes the script.
>You know, this is very simple with a texteditor and some basic knoweldege.
>Is there a posibity that the Script is encrypted and decrypted 
>at execution time.
>I think a very simple encryption would done it well.
>

Actually, a simple encryption scheme like XOR or ROT-13 or something
like that would probably be a very poor choice in this case. Perl (and
pretty much all other programming languages, for that matter)
understand such a comparatively small number of syntactic constructs
that a known plaintext attack could easily be carried out. On the
other hand, more complicated algorithms are going to significantly
impact the performance of your script if it has to be decrypted every
time somebody visits the URL. If you have a lot of users, that could
definitely be a problem. Of course this all depends on how serious you
are about keeping your script from being modified. If you're just
trying to keep clueless people from casually toying with it and
breaking something, you could probably rig some way of doing that. If
this is something really important, however, a simple encryption
scheme is not going to provide any real security. 

If you have access to these machines, you might want to consider just
running a cron job every night that checks the script with MD5 and
mails you if it has been changed.

Good luck,

Heath

--
Heath Holcomb                 * I want to be more like the ocean
holcojh5@wfu.edu              * No talking
holcomb@mthcsc.wfu.edu        * All action
http://www.wfu.edu/~holcojh5/ * - Perry Farrell
Heath Holcomb                 * I want to be more like the ocean
holcojh5@wfu.edu              * No talking, man...
holcomb@mthcsc.wfu.edu        * All action
http://www.wfu.edu/~holcojh5/ * - Perry Farrell


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

Date: Fri, 01 May 1998 17:04:55 GMT
From: Gellyfish@btinternet.com (Jonathan Stowe)
Subject: Re: Encryption of perl scripts
Message-Id: <3549fe8f.26487691@news.btinternet.com>

On Sun, 03 May 1998 01:08:13 GMT, Tom Phoenix wrote :

<snip>
>To find out more about what compiling might accomplish for you, though,
>the FAQ has some good information.
>
But it doesnt address how I get the pizza off page 236 of the Camel,
does it.  

Also (While I'm here) I recant anything I might have said previously
about using QBasic for CGI 'cause I tried it out and it just dont work
(unless anyone knows better).  Someone however mentioned FORTH earlier
and I figure that thats worth a try.  SNOBOL, pah!!     (;-})
Jonathan Stowe
Some of your questions answered:
<URL:http://www.btinternet.com/~gellyfish/resources/wwwfaq.htm>



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

Date: Sun, 03 May 1998 06:00:27 +0200
From: N i c l a s O l o f s s o n <gurun@acc.umu.se>
Subject: Re: Encryption of perl scripts
Message-Id: <354BEBDA.969F68AA@acc.umu.se>

brian d foy wrote:
> curious idea, but it wouldn't stop the determined.  what about storing
> gzipped scripts that are uncopressed then fed to the perl interpreter.
> seems like a simple, fake wrapper "perl" could do that for you.  probably
> doesn't solve your problem and is easy to crack, but sounds like a cool
> hack :)

Change that to a crypto-wrapper and you have a real hack... 
You can never stop the determined but you can sure give him hell trying!
PGP-Perl next :)

/Niclas


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

Date: Sun, 03 May 1998 05:46:39 GMT
From: hawk@algonet.se (Hakan Hjelmstrom)
Subject: Re: extracting a sub-string
Message-Id: <354c0183.142228543@news.algonet.se>

On 2 May 1998 23:01:09 GMT,  Tom Christiansen wrote:
> In comp.lang.perl.misc, hawk@algonet.se writes:
> :What's so terribly wrong with something like:
> :while ( <HTML> ) {
> :    foreach ( /<.*?>/g ) { 
> :        print "$_\n";
> :    }
> :}
> My advice is that you abandon the regex approach.

Nice example, horrible looking HTML though. I was just trying
something for fun after the first post to this thread. 
The problem, I gather, is that however I go about extracting tags or
plaintext I really need an algorithm that can analyze and adapt to the
contents of the file and just not the structure. Right?

I'll have a look inside the HTML::Parser.

Hekan Hjelmstrvm
hawk@algonet.se

>     <A 
> 	NAME="fred"
>         HREF="#thither
>     >
> 
>     <IMG SRC = "foo.gif" ALT = "A > B">
> 
>     <!-- <A comment> -->
> 
>     <SCRIPT>if (a<b && a>c)</SCRIPT>
> 
>     <# Just data #>
> 
>     <![INCLUDE CDATA [ >>>>>>>>>>>> ]]>
> 
>     <!-- This section commented out.  <B>You can't see me!</B> -->
> 
> --tom



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

Date: Sun, 03 May 1998 06:38:20 GMT
From: alan@sonic.net (Taran)
Subject: HELP win32 perl
Message-Id: <3544ec30.323670383@news.2xtreme.net>

Hello,  I just downloaded the newest version of PERL build 316.  

I am very new at programming with PERL (I have used C for 5 years
now).  Working though some books I am finding a bunch of stuff that is
not 
working for me.  Such as O'Reilly's book Learning Perl Win32.  It
talks about saving the registry out.  The example is:

use Win32::Registry;
$main::HKEY_CURRENT_USER->Open("SOFTWARE", $Software) || die "Open
$!";
$Software->Open("ERIKO", $tk) || die "Open: $!";
$tk->Save("SAVED") || die "Save $!";


The save command totally does not work.  I have done everything I can
think of.  It seems that the Save command in registry.pm does not
recieve a value 
but I am very new so I don't know for sure.  other things like this
simple ping code 

    use Net::Ping;
    print "'jimmy' is alive and kicking\n" if pingecho('jimmy', 10) ;

also do not work.  Under the ping.pm lib I find that perl does not
support the alarm code they use.  

What am I doing wrong.  perl's lib's can't really be this bad...  are
they????

HELP...

Alan...

Please email me if you can at   alan@sonic.net

Thank you very much


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

Date: Sun, 03 May 1998 01:44:59 -0400
From: Ronald J Kimball <rjk@coos.dartmouth.edu>
Subject: Re: looking for a little bit of help here.
Message-Id: <354C045C.FC6E66C7@coos.dartmouth.edu>

Allan M. Due wrote:
> 
> >    $in =~ s/\\y\//\\..//g;
> 
> on the other hand, I do know that you need some more backslashes.  Both of
> those periods need to be escaped.

He does need another backslash, but not for the periods, which are only
special on the LHS of a substitution.  On the RHS, they're literal characters.

-- 
 _ / '  _      /         - aka -             rjk@coos.dartmouth.edu
( /)//)//)(//)/(    Ronald J. Kimball           chipmunk@m-net.arbornet.org
    /                                   http://www.ziplink.net/~rjk/
        "It's funny 'cause it's true ... and vice versa."


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

Date: Sun, 03 May 1998 04:57:53 +0000
From: qazmlp <qazmlp@ix.netcom.com>
Subject: Newbie config CGI question
Message-Id: <354BF951.35B96DC5@ix.netcom.com>

Platform: Red Hat Linux 5.0
Web Server: Apache 1.2
Perl: 5.004.1

In my test script located in /home/cgi-bin/ when I try to execute the
following:

#!/usr/bin/perl
#
#
use CGI;

$q = new CGI;

$q->header;
#print "Content-type: text/html\n\n";
print "This is a test";

I receive the error:

"Internal Server Error

The server encountered an internal error or misconfiguration and was
unable to complete your request.

Please contact the server administrator, root@localhost and inform them
of the time the error occurred, and
anything you might have done that may have caused the error."

This script, however, :

#!/usr/bin/perl
#
#
use CGI;

$q = new CGI;

#$q->header;
print "Content-type: text/html\n\n";
print "This is a test";


works fine. I suppose I can create this CGI object, but anytime I call
any methods on  it, I get that error. Do I need to configure something?

Nate Bowler







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

Date: Sun, 03 May 1998 05:51:58 +0200
From: N i c l a s O l o f s s o n <gurun@acc.umu.se>
Subject: Re: QRe: == vs. eq
Message-Id: <354BE9DE.D94CC95D@acc.umu.se>

Jonathan Stowe wrote:
> N i c l a s O l o f s s o n wrote
> > FTM, who needs it!
> >
> You did WHAT to the manual?

Not so much what I did TO it, is't more of what I did WITH it...

/Niclas - Perl, a man's best friend?


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

Date: 3 May 1998 04:49:41 GMT
From: dha@panix.com (David Adler)
Subject: Re: randal stars in merlin!
Message-Id: <6igt15$g4l@news1.panix.com>

On 27 Apr 1998 12:00:52 -0400, Uri Guttman <uri@sysarch.com> wrote:
>
>i just spent a wonderful saturday evening bending elbows with and listening
>to randal. his lecture on his troubles was educational, fun, scary and
>serious.
>
>last night i watched the first half of the miniseries merlin, and i
>noticed an amazing coincidence. the actor (sam neill) playing the role
>of merlin and randal look like they could be brothers! so our merlyn is
>starring in merlin!
>
>tell me if you think they look alike. maybe someone should publish on
>the web side by side pictures of the two.
>
>one important note: when i was watching randal, i was under the
>influence, while watching the tube, i was sober. i wonder if that made
>the similarity work.

Hmm.. good point, but Randal was certainly "influenced" as well, so
wouldn't that cancel out? :-)

-- 
David H. Adler - <dha@panix.com> - http://www.panix.com/~dha/
Free Randal Schwartz!  <http://www.rahul.net/jeffrey/ovs/>


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

Date: Sat, 02 May 1998 23:50:56 -0400
From: Eryq <eryq@zeegee.com>
To: Mark-Jason Dominus <mjd@op.net>
Subject: Re: Ref to an LVALUE???  I expected a simple SCALAR ref!
Message-Id: <354BE9A0.42D76D0E@zeegee.com>

Mark-Jason Dominus wrote:

> That's really peculiar, and it makes me wonder if the code is truly
> what you say it is, because in this case \$val; is clearly a reference
> to a scalar---the scalar being the lexical variable $val.
> 
> >What's going on?  I've never seen a ref to an LVALUE before... where
> >do they come from, in this case?
> 
> The only way I know to make them is by taking a reference to a substr,
> pos, or vec expression.  Are you really telling us the truth about the
> code?

Here's an *actual* snippet of the code, which *sometimes*
dies via the indicated fatal expression.  Basically,
method _set2 takes a key and value, and stores a ref-to-an-array
based on the value $v:

	$v		means...
	-----------------------------------------------
	undef		delete the key from the object
	[]		ditto
	arrayref	assume ref to array of strings: set values
	scalar		assume single value: set it


# _set2 KEY, VALUE
#
# Invoked only by set().
#
sub _set2 {
    my ($self, $k, $v) = @_;
    $k = $self->fold_var($k);	  # case-fold if desired
    defined($v) or $v = [];    
    my @vs = (ref($v) ? @{$v} : ($v));
    if (@vs) { 
	$self->{V}{$k} = \@vs;
	die "caught LVALUE" if (ref(\$vs[0]) eq 'LVALUE');
	&Storable::nfreeze(\@vs);
    }
    else { 
	delete $self->{V}{$k};
    }
    1;
}


# set KEY=>VALUE, ... 
#
# Usually used like:  
#      $o->set(THIS => 1, THAT => [2,3], KILLME => undef);
# just invokes _set2()
#
sub set {
    my ($self, @p) = @_;
    while (@p) { 
	$self->_set2(shift @p, shift @p);
    }
    $self;
}


-- 
  ___  _ _ _   _  ___ _   Eryq (eryq@zeegee.com)
 / _ \| '_| | | |/ _ ' /  President, Zero G Inc: http://www.zeegee.com/
|  __/| | | |_| | |_| |   
 \___||_|  \__, |\__, |___/\  Visit STREETWISE, Chicago's newspaper by/
           |___/    |______/ of the homeless: http://www.streetwise.org


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

Date: Sun, 03 May 1998 01:51:33 -0400
From: Ronald J Kimball <rjk@coos.dartmouth.edu>
To: mehta@mama.indstate.edu
Subject: Re: regex help
Message-Id: <354C05E7.6438BD26@coos.dartmouth.edu>

[posted and mailed]

mehta@mama.indstate.edu wrote:
> 
> (any char other than dott including no char)

What are you really matching when you want to match no characters as the start
of the regex?  The beginning of the string.  Thus:

/(^|[^.])(identifier)/

-- 
 _ / '  _      /         - aka -             rjk@coos.dartmouth.edu
( /)//)//)(//)/(    Ronald J. Kimball           chipmunk@m-net.arbornet.org
    /                                   http://www.ziplink.net/~rjk/
        "It's funny 'cause it's true ... and vice versa."


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

Date: Sun, 03 May 1998 02:35:50 GMT
From: Tom Phoenix <rootbeer@teleport.com>
To: Joel Horowitz <horowitz@ulb.ac.be>
Subject: Re: Style question: trouble with $_ ...
Message-Id: <Pine.GSO.3.96.980502185830.8809Q-100000@user2.teleport.com>

On Sat, 2 May 1998, Joel Horowitz wrote:

> I realised that assigning to $_ can lead to trouble.

Of course, so can using a computer in the first place. :-)

> And actually, using $_ in general can lead to trouble...
> Here's an example:
> 
> 	sub troublemaker {
> 	  open(FILE,"anyfile");

Even when your script is "just an example" (and perhaps especially in that
case!) you should _always_ check the return value after opening a file.

> 	  while (<FILE>) { };

Well, your sub should probably localize $_ before it uses it like that.
But since many subs aren't that careful, you're right to be cautious about
expecting $_ to be unchanged after any old sub call.

> If instead I define troublemaker as
> 
> 	sub troublemaker {
> 		foreach (a..e) {}
> 	}

Of course, you know that foreach implicitly localizes its control
variable. That's $_ in this case, so this is safe. 

> Good programming practice recommends using local variables wherever it's
> possible. However, when I try to put 'my $_' in the definition of
> 'troublemaker', it doesn't work... 

Use local($_) instead. (I had thought that Perl's error message in this
case said to do this, but I guess I was just dreaming.) 

Hope this helps!

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



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

Date: Sat, 02 May 1998 22:05:02 -0600
From: rpearce@fastlane.net
Subject: Use of Uninitialized Value
Message-Id: <6igmsu$549$1@nnrp1.dejanews.com>

I've written a script that reads an html document, pulls out the email
addresses, sorts and removes duplicates, then writes them to a .txt file.

It does everything it's supposed to do, but I always get an error that states:
Use of Uninitialized Variable.  I've checked FAQ's, the Llama book, among
others, and the perldiag.

Perldiag says:

Use of uninitialized value
     (W) An undefined value was used as if it were already defined. It was
interpreted as a ``'' or a 0, but maybe it was a mistake. To suppress this
warning assign an initial value to your variables.

Well, I've assigned an initial variable to everything I can find, including
trying to define $1, which booted me out as it is apparently read only.

The line number indicates it's caused by the $1 assignment in a match regex.

if(/mailto:(.*)"/i) {

etc...etc...

Any idea what's causing it?  How do I stop it?

Here's the whole script:

#!/usr/local/bin/perl -w
#
#  grabemail.pl
#  scans an html document, pulls out emails, sorts and removes duplicates
#  then writes them to a text file
#
######################################################

$directory = "$ARGV[0]";	#location of input file
$addressbook = "address.txt";	#location of output file

open(FILE,"$directory") || die "Can't Open $directory: $!\n";
@LINES=<FILE>;				#open input file and read lines
close(FILE);				# into an array.
$SIZE=@LINES;      			#number of lines in file


$c=0;     				#initialize email-found counter

for ($i=0;$i<=$SIZE;$i++) {         #read each line of the input file
 $_ = $LINES[$i];

  if(/mailto:(.*)"/i) {            	#grab text between 'mailto:' and a "
    $email[$c]= $1;                	#put it in an array
    $email[$c]=~ tr/[A-Z]/[a-z]/;   #uncapitalize emails

    $c++; 				#increment email-found counter
  }

}

open (IN,"$addressbook") || die "Can't Open $addressbook: $!\n";
@list = <IN>;
					#open addressbook and read in
foreach $listing (@list){		#existing vailues.
 chomp($listing);
 tr/[A-Z]/[a-z]/;
 $new =  push(@email,$listing);	#combine old and new emails in array.
}
close (IN);

open (OUT,">$addressbook") || die "Can't Open $addressbook: $!\n";

@esort = sort @email;			#sort email list
$prev = 'nonesuch';
					#remove duplicate email addresses
@out = grep($_ ne $prev && ($prev = $_), @esort);

foreach $item (@out){ 			#print email list to address.txt
  print OUT "$item\n";
}

close (OUT);

-----== Posted via Deja News, The Leader in Internet Discussion ==-----
http://www.dejanews.com/   Now offering spam-free web-based newsreading


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

Date: Sun, 3 May 1998 01:01:22 -0500
From: tadmc@flash.net (Tad McClellan)
Subject: Re: Use of Uninitialized Value
Message-Id: <i71hi6.7bf.ln@localhost>

rpearce@fastlane.net wrote:
: I've written a script that reads an html document, pulls out the email
: addresses, sorts and removes duplicates, then writes them to a .txt file.

: It does everything it's supposed to do, but I always get an error that states:
: Use of Uninitialized Variable.  I've checked FAQ's, the Llama book, among
: others, and the perldiag.

: Perldiag says:

: Use of uninitialized value
:      (W) An undefined value was used as if it were already defined. It was
: interpreted as a ``'' or a 0, but maybe it was a mistake. To suppress this
: warning assign an initial value to your variables.

: Well, I've assigned an initial variable to everything I can find, including
                                             ^^^^^^^^^^^^^^^^^^^^^

Ah. 

But machines (perl) have to better than the humans at _something_  ;-)


: trying to define $1, which booted me out as it is apparently read only.

: The line number indicates it's caused by the $1 assignment in a match regex.
: if(/mailto:(.*)"/i) {


Sometimes the line number is not where the error is.

It is the line number *when the parser (perl) noticed* that
there was an error (or warning, in this case)



: Any idea what's causing it?  How do I stop it?


Yep.


: Here's the whole script:


Oooh. Code!

I like it...


: open(FILE,"$directory") || die "Can't Open $directory: $!\n";
: @LINES=<FILE>;				#open input file and read lines
: close(FILE);				# into an array.
: $SIZE=@LINES;      			#number of lines in file


So, if there where 20 lines, then $SIZE (ack! UPPERCASE is, well, just yucky)
will have the value '20' in it.

@LINES has 20 values in it. Subscripted from 0-19...


: $c=0;     				#initialize email-found counter

: for ($i=0;$i<=$SIZE;$i++) {         #read each line of the input file
               ^
               ^
Danger Will Robinson. You have one too many characters in your
program. I hate it when that happens.

Take that one out, and all will be well. 

You're walking past the end of the 20 elements...


:  $_ = $LINES[$i];
:   if(/mailto:(.*)"/i) {            	#grab text between 'mailto:' and a "


--
    Tad McClellan                          SGML Consulting
    tadmc@metronet.com                     Perl programming
    Fort Worth, Texas


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

Date: 8 Mar 97 21:33:47 GMT (Last modified)
From: Perl-Request@ruby.oce.orst.edu (Perl-Users-Digest Admin) 
Subject: Digest Administrivia (Last modified: 8 Mar 97)
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.misc (and this Digest), send your
article to perl-users@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.

The Meta-FAQ, an article containing information about the FAQ, is
available by requesting "send perl-users meta-faq". The real FAQ, as it
appeared last in the newsgroup, can be retrieved with the request "send
perl-users FAQ". Due to their sizes, neither the Meta-FAQ nor the FAQ
are included in the digest.

The "mini-FAQ", which is an updated version of the Meta-FAQ, is
available by requesting "send perl-users mini-faq". It appears twice
weekly in the group, but is not distributed in the digest.

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 V8 Issue 2481
**************************************

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