[6530] in Perl-Users-Digest
Perl-Users Digest, Issue: 155 Volume: 8
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Fri Mar 21 15:37:19 1997
Date: Fri, 21 Mar 97 12:00:31 -0800
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, 21 Mar 1997 Volume: 8 Number: 155
Today's topics:
curses perl module on Sun - need help! (Ralph Forsythe)
Re: diff. between 0 and "" <ian@dial.pipex.com>
Re: Do sysopen() and open() create equivalent filehandl <tmh@possibility.com>
File upload (Yinglee)
File upload (Yinglee)
Getting data in random order. <tshell@mcs.net>
Re: How to concat many digits to be one string? (Honza Pazdziora)
Re: How to concat many digits to be one string? <dehon_olivier@jpmorgan.com>
Re: How to concat many digits to be one string? (Tad McClellan)
Re: interupt option fo Perl <ian@dial.pipex.com>
Re: Multi-dimension array creation <tchrist@mox.perl.com>
Need Help Writing PERL script... FORMS/DB <saint@firefly.prairienet.org>
NNTPClient 2.6 problems <mystery@itis.com>
Re: Perl Compiler for DOS <jaywill@ix.netcom.com>
Re: Perl Data Structures Cookbook. Wher did it go? <joneil@is.ssd.k12.wa.us>
Perl under AIX: HELP!!! <walter.boev@nrc.ca>
Please Help With Regular Expression <quell@xnet.com>
Re: Please Help With Regular Expression (Tad McClellan)
Re: Please Help With Regular Expression (Brian L. Matthews)
Re: Recognizing spaces (Jeffrey)
Reg: tr command <zgeorge@eos.ncsu.edu>
Re: regex for UNIX usernames needed! <usenet-tag@qz.little-neck.ny.us>
Re: regex in perl4 <usenet-tag@qz.little-neck.ny.us>
seeking chat2 or comm <wsfaplau@sprynet.com>
Re: Single character representing all regexp metacharac (Dave Thomas)
Re: Single character representing all regexp metacharac (Bennett Todd)
Re: Split (Jeffrey)
surrogate for flastmod <rvince@sprynet.com>
Re: Telnet scripting with perl (Matthew H. Gerlach)
Re: TEST for empty DIR (Bob Wilkinson)
Re: TEST for empty DIR (Juergen Heinzl)
Re: undef() fails when given a list of arguments <rootbeer@teleport.com>
Re: Who makes more $$ - Windows vs. Unix programmers? <idfix@worldaccess.nl>
Re: Who makes more $$ - Windows vs. Unix programmers? (Peter da Silva)
Digest Administrivia (Last modified: 8 Mar 97) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: 21 Mar 1997 18:44:05 GMT
From: ralph@hemi.com (Ralph Forsythe)
Subject: curses perl module on Sun - need help!
Message-Id: <5guktl$9l2@news.hemi.com>
I installed the Curses module for perl 5.003 on a Sun Sparc 4/330, running
SunOS 4.1. The install seemed to go OK, but when I try the demo programs
like the install suggests I get a bunch of "library not found" stuff,
which probably means that the curses install itself will not work
properly... help!!!
- ralph forsythe
ralph@contact-paging.com
------------------------------
Date: Fri, 21 Mar 1997 15:35:42 +0000
From: Ian Phillipps <ian@dial.pipex.com>
Subject: Re: diff. between 0 and ""
Message-Id: <3332AACE.3DE8@dial.pipex.com>
Susan Starr wrote:
> if ($val == "") { return 0; }
> to the function isbetween, then, when $val is equal to 0, the function
> returns 0; How can I fix this?
Use
$val eq ''
instead. The == operator does a numerical comparison, with
no-number-at-all defaulting to 0.
If you want your "between" to be robust with respect to non-numerical
strings, then you probably need to do more checking of the format of the
values - e.g. you could insist on integers:
die "Non-numeric value $val to &between" unless $val =~ /^[-+]?\d+$/;
Ian
------------------------------
Date: Fri, 21 Mar 1997 10:31:13 -0800
From: Todd Hoff <tmh@possibility.com>
Subject: Re: Do sysopen() and open() create equivalent filehandles?
Message-Id: <3332D3F1.6A72@possibility.com>
Tom Christiansen wrote:
> :Tangential idea: With all the CGI going on, it may be useful for open()
> :to grow a "lockable" option. Not only would it be convenient, but many
> :people need locking without realizing it.
>
> No, I don't want to make it more convenient. Locking is tough stuff.
> They will learn to do it right, or stop pretending to be programmers.
Also browsers tend to leave around a lot of processes which means
all these locks won't be released. This can lead to a lot of
subtle problems.
---------------------------------------------------------------------
tmh@possibility.com | I have no interest in any ship that does
http://www.possibility.com | not sail fast, for I plan to go in
| harm's way. -- J.P. Jones
------------------------------
Date: Fri, 21 Mar 97 17:20:51 GMT
From: yinglee@hkstar.com (Yinglee)
Subject: File upload
Message-Id: <5gug4d$kma@capella.hkstar.com>
I am using WinNT4.0 + Perl 5 + Netscape 3 to upload file(binary) from client
to server. The size of uploaded file usually > 1Mb. So I can't use cgi-lib.pl
I use the follow code to read from STDIN and write to a file.
------------------------------
Date: Fri, 21 Mar 97 17:14:55 GMT
From: yinglee@hkstar.com (Yinglee)
Subject: File upload
Message-Id: <5gufp9$jld@capella.hkstar.com>
I am using WinNT4.0 + Perl 5 + Netscape 3 to upload file(binary) from client
to server. The size of uploaded file usually > 1Mb. So I can't use cgi-lib.pl
I use the follow code to read from STDIN and write to a file.
------------------------------
Date: Fri, 21 Mar 1997 12:11:52 -0600
From: Timothy Shell <tshell@mcs.net>
Subject: Getting data in random order.
Message-Id: <3332CF68.B3A@mcs.net>
I have been unable to come up with an elegant way to do this, and as
always, there's this nagging suspicion that I'm overlooking something
simple.
I want to output a list of records in a random sequence each time the
program runs. So if I have a data file with 100 records, I'd like to
pick, say, 20 records at random and display them in no particular order.
Thanks for any help,
--
Timothy Shell : tshell@mcs.net
Freedom's Nest: http://www.freedoms-nest.com
------------------------------
Date: Fri, 21 Mar 1997 16:18:02 GMT
From: adelton@fi.muni.cz (Honza Pazdziora)
Subject: Re: How to concat many digits to be one string?
Message-Id: <adelton.858961082@aisa.fi.muni.cz>
Joruno Jobana <b39jrj@nontri.ku.ac.th> writes:
> Dear,
> I write program for randomming 8 digits.
>
> #/usr/bin/perl
> srand(time|$$);
> for($i=0;$i<8;$i++) {
> $ID[$i]=int(rand(10));
> }
>
> I want to concat all 8 digits to be one string;
>
> e.g.
> The random result is
> $ID[0] = 2 $ID[1] = 4 $ID[2] = 6 $ID[3] = 8
> $ID[4] = 1 $ID[5] = 3 $ID[6] = 5 $ID[7] = 7
> I want this output
> $ST = "24681357"
Array, when put into a string, gets expanded and the elements are
separated by value of $". So this will do the work for you:
$"='';
$ST = "@ID";
Hope this helps.
--
------------------------------------------------------------------------
Honza Pazdziora | adelton@fi.muni.cz | http://www.fi.muni.cz/~adelton/
I can take or leave it if I please
------------------------------------------------------------------------
------------------------------
Date: 21 Mar 1997 17:00:36 +0000
From: Olivier Dehon <dehon_olivier@jpmorgan.com>
Subject: Re: How to concat many digits to be one string?
Message-Id: <njzpvwtkwnf.fsf@jpmorgan.com>
Joruno Jobana <b39jrj@nontri.ku.ac.th> writes:
>
> Dear,
> I write program for randomming 8 digits.
>
> #/usr/bin/perl
> srand(time|$$);
> for($i=0;$i<8;$i++) {
> $ID[$i]=int(rand(10));
> }
>
> I want to concat all 8 digits to be one string;
>
> e.g.
> The random result is
> $ID[0] = 2 $ID[1] = 4 $ID[2] = 6 $ID[3] = 8
> $ID[4] = 1 $ID[5] = 3 $ID[6] = 5 $ID[7] = 7
> I want this output
> $ST = "24681357"
>
> Sincerely.
Search for 'join' in the perlfunc manpage. This should do what you need.
$ST = join('', @ID);
Hope this helps.
Olivier Dehon
------------------------------
Date: Fri, 21 Mar 1997 11:10:15 -0600
From: tadmc@flash.net (Tad McClellan)
Subject: Re: How to concat many digits to be one string?
Message-Id: <ndfug5.802.ln@localhost>
Olivier Dehon (dehon_olivier@jpmorgan.com) wrote:
: Joruno Jobana <b39jrj@nontri.ku.ac.th> writes:
: >
: > Dear,
: > I write program for randomming 8 digits.
: >
: > #/usr/bin/perl
: > srand(time|$$);
: > for($i=0;$i<8;$i++) {
: > $ID[$i]=int(rand(10));
: > }
: >
: > I want to concat all 8 digits to be one string;
: >
: > e.g.
: > The random result is
: > $ID[0] = 2 $ID[1] = 4 $ID[2] = 6 $ID[3] = 8
: > $ID[4] = 1 $ID[5] = 3 $ID[6] = 5 $ID[7] = 7
: > I want this output
: > $ST = "24681357"
: >
: > Sincerely.
: Search for 'join' in the perlfunc manpage. This should do what you need.
: $ST = join('', @ID);
or simply:
$" = '';
$ST = "@ID";
--
Tad McClellan SGML Consulting
Tag And Document Consulting Perl programming
tadmc@flash.net
------------------------------
Date: Fri, 21 Mar 1997 15:26:25 +0000
From: Ian Phillipps <ian@dial.pipex.com>
Subject: Re: interupt option fo Perl
Message-Id: <3332A8A1.185@dial.pipex.com>
SRFord wrote:
>
> Is there a command in Perl that can perform a certain action if a user
> who
> is running the script hits control-C. I'm writing a menu type script
> and I do not want users to be able to exit to the command line by typing
> control-C. Is this possible in Perl. Thanks.
Check out the @SIG array in perlvar.
You'll need to set $SIG{'INT'} to trap the Ctrl/C, but don't forget that
if it's Unix, the user has other tricks available, e.g. TSTP, ABORT,
TERM, QUIT. Also note that a user can *always* terminate a process with
an untrappable signal (SIGKILL) if sufficiently dedicated and
knowledgable.
http://www.metronet.com/perlinfo/doc/manual/html/pod/perlvar.html#item__SIG_expr_
Ian
------------------------------
Date: 21 Mar 1997 19:04:03 GMT
From: Tom Christiansen <tchrist@mox.perl.com>
Subject: Re: Multi-dimension array creation
Message-Id: <5gum33$a91$1@csnews.cs.colorado.edu>
[courtesy cc of this posting sent to cited author via email]
In comp.lang.perl.misc,
Jose4 Carlos Oliveira Pereira <jcp@misty.EUnet.pt> writes:
:I'm having trouble creating multidimension arrays.
..
: I don't think that this is supported by perl.
Sure it is.
:All the documentation I have on multi-dimension array emulation isn't
:very clear.(I am using perl5.003 but have only perl4 documentation :( )
That's a big problem.
See http://www.perl.com/perl/nmanual/index.html for how to get much
better documentation, include stuff to do what you want here.
--tom
--
Tom Christiansen tchrist@jhereg.perl.com
The autodecrement is not magical.
--Larry Wall in the perl man page
------------------------------
Date: Fri, 21 Mar 1997 12:59:19 -0600
From: "$T.&REUX,KSC" <saint@firefly.prairienet.org>
Subject: Need Help Writing PERL script... FORMS/DB
Message-Id: <3332DA87.5178@firefly.prairienet.org>
Okay...
I've looked at all the PERL scripts out there,
but I'm still new to this game and need a little
help...
What I would like the script to do is to accept
stuff from a feedback form, stuff it into a SQL Server 6.5
database, and *also* email the results to me (just so
I can have 'em).
That way, I can use the results in a dynamic page that'll
kind of give me running totals while on the web.
Any suggestions as to sample programs or whatnot?
thanks in advance...
andrew
--
$T.&REUX,KSC ---><--- OGYR NETWORK saint@prairienet.org
The SacraMenstrual Church of the SubGenius Outreach Ministry
LOGIC OF SLACK :: PURE HATRED IS THE PUREST FORM OF LOVE
------------------------------
Date: Fri, 21 Mar 1997 14:02:46 -0500
From: Prince Mystery <mystery@itis.com>
Subject: NNTPClient 2.6 problems
Message-Id: <3332DB56.167E@itis.com>
Hi,
I can't seem to get NNTPClient to run. I got the latest version off of
CPAN, but it seems like my server is lacking something.
I'm trying to get the latest articles in a particular group from the
last 24 hours. Unfortunately, the server at which I'm trying to
retrieve these articles does not implement the newnews command. When I
run help, here is the list I'm given:
authinfo
help
ihave
check
takethis
list
mode
quit
head
stat
xpath
xreplic
For more information, contact "news" at this machine.
Now, some of these commands aren't implemented in the NNTPClient object,
so I'm not sure what they do.
Do you have any idea which command I should use to retrieve the newnews
that I'm looking for?
Thomas
------------------------------
Date: Fri, 21 Mar 1997 10:04:18 -0800
From: Jason Williamson <jaywill@ix.netcom.com>
Subject: Re: Perl Compiler for DOS
Message-Id: <3332CDA2.42F5@ix.netcom.com>
Guy Saner wrote:
>
> Does anybody have, or know the location of
> a precompiled version of the Perl Compiler for DOS.
> By Perl Compiler, I mean the compiler that converts
> Perl code into C code. I think it's still in it's alpha release.
>
> Thanks in advance.
>
> Guy
I know that the Walnut Creek CD release of Perl5 had a DOS perl compiler
in the perlsrc directory.
--
Jason Williamson
(jaywill@ix.netcom.com)
------------------------------
Date: Fri, 21 Mar 1997 07:50:01 -0800
From: Jerome O'Neil <joneil@is.ssd.k12.wa.us>
To: Tom Christiansen <tchrist@mox.perl.com>
Subject: Re: Perl Data Structures Cookbook. Wher did it go?
Message-Id: <3332AE28.4723@is.ssd.k12.wa.us>
Tom Christiansen wrote:
> In comp.lang.perl.misc,
> type
>
> man perldsc
>
Thanks, but I'm looking to distribute a URL to some people who may not
have access to the man pages, so the on-line version is realy what I
need.
> http://www.perl.com/perl/nmanual/html/pod/perldsc.html
http://www.perl.com/perl/nmanual/html/pod/perldsc.html returns
File Not Found
The requested URL /perl/nmanual/html/pod/perldsc.html was not found on
this server.
Jerome
------------------------------
Date: 21 Mar 1997 15:51:52 GMT
From: "Walter Boev" <walter.boev@nrc.ca>
Subject: Perl under AIX: HELP!!!
Message-Id: <01bc360f$ada348e0$5d50f684@pc93.cisti.nrc.ca>
Hi ALL,
I work at the National Research Council and am trying to compile
Perl 5.03 Under AIX (4.14) on a RISC 6000 machine.
I use all the standard defaults and the compilation script recognizes that
I am using AIX.
I get the following error messages:
"/usr/include/unistd", line 92.12: 1506-046 (S) Syntax error.
"toke.c", line 127.13: 1506-045 (S) Undeclared identifier toketype.
The first error line is merely the declaration of pause() as an external
function.
The second line complains that the variable toketype is undeclared. However
it is
declared as type int about 4 lines before it is used.
Can anyone help? Has anyone compiled PERL under AIX successfully?
Thanks.
Walter Boev
e-mail: walter.boev@nrc.ca
------------------------------
Date: Fri, 21 Mar 1997 10:09:23 -0600
From: quell <quell@xnet.com>
Subject: Please Help With Regular Expression
Message-Id: <3332B2B3.E32@xnet.com>
Hello,
I need a regular expression to replace spaces with underscores. I
tried this and it did not work:
$attribute1 =~ s/ /_/g;
I also tried this:
$attribute1 =~ s/\s/_/g;
Thanks in advance for any help.
RMroch
------------------------------
Date: Fri, 21 Mar 1997 11:05:31 -0600
From: tadmc@flash.net (Tad McClellan)
Subject: Re: Please Help With Regular Expression
Message-Id: <r4fug5.802.ln@localhost>
quell (quell@xnet.com) wrote:
: Hello,
: I need a regular expression to replace spaces with underscores. I
: tried this and it did not work:
: $attribute1 =~ s/ /_/g;
: I also tried this:
: $attribute1 =~ s/\s/_/g;
There is something wrong elsewhere in your program.
So we cannot help you.
To avoid this in the future, you may want to consider giving us a
_complete script_ (like below) that illustrates your problem.
----------------
#! /usr/bin/perl -w
$attribute1 = "quell at Another Netscape News Server User\n";
$attribute1 =~ s/ /_/g;
print $attribute1;
----------------
works for me...
--
Tad McClellan SGML Consulting
Tag And Document Consulting Perl programming
tadmc@flash.net
------------------------------
Date: 21 Mar 1997 11:07:42 -0800
From: blm@halcyon.com (Brian L. Matthews)
Subject: Re: Please Help With Regular Expression
Message-Id: <5gum9u$gdr$1@halcyon.com>
In article <3332B2B3.E32@xnet.com>, quell <quell@xnet.com> wrote:
| I need a regular expression to replace spaces with underscores. I
|tried this and it did not work:
|$attribute1 =~ s/ /_/g;
|I also tried this:
|$attribute1 =~ s/\s/_/g;
I suggest you check the logic that led you to the conclusion neither
of those work, because they both do. Of course the second one replaces
more than just spaces, but it does the spaces too.
You could also look at tr: $attribute1 =~ tr/ /_/;
Brian
--
Brian L. Matthews Illustration Works, Inc.
For top quality, stock commercial illustration, visit:
http://www.halcyon.com/artstock
------------------------------
Date: 21 Mar 1997 16:57:53 GMT
From: jfriedl@tubby.nff.ncl.omron.co.jp (Jeffrey)
To: mriggsby@sybex.com
Subject: Re: Recognizing spaces
Message-Id: <JFRIEDL.97Mar22015753@tubby.nff.ncl.omron.co.jp>
[mail and post and cc to FAQ maintainer (possible inclusion Tom?)]
Matt Riggsby <mriggsby@sybex.com> wrote:
|> ...take the text (which I'm calling $message), strip out any existing
|> linefeeds, then parse through the text and put in a \n after every word
|> that takes a line over a given number of characters (as the code
|> fragment below indicates, I'm trying to end up with lines not much over
|> 60 characters long).
If you're looking for a ``hey, I didn't know I could do that'' method
to amaze and impress your friends, you might consider:
$DesiredWidth=60; # setup
:
$start = $DesiredWidth;
while ($start < length($message))
{
substr($message, $start) =~ s/(\S*)\s+/$1\n/;
$start += length($1) + $DesiredWidth + 1;
}
Yup, you can apply a substitution to a substr() of a variable and have it
``work'' right.
However, if you want it simple, understandable, and a lot faster way....
The Perl Way... you might try simply:
$tmp = $DesiredWidth - 1;
$message =~ s/\G(.{1,$tmp}\S+)\s+/$1\n/go;
Basically, the /.{1,$tmp}/ grabs most of what you want, and the \S+ takes
you to the 60-column mark (or beyond). However, if the 60-column mark is
whitespace, the /.{1,$tmp}/ will backpedal to just before the start of the
whitespace. In either case, that's where the line is split -- whitespace is
then replaced by a single newline.
On the other hand, if you want to match up to *but not beyond* the Desired
Width, remove a key '+' and you're set:
$message =~ s/\G(.{1,$tmp}\S)\s+/$1\n/go;
It might be instructive to really understand, intrinsically, the difference
between the two.
|> @chars = split(//, $message);
|> foreach $variable (0 .. $#chars) {
Somehow I get a feeling that what follows is definately not The Perl Way.
Looks more like C or something....... /-:
Jeffrey
----------------------------------------------------------------------------
Jeffrey Friedl <jfriedl@ora.com>
O'Reilly & Associates' _Mastering Regular Expressions_
http://enterprise.ic.gc.ca/~jfriedl/regex/
------------------------------
Date: Fri, 21 Mar 1997 14:12:16 -0500
From: Zacharia George <zgeorge@eos.ncsu.edu>
Subject: Reg: tr command
Message-Id: <3332DD90.3E5B@eos.ncsu.edu>
Hi,
Could someone please tell me how to convert from Uppercase to
Lowercase in a string EXCEPT for the first letter of each word in the
string. I assume that the "tr" command (I may be wrong!) can do this but
I am not sure how.
e.g.:
to convert
ZACHARIA GEORGE to Zacharia George
Thanks in advance.
Zac.
--
Zacharia George | e-mail: zgeorge@eos.ncsu.edu
------------------------------
Date: 21 Mar 1997 18:39:26 GMT
From: Eli the Bearded <usenet-tag@qz.little-neck.ny.us>
Subject: Re: regex for UNIX usernames needed!
Message-Id: <5gukku$qv2$1@news.netusa.net>
Brian <signal@shreve.net> wrote:
>Has anyone written a thourough regular expression that I can use to
>filter valid UNIX usernames with?
Is there a specification for "valid UNIX usernames"? I have never
seen one.
>I am using: /^[a-zA-Z]{1,8]$/
>
>but feel I need more than that.......I want to use this so the user wont
You left out numbers, most obviously. I've also seen - in usernames
(finger hal-j@netusa.net). Due to the format of the passwd file,
I think the best one can do without a specification is:
/^[^\s:]{1,8}$/
Elijah
------
wondering if & in usernames would break any & in full name implementations
------------------------------
Date: 21 Mar 1997 18:19:31 GMT
From: Eli the Bearded <usenet-tag@qz.little-neck.ny.us>
Subject: Re: regex in perl4
Message-Id: <5gujfj$qu1$1@news.netusa.net>
Bruno Pagis <pagib@aur.alcatel.com> wrote:
>I want to extract the second field (the one conaining Ys)
>in the following lines:
>X:Y:Z:
>XXX:YYYY:Z:WW:Q
>ZZ:YY:DD:SSSSSS:HHHHH
>
>And I'm stuck. In perl5, I would do
>/^.*?:(.*?):.*$/
>but what about perl4 where non-greedy modifiers don't exist.
If you don't want :'s matched in some part, don't ask for them.
/^[^:]*:([^:]*):.*$/
Your perl5 'solution' is pretty ugly, IMNSHO.
Elijah
------
Friedl could probably tell you which is more effecient, I don't care much
------------------------------
Date: Fri, 21 Mar 1997 10:23:27 -0500
From: Bob Kryger <wsfaplau@sprynet.com>
Subject: seeking chat2 or comm
Message-Id: <3332A7EF.5172@sprynet.com>
I am looking to write what used to be called a 'chat script' and as
I learn Perl5 I see that chat2 is not the prefered method (if it'll even
work is questionable in my mind). The FAQ says to use a module called
COMM. but I cannot seem to find it in CPAN or elsewhere. Can someone
please point me in the right direction?
Thanks.
Bob
--
Bob Kryger
mailto:wsfaplau@sprynet.com
Web Site: Soon to come
*************************** Disclaimer ******************************
* *
* The above statements are my opinions and do not represent the *
* position(s) of my employer, family, state, national government, *
* religious or professional affiliates, or the almighty it's *
* ever-flowing-self. If you care to take me more seriously than *
* I do myself, then congratulations, for you are a greater being *
* than I. *
* *
*********************************************************************
Work Info:
---------- (914) 345-1100 - Main
Senior Member of Technical Staff (914) 789-0333 - Direct
NextWave Wireless Inc. (914) 345-1140 - FAX
3 Skyline Drive
Hawthorne, NY 10532 mailto:bkryger@nextwavetel.com
http://www.nextwavetel.com
------------------------------
Date: 21 Mar 1997 14:40:07 GMT
From: dave@fast.thomases.com (Dave Thomas)
Subject: Re: Single character representing all regexp metacharacters? wheeere?
Message-Id: <slrn5j57e5.6ib.dave@fast.thomases.com>
On Fri, 21 Mar 1997 08:01:24 -0600, x@apocalypse.org wrote:
> Is there a single escaped character which represents all the
> metacharacters recognized by the perl regexp engine?
No, but from 'perldoc perlre'
\E end case modification (think vi)
\Q quote regexp metacharacters till \E
HTH
Dave
--
_________________________________________________________________________
| Dave Thomas - Dave@Thomases.com - Unix and systems consultancy - Dallas |
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
------------------------------
Date: Fri, 21 Mar 1997 19:00:02 GMT
From: bet@nospam.interactive.net (Bennett Todd)
Subject: Re: Single character representing all regexp metacharacters? wheeere?
Message-Id: <slrn5j5mli.pbk.bet@onyx.interactive.net>
On Fri, 21 Mar 1997 08:01:24 -0600, x@apocalypse.org <x@apocalypse.org> wrote:
>I'm trying to program a simple search engine with user input...
Why not leave the input alone, and use something like
$data =~ m/\Q$user_input/
or whatever. From the perlre(1) man page:
\Q quote regexp metacharacters till \E
-Bennett
------------------------------
Date: 21 Mar 1997 17:27:57 GMT
From: jfriedl@tubby.nff.ncl.omron.co.jp (Jeffrey)
To: b.wilkinson@NOSPAM.pindar.co.uk (Bob Wilkinson)
Subject: Re: Split
Message-Id: <JFRIEDL.97Mar22022757@tubby.nff.ncl.omron.co.jp>
[mail and post]
Bob Wilkinson <b.wilkinson@NOSPAM.pindar.co.uk> wrote:
|> > $tmp="a|||b|||";
|> > @li=split('\|',$tmp);
|> >
|> > This program split string into array with size only 4. Why?
|>
|> Split expects a /PATTERN/ as the first parameter, rather than a string.
No, split expects either. Strings (except for " " and the like -- ' ', q{ },
etc., which are special) are taken as patterns. The differences are that
normal string processing is done before the regex engine gets ahold of it,
and the regex is not cached.
(Now, that being said, the use of a string instead of a pattern is probably
more often a misunderstanding on the part of the programmer than the
use of a feature.)
However, as other responders have pointed out, this has nothing to do with
the misunderstanding that the original poster had. As the man page clearly
says, trailing empty fields are normally stripped.
Lewis Taylor <lewis@nexusint.com> suggested:
|> One unelegant but practical solution, is therefore to append some
|> arbitrary character to the string, split it and then remove the last
|> element.
A better solution would be to supply -1 as the 3rd argument, which tells
Perl to not strip trailing empty fields. [see Hip Owls p262]
Jeffrey
----------------------------------------------------------------------------
Jeffrey Friedl <jfriedl@ora.com>
O'Reilly & Associates' _Mastering Regular Expressions_
http://enterprise.ic.gc.ca/~jfriedl/regex/
------------------------------
Date: 21 Mar 1997 14:00:16 GMT
From: "R. Vince" <rvince@sprynet.com>
Subject: surrogate for flastmod
Message-Id: <01bc3600$1df61e20$cac0a6cf@isjfvklh>
IS anyone aware of a public domain script which does the equivalent of the
SSI <--#flastmod for files on a different server? I am trying to create a
script which returns the date of the last revision to a file on a remote
server. Thanks, Ralph
------------------------------
Date: Fri, 21 Mar 1997 16:11:28 GMT
From: gerlach@netcom.com (Matthew H. Gerlach)
Subject: Re: Telnet scripting with perl
Message-Id: <gerlachE7EIB4.JEs@netcom.com>
Another alternative, if you are running on the more common flavors of
UNIX is to use Comm.pl. It has examples of "talking" to the telnet
program.
Matthew
In article <t6x67yllv0z.fsf@fluffy.rgrs.com> Jay Rogers <jay@rgrs.com> writes:
>"Joonas Kekoni" <jkekoni@cc.hut.fi> writes:
>
>> So i think using the telnet program is not an option. I am not familiar
>> with tcpip-programming, so i thought it could be easier to find a ready
>> "telnet script" and
>> then change it to fit my purpose.
>
>I just released Net::Telnet which should do what you want. Is has an
>easy to use interface, especially for those unfamiliar with TCP
>programming. You can also use it to communicate with ports other than
>TELNET. It also has interactive features that make it easier to
>communicate with the program at the other end of the telnet session.
>
>It's located at:
>
> $CPAN/modules/by-module/Net/Net-Telnet-3.00.tar.gz
>
>To find a CPAN site near you see ftp://ftp.cis.ufl.edu/pub/perl/CPAN/SITES
>
>--
>Jay Rogers
>jay@rgrs.com
------------------------------
Date: Fri, 21 Mar 1997 15:51:26 -0500
From: b.wilkinson@NOSPAM.pindar.co.uk (Bob Wilkinson)
Subject: Re: TEST for empty DIR
Message-Id: <b.wilkinson-2103971551260001@ip57-york.pindar.co.uk>
In article <3331E418.4885@nexusint.com>, lewis@nexusint.com wrote:
> Here is a very long (and primative) routine I wrote to test if the
> directory in $d is empty
>
> $c=0;
> opendir(D,$d);while(readdir(D)){$c++;}closedir(D);
> if ($c > 2) # remember ./ and ../
> {#directory not empty}
> else
> {#directory empty}
>
> it works but there must be more elegant code to do the same, is there?
>
> Cheers, Lewis (lewis@nexusint.com)
>From the entry about readdir in pink camel pp.170 -
If there are no more entries, the function returns an undefined value in
a scalar context, or a null list in an array context.
Therefore, I think that you should be able to do
opendir(D,$d) or die "Can't open directory, $d, $!";
if (readdir(D)) {
#directory not empty
} else {
#directory empty
}
closedir(D)
If you are working under Unix and want to avoid "." and ".." then you'd do
if (grep(!/^\.\.?$/,readdir(D)) {
#directory not empty
} else {
#directory empty
}
Bob
--
I have become death, destroyer of the worlds.
------------------------------
Date: 21 Mar 1997 18:53:38 GMT
From: juergen@unicorn.noris.de (Juergen Heinzl)
Subject: Re: TEST for empty DIR
Message-Id: <slrn5j5m90.mk.juergen@unicorn.noris.de>
Hello,
>$c=0;
>opendir(D,$d);while(readdir(D)){$c++;}closedir(D);
>if ($c > 2) # remember ./ and ../
why not just skipping . and .. and the next readdir()
either fails (due to an error or an empty directory)
or it succeeds ?
Not terribly elegant but I would like to know a better
way too.
Bye, Juergen
--
\ Real name : Juergen Heinzl \ no flames /
\ EMail Private : unicorn@noris.de \ send money instead /
\ Phone Private : +49 0911-4501186 \ /
------------------------------
Date: Fri, 21 Mar 1997 11:01:14 -0800
From: Tom Phoenix <rootbeer@teleport.com>
To: Patrick Duff <pduff@airmail.net>
Subject: Re: undef() fails when given a list of arguments
Message-Id: <Pine.GSO.3.96.970321105336.14218C-100000@kelly.teleport.com>
On Fri, 21 Mar 1997, Patrick Duff wrote something like this (edited for
brevity).
> when I do something like
>
> undef(%one,%two,%three);
>
> I get the error messages:
>
> Useless use of "%two" in void context.
> Useless use of "%three" in void context.
> IMHO, undef should do what I mean when I pass it a list of variable
> names.
> regards, Patrick Duff (pduff@airmail.net)
I tend to agree, but I don't know whether there's some reason it can't be
done. (Prototypes, perhaps?) I'm forwarding this idea to p5p because maybe
somebody there has either a reason or a patch.
-- Tom Phoenix http://www.teleport.com/~rootbeer/
rootbeer@teleport.com PGP Skribu al mi per Esperanto!
Randal Schwartz Case: http://www.lightlink.com/fors/
------------------------------
Date: 21 Mar 1997 14:28:14 GMT
From: Silvio Bierman <idfix@worldaccess.nl>
Subject: Re: Who makes more $$ - Windows vs. Unix programmers?
Message-Id: <5gu5tu$28l28@easy4.worldaccess.nl>
bdh@nospam.deus.com (William de Haan) writes: > In message <332A07CA.3949@ici.net>, on Fri, 14 Mar 1997 21:22:02 -0500, Alicia
> Carla Longstreet <carla@ici.net> wrote:
>
> >I can see it now, the Windows NT Server continously telling the Novell
> >Server how beautiful it is. I think you mean complEment. See below.
>
> Cute ;-)
>
> >Actually, didn't Novell get really smart a couple of years ago and buy
> >Unix from AT&T? In any event, they are supposedly perfecting a product
>
> Yes, Novell bought Unix from USL several years ago, cursed be their
> names. They treated it with the same respect and reverance that they
> showed WordPerfect.
>
> >called Unixware, which will be a Unix Server OS with built-in Netware
> >support. It will make a terrific Server.
>
> It's been out for a while, actually. Are you talking about something
> new?
>
> ________________________________________________________________________
> William de Haan bdh@deus.com 905-281-3523 Voice 905-281-3524 Fax
> Deus Ex Machina Ltd., 3650 Kaneff Crescent, Mississauga, Ontario L5A 4A1
> No hablo espanol. Non parlo Italiano. eG'K Hy's Klingon.
>
Novell sold Unix to SCO over a year ago.
SCO had its own Unix version which had been derived from an
earlier version of Unix. The SCO kernel was really outdated
and SCO will probably merge what was known as UnixWare with
SCO Unix.
Silvio Bierman
Nijmegen, The Netherlands
------------------------------
Date: 21 Mar 1997 18:29:44 GMT
From: peter@nmti.com (Peter da Silva)
Subject: Re: Who makes more $$ - Windows vs. Unix programmers?
Message-Id: <5guk2o$btu@web.nmti.com>
In article <5fumqk$35v$1@news.calweb.com>,
John Lockwood <johnl@calweb.com> wrote:
> Unix is more advanced technically? That's interesting. The last time
> I installed a modem on Windows NT the OS found it for me.
OK, now install a PROM programmer on NT. Does the OS find it for you?
Nope.
The OS didn't find it for you, an application did.
Nobody has written those applications for the version of UNIX you were using
(I don't know what NeXT does), and the application you were using on UNIX to
dial the modem was less proactive than the NT one.
Try running vanilla kermit on both.
Exactly the same behaviour.
--
The Reverend Peter da Silva, ULC, COQO, BOFH.
Har du kramat din varg, idag? `-_-'
------------------------------
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 155
*************************************