[7975] in Perl-Users-Digest
Perl-Users Digest, Issue: 1600 Volume: 8
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Thu Jan 8 09:08:25 1998
Date: Thu, 8 Jan 98 06:01:11 -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 Thu, 8 Jan 1998 Volume: 8 Number: 1600
Today's topics:
2 file scripts and -w <wallp@earthlink.net>
Re: 2 file scripts and -w <zenin@best.com>
[Help] Capturing STDOUT under DOS ? (Augusto Cardoso)
Re: Calling 'require' on an arbitrary module <joseph@5sigma.com>
Re: CgiWrap - perl: can't map file error <makler@man.torun.pl>
Convert .bmp to .jpg via Perl (Eric Hilding)
Convert .bmp to .jpg via Perl (Eric Hilding)
Database File Manipulation? <michael.georgiadis@btinternet.com>
Re: ex-ish or sed-ish regexp manipulation (Tom Grydeland)
Re: file glob restrictions?! <joseph@5sigma.com>
Re: file glob restrictions?! (Jeffrey R. Drumm)
Re: Firewalls and UserAgent (Martin Vorlaender)
Re: Good place to start in Perl 5 <jes@dircon.co.uk>
Re: Good place to start in Perl 5 (Lynchqvctc)
Re: Hash Slice Syntax Question (Gerry Buzzell)
how does 'require' work? <michael.georgiadis@btinternet.com>
Re: Modularize non object code <tchrist@mox.perl.com>
Perl and Visual Basic? <bts@proof.org>
Perl programming with NT4.0: sendmail problem <splyc2@klm.nl>
Perl Question <SIDDIQM2@boat.bt.com>
POP3 <pesalomo@online.no>
Re: range operator with decimal numbers <joseph@5sigma.com>
Re: readdir() and file named '0' <kgraham@alpha.furman.edu>
Re: regex to escape {, } except in TeX commands <*@qz.to>
Re: serious post about gmtime and year-1900 (was Re: Pe (Chris Nandor)
Simple array initialisation question (Keith Oborn)
Re: Simple array initialisation question Remove xx to reply xxTony.Curtis@vcpc.univie.ac.at>
Re: soriting a file <mgm@gxn.net>
Telnet client written in perl (Stefan Herz)
Re: Testing for valid RegExps? <ajohnson@gpu.srv.ualberta.ca>
Re: Testing for valid RegExps? <tchrist@mox.perl.com>
Re: Testing for valid RegExps? <tchrist@mox.perl.com>
Unpacking length-infor style data. <rjc@liddell.cstr.ed.ac.uk>
Digest Administrivia (Last modified: 8 Mar 97) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: Wed, 07 Jan 1998 23:15:02 -0600
From: Philip Wall / Wild Card <wallp@earthlink.net>
Subject: 2 file scripts and -w
Message-Id: <34B460D6.45E1@earthlink.net>
Greetings all,
Hopefully someone here can point me in the right direction on how to
get this working correctly. I've been through the manpages (perlsup,
Exporter) and for some reason it just won't click how to get this to
work.
I have a Perl CGI script that I want to be able to run under mod_perl
for Apache using Taint checking, warns and strict. The script is in 2
seperate files.
The first file, which is called by the client, does nothing but setup
a few configurable variables then makes a call to a function in the
second file which does all the work. The second file is brought in using
a require statement.
Without taint, strict or warn everything works right as rain. But with
mod_perl it's best to use these or run into variables from one script
pounding anothers.
With use strict, perl throws errors about packages. So I attach my to
all the variables in the first file. This of course won't work as far as
I can tell becuase of scoping issues with my. Using local still requires
package statements.
After putting in a few package statements warn complains about
variables only being used once. Why would it do that? Does it not look
in the second file where they are used many times?
The Exporter man page is not real clear to me on how to use the
Exporter, but I tried their examples by placing them in the second file
and exporting the primary function that is in there. Warn and strict
still had plenty to say about packages and using something once.
Anyone got any ideas on what I'm missing?
--
=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
Handle:Wild Card
e-mail:wallp@earthlink.net
Thought of the day:
OK, enough hype. --Larry Wall in the perl man page
------------------------------
Date: 8 Jan 1998 11:47:26 GMT
From: Zenin <zenin@best.com>
Subject: Re: 2 file scripts and -w
Message-Id: <884260305.298953@thrush.omix.com>
[posted & mailed]
Philip Wall / Wild Card <wallp@earthlink.net> wrote:
: Hopefully someone here can point me in the right direction on how to
: get this working correctly. I've been through the manpages (perlsup,
: Exporter) and for some reason it just won't click how to get this to
: work.
Always, always, always post your code... :-(
Without your code we have vary little to go on, no matter how
well you try to explain the problem.
>snip<
: The first file, which is called by the client, does nothing but setup
: a few configurable variables then makes a call to a function in the
^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^
: second file which does all the work.
^^^^^^^^^^^
Hmm, I'm assuming (danger!) then that these are "global" variables
that the function you're calling is trying to use? Can you pass
them as arguments? Must you use globals? There are ways you can,
but it's really Bad Style[tm].
: The second file is brought in using a require statement.
^^^^^^^^^^^^^^^^^
Require statements are done at run time, not compile time. This
is why you'll get warnings about variables used only once since
the second use of them is not seen when these tests are done.
: Without taint, strict or warn everything works right as rain. But with
: mod_perl it's best to use these or run into variables from one script
: pounding anothers.
Vary, vary true.
: With use strict, perl throws errors about packages. So I attach my to
: all the variables in the first file. This of course won't work as far as
: I can tell becuase of scoping issues with my. Using local still requires
: package statements.
Don't use local. Just don't. You're right about not being able
to access my() vars from another file. If you *must* use globles,
declare them as such at the top of your first file:
use strict;
use vars qw($Foo $Bar $Cat $Dog);
$Foo = 'foo';
...etc...
: After putting in a few package statements warn complains about
: variables only being used once. Why would it do that? Does it not look
: in the second file where they are used many times?
It doesn't look in the second file until run time since you're
using a require statement instead of a use statement (see above).
-Use is done at compile time and thus you would not have this
problem, but I'm pretty sure you'd run into others if you try it
with your current (invisible to us...) code.
: The Exporter man page is not real clear to me on how to use the
: Exporter, but I tried their examples by placing them in the second file
: and exporting the primary function that is in there. Warn and strict
: still had plenty to say about packages and using something once.
: Anyone got any ideas on what I'm missing?
Yes, many. However I'm not prepared to waste my time guessing until
you can post the belligerent code in question.
--
-Zenin
zenin@best.com
------------------------------
Date: Thu, 08 Jan 1998 09:43:04 GMT
From: cardoso.a@mail.telepac.pt (Augusto Cardoso)
Subject: [Help] Capturing STDOUT under DOS ?
Message-Id: <34b39bf5.5746143@news>
What can I do to capture the output of Perl programs to a disk file
insted of screen ? I tried all "redirection" and other "piping" I
could think of, no results!
Ex.
POD2TEXT C:\PERL\README.POD
... I would like to catch the output for later printing ...
Thanks for suggestions.
------------------------------
Date: Wed, 07 Jan 1998 23:20:00 -0700
From: "Joseph N. Hall" <joseph@5sigma.com>
Subject: Re: Calling 'require' on an arbitrary module
Message-Id: <34B46FEE.74F0F066@5sigma.com>
OK, in that case, put your require in a string eval:
eval "require $foo";
-joseph
http://www.effectiveperl.com
Tom Hukins wrote:
> However, the code above would not work because require doesn't
> like package names like "Animal::$creature::. So, my question is,
> is it possible to do anything like this?
------------------------------
Date: Thu, 8 Jan 1998 10:18:44 +0100
From: Piotr Klaban <makler@man.torun.pl>
To: Tom Phoenix <rootbeer@teleport.com>
Subject: Re: CgiWrap - perl: can't map file error
Message-Id: <Pine.GSO.3.96.980108101158.5327A-100000@flis>
On Wed, 7 Jan 1998, Tom Phoenix wrote:
> On 6 Jan 1998, Piotr Klaban wrote:
> > Subject: CgiWrap - perl: can't map file error
>
> When you're having trouble with a CGI program in Perl, you should first
> look at the please-don't-be-offended-by-the-name Idiot's Guide to solving
> such problems. It's available on CPAN. Hope this helps!
> http://www.perl.org/CPAN/doc/FAQs/cgi/idiots-guide.html
Thank you for the answer. I am sorry for the simple question I have sent
to the newsgroup. The above URL has nothing to do with my problem.
The problem is in the cgiwrap program configuration. There is an option
limiting the virtual memory. I have found the answer in the CGIWRAP
listserv group logs, yesterday. The solution is:
not limit the virtual memory, because the limit is too low for
loading the perl program into the memory. LD stops loading libraries
during the execution of the perl script.
De facto the problem is not a perl problem, but many users could
find that problem only when they are running the perl CGI script
from cgiwrap. That is why I think it is good to send current
article also to the perl newsgroup.
Regards,
Piotr Klaban
--
makler@man.torun.pl
------------------------------
Date: 8 Jan 1998 06:54:09 GMT
From: eric@garlic.com (Eric Hilding)
Subject: Convert .bmp to .jpg via Perl
Message-Id: <691t6h$gb4$1@bulb.garlic.com>
Keywords: graphics file conversion
Does anyone know if a .bmp graphics file can be
converted to a .jpg format via a perl script?
It may sound bizarre, but such a thing would sure
eliminate having to manually convert umpteen files
using a WIN graphics program.
Tnx.
Eric
------------------------------
Date: 8 Jan 1998 06:51:25 GMT
From: eric@garlic.com (Eric Hilding)
Subject: Convert .bmp to .jpg via Perl
Message-Id: <691t1d$gb0$1@bulb.garlic.com>
Keywords: perl graphic file conversion
Does anyone know if a .bmp graphic file can be
converted to a .jpg format with a perl script...
or if something like this has already been done?
It may sound bizarre, but would solve a problem
in lieu of having to manually convert umpteen
files manually in a Windoze graphics program.
Tnx.
Eric
------------------------------
Date: Thu, 8 Jan 1998 13:38:05 -0000
From: "Michael Georgiadis" <michael.georgiadis@btinternet.com>
Subject: Database File Manipulation?
Message-Id: <692l24$eal$1@mendelevium.btinternet.com>
i have a text-delimited file stored on my host's server. this file is a
database which contains records (one per line) which are seperated by a
comma, say for example:
fred, 20, engineer
simon, 32, doctor
and so on...
i want to be able to write a script which uses a form with a search field on
it that someone can type, for example, fred, and they will be presented with
all the records that contain 'fred'. or by just leaving the search field
blank, will return all the entries in the file. this is kind of like sql but
all i have is access to a cgi-bin directory which my host has put up for me
to add scripts as i want.
any suggestions??
------------------------------
Date: 8 Jan 1998 09:21:24 GMT
From: Tom.Grydeland@phys.uit.no (Tom Grydeland)
Subject: Re: ex-ish or sed-ish regexp manipulation
Message-Id: <slrn6b96kk.vnu.Tom.Grydeland@mitra.phys.uit.no>
On 30 Dec 1997 20:14:32 GMT,
David Fetter <dfetter@shell4.ba.best.com> wrote:
> I'd like edit files in place and do things to a range of lines
> delimited by regular expressions, for example:
> frobnicate (/BeginFrob/+1,/EndFrob/-1) # by line
> How do I get perl to grok between-ness?
the range operator.
if (/BeginFrob/ .. /EndFrob/) {
frobnicate;
}
> Thanks in advance for any tips, pointers or specific RTFM's.
perldoc perlop
> David Fetter 888 O'Farrell Street Apt E1205
--
//Tom Grydeland <Tom.Grydeland@phys.uit.no>
------------------------------
Date: Wed, 07 Jan 1998 22:52:09 -0700
From: "Joseph N. Hall" <joseph@5sigma.com>
Subject: Re: file glob restrictions?!
Message-Id: <34B46968.A01D7C5E@5sigma.com>
We should emphasize that: readdir is like, WAY faster.
-joseph
Tom Phoenix wrote:
> [...] Although there are other
> workarounds, I recommend that you use readdir and friends instead of
> globbing. (That's faster than globbing, anyway.) Hope this helps!
------------------------------
Date: Thu, 08 Jan 1998 12:56:29 GMT
From: drummj@mail.mmc.org (Jeffrey R. Drumm)
Subject: Re: file glob restrictions?!
Message-Id: <34b4c4a4.2306969096@news.mmc.org>
On Wed, 7 Jan 1998 18:41:37 -0800, Tom Phoenix <rootbeer@teleport.com> wrote:
>Globbing will (by default, in most cases) call /bin/csh to do the actual
>work, and csh has a limit on what it can return. Although there are other
>workarounds, I recommend that you use readdir and friends instead of
>globbing. (That's faster than globbing, anyway.) Hope this helps!
Looking through the Todo list on my local installation of Perl, I noticed that
"built-in globbing" is listed as a "vague possibility".
Has this changed at all? I don't have more than a couple of years experience
with Unix, but I've heard numerous times that trusting csh is unwise, given its
variability across Unices.
Readdir and grep are obviously workable (and better) alternatives, but globbing
just seems more natural . . . well, to me anyway.
--
Jeffrey R. Drumm, Systems Integration Specialist
Maine Medical Center - Medical Information Systems Group
420 Cumberland Ave, Portland, Maine 04101
Voice: 207-871-2150 Fax: 207-871-6501 Email: drummj@mail.mmc.org
------------------------------
Date: Thu, 08 Jan 1998 07:02:16 +0100
From: martin@RADIOGAGA.HARZ.DE (Martin Vorlaender)
Subject: Re: Firewalls and UserAgent
Message-Id: <34b46be8.524144494f47414741@radiogaga.harz.de>
Allen Choy (achoy@us.oracle.com) wrote:
: I'm having problems running an UserAgent script requests a file outside
: the firewall. I reinstalled the
: libwwwperl bundle but I still have the same problems. It must be the
: settings.
Read the fine LWP::UserAgent POD. Especially look at the env_proxy method,
and
1. set your environment variables accordingly
2. make sure that the script use these, i.e. find the line with 'new
LWP::UserAgent' (e.g. assigned to $ua), and add a line like
$ua->env_proxy;
Another method would be to hard-code the firewall into the script, like
$ua->proxy( ['http', 'ftp'] => 'http://your.firewall:port/' );
cu,
Martin
--
| Martin Vorlaender | VMS & WNT programmer
Ceterum censeo | work: mv@pdv-systeme.de
Redmondem delendam esse. | http://www.pdv-systeme.de/users/martinv/
| home: martin@radiogaga.harz.de
------------------------------
Date: Thu, 08 Jan 1998 08:19:11 +0000
From: Justin Stenner <jes@dircon.co.uk>
Subject: Re: Good place to start in Perl 5
Message-Id: <34B48BFF.36B1@dircon.co.uk>
Claus Eikemeier wrote:
>
> Gabriele Endress wrote:
>
> > Hi,
> >
> > I'm really interested in learning Perl 5 so I can begin writing my own
> > CGI scripts. I was wondering if any of you had a recommendation of any
> > good beginners books for me start with?
> >
> > This would be the first hard core programming language I'd be learning.
> > The only other "code" I've ever learned are HTML and BASIC. :-)
> >
> > Thanks in advance,
> >
> > Gabi
> > --
> > --------------------------------------------------------------
> > Gabriele Endress Symbios, Inc.
> > Assistant Webmaster Fort Collins, CO
> >
> > "Reality is merely an illusion, albeit a very persistent one."
> > - Albert Einstein (1879-1955)
> > -------------------------------http://www.symbios.com---------
>
> Dear Gabi,
>
> a good choice would be
> "Learning PERL" by Randal L. Schwartz (O'Reilly).
>
> I bought the book in German and it helped me a lot.
> I'm not sure, if in the newer version, there is a much on
> Version 5.
> If you stress on Version 5 ("object-oriented"), you nevertheless
> have to know the basics of Version 4 and so in my opinion,
> the above book is a good start.
>
> After that you should go to a bookstore and choose the
> right book yourself. I think there are a lot of good books
> out there.
>
> Hope that helps
>
> Claus
>
> Institute of Statistics, Informatics and Epidemiology (IMSIE),
> University of Cologne
> Germany
Gabriele,
I was in a similar situation to you a short while ago, in that I don't
really have a programming background, but I needed something to automate
a few system tasks and do some CGI for my server. I went and bought
both O'Reilly books, Learning Perl & Programming Perl to find that the
latter was completely over my head.
A little later, a friend lent me "Discover Perl 5" by Naba Bakarti,
published by IDG books. This in conjunction with the "Learning Perl"
book has proved to be excellent. I'm no Perl Hacker yet, but at least
I'm not scared of curly brackets anymore!
Cheers & good luck,
Justin Stenner
Web Support (Amongst other things), SBC Warburg Dillon Read.
------------------------------
Date: 8 Jan 1998 13:34:30 GMT
From: lynchqvctc@aol.com (Lynchqvctc)
Subject: Re: Good place to start in Perl 5
Message-Id: <19980108133400.IAA18084@ladder01.news.aol.com>
>Hi,
>
>I'm really interested in learning Perl 5 so I can begin writing my own
>CGI scripts. I was wondering if any of you had a recommendation of any
>good beginners books for me start with?
>
>This would be the first hard core programming language I'd be learning.
>The only other "code" I've ever learned are HTML and BASIC. :-)
>
>Thanks in advance,
>
>Gabi
>--
>--------------------------------------------------------------
>Gabriele Endress Symbios, Inc.
>Assistant Webmaster Fort Collins, CO
>
>
A little out of the "pack" of Camels and O'Reilleys etc., I would recommend
(highly) Erik Strom's Perl CGI Programming: No Experience Required, by "Sybex."
I had no UNIX, no C (or C++) etc. and only a little Basic knowledge... and
have found a good start with Strom's intro.
------------------------------
Date: Thu, 08 Jan 1998 06:04:55 GMT
From: gbuzzell@hardlink.com (Gerry Buzzell)
Subject: Re: Hash Slice Syntax Question
Message-Id: <34b46c64.43721396@news.ne.mediaone.net>
gbuzzell@hardlink.com[Gerry Buzzell] wrote:
$b-> and @$b are two ways to dereference $b
Evidently @$b-> is a bit of overkill.
>so far so good, BUT:
>
> print @$b->{Two,Three};
>
> Not an ARRAY reference at (eval 136) line 2.
------------------------------
Date: Thu, 8 Jan 1998 13:50:41 -0000
From: "Michael Georgiadis" <michael.georgiadis@btinternet.com>
Subject: how does 'require' work?
Message-Id: <692lii$eca$1@mendelevium.btinternet.com>
when you say
require cgi-lib.pl;
where does this library need to be installed? does it have to reside in the
cgi-bin and if so will its contents be available to any program that calls
it in this way if they too are in the cgi-bin?
please advise
------------------------------
Date: 8 Jan 1998 13:43:29 GMT
From: Tom Christiansen <tchrist@mox.perl.com>
Subject: Re: Modularize non object code
Message-Id: <692l61$uh$1@csnews.cs.colorado.edu>
[courtesy cc of this posting sent to cited author via email]
In comp.lang.perl.misc, breville@uoguelph.ca (Barry G Reville) writes:
: I have written a non object perl program that works fine but I
:would like to modularize it for maintainability and reusability.
% man perlmod
--tom
--
Tom Christiansen tchrist@jhereg.perl.com
What about WRITING it first and rationalizing it afterwords? :-)
--Larry Wall in <8162@jpl-devvax.JPL.NASA.GOV>
------------------------------
Date: Wed, 7 Jan 1998 20:40:31 -0800
From: "Bruce T. Smith" <bts@proof.org>
Subject: Perl and Visual Basic?
Message-Id: <691lcs$o7p$1@nntp2.ba.best.com>
Can anyone point to examples of using Perl from Visual Basic? I'm wondering
how well
VB for GUI and Perl for backend stuff would work.
Thanks in advance!
------------------------------
Date: Thu, 8 Jan 1998 09:51:01 +0100
From: "John Goor" <splyc2@klm.nl>
Subject: Perl programming with NT4.0: sendmail problem
Message-Id: <6923p6$fu8$1@ocsgw2.klm.nl>
Hello,
Hopefully you may know the answer to my problem I'm really stuck with:
I am programming some Perl scripts for an Intranet site, which runs on a
Windows NT 4.0 platform.
Now I want to invoke a 'feedback' option, however: In Unix I use 'sendmail',
being invoked from a Perl script.
Ofcourse NT hasn't such a tool, but is there another way to accomplish what
I want: 'sendmail for NT'?
Please help. I'm waiting anxiously for an answer...
Thanks in advance.
Regards,
John Goor
(John.Goor@Turnkiek.nl)
------------------------------
Date: Thu, 08 Jan 1998 13:12:21 +0000
From: Muhammad Siddiqui <SIDDIQM2@boat.bt.com>
Subject: Perl Question
Message-Id: <34B4D0B5.25F1@boat.bt.com>
How do I create a process on some remote machine, that will sleep for
most of the time (but checks for the arrival of a file - via ftp). On
seeing that the file has arrived, wakes up, does some processing or
execute some commands and then going back to sleep before deleting the
newly arrived file.
Thanks
M Siddiqui
--
Views expressed are my own, and do not represent those of my employer.
------------------------------
Date: 8 Jan 1998 11:56:40 GMT
From: "Peter Salomonsen" <pesalomo@online.no>
Subject: POP3
Message-Id: <01bd1c2c$bed1c840$32694382@peterhome>
I've tried to use the freeware perl-script Mail::POP3Client. My wish is to
run it from DOS under win95. But I only get the message, Socket not
connected. What can I do to make it work?
Please CC your answer to pesalomo@online.no
Peter Salomonsen
------------------------------
Date: Wed, 07 Jan 1998 23:04:08 -0700
From: "Joseph N. Hall" <joseph@5sigma.com>
Subject: Re: range operator with decimal numbers
Message-Id: <34B46C36.BD1190DE@5sigma.com>
I assume the book is wrong. 5.003 and 5.00403 both seem to
integer-ize arguments. I don't recall whether the previous behavior
was different.
-joseph
http://www.effectiveperl.com
Byron Rendar wrote:
>
> The Learning Perl book (2nd edition) states on p.49 that (1.2 .. 5.2) gives
> the list (1.2, 2.2, 3.2, 4.2, 5.2). Using perl5.004_1 I tried @a = (1.2 ..
> 5.2); print "@a\n" and got a list of integers 1 through 5.
>
> Is the book wrong or am I missing something?
> --
> Byron Rendar
> brendar@pcc.edu
------------------------------
Date: Wed, 7 Jan 1998 11:04:32 -0500
From: Kevin Graham <kgraham@alpha.furman.edu>
To: Koos Pol <koos_pol@bigfoot.com>
Subject: Re: readdir() and file named '0'
Message-Id: <Pine.OSF.3.96.980107110308.29482A-100000@alpha.furman.edu>
Anytime you run across a 0, perl will evaluate it as false. The thing is
to make sure that it's the VALUE you really want to check.. I'd recommend
using:
while (defined($next_entry = readder ($dirh)))
..kg..
On Tue, 6 Jan 1998, Koos Pol wrote:
> while ($next_entry = readdir ($dirh)) {
>
> Why does it fall-through as soon as I reach a file named '0' (null) ?
> Although '0' is FALSE in perl terms, what has it got to do with the
> name of the file ?
------------------------------
Date: 8 Jan 1998 05:00:03 GMT
From: Eli the Bearded <*@qz.to>
Subject: Re: regex to escape {, } except in TeX commands
Message-Id: <qz$9801072341@qz.little-neck.ny.us>
Michael Friendly <friendly@hotspur.psych.yorku.ca> wrote:
> I need a regex to escape braces, {}, translating them to \{, \},
> except when they are part of a TeX command like \texttt{stuff}.
What can "stuff" be? I've never looked closely at TeX source ([nt]roff
suits me fine). If it can contain nested {} pairs, then you are out
of luck for now. (See the matching ( ) thread currently going on.)
> Can anyone help?
First stab (ie untested) I'd take is:
s/ ( # begin $1
\\ # literal backslash
\w+ # text word (*)
) # end $1
? # $1 is optional
{ # your open brace
( # begin $2
[^}] # anything but } (**)
* # zero or more times
) # end $2
} # your close brace
/ # begin replace part
defined($1)? # if we captured something in $1: leave the text as is
( $1 . '{' . $2 . '}' )
: # else, modify it
( '\\{' . $2 . '\\}' )
/xe; # /x: extended format; /e: execute replacement part
You might need to adjust (*) and (**) for TeX syntax rules.
Elijah
------
is not sure he will ever bother learning TeX
------------------------------
Date: Thu, 08 Jan 1998 08:08:51 -0500
From: pudge@pobox.com (Chris Nandor)
Subject: Re: serious post about gmtime and year-1900 (was Re: Perl not Y2K compliant)
Message-Id: <pudge-0801980808510001@ppp-19.ts-1.kin.idt.net>
In article <qz$9801071636@qz.little-neck.ny.us>, Eli the Bearded <*@qz.to>
wrote:
# Chip Salzenberg <chip@pobox.com> wrote:
# > According to Russell Schulz <Russell_Schulz@locutus.ofB.ORG>:
# > >it does all depend on the underlying C runtime supplying the correct
# > >number -- and we all know there are no errors in the C runtime, right?
# > Well, the C runtime is an issue with your C compiler vendor, not
# > Perl's maintainers.
#
# Yes but he'd still like to see some code in the documentation so that
# you can check if perl's reliance on the underlying C is wise. I think
# he should submit a test script for this to be run at 'make test' time.
#
# Elijah
# ------
# making such a test script platform independent should prove interesting
#y2k.t
printf "%s 1\n", (
length(${[localtime(time()+315360000)]}[5]) == 3 ? 'ok' : 'not ok'
);
__END__
This script should work for the next thousand years, give or take a few.
Unless your clock is set back before 1990. In that case, it is your
problem.
--
Chris Nandor pudge@pobox.com http://pudge.net/
%PGPKey=('B76E72AD',[1024,'0824 090B CE73 CA10 1FF7 7F13 8180 B6B6'])
#== MacPerl: Power and Ease ==#
#== Publishing Date: Early 1998. http://www.ptf.com/macperl/ ==#
------------------------------
Date: 8 Jan 1998 12:36:04 GMT
From: keith@so-net.co.uk (Keith Oborn)
Subject: Simple array initialisation question
Message-Id: <692h7k$20u@newsgate.so-net.or.jp>
This will doubtless seem dumb, but so what--
I have a variable, $users, which contains a string like this:
fred,joe,bert
I need to produce an array that contains the above, equivalent to
simply saying @userarray = (fred,joe,bert).
For the life of me I can't see how--.
Mail me an answer, someone?
------------------------------
Date: 08 Jan 1998 14:10:03 +0100
From: Remove xx to reply xxTony.Curtis@vcpc.univie.ac.at>
To: keith@so-net.co.uk
Subject: Re: Simple array initialisation question
Message-Id: <7xg1mzdsd0.fsf@vcpc.univie.ac.at>
Re: Simple array initialisation question, Keith
<keith@so-net.co.uk> said:
Keith> This will doubtless seem dumb, but so what-- I have a
Keith> variable, $users, which contains a string like this:
Keith> fred,joe,bert
Keith> I need to produce an array that contains the above,
Keith> equivalent to simply saying @userarray =
Keith> (fred,joe,bert).
splitter!
@users = split(/,/, $users);
hth,
tony
------------------------------
Date: 8 Jan 1998 10:26:48 GMT
From: "Mark Morgan" <mgm@gxn.net>
Subject: Re: soriting a file
Message-Id: <01bd1c20$4bc58910$86507ec2@simont>
You could do this by reading the file into an array of hashes, with each
record in the array, and then the name, lastname, etc, in the hast that the
index is pointing to. You could then sort this on
$array_element[x]{lastname}. I wouldn't really recommend this, unless you
are going to be adding some variable information to the various records.
The simplest alternative for data like this, as Brian d'Foy pointed out,
would be to change the file to the format he mentioned. Then, a simple
split, and query on the relevant record would be all that's needed.
Mark.
Ramon B. <ramonb@data.net.mx> wrote in article
<34AC08EA.2C96ED99@data.net.mx>...
> Hi!!
>
> I have a file like this:
>
> name: xxxx
> Lastname:xxxx
> phone: xxx-xx
> Zip: xxx
>
> **********************
> name: xxxx
> Lastname:xxxx
> phone: xxx-xx
> Zip: xxx
>
> ********
>
> And i need to sort it by lastname, but keeping the other records, in the
> same part, the information of each person is divided by the ********
>
> i put the info on an array, and is diveded by the *****, but i dont have
> a clue, on how to sort them by lastname, and keep the other information
> in the same block.
>
> Any idea?
>
> Thanks in advance!!
>
> R.B.
>
>
>
------------------------------
Date: 8 Jan 1998 11:45:48 GMT
From: e9427662@stud2.tuwien.ac.at (Stefan Herz)
Subject: Telnet client written in perl
Message-Id: <692e9c$fjh@news.tuwien.ac.at>
Hi There !
I need a telnet client (for MS NT), which is written in perl.
Does anboy know, where to find such a telnet client ?
TIA Tom
------------------------------
Date: Wed, 07 Jan 1998 20:40:59 -0600
From: Andrew Johnson <ajohnson@gpu.srv.ualberta.ca>
Subject: Re: Testing for valid RegExps?
Message-Id: <34B43CBB.1C6EA573@gpu.srv.ualberta.ca>
Tom Christiansen wrote:
!
! [courtesy cc of this posting sent to cited author via email]
!
! In comp.lang.perl.misc, gbacon@adtran.com (Greg Bacon) writes:
! : sub is_valid_regex {
! : my $pat = shift;
! : eval { local $_ = ''; /$pat/, 1 };
! : }
!
! No, sir. That zaps your //g state. local doesn't preserve that.
!
is there any reason not to eval the regex against a literal rather
than setting up a variable?
#!/usr/bin/perl -w
$_='blah b.*h .* b.**b bl?';
while (/(\S+)/g) {
print pos,": "; #just checking
print is_valid_regex($1)?"its valid\n":"nope not valid $@";
}
sub is_valid_regex {
eval {''=~/@_/,1};
}
regards
andrew
------------------------------
Date: 8 Jan 1998 13:21:27 GMT
From: Tom Christiansen <tchrist@mox.perl.com>
Subject: Re: Testing for valid RegExps?
Message-Id: <692jsn$sa3$1@csnews.cs.colorado.edu>
[courtesy cc of this posting sent to cited author via email]
In comp.lang.perl.misc,
Andrew Johnson <ajohnson@gpu.srv.ualberta.ca> writes:
:is there any reason not to eval the regex against a literal rather
:than setting up a variable?
None that I can think of.
--tom
--
Tom Christiansen tchrist@jhereg.perl.com
Perl itself is usually pretty good about telling you what you shouldn't do. :-)
--Larry Wall in <11091@jpl-devvax.JPL.NASA.GOV>
------------------------------
Date: 8 Jan 1998 13:24:38 GMT
From: Tom Christiansen <tchrist@mox.perl.com>
Subject: Re: Testing for valid RegExps?
Message-Id: <692k2m$sa3$2@csnews.cs.colorado.edu>
[courtesy cc of this posting sent to cited author via email]
In comp.lang.perl.misc,
gbacon@adtran.com (Greg Bacon) writes:
:Is there a reason local() shouldn't preserve pos()?
Shouldn't or doesn't? It's because local doesn't make
locals. I see no reason to promote the idea that it does. :-)
$BRAIN =~ s/local/savevar/g
--tom
--
Tom Christiansen tchrist@jhereg.perl.com
There ain't nothin' in this world that's worth being a snot over.
--Larry Wall in <1992Aug19.041614.6963@netlabs.com>
------------------------------
Date: 08 Jan 1998 10:38:33 +0000
From: Richard Caley <rjc@liddell.cstr.ed.ac.uk>
Subject: Unpacking length-infor style data.
Message-Id: <eyhn2h7xnbq.fsf@liddell.cstr.ed.ac.uk>
If I have data of the form
2-byte-length
that-many-bytes
another-2-byte-length
that-many-bytes
...
is there some neat way I am not spotting to extract the byte
sequences, say into an array?
(that is, I want the equivalent of split for a case where I am handed
a seqence of strings in length followed by data format rather than
separated by a token).
Of course, I can loop and do it, but it would seem to be something
that perl might have a fast way of doing hidden away somewhere.
--
rjc@cstr.ed.ac.uk _O_
|<
------------------------------
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 1600
**************************************