[10460] in Perl-Users-Digest
Perl-Users Digest, Issue: 4052 Volume: 8
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Fri Oct 23 06:04:17 1998
Date: Fri, 23 Oct 98 03:00:19 -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 Fri, 23 Oct 1998 Volume: 8 Number: 4052
Today's topics:
Re: "->" operator and "unquoted string warning" ronald_f@my-dejanews.com
Re: "->" operator and "unquoted string warning" <zenin@bawdycaste.org>
Re: 3D array: request lengths? <zenin@bawdycaste.org>
Re: 3D array: request lengths? <ajohnson@gatewest.net>
>> Array of Lists - Thanks to all stefan_007@my-dejanews.com
A CPAN mirror tmcguiga@my-dejanews.com
Re: Can a Perl program effect the parent process?? (Sam Holden)
Re: CGI.pm and $query->self_url problems <cgormley@netcomuk.co.uk>
Re: Count files in a dir SSI or CGI (David Alan Black)
Re: curly quick question jlamport@calarts.edu
filehandles, packages, :: and -> miko@idocs.com
Re: Help needed ronald_f@my-dejanews.com
How to modify argv? <lux@coo.mts.dec.com>
how to use CGI to download <eyebeam@unexpected.com>
Re: how to use CGI to download (David Alan Black)
Re: Info on crypt() (Peter Holzer)
Re: Keith : CreateObject doesn't work via my browser nicolaslecart@my-dejanews.com
Re: Matt : CreateObject doesn't work via my browser nicolaslecart@my-dejanews.com
Re: Perl & Y2K - booby trap code <jimbo@soundimages.co.uk>
Re: Perl Modulus operator unreliable? Help!! (Jason Witherspoon)
Re: reg-exp: change < to < but keep <I> jlamport@calarts.edu
Re: regexp matching having prblems.. (Sam Holden)
SV_TYPE address for Novell 4.x Servers ? <ppopour@infoave.net>
Re: write a long string... (David Alan Black)
Special: Digest Administrivia (Last modified: 12 Mar 98 (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: Fri, 23 Oct 1998 06:41:20 GMT
From: ronald_f@my-dejanews.com
Subject: Re: "->" operator and "unquoted string warning"
Message-Id: <70p8eg$mo3$1@nnrp1.dejanews.com>
In article <70hvv4$soj$1@pilot.njin.net>,
dblack@pilot.njin.net (David Alan Black) wrote:
> >When using the "-w" switch, I get the warning message
>
> > Unquoted string "mod" may clash with future reserved word
>
> >for the expression (mod->new()). Beside this nasty warning, the
> >program seems to work fine.
>
> If you capitalize your module's name, you won't get the warning:
>
> package Mod;
>
> ...
>
> my $i = Mod->new();
Thank you so much. I can't remember to have seen this "capitalize the module's
name" rule documented, but certainly it is somewhere. Could you give me
a hint where I can find this documented?
--
Ronald Fischer <ronald_f@my-dejanews.com>
http://ourworld.compuserve.com/homepages/ronald_fischer/
-----------== Posted via Deja News, The Discussion Network ==----------
http://www.dejanews.com/ Search, Read, Discuss, or Start Your Own
------------------------------
Date: 23 Oct 1998 09:39:55 GMT
From: Zenin <zenin@bawdycaste.org>
Subject: Re: "->" operator and "unquoted string warning"
Message-Id: <909135546.919522@thrush.omix.com>
[posted & mailed]
ronald_f@my-dejanews.com wrote:
>snip<
: Thank you so much. I can't remember to have seen this "capitalize the module's
: name" rule documented, but certainly it is somewhere. Could you give me
: a hint where I can find this documented?
From the perlmod man page:
"Module names are also capitalized unless they're functioning as
pragmas, "Pragmas" are in effect compiler directives, and are
sometimes called "pragmatic modules" (or even "pragmata" if you're
a classicist)."
And from the perlstyle man page:
"Perl informally reserves lowercase module names for
"pragma" modules like integer and strict. Other
modules should begin with a capital letter and use
mixed case, but probably without underscores due to
limitations in primitive file systems' representations
of module names as files that must fit into a few
sparse bytes."
And I'm sure in many other pieces of Perl documentation as
well.
--
-Zenin (zenin@archive.rhps.org) From The Blue Camel we learn:
BSD: A psychoactive drug, popular in the 80s, probably developed at UC
Berkeley or thereabouts. Similar in many ways to the prescription-only
medication called "System V", but infinitely more useful. (Or, at least,
more fun.) The full chemical name is "Berkeley Standard Distribution".
------------------------------
Date: 23 Oct 1998 06:48:40 GMT
From: Zenin <zenin@bawdycaste.org>
Subject: Re: 3D array: request lengths?
Message-Id: <909125272.188314@thrush.omix.com>
[posted & mailed]
Justin Wilde <jwilde@openskies.com> wrote:
: Here's a multidim. array I've set up.
: I would like to run this beast through
: a loop to make comparisions. I manage
: to reference individual elements with:
:
: $fareTableCodes -> [1] [0] [1];
: # references element J
: However, I can't figure out how to request
: the num of elements in each of these lists.
: (There are 3 levels of lists... see them all?)
perldoc perlref
perllol
perldsc
$#{ $fareTableCodes }
$#{ $fareTableCodes->[1] }
$#{ $fareTableCodes->[1][0] }
...etc...
Or, if for humor's sake you want to code like Java you can do:
$ cat foo.pl
$foo = [ 'foo', 'bar', 'baz' ];
bless $foo, 'Array';
sub Array::length { $#{ $_[0] } + 1 };
print "@$foo\n";
print "Foo has ", $foo->length(), " elements\n";
$ perl foo.pl
foo bar baz
Foo has 3 elements
*shutter*
--
-Zenin (zenin@archive.rhps.org) From The Blue Camel we learn:
BSD: A psychoactive drug, popular in the 80s, probably developed at UC
Berkeley or thereabouts. Similar in many ways to the prescription-only
medication called "System V", but infinitely more useful. (Or, at least,
more fun.) The full chemical name is "Berkeley Standard Distribution".
------------------------------
Date: Fri, 23 Oct 1998 01:35:29 -0500
From: Andrew Johnson <ajohnson@gatewest.net>
Subject: Re: 3D array: request lengths?
Message-Id: <363023B1.7A02A69A@gatewest.net>
Justin Wilde wrote:
!
! Here's a multidim. array I've set up.
! I would like to run this beast through
! a loop to make comparisions. I manage
! to reference individual elements with:
!
! $fareTableCodes -> [1] [0] [1];
! # references element J
!
! However, I can't figure out how to request
! the num of elements in each of these lists.
! (There are 3 levels of lists... see them all?)
[snip]
well, you do know that you can get obtain the number of elements in
an array by evaluating it in a scalar context right?
@array = (4,3,2,1);
$num_elements = @array;
now, if we have a reference to an anonymous array:
$a_ref = [4,3,2,1];
we can do the same thing, but we have to dereference first, because
the variable $a_ref is not an array, but contains a reference to one:
$a_ref = [4,3,2,1];
$num_elements = @{$a_ref};
print $num_elements;
This extends to any level of nesting:
$a_ref = [
[1,2,3],
[4,5,6]
],
# how many elements in the outer array?
$num_elems_outer = @{$a_ref};
print $num_elems_outer,"\n";
# how many elements in the first element of the outer array?
$num_elems_inner_1 = @{$a_ref->[0]};
print $num_elems_inner_1,"\n";
so, for example, to get the number of elements in the array referenced
by $fareTableCodes->[1][0] in your example:
$fareTableCodes =
[
[
[ "B" , "D" , "F" ] ,
[ "A" , "R" ]
] ,
[
[ "H" , "J" , "C" , "R" ] ,
[ "F" , "C" , "D" , "C" ] ,
[ "R" , "D" , "D" ]
]
];
$num_elems = @{$fareTableCodes->[1][0]}; # the one with element "J"
print $num_elems;
for further help, please see the following:
perldoc perllol
perldoc perldsc
perldoc perlref
regards
andrew
------------------------------
Date: Fri, 23 Oct 1998 07:47:26 GMT
From: stefan_007@my-dejanews.com
Subject: >> Array of Lists - Thanks to all
Message-Id: <70pcad$qmf$1@nnrp1.dejanews.com>
Hi,
thanks to all who answered - it works :-))))
Stefan.
-----------== Posted via Deja News, The Discussion Network ==----------
http://www.dejanews.com/ Search, Read, Discuss, or Start Your Own
------------------------------
Date: Fri, 23 Oct 1998 09:19:17 GMT
From: tmcguiga@my-dejanews.com
Subject: A CPAN mirror
Message-Id: <70phmj$ut2$1@nnrp1.dejanews.com>
Anyone know how large is CPAN and what kind of traffic would a mirror be
expecting?
-----------== Posted via Deja News, The Discussion Network ==----------
http://www.dejanews.com/ Search, Read, Discuss, or Start Your Own
------------------------------
Date: 23 Oct 1998 07:04:08 GMT
From: sholden@pgrad.cs.usyd.edu.au (Sam Holden)
Subject: Re: Can a Perl program effect the parent process??
Message-Id: <slrn730aj8.2oo.sholden@pgrad.cs.usyd.edu.au>
On Thu, 22 Oct 1998 22:31:46 GMT, Darren Greer <drgreer@qtiworld.com> wrote:
>The subject explains it all....but here is my situation. I have a
>perl program that I want to set the DISPLAY env variable.
>Unfortunatley from what I understand on a *nix system, a child process
>(ie perl program) can not effect the parent process?) Is there anyway
>to do this.
>
>For Example:
>
>I set my DISPLAY env var to "0"
>
>When I run my perl program it finds the real IP and then does a
>system("export DISPLAY=$ip");
>
>But when the perl program is done the IP is still 0. And I do know
>that $ip is not 0.
>
>Any help would be appreciated
There was a thread in this news group on this a couple of weeks ago...
It would be a rather large security problem if what you propose could
be done...
The obvious way to get around this (which mightn't work in your
situation) is :
DISPLAY=`<perl program>`
in your shell and have the perl program print the IP address.
Of course writing the thing in shell to start with might be better.
--
Sam
Just don't create a file called -rf. :-)
--Larry Wall
------------------------------
Date: Fri, 23 Oct 1998 09:30:36 +0100
From: "Clinton Gormley" <cgormley@netcomuk.co.uk>
Subject: Re: CGI.pm and $query->self_url problems
Message-Id: <70peql$g67$1@taliesin.netcom.net.uk>
I think you're right - i modified your script to keep calling itself, and
sure enough, it lengthened by 1 URL at each stage
thank goodness for apache!
Clint
Ronald J Kimball wrote in message
<1dhbpcl.6rj8d11v1lr9cN@bay2-265.quincy.ziplink.net>...
>Clinton Gormley <cgormley@netcomuk.co.uk> wrote:
>
>> So the script is called recursively. in order to preserve state, I am
using
>> the CGI method self_url to generate URL + query string as a redirection.
>> (running on NT 4 + IIS).
>>
>> The problem is (if the URL is http://www.foo.com/cgi-bin/bar.pl?a=1&b=2),
>> self_url is generating url's life
>>
http://www.foo.com/cgi-bin/bar.pl/www.foo.com/cgi-bin/bar.pl/www.foo.com/cgi
>> -bin/bar.pl?a=1&b=2)
>>
>> Obviously, it is putting in the URL as many times as the script has been
>> called. I've got around this by redirecting to
>> $query->url.'?'.$query->query_string.
>>
>> Is this a problem with CGI.pm, or IIS, or something I'm doing.
>
>I'd have to assume it's either IIS, or something you are doing. I did
>not have any problems with the following script:
>
>
>#!/usr/local/bin/perl5.004_04
>
>use strict;
>
>use CGI;
>
>my $query = new CGI;
>
>print $query->header;
>
>my $self_url = $query->self_url;
>
>print <<EOHTML;
><HTML>
><HEAD>
><TITLE>Self Url</TITLE>
></HEAD>
><BODY>
><A HREF="$self_url">$self_url</A>
></BODY>
></HTML>
>EOHTML
>
>__END__
>
>--
> _ / ' _ / - 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: 23 Oct 1998 05:11:59 -0400
From: dblack@pilot.njin.net (David Alan Black)
Subject: Re: Count files in a dir SSI or CGI
Message-Id: <70ph8v$t8c$1@pilot.njin.net>
Fred Richards <gadget@bc.sympatico.ca> writes:
>opendir(DIR, ".");
>@files = readdir(DIR);
>closedir(DIR);
># *** Evaluate @files array in a scalar context ***
>$files_found = @files;
>print "Files found: ", $files_found;
>Note: It will include '.' and '..' (WIN95)
. and .. (self and parent directory) are not specific
to W. Nine-to-Five. You will also find them among
a directory's contents on operating systems.
David Black
dblack@pilot.njin.net
------------------------------
Date: Fri, 23 Oct 1998 05:49:25 GMT
From: jlamport@calarts.edu
Subject: Re: curly quick question
Message-Id: <70p5d5$k5k$1@nnrp1.dejanews.com>
In article <362CE36C.6B78@datamail.co.nz>,
Arran Price <arranp@datamail.co.nz> wrote:
> Take the following script:
>
> #!/usr/local/bin/perl
>
> print "doing something";
> system("find /usr/* -name foo");
>
> Why does the print happen after the system call has finished?
>
> if I change it so theres a \n in the print call then it does do it first
> eg
>
> #!/usr/local/bin/perl
>
> print "doing something\n";
> system("find /usr/* -name foo");
>From the perlvar section of the docs:
$| If set to nonzero, forces a flush after every write or print on the
currently selected output channel. Default is 0 (regardless of whether the
channel is actually buffered by the system or not; $| tells you only whether
you've asked Perl explicitly to flush after each write). Note that STDOUT
will typically be line buffered if output is to the terminal and block
buffered otherwise. Setting this variable is useful primarily when you are
outputting to a pipe, such as when you are running a Perl script under rsh
and want to see the output as it's happening. This has no effect on input
buffering. (Mnemonic: when you want your pipes to be piping hot.)
Hope this helps.
-jason
-----------== Posted via Deja News, The Discussion Network ==----------
http://www.dejanews.com/ Search, Read, Discuss, or Start Your Own
------------------------------
Date: Fri, 23 Oct 1998 07:50:47 GMT
From: miko@idocs.com
Subject: filehandles, packages, :: and ->
Message-Id: <70pcgm$qpg$1@nnrp1.dejanews.com>
At this time it is traditional to plea that I have RFTMed, read the FAQ,
searched extensively through DejaNews, perldoc-ed a variety modules, read the
Camel book, the Llama book, the Black Leopard book, and the entire list of
Larry Wall quotes, all in search of an answer to the question I am about to
ask. Therefore, beat me, flame me, use my name in bad poetry, but please
believe I have diligently searched in the appropriate places for this
information. My question resembles a FAQ, but concerns a specific
incarnation not mentioned in any of the above-mentioned sources, at least not
in a form recognizable to my eyes. (I'm always so scared posting to Usenet.)
Consider this code, with line numbers added for your convenience:
0 #!/usr/local/bin/perl -wI../lib
1
2 open (ARCHIVE,"mime.txt") or die "cannot open file";
3 DataCarton::headersfromfh(\*ARCHIVE);
4 close (ARCHIVE);
5
6 package DataCarton;
7
8 sub headersfromfh
9 {
10 local($fh)=@_;
12 while(<$fh>){print $_}
13 }
This code gleefully spits out the entire contents of "mime.txt". Now, suppose
we change just two characters in line 3, the :: to -> like this:
3 DataCarton->headersfromfh(\*ARCHIVE);
The function is still called, but the file handle is no longer passed as a
file handle. No contents are spit out. I also followed the advice in the
FAQ and tried this construct:
0 #!/usr/local/bin/perl -wI../lib
1 use FileHandle;
2
3 my $archive = FileHandle->new();
4 open($archive, "mime.txt") or die "cannot open file: $!";
5 DataCarton::headersfromfh($archive);
6 close ($archive);
7
8 package DataCarton;
9
10 sub headersfromfh
11 {
12 local($fh)=@_;
13 while(<$fh>){print $_}
14 }
The result is identical. If the :: in line 5 is changed to -> then the file
handle is not passed as a file handle. So what am I missing here? What is
correct syntax? Is this even a problem? (Patient: "It hurts when I go like
this." Doctor: "So don't go like that.")
Much appreciation for any help you can give.
-miko
-----------== Posted via Deja News, The Discussion Network ==----------
http://www.dejanews.com/ Search, Read, Discuss, or Start Your Own
------------------------------
Date: Fri, 23 Oct 1998 07:26:30 GMT
From: ronald_f@my-dejanews.com
Subject: Re: Help needed
Message-Id: <70pb37$pl9$1@nnrp1.dejanews.com>
In article <70o2ep$hvn$1@nnrp1.dejanews.com>,
sandeep_aggarwal@my-dejanews.com wrote:
> Hi guys,
>
> I need help with the following task and I'd really appreciate your help.
>
> I need to consolidate two host files (unix) into one file. The situation is
> that system x and system y have different host maps. I would like to
> consolidate the two files in the following way:
>
> 1) Take the two files and come up with one file with no duplicates.
> 2) When you do run into duplicates keep the entry from system y and discard
> the entry from system x.
>
> The files are in the following format:
>
> IP Name Aliases
> -- ---- -------
> 1.2.3.4 x a b c
> 5.6.7.8 y e f
A quick-and-dirty method would be to shell out and use the Unix sort command;
note
in particular the "-u" switch to sort. Of course you would not have any error
checking here (for example detecting two lines with the same IP address, but
different names).
When you do it in perl, you could read each line and use "split" or a regexp
to split it in the fields (IP, Name and Aliases). Use a hash to store the IP
address - that way you can find duplicates. Write the hash to a new file when
you are done.
Ronald
--
Ronald Fischer <ronald_f@my-dejanews.com>
http://ourworld.compuserve.com/homepages/ronald_fischer/
-----------== Posted via Deja News, The Discussion Network ==----------
http://www.dejanews.com/ Search, Read, Discuss, or Start Your Own
------------------------------
Date: Fri, 23 Oct 1998 10:34:18 +0100
From: Wolfgang Lux <lux@coo.mts.dec.com>
Subject: How to modify argv?
Message-Id: <36304D99.378E897F@coo.mts.dec.com>
I have the following question:
In a C program, I can modify the arguments in a way that ps prints the
modified
arguments (e.g. argv[1][2] = 'a').
In Perl, modifications to @ARGV have no effect to ps. @ARGV seems to be
a copy
of argv.
Can anybody tell me, how to modify argv from Perl?
Wolfgang Lux
Digital Cologne
------------------------------
Date: Fri, 23 Oct 1998 00:09:26 -0700
From: Ucalegon <eyebeam@unexpected.com>
Subject: how to use CGI to download
Message-Id: <36302BA0.43B681E2@unexpected.com>
Is there any way within a perl program running on the web to download a
file to the user's machine? If not, is there any way more
straightforward than generating html that asks the user to click on a
link to do the download?
If anyone has an answer, please e-mail me directly at
eyebeam@unexpected.com
Thanks.
------------------------------
Date: 23 Oct 1998 05:22:42 -0400
From: dblack@pilot.njin.net (David Alan Black)
Subject: Re: how to use CGI to download
Message-Id: <70pht2$v$1@pilot.njin.net>
Ucalegon <eyebeam@unexpected.com> writes:
>Is there any way within a perl program running on the web to download a
>file to the user's machine? If not, is there any way more
>straightforward than generating html that asks the user to click on a
>link to do the download?
Maybe a phone call?
David Black
dblack@pilot.njin.net
------------------------------
Date: 23 Oct 98 09:43:19 GMT
From: hjp@wsr.ac.at (Peter Holzer)
Subject: Re: Info on crypt()
Message-Id: <hjp.909135799@titan.wsr.ac.at>
bart.mediamind@ping.be (Bart Lateur) writes:
>Peter Holzer wrote:
>>bart.mediamind@ping.be (Bart Lateur) writes:
>>
>>>In particular I want to create my own password geberation/encryption
>>>code. One requirement I put on it, is that generated passwords only
>>>consist of upper case letter, and digits: [A-Z0-9].
>>
>>Sure you want upper case, not lower case? Most people would hate to hit
>>caps lock to enter their password (German users would hate it even
>>more, since German keyboards have a shift lock key instead of caps
>>lock).
>In fact, I make it case insensitive. Case sensitive "passwords" don't
>make much sense, since people usually can't see what they type in.
If you are stuck with 8 character passwords and care about security,
don't do this. You are taking out quite a chunk from the search space.
If convenience to the user is more important, this is good advice. You
should also avoid usng characters which are not easy to distinguish,
like "1" and "l" or "0" and "O".
> But anyway, no accented characters; only plain letters.
Right.
Standard crypt uses the lower 7 bits of each character only. If I enter
"v" (in ISO-Latin-1 charset) will be treated the same as "v". So using
accented characters doesn't buy you much, in only increases the chances
of problems with character sets or Keyboards.
hp
------------------------------
Date: Fri, 23 Oct 1998 09:07:28 GMT
From: nicolaslecart@my-dejanews.com
Subject: Re: Keith : CreateObject doesn't work via my browser
Message-Id: <70ph0f$uf0$1@nnrp1.dejanews.com>
Hello Keith,
i don't understand why it works with you (you are very lucky ;))) ), even if
there is a difference between our configuration (i use Win NT 4.0 with
NES3.5.1 when you use Win95 with MS personal Web server).
I do what you told me , and i can run "a simple CGI script on the same
*directory*, with the same *file
type* (like .pl for both) on the
same *system*, with the same *browser*
i am trying with my OLE script".
Moreover, the scripts have the same permissions.
The problem in my OLE script is that the CreateObject function can't create
an Excel application instance :((((((((
Thank you for your help anyway
Regards
Nicolas
In article <362D0CE2.7841184E@mindspring.com>,
keithmur@mindspring.com wrote:
> Actually the script works fine on my system (Win95 running MS Personal
> Web Server; the browser is Netscape 4.06). I take it from your previous
> postings that you *CAN* run a simple CGI script from a browser. Can you
> run a simple CGI script on the same *directory*, with the same *file
> type* (like .pl for both) on the same *system*, with the same *browser*
> that you're trying with your OLE script? Do the *scripts* have the same
> permissions (check the file properties)? If so, *I'm* baffled. Let me
> know.
>
>
-----------== Posted via Deja News, The Discussion Network ==----------
http://www.dejanews.com/ Search, Read, Discuss, or Start Your Own
------------------------------
Date: Fri, 23 Oct 1998 09:14:51 GMT
From: nicolaslecart@my-dejanews.com
Subject: Re: Matt : CreateObject doesn't work via my browser
Message-Id: <70pheb$uip$1@nnrp1.dejanews.com>
Hello Matt,
ok i found LAOLA and i 'll try to use it.
as you said, it seems to give me a lightweight solution
(it doesn't need to create an OLE object)
Thank you
Regards,
Nicolas
In article <362DB230.A7E8ADAC@ndirect.co.uk_NOSPAM>,
Matt Sergeant <msergeant@ndirect.co.uk_NOSPAM> wrote:
> I suggest you take a look at LAOLA (I think it's been renamed, but a
> search for LAOLA would get you the right thing). It is a much better way
> to get what you want, and much more lightweight too.
>
> --
> <Matt/>
-----------== Posted via Deja News, The Discussion Network ==----------
http://www.dejanews.com/ Search, Read, Discuss, or Start Your Own
------------------------------
Date: 23 Oct 1998 07:59:25 +0100
From: Jim Brewer <jimbo@soundimages.co.uk>
Subject: Re: Perl & Y2K - booby trap code
Message-Id: <ubtn3wype.fsf@jimbosntserver.soundimages.co.uk>
rjk@coos.dartmouth.edu (Ronald J Kimball) writes:
>
> What a ridiculous analogy. We can argue with analogies all day, but it
> will be completely futile if our analogies map so poorly onto reality.
>
> Is that analogy any better? Who cares. The fact remains, returning the
> year - 1900 is not intuitive. Simply returning the year would have been
> simpler and less likely to lead to programmer error.
>
Agreed. I will never use analogy again. For the record, your analogy
does not map onto reality that much better. Reading a note in the
glove box is NOT the same as reading the owners manual that the
manufaturer provides with the car. If the owners manual states a set
of procedures to ensure safe use of the hand brake, well that is a
different matter. If the owner fails to read the manual for the proper
use of the hand brake, isn't that the responsibility of the owner? If
the owner fails to read the manual for the proper and safe use of the
vehicle, should they be surprised when the vehicle fails in use that
deviates from that as prescribed in the manual?
Whatever happened to the 'RTFM, HTH.' posters? Suddenly its okay for
Perl programmers not to read the bloody thing. TFM, that is. One
cannot have it both ways. If the use and behaviour of the function is
documented where does the problem lie? With Perl? Not a chance. With
the programmer? Does it need to be so obvious?
The behaviour of the built-in bother you? Write a module to provide
you with the date in a format you find useful.
As an aside, there is a whole lot of Perl which seems unintuitive. So
what. The documentation exists for that purpose. To make clear the use
and behaviour of Perl. Not to render it intuitive. Even if that would
be nice.
--
Jim Brewer
e-mailed courtesy copies are unappreciated, please refrain.
------------------------------
Date: 23 Oct 1998 08:37:35 GMT
From: arzachel@best.spamazoid.com (Jason Witherspoon)
Subject: Re: Perl Modulus operator unreliable? Help!!
Message-Id: <3630404f$0$6384@nntp1.ba.best.com>
Hey all--
$price was generated by taking a price from a list (in this case,
17.99), multiplying by 100, before taking the modulus. The trick was
to round up to nearest nickel if the price was <9, or up to the nearest
quarter if it was over, & I figured modulus would be the easiest way to
go about this.
Yup, in the multiplication 17.99 * 100, one gets 1798.9999438798 or
somesuch. When I asked the debugger to print the price, it
conveniently rounds up for me, apparently. Which, of course, it
doesn't when it actually prints the price on my auto-generated html.
I just used the two math modules, which seem to help Perl considerably
w/accuracy (seems kind of non-existent w/o them, frankly, but I can
sense some of you are touchy on this point ;-) ). Anyway, thanks for
all the help (which I didn't realize had arrived until today-- uh,
sorry about the anti-spam measure making it difficult to e-mail me--
don't quite know how you guys get along w/o them, though!)
<><><>Remove the ".spamazoid" to reach me, unless ye be a spammer<><><>
Jason Witherspoon
--- ---
----O----
--- ---
--- ---
---------
--- ---
com/~arz
http://www.best.com/~arzachel
www.best.com/~arzachel
best.com/~a
------------------------------
Date: Fri, 23 Oct 1998 06:29:19 GMT
From: jlamport@calarts.edu
Subject: Re: reg-exp: change < to < but keep <I>
Message-Id: <70p7nv$m36$1@nnrp1.dejanews.com>
In article <70kjqc$g0a$1@cnn.cc.biu.ac.il>,
"Avshi Avital" <avitala@macs.biu.ac.il> wrote:
>
> Alex Farber wrote in message <361E43B1.CCD2F3D5@kawo2.rwth-aachen.de>...
> >[....]
> >the typical way not to let people use HTML-tags
> >in a webboard is to s/</</g and s/>/>/g
> >
> >But how do you still allow people using <I>, </I>,
> ><A HREF=""> and </A> ? I guess it is probably done
> >somehow with (!=...)
>
> you got that right!
> "lookahead" in perlre
Sure, if you want to write regexps that look like line-noise. A much more
readable solution is:
s|&|&|g; # "escape" ampersands,
s|<|<|g; # left brackets,
s|>|>|g; # and right brackets.
s|<I>|<I>|gi; # convert "escaped" <I>'s,
s|</I>|</I>|gi; # </I>'s,
s|<(A HREF="[^"]*")>|<$1>|gi; # <A HREF="">'s,
s|</A>|</A>|gi; # and </A>'s back into HTML tags.
Then again, maybe you aspire to win an obfuscated perl contest someday. Or
you're running Perl on a Commodore 64, and REALLY need those extra 60 bytes of
RAM.... then by all means, use (!=...) as often as possible. :)
-jason
-----------== Posted via Deja News, The Discussion Network ==----------
http://www.dejanews.com/ Search, Read, Discuss, or Start Your Own
------------------------------
Date: 23 Oct 1998 06:57:22 GMT
From: sholden@pgrad.cs.usyd.edu.au (Sam Holden)
Subject: Re: regexp matching having prblems..
Message-Id: <slrn730a6i.2oo.sholden@pgrad.cs.usyd.edu.au>
On Thu, 22 Oct 1998 21:57:46 GMT, bthak@bascom.com <bthak@bascom.com> wrote:
>okay why does the following code doesnt match...
>
>%hash = ( 'key' => '/a?b=c/;' );
>print "hash = " . $hash{key} . "\n";
print "hash = $hash{key}\n";
Is much nicer - in my opinion anyway...
>
>$match = $hash{key};
>
>print "match = " . $match . "\n";
>
>if ($hash{key} =~ /$match/) { print "match\n"; }
>else { print "no match\n"; }
>
>if ($hash{key} =~ $hash{key} { print "yeaaaaaaaaa a match"; }
>else { print "awwww no match"; }
Your missing a ) on that last if...
Maybe you should read the fine documentation that comes with perl...
In effect you are doing the following :
($hash{key} =~ m#/a?b=c/;#)
I'm pretty sure you don't want the two / and the ; in the pattern...
--
Sam
Even if you aren't in doubt, consider the mental welfare of the person
who has to maintain the code after you, and who will probably put parens
in the wrong place. --Larry Wall
------------------------------
Date: 21 Oct 1998 21:07:59 GMT
From: "Paul Popour" <ppopour@infoave.net>
Subject: SV_TYPE address for Novell 4.x Servers ?
Message-Id: <01bdfd36$b4a2ee80$f6a7d886@23dgwpr-p200>
Does anyone know the SV_TYPE codes for Novell 4.x servers.
I am able to list all of the NT servers in the NT domain with the following
Win32::NetAdmin::GetServers($pdc, $domain, 0x00000008, \@servers1);
Win32::NetAdmin::GetServers($pdc, $domain, 0x00000010, \@servers2);
Win32::NetAdmin::GetServers($pdc, $domain, 0x00008000, \@servers3);
The only documentation I can find for the GetServers function or the
SV_TYPE address list 0x00000080 as Novell servers, however, none are found
on that address.
Or, is the a Win32 module/function to get Novell information (tree names,
server names, volume names, volume free space, etc.,.)?
------------------------------
Date: 23 Oct 1998 05:17:09 -0400
From: dblack@pilot.njin.net (David Alan Black)
Subject: Re: write a long string...
Message-Id: <70phil$t9c$1@pilot.njin.net>
Hello -
dennis@info4.csie.nctu.edu.tw (GEMINI) writes:
>hi all,
> if I want to define a variable with a long string,
>I usually use:
> $A="a long string long string long string long string ".
> "a long string long string long string long string ".
> "a long string long string long string long string ";
> Is there any way to avoid from concatenate several strings into one
>and also not to write the string too long?
If you're talking about just creating a dummy string like the above,
you could do:
$A = "a long string " x 10;
or something like that.
David Black
dblack@pilot.njin.net
------------------------------
Date: 12 Jul 98 21:33:47 GMT (Last modified)
From: Perl-Request@ruby.oce.orst.edu (Perl-Users-Digest Admin)
Subject: Special: Digest Administrivia (Last modified: 12 Mar 98)
Message-Id: <null>
Administrivia:
Special notice: in a few days, the new group comp.lang.perl.moderated
should be formed. I would rather not support two different groups, and I
know of no other plans to create a digested moderated group. This leaves
me with two options: 1) keep on with this group 2) change to the
moderated one.
If you have opinions on this, send them to
perl-users-request@ruby.oce.orst.edu.
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 4052
**************************************