[19338] in Perl-Users-Digest
Perl-Users Digest, Issue: 1533 Volume: 10
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Wed Aug 15 18:06:10 2001
Date: Wed, 15 Aug 2001 15:05:17 -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: <997913116-v10-i1533@ruby.oce.orst.edu>
Content-Type: text
Perl-Users Digest Wed, 15 Aug 2001 Volume: 10 Number: 1533
Today's topics:
Re: checking for non-letters 194.203.212.8 [demerphq]
Re: Re: Evaluation order of object methods 194.203.212.8 [demerphq]
Re: Using my delete() alongside Perl's delete()?? 194.203.212.8 [demerphq]
Re: accessing multiple hashes and regex <krahnj@acm.org>
Re: Alphabetized list of perldoc documentation?? (John J. Trammell)
Re: Alphabetized list of perldoc documentation?? (Tad McClellan)
Re: Alphabetized list of perldoc documentation?? <miscellaneousemail@yahoo.com>
Re: behavior in a while loop (Yves Orton)
Re: Can someone critique my code and point to better wa <johndporter@yahoo.com>
checking for non-letters (Ken)
Re: checking for non-letters <ilya@martynov.org>
Re: checking for non-letters <kloder@ux7.cso.uiuc.edu>
Re: checking for non-letters (Malcolm Dew-Jones)
Re: checking for non-letters <bart.lateur@skynet.be>
Re: Comma's at end of list can break program?? (Abigail)
Re: Comma's at end of list can break program?? (Abigail)
encrypting passwords (AJ)
Re: encrypting passwords <ilya@martynov.org>
Re: encrypting passwords <tsee@gmx.net>
Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: 15 Aug 2001 21:28:51 GMT
From: 194.203.212.8 [demerphq]
Subject: Re: checking for non-letters
Message-Id: <9lepij09ka@enews3.newsguy.com>
> How can I check a character to see if it is a letter (a-z or A-Z).
> I've tried:
>
> if ($char =~ /a-zA-Z/) {
SNIP
> if ($char !~ /a-zA-Z/) {
> Anyone know what I'm doing wrong?
Yes. You haven't read perlre the minimum 5 times. :-)
Especially the part about character classes.
Ok, seriously, what you are doing is asking to match your character to literal string 'a-zA-Z'. What you really want to do is stick square brackets around the whole lot and turn it into a character class specification.
if ($char =~ /[a-zA-Z]/) {
Also if you wanted you could check for any non alpha characters in a string by saying
if ($string=~/[^a-zA-Z]/) {
But if you tried to do
if ($string=~/[a-zA-Z]/) {
then you would find that if there was at least one alpha character in your string then the if would execute.
So you could also check to make sure the string contained only alpha chars (or was empty) a different way:
if ($string=~/^[a-zA-Z]*$/) {
Or even by
if ($string=~/^[[:alpha:]]*$/) { #posix char class
But im not going to explain any of these cause it s now time for you to read perlre. (Its confusing and difficult at times. Stick with it. Understanding how to read a regex is essential to utilizing perl to the max. Also it will open your eyes to completely different ways to solving problems....)
Cheers,
Yves
==================================
Poster's IP address: 194.203.212.8
Posted via http://nodevice.com
Linux Programmer's Site
------------------------------
Date: 15 Aug 2001 21:16:45 GMT
From: 194.203.212.8 [demerphq]
Subject: Re: Re: Evaluation order of object methods
Message-Id: <9leort08rl@enews3.newsguy.com>
'>' == Uri Guttman wrote..
> >>>>> "DB" == Daniel Berger <djberg96@hotmail.com> writes:
> DB> sub new{
> DB> my $class = shift;
> DB> @array = @_;
> DB> my $self = [];
> DB> bless($self, $class);
> DB> }
>
> my( $class, @array ) = @_ ;
> return bless [], $class ;
Maybe even he should be told about
my ($proto,@array) = @_ ;
my $class = ref($proto) || $proto ;
return bless [],$class ;
Or did you want him to learn that stuff from perltoot or perlboot?
:-)
> you can cascade method calls only if each earlier method returns the
> invocant (thanx damian!) object. it is a well known api feature.
^^^^^^^^
So thats the word!
Cool.
Yves
==================================
Poster's IP address: 194.203.212.8
Posted via http://nodevice.com
Linux Programmer's Site
------------------------------
Date: 15 Aug 2001 19:59:29 GMT
From: 194.203.212.8 [demerphq]
Subject: Re: Using my delete() alongside Perl's delete()??
Message-Id: <9lekb1026d@enews3.newsguy.com>
Carlos wrote....
> I have this function....
>
> sub delete
> {
> my ($hashref, $key) = @_;
> delete $hashref->{$key};
> }
>
SNIP
> Is there a way to use my version of delete() with Perl's in the same
> code? Can they co-exist? I tried calling mine with main::delete(\%h, $key) but that didn't quite work.
Two points: first if it were a method call then it wouldnt matter at all:
$obj->delete();
But thats not what you asked 8-)
So heres code that should answer your question. The idea to understand is that alongside the types $Scalars, @Arrays and
%Hashes you have &Subs as well (there are more but ill leave that to a guru).
Yves
#!perl
local $\="\n";
local $,=",";
sub delete {
print "Delete",@_;
}
my @array=(1,2,3);
print @array;
delete $array[2]; #perls
print @array;
&delete('Test'); #yours
==================================
Poster's IP address: 194.203.212.8
Posted via http://nodevice.com
Linux Programmer's Site
------------------------------
Date: Wed, 15 Aug 2001 19:48:17 GMT
From: "John W. Krahn" <krahnj@acm.org>
Subject: Re: accessing multiple hashes and regex
Message-Id: <3B7AD26C.752E09DA@acm.org>
Leary 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};
> }
>
> No smiles :(
for my $key ( keys %acct_tot ) {
printf "%10d %30s %15.2f\n", $key, $acct_names{$key+0},
$acct_tot{$key};
}
John
--
use Perl;
program
fulfillment
------------------------------
Date: 15 Aug 2001 18:13:23 GMT
From: trammell@haqq.hypersloth.invalid (John J. Trammell)
Subject: Re: Alphabetized list of perldoc documentation??
Message-Id: <slrn9nleu2.5k4.trammell@haqq.hypersloth.net>
On Wed, 15 Aug 2001 18:01:14 GMT, Carlos C. Gonzalez wrote:
> I have to scroll up and down until the perlf..'s come into view. I was
> hoping for a way to just view the basic perldoc's alphabetically.
> Perldoc's as in perlfunc, perlsyn, perlfag, etc..
Here's a short, easy-to-remember command:
% man perl | col -bx | grep '^ *perl' | grep Perl | sort
> Thanks.
No problem.
--
To think intelligently about copyrights, patents or trademarks, you must
think about them separately. The first step is declining to lump them
together as "intellectual property". - Richard Stallman
------------------------------
Date: Wed, 15 Aug 2001 13:28:59 -0400
From: tadmc@augustmail.com (Tad McClellan)
Subject: Re: Alphabetized list of perldoc documentation??
Message-Id: <slrn9nlcar.29p.tadmc@tadmc26.august.net>
Carlos C. Gonzalez <miscellaneousemail@yahoo.com> wrote:
>
>I have noticed that in both the ActiveState and the www.perldoc.com list
>of perldocs that the lists are not in alphabetical order. It's a pain to
>look one up because I have to do a bunch of scanning of the list before I
>find the one I am looking for (although I am finding that I am starting
>to get to know about where one is because of repeated scanning for the
>same perldoc).
Since I have the raw *.pods, it takes 5 characters (ls -1) to get an
alphabetical listing.
:-)
>Anyways I am wondering if anyone knows of a link to where I can find the
>list of perldocs in alphabetical order by name?
Since I have the raw *.pods,
grep '^ perl' perl.pod | sort | more
extracts an alphabetical listing along with description.
:-) :-)
Here's the output from my system:
perl5004delta Perl changes in version 5.004
perl5005delta Perl changes in version 5.005
perlamiga Perl notes for Amiga
perlapio Perl internal IO abstraction interface
perlapi Perl API listing (autogenerated)
perlbook Perl book information
perlboot Perl OO tutorial for beginners
perlbot Perl OO tricks and examples
perlcall Perl calling conventions from C
perlcompile Perl compiler suite intro
perlcygwin Perl notes for Cygwin
perldata Perl data structures
perldbmfilter Perl DBM filters
perldebguts Perl debugging guts and tips
perldebug Perl debugging
perldelta Perl changes since previous version
perldiag Perl diagnostic messages
perldos Perl notes for DOS
perldsc Perl data structures intro
perlembed Perl ways to embed perl in your C or C++ application
perlfaq Perl frequently asked questions
perlfilter Perl source filters
perlfork Perl fork() information
perlform Perl formats
perlfunc Perl builtin functions
perlguts Perl internal functions for those doing extensions
perlhack Perl hackers guide
perlhist Perl history records
perlhpux Perl notes for HP-UX
perlintern Perl internal functions (autogenerated)
perlipc Perl interprocess communication
perllexwarn Perl warnings and their control
perllocale Perl locale support
perllol Perl data structures: arrays of arrays
perlmachten Perl notes for Power MachTen
perlmodinstall Perl modules: how to install from CPAN
perlmodlib Perl modules: how to write and use
perlmod Perl modules: how they work
perlnumber Perl number semantics
perlobj Perl objects
perlopentut Perl open() tutorial
perlop Perl operators and precedence
perlos2 Perl notes for OS/2
perlos390 Perl notes for OS/390
perl Perl overview (this section)
perlpod Perl plain old documentation
perlport Perl portability guide
perlref Perl references, the rest of the story
perlreftut Perl references short introduction
perlre Perl regular expressions
perlrun Perl execution and options
perlsec Perl security
perlstyle Perl style guide
perlsub Perl subroutines
perlsyn Perl syntax
perlthrtut Perl threads tutorial
perltie Perl objects hidden behind simple variables
perltoc Perl documentation table of contents
perltodo Perl things to do
perltootc Perl OO tutorial, part 2
perltoot Perl OO tutorial, part 1
perltrap Perl traps for the unwary
perlunicode Perl unicode support
perlvar Perl predefined variables
perl -V:man.dir
perlvms Perl notes for VMS
perlwin32 Perl notes for Windows
perlxs Perl XS application programming interface
perlxstut Perl XS tutorial
If you have the "source" you can pretty much figure out how
to do just about anything that you want to do ;-)
Want a list of Perl's builtin functions?
grep ^=item perlfunc.pod | more
A few false hits, but I don't think it leaves any out.
--
Tad McClellan SGML consulting
tadmc@augustmail.com Perl programming
Fort Worth, Texas
------------------------------
Date: Wed, 15 Aug 2001 18:40:30 GMT
From: Carlos C. Gonzalez <miscellaneousemail@yahoo.com>
Subject: Re: Alphabetized list of perldoc documentation??
Message-Id: <MPG.15e47022402cdc5c989758@news.edmonton.telusplanet.net>
In article <slrn9nleu2.5k4.trammell@haqq.hypersloth.net>, John J.
Trammell at trammell@haqq.hypersloth.invalid says...
> Here's a short, easy-to-remember command:
>
> % man perl | col -bx | grep '^ *perl' | grep Perl | sort
>
Thanks again John.
Normally when I see a line like that I just run =:) the other way. Boy
oh boy has Windows spoiled me or what? I don't have to think or remember
much on Windows compared to you Unix folks. I'm kicking and screaming
inside but perhaps I will start doing things a la command prompt like you
all with enough practice. I think I will take some kind of brain
enhancement course to enlarge my capacity to come up with such beauties
=:).
---
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: 15 Aug 2001 14:00:44 -0700
From: demerphq@hotmail.com (Yves Orton)
Subject: Re: behavior in a while loop
Message-Id: <74f348f7.0108151300.184a682@posting.google.com>
c_barbet@hotmail.com (djcabz) wrote in message news:<4256dfd1.0108150618.3ee08c75@posting.google.com>...
> tadmc@augustmail.com (Tad McClellan) wrote in message news:<slrn9nj3c8.b3i.tadmc@tadmc26.august.net>...
> > [ Please fix your word wrap. It breaks your code. ]
> ^^^^^ -- I am using google it breaks at 80chr/row -cb
So then reformat it. I use google as well. Reformatting your code so
we all can help without reformatting it for you increases your chance
that we will in the end help. (yeah yeah i know its a pain... :-)
SNIP
> > And your diag message says "copy" when you are NOT doing
> > any copying. That's kinda misleading.
> >
> ^^^^ - I've corrected it to say move. I initially had "use
> File::Copy" and was using the copy command. The final goal is to move
> the file; I understand rename is better. -cb
Ummm. Sorry? Why is it better? Why dont you just use the move()
command? It should be more portable then (for instance I _think_ on a
W32 enviornment you cant rename across the network, but you _CAN_ (for
sure) move() across the network.). Then your code should be more
portable. (Dont tell me that you arent going to port it. It doesnt
matter. Good practice is good practice for a reason)
SNIP
> #!/usr/bin/perl -w
might (IMO) want to convert this to:
use warnings;
(My logic is that I am MUCH more likely to notice a missing use
warings statement than I am to notice a missing -w switch)
and you should definitely add:
use strict;
Between the two of them you can sort the majority of problems and
minor bugs.
>
> ### perl modules
>
>
> #### VARIBLE DEFINITIONS #####
> $fsndir = shift || '.';
So this is part of a sub then? If so where is the sub declaration, if
not then what do think you are doing here? also be aware that if the
value returned from shift() is '0' then you will change it to '.'. Ive
been nailed in my code and in CLPM for that one too many times.
>
> #### opening log files and creating directories
> open(ERROR_LOG, ">>./fatal_error.log")
or die "Could not open ERROR_LOG: $!\n";
Notice I split on the 'or' this is because we are expecting open to
succeed so it can be quite nicely stuck underneath and out of the way.
Its a good idea in your code not just to fit google input box.
> if (!chdir "./fsn") {
> mkdir("./fsn",0777);
> print ERROR_LOG "\nHad to create ./fsn Directory";
> }
So by this point if the directory existed you are in it, and if it
didnt then you create it but you arent in it. Maybe not what you
want? Perhaps you should read up on the -d filetest in perlfunc
(under -X)
if (-d ".fsn") {
That way you get the same machine state before and after.
>
> #### Create list of files FromScan
> open(FSN_LIST, ">./fromscan.lst")
or die ERROR_LOG, "\nCould not open ./fromscan.lst: $!";
As others have stated ERROR_LOG will not be treated as a filehandle
with die()
Maybe you should write your own sub, something like:
sub bail {
my $FH=shift;
print $FH join("",@_)."\n";
die join("",@_)."\n"; #so you see it on the screen as well
}
> opendir FSN_DIR, $fsndir
or die "Error opening directory $fsndir: $!\n";
So maybe this should now be:
opendir FSN_DIR, $fsndir
or bail \*ERROR_LOG,"Error opening directory $fsndir: $!\n";
> while ($fileFSN = readdir FSN_DIR) {
> next if ($fileFSN=~/^\./ || $fileFSN!~/$\.fsn/);
Hmm. second regex makes no sense. Lets convert it to english:
next iteration of while loop if $fileFSN has a '.' (dot) at the
beginning or if $fileFSH does not .... ehhhr.
What did you _think_ you meant by putting the $ at the beginning? $
matches the end of string (loosely defined) so putting it BEFORE the
rest of the regex makes no sense.
Did you mean:
next if ($fileFSN=~/^\./ || $fileFSN!~/\.fsn$/);
next iteration of while loop if $fileFSN has a '.' (dot) at the
beginning or if $fileFSH does not have .fsn as its last characters.
or did you mean
next if ($fileFSN=~/^\./ || $fileFSN!~/^\.fsn/);
next iteration of while loop if $fileFSN has a '.' (dot) at the
beginning or if $fileFSH does not have .fsn as its first characters.
Or maybe both (on both)?
next if ($fileFSN=~/^\.$/ || $fileFSN!~/^\.fsn$/);
next iteration of while loop if $fileFSN matches exactly the string
'.' (dot) if $fileFSH does not exactly mathch '.fsn'.
In which case the below makes more sense to read and is more
efficient:
next if $fileFSN eq '.' || $fileFSN ne '.fsn';
Anyway, I suspect you need to reconsider this line.
> print FSN_LIST "$fileFSN\n";
For cleaner code you might look into local()ising $\ and $, for this
loop.
If you put the statement:
local $\="\n";
as the first line of the while block (or at an even higher scope..
your call) then you can change the above to
print FSN_LIST $fileFSN;
This one I picked up off of Uri, and once i started playing with it
have used it considerably. (thanks Uri)
> }
> close(FSN_LIST)
or warn ERROR_LOG, "\nCould not close ./fsnlist.lst:$!";
Well, two points here, Im not sure how usual it would be to check to
see if a close() operation fails. Maybe a Guru will pipe up with an
opinion, all I can say is that I havent seen it done before, and never
do it personally. Partially because my code would never execute a
close() unless the apropriate open() had succeded. As for warn(), it
doesnt take a filehandle. Perhaps you should expand on the earlier
idea of bail() and create something like:
sub mutter {
my $FH=shift;
print $FH join("",@_)."\n";
warn join("",@_)."\n"; #so you see it on the screen as well
}
so the above becomes (maybe)
close(FSN_LIST)
or mutter \*ERROR_LOG, "\nCould not close ./fsnlist.lst:$!";
> closedir(FSN_DIR)
or warn ERROR_LOG, "Could not close $fsndir: $!";
Same story as last comment...
> open(FSN_LIST, "./fromscan.lst")
or die ERROR_LOG, "\nCould not read ./fromscan.lst: $!";
> while (<FSN_LIST>) {
> print "I passed this file: $_";
> chomp($_);
> rename("$fsndir/$_", "./fsn/$_")
|| die ERROR_LOG, "\nCould not rename $_: $!"; #changed to
rename
> }
So why arent you using move? If you are going to move() then move()
dont rename. (Head pops above trench and does guru shoot it off?)
<Dead code removed>
> #### closing temporary and log files
> close(ERROR_LOG)
or warn ERROR_LOG, "\nfatal_error.log did not close:$!";
Anyway, I dont know how much this helped, but sort out what I have
said then resubmit to the gurus and maybe youll get less flak when
they try to help you.
Especially all of those warn() and die()s to a filehandle. You were
told about that in Tads mail, but didnt fix them.
Yves
Ps (They really are nice people, just a bit testy at times, especially
when they think someone hasnt put in the effort before they ask for
help.)
------------------------------
Date: Wed, 15 Aug 2001 19:44:36 GMT
From: John Porter <johndporter@yahoo.com>
Subject: Re: Can someone critique my code and point to better way??
Message-Id: <3B7AD054.8CCF4FE8@yahoo.com>
Uri Guttman wrote:
> long names are fine where they help, but FH is so common and well
> understood that it is ok too. FILE works too. i have never seen
> FILE_HANDLE except by newbies or long named phreaks.
Better advice would be to give the variable a name that
signifies its role in the function. $OUTPUT, for example.
If a name isn't going to be meaningful, it may as well be
short. But better, in general, to make them meaningful,
and as long as necessary.
--
John Porter
------------------------------
Date: 15 Aug 2001 13:24:29 -0700
From: kenphilbrick@mindspring.com (Ken)
Subject: checking for non-letters
Message-Id: <f8b445c0.0108151224.d36ed7b@posting.google.com>
How can I check a character to see if it is a letter (a-z or A-Z).
I've tried:
if ($char =~ /a-zA-Z/) {
print "it's a letter\n";
}
where $char holds a single character. But that didn't work. It came
up false every time, even when it really was a letter. This didn't
seem to work either:
if ($char !~ /a-zA-Z/) {
print "it's not a letter\n";
}
Anyone know what I'm doing wrong?
Thanks.
--
Ken
------------------------------
Date: 16 Aug 2001 00:54:25 +0400
From: Ilya Martynov <ilya@martynov.org>
Subject: Re: checking for non-letters
Message-Id: <87n151kpry.fsf@abra.ru>
K> How can I check a character to see if it is a letter (a-z or A-Z).
K> I've tried:
K> if ($char =~ /a-zA-Z/) {
K> print "it's a letter\n";
K> }
K> where $char holds a single character. But that didn't work. It came
K> up false every time, even when it really was a letter. This didn't
K> seem to work either:
K> if ($char !~ /a-zA-Z/) {
K> print "it's not a letter\n";
K> }
K> Anyone know what I'm doing wrong?
Pattern /a-zA-Z/ just matches string 'a-zA-Z'.
Correct pattern is /[a-zA-Z]/
--
-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
| 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: Wed, 15 Aug 2001 20:57:26 GMT
From: stephen allen kloder <kloder@ux7.cso.uiuc.edu>
Subject: Re: checking for non-letters
Message-Id: <WmBe7.6392$A3.46171@vixen.cso.uiuc.edu>
Ken <kenphilbrick@mindspring.com> wrote:
> How can I check a character to see if it is a letter (a-z or A-Z).
> I've tried:
> if ($char =~ /a-zA-Z/) {
> print "it's a letter\n";
> }
I'm guessing you recall a-zA-z from tr///. It works a little differently in
m.// and s///. What you are looking for is a character class, which requires
square brackets:
$char =~ /[a-zA-Z]/;
Or even:
$char =~ /[a-z]/i;
A character class matches iff the character matches one of the characters
between the brackets. ^ and - can be used for more elaborate features.
Read perlre for more information. You may even want to look into \w and \W.
perldoc perlre
HTH
------------------------------
Date: 15 Aug 2001 14:03:21 -0800
From: yf110@vtn1.victoria.tc.ca (Malcolm Dew-Jones)
Subject: Re: checking for non-letters
Message-Id: <3b7ae399@news.victoria.tc.ca>
Ken (kenphilbrick@mindspring.com) wrote:
: How can I check a character to see if it is a letter (a-z or A-Z).
: I've tried:
: if ($char =~ /a-zA-Z/) {
: print "it's a letter\n";
: }
: where $char holds a single character. But that didn't work. It came
: up false every time,
...
: Anyone know what I'm doing wrong?
you want to match a "character class", not a string that just happens to
have two dashes in it.
(untested)
if ($char =~ /[a-zA-Z]/) {
^ ^
^ ^
See 'perldoc perlre' for further details.
*however*, note that this checks that the string *contains* at least one
character, not that the string *is* one character. You might want to use
if ($char =~ /^[a-zA-Z]\Z/)
which checks that the entire string is just a single letter,
or sometimes you want
if ($char =~ /^[a-zA-Z]$/)
which checks a *line* has a single letter on it ($ ignores any newline).
------------------------------
Date: Wed, 15 Aug 2001 21:19:22 GMT
From: Bart Lateur <bart.lateur@skynet.be>
Subject: Re: checking for non-letters
Message-Id: <4rplnt8pqrpp3in5tiqqjpd93vbmu7g9i6@4ax.com>
Ken wrote:
>How can I check a character to see if it is a letter (a-z or A-Z).
>I've tried:
>
>if ($char =~ /a-zA-Z/) {
> print "it's a letter\n";
>}
>
>where $char holds a single character. But that didn't work. It came
>up false every time, even when it really was a letter.
You forgot to make it a character class. Put square brackets around your
stuff.
$char =~ /[a-zA-Z]/
You must be confusing this with tr///:
$char =~ tr/a-zA-Z//
where the stuff on the LHS is *always* considered as the bulk of a
character class.
--
Bart.
------------------------------
Date: 15 Aug 2001 21:24:03 GMT
From: abigail@foad.org (Abigail)
Subject: Re: Comma's at end of list can break program??
Message-Id: <slrn9nlq47.9sn.abigail@alexandra.xs4all.nl>
Logan Shaw (logan@cs.utexas.edu) wrote on MMCMIV September MCMXCIII in
<URL:news:9l7lcd$jfq$1@charity.cs.utexas.edu>:
?? In article <x7r8uglirx.fsf@home.sysarch.com>,
?? Uri Guttman <uri@sysarch.com> wrote:
?? >>>>>> "CCG" == Carlos C Gonzalez <miscellaneousemail@yahoo.com> writes:
?? > CCG> "Put commas at the end of lists to so your program won't break if
?? > CCG> someone inserts another item at the end of the list."
?? >
?? >very simple concept. here is a list of quoted strings:
?? >
?? > @list = (
?? > 'first string',
?? > 'another one',
?? > 'last but not least'
?? > ) ;
?? >
?? >now you are editing this and need to put another string at the end of
?? >the list so you insert the line:
?? >
?? > 'added line to end'
?? >
?? >and your program now breaks because the code below has illegal syntax.
??
?? And then you ask yourself, "Why did I become a programmer, when
?? apparently I'm not smart enough to edit a text file and keep in mind a
?? 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
?? along with the zillions of other rules that are way, way more complex
?? than that (and which have worse consequences)?
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.
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.
Commas are your friends. Commas are good.
Commas know what's good for you. Use commas.
?? In other words, I've never seen the point in adding the comma. It just
?? seems to make the code more cluttered, and not only that, but when I
?? see code with the comma after the last item, I sometimes wonder if
?? maybe someone has accidentally deleted the last item of the list.
Ah, yes, like people who are getting hopelessly confused if they spot
a double quoted string without interpolation.
Abigail
--
srand 123456;$-=rand$_--=>@[[$-,$_]=@[[$_,$-]for(reverse+1..(@[=split
//=>"IGrACVGQ\x02GJCWVhP\x02PL\x02jNMP"));print+(map{$_^q^"^}@[),"\n"
__END__
A songbird singing. // A pair of goldfish in a // stream. A carp darting.
------------------------------
Date: 15 Aug 2001 21:34:39 GMT
From: abigail@foad.org (Abigail)
Subject: Re: Comma's at end of list can break program??
Message-Id: <slrn9nlqo3.9sn.abigail@alexandra.xs4all.nl>
Anno Siegel (anno4000@lublin.zrz.tu-berlin.de) wrote on MMCMV September
MCMXCIII in <URL:news:9lbcsj$etu$2@mamenchi.zrz.TU-Berlin.DE>:
'' According to Michael Carman <mjcarman@home.com>:
''
'' [...]
''
'' > Sometimes I put the trailing comma there just because I can. It's a
'' > small form of retaliation against those languages which are paranoid
'' > about such things. :)
''
'' Yay! The best reason I've heard so far :)
''
'' Otherwise, I wouldn't make a religion out of the final comma. As many
'' optional features it can be used as a hint for posterity: If it's there,
'' a maintainer may conclude she is supposed to make changes there, which
'' can be comforting. If it isn't, she'll make her changes anyhow.
Another reason is aesthetics:
@list = (
"We have one string here",
"and one here" ,
"and another string" ,
"this is also a string" ,
"final string is here" ,
);
looks better than:
@list = (
"We have one string here",
"and one here" ,
"and another string" ,
"this is also a string" ,
"final string is here"
);
which has something "missing".
OTOH,
@dingly = (foo => bar => baz => qux => quux =>);
or
my $fruit = apple =>;
is overdoing it.
Abigail
--
sub f{sprintf'%c%s',$_[0],$_[1]}print f(74,f(117,f(115,f(116,f(32,f(97,
f(110,f(111,f(116,f(104,f(0x65,f(114,f(32,f(80,f(101,f(114,f(0x6c,f(32,
f(0x48,f(97,f(99,f(107,f(101,f(114,f(10,q ff)))))))))))))))))))))))))
------------------------------
Date: 15 Aug 2001 14:28:51 -0700
From: jerseycat10@yahoo.com (AJ)
Subject: encrypting passwords
Message-Id: <7eddc058.0108151328.29ac8787@posting.google.com>
Hello, right now, I have a perl logon/logoff system on my site.
However, all the data files I use (.passwd, .email, etc), are set with
lax security permissions to satisfy perl. I am wondering if there are
any encryption techniques widely available to combat this problem.
Thanks.
AJ
------------------------------
Date: 16 Aug 2001 01:39:33 +0400
From: Ilya Martynov <ilya@martynov.org>
Subject: Re: encrypting passwords
Message-Id: <87g0atknoq.fsf@abra.ru>
A> Hello, right now, I have a perl logon/logoff system on my site.
A> However, all the data files I use (.passwd, .email, etc), are set with
A> lax security permissions to satisfy perl. I am wondering if there are
A> any encryption techniques widely available to combat this problem.
A> Thanks.
For passwords you can use one-way encryption (I hope it is correct
English name). See 'perldoc -tf crypt'.
But for other data ... it is better to setup your permissions
correctly so these files are readable only for your perl scripts.
--
-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
| 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: Wed, 15 Aug 2001 23:40:36 +0200
From: "Steffen Müller" <tsee@gmx.net>
Subject: Re: encrypting passwords
Message-Id: <9leq28$nol$02$1@news.t-online.com>
"AJ" <jerseycat10@yahoo.com> schrieb im Newsbeitrag
news:7eddc058.0108151328.29ac8787@posting.google.com...
> Hello, right now, I have a perl logon/logoff system on my site.
> However, all the data files I use (.passwd, .email, etc), are set with
> lax security permissions to satisfy perl. I am wondering if there are
> any encryption techniques widely available to combat this problem.
> Thanks.
>
> AJ
RTFM.
Read about crypt() in perlfunc.
Steffen Müller
------------------------------
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 1533
***************************************