[10734] in Perl-Users-Digest
Perl-Users Digest, Issue: 4333 Volume: 8
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Tue Dec 1 14:17:23 1998
Date: Tue, 1 Dec 98 11:00:21 -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 Tue, 1 Dec 1998 Volume: 8 Number: 4333
Today's topics:
Breaking a string into fixed lengths (Chih-long Lin)
Can I force Perl to run C Shell (or tcsh) ?CGI? <wtang@flash.net>
Re: does perl support | piping? (was Re: localtime () - (David Formosa)
executing scripts when html page is loaded jlhughes@pobox.com
Re: help with a new game wyndo@cxo.com
How to remove characters from HTTP_REFERER? <khayu@shweinc.com>
Is there Perl ERR output for a programmer's editor? (Jim Mooney)
memory leak jschueler@detroit.usweb.com
Re: NO DOC NOWHERE!! (Was: emulating sed's "/start/,/st (Mark-Jason Dominus)
Perl and Y2K <edl@lucent.com>
Re: Perl for old, outdated, ancient systems <ckuskie@cadence.com>
perlcc; cc complains about undefined sym "runops" wkw@htc.com
Problems with 'setenv' within .sh and .pl scripts under <CHorton@STSSystems.com>
Q: Installed Modules (Roland Holzapfel)
Re: Reference to eval'd code theorb@my-dejanews.com
Sorting an assoc array with a float value (Walter Smith)
Re: Sorting an assoc array with a float value (Mark-Jason Dominus)
Tail recursion <s1204672@aix2.uottawa.ca>
Re: target help <dales@enhanced-performance.com>
Terribly simply perl question about qw() (James Weisberg)
Re: Terribly simply perl question about qw() <jdf@pobox.com>
Re: Terribly simply perl question about qw() <br@ndon.com>
Re: Terribly simply perl question about qw() (James Weisberg)
Using RCS in Perl scripts <chris.hinds@arm.com>
Re: Using RCS in Perl scripts <garethr@cre.canon.co.uk>
Using SWIG to create C++ class wrappers. <lss@shaw.wave.ca>
Re: When does CLOSE not FLUSH? (Snowhare)
Special: Digest Administrivia (Last modified: 12 Mar 98 (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: 1 Dec 1998 12:06:58 -0500
From: clin@bordeaux.esp.bellcore.com (Chih-long Lin)
Subject: Breaking a string into fixed lengths
Message-Id: <36642232.0@froot.cc.bellcore.com>
This also seems working:
$a = "This is a line that is very long and I want to break it into pieces.";
$len = 5;
foreach (unpack "a$len" x ((length($a) + $len - 1) / $len), $a) {
print "<$_>\n";
}
------------------------------
Date: 1 Dec 1998 17:49:01 GMT
From: "William Tang" <wtang@flash.net>
Subject: Can I force Perl to run C Shell (or tcsh) ?CGI?
Message-Id: <01be1cba$cf7070e0$5d68b9a3@wtang-sgl.sugar-land.geco-prakla.slb.com>
Hello,
Since the Perl runs on Bourne Shell, I can't run my csh scripts in my Perl
program, and there will be a lot of work if I must to re-write those
scripts. The question is can I force Perl run on C Shell (or even tcsh)
(even change some perl source code and re-compile it)?
Another question is I found that Perl CGI program will lose some
environment variables, like $LD_LIBRARY_PATH (on SunOS), I can see it from
Perl script, but when I put it into CGI program, the $ENV{LD_LIBRARY_PATH}
is undefined, I must define it manually. Is it true that some of the
environment variables will be undefined in CGI program?
Thanks.
------------------------------
Date: 1 Dec 1998 18:13:56 GMT
From: dformosa@zeta.org.au (David Formosa)
Subject: Re: does perl support | piping? (was Re: localtime () - perl's bug ?)
Message-Id: <slrn768cf4.d93.dformosa@godzilla.zeta.org.au>
In article <MPG.10cdb35d37c2bddf98993a@nntp.hpl.hp.com>, Larry Rosler wrote:
>[Posted to comp.lang.perl.misc and copy mailed.]
>
>In article <slrn7678t8.95d.dformosa@godzilla.zeta.org.au> on 1 Dec 1998
>08:07:04 GMT, David Formosa <dformosa@zeta.org.au> says...
[...]
>> # My Grandmother was born on 01/01/18
>> $year=18;
>> #Your snipplet gives.
>> 2018
>
>How about the last sentence of the post that you selectively quoted from
>above:
>
>"The CONTEXT for the two-digit disambiguation is the Unix epoch, which
>will do perfectly well for almost all of our programs."
>
>As I stated explicitly in a previous post, the Unix epoch will not do
>at all for historical or astronomical programs.
As my Grandmother is still alive I don't think she counts as
historical. For dates that involve humans (wich is meany of them)
your script is hopelessly inaccurate.
--
Please excuse my spelling as I suffer from agraphia. See
http://www.zeta.org.au/~dformosa/Spelling.html to find out more.
------------------------------
Date: Tue, 01 Dec 1998 17:22:56 GMT
From: jlhughes@pobox.com
Subject: executing scripts when html page is loaded
Message-Id: <7418kr$nkh$1@nnrp1.dejanews.com>
I have a virtual postcard script that uses perl to create a html document.
The link to that document is sent to the recipient of the card, who then can
view the card by clicking on the link. (The original script is from http://
bignosebird.com)
I want to add e-mail notification to the sender when the card is read.
Creating the cgi script to notify the sender shouldn't be a problem. But how
do I execute the script from the html document?
I could invite the recipient to press a button to notify the sender that the
card was read. But I would rather "hide" the notification.
I do not want to use server-side includes.
Can Javascript's onLoad function be used to execute the cgi script to send
e-mail to the card sender? Or is there another way to embed a cgi command in
an html document without using SSI?
John Hughes
--
http://come.to/digital_art_desktops
-----------== Posted via Deja News, The Discussion Network ==----------
http://www.dejanews.com/ Search, Read, Discuss, or Start Your Own
------------------------------
Date: Tue, 01 Dec 1998 17:12:54 GMT
From: wyndo@cxo.com
Subject: Re: help with a new game
Message-Id: <741825$n4e$1@nnrp1.dejanews.com>
> > what would be better to use to build a text multiplayer game? perl, c++,
> > basic? any responses please
>
> You dont really expect a considered respnse to this question from this
> group now really did you ?
I can give a considered response, having built multiplayer games in all three
of those languages.
First, how do you plan to implement "multiplayer" ? If you're wanting it to
run on a BBS, then you need to use C or BASIC (shareware Door and COMM
libraries are available for both). Do you know one language better than the
other? If so, go with it. I wouldn't go with Perl for a BBS game (never done
it) but I'm sure it's possible. Check out
http://www.cxo.com/~wyndo/tpsource.zip for complete source code to a BBS RPG
in QuickBASIC (requires the QBSerial library).
If you're wanting to write it web-based, Perl or C will work (probably
shouldn't go with BASIC unless it'll run on a win95/nt server, and even then
I don't have any advice for making it work). For an example of a web-based
multiplayer RPG written in Perl, go to http://www.lunatix-online.com. With a
web-based game, sometimes Perl wins out because if you have a strict web
host, I doubt they'll let you compile on the server.
If you're wanting to create something the user downloads and plays via an
internet connection, probably best to go with C++. If you know the language,
and you have the option of using it, I'd recommend it. We have written
multiplayer worldgroup modules in Borland C++, and of the three languages I
find it the most manageable for what I do (IMHO).
Mike Snyder
Prowler Productions
http://www.prowler-pro.com/
-----------== Posted via Deja News, The Discussion Network ==----------
http://www.dejanews.com/ Search, Read, Discuss, or Start Your Own
------------------------------
Date: Tue, 1 Dec 1998 13:40:00 -0500
From: "Khayu Nyein" <khayu@shweinc.com>
Subject: How to remove characters from HTTP_REFERER?
Message-Id: <3664384d.0@news.inch.com>
Hi!
I'm trying to put together two scripts. One script that will let the visitor
click on the link to go to a form generated by script. At the form, they can
fill in their comments, etc and the script should save it to a variable file
name parsed from HTTP_REFERER. And the other (SSI) script to call up a
filename parsed from DOCUMENT_URI.
I got a few lines of code from other scripts for removing the /'s and non
letters-numbers. But the referer gives:
http://www.shweinc.com/sitewars/anyfile.shtml. I'd like to remove
everything except the file name and and pass the final value (anyfile) back
to $PAGE. Please show me a routine that will remove
http://www.shweinc.com/sitewars/ and .shtml, and
http://shweinc.com/sitewars/ without the www.
# In file writing script
#need to remove domain names and extension, etc.
$PAGE = $ENV{'HTTP_REFERER'};
# In SSI file display script
#need to remove /sitewars/ and .shtml
$PAGE = $ENV{'DOCUMENT_URI'};
# Chop off any trailing /'s
if ($COMMENTS_PAGE =~ /\/$/)
{ chop($COMMENTS_PAGE); }
# Any characters that are not letters or numbers are turned into an
underscore
$COMMENTS_PAGE =~ s/[^\w]/_/g;
Sorry if the question seems lame or confusing, I've just started putting
together (hacking) snippets of code to create customized scripts.... these
two scripts will together serve as a cool guestbook/comments type script
combo for any page under http://www.shweinc.com/sitewars.
Thanks.
Khayu Nyein.
------------------------------
Date: Tue, 01 Dec 1998 17:32:53 GMT
From: gemhound@gemhound.com (Jim Mooney)
Subject: Is there Perl ERR output for a programmer's editor?
Message-Id: <36642794.13159455@news.primeline.com>
I've just started in Perl and can't seem to get my programmer's editor
(Uedit32) to capture compiler errors. (Yes, I know it's an
interpreter, but it also seems to do some sort of compile first, so I
am hoping.)
Is there some switch I'm missing? Does Perl generate a standard *.ERR
file or is there some other way I can capture the error output into my
editor? It would make things a lot easier, especially finding the
line numbers of the errors. (Okay, there's not THAT many errors -- I
don't know enough yet to screw up bigtime ;')
------------------------------
Date: Tue, 01 Dec 1998 18:43:25 GMT
From: jschueler@detroit.usweb.com
Subject: memory leak
Message-Id: <741dc9$rqu$1@nnrp1.dejanews.com>
I'm running the following subroutine several million times, and it seems to
cause a slow memory leak. Anybody know why?
sub htmlclean () {
local( $T ) = $_[0] ;
while ( $T =~ s/\%([0-9a-eA-F]{2})/pack( 'c', hex($1) )/e ) {}
return $T ;
}
Here's perl -v:
> This is perl, version 5.004_04 built for i386-bsdos
Jim Schueler
USWeb Corporation
-----------== Posted via Deja News, The Discussion Network ==----------
http://www.dejanews.com/ Search, Read, Discuss, or Start Your Own
------------------------------
Date: 1 Dec 1998 12:22:05 -0500
From: mjd@op.net (Mark-Jason Dominus)
Subject: Re: NO DOC NOWHERE!! (Was: emulating sed's "/start/,/stop/<do something>"?)
Message-Id: <7418jt$bif$1@monet.op.net>
In article <dkcombsF3Ap0H.Mxn@netcom.com>,
David Combs <dkcombs@netcom.com> wrote:
>>To emulate sed, you need to use the little-known `...' operator
>>instead of the more common `..' operator.
>>
>
>
>Nice, but there is NO DOC on this feature!
It's in perlop with the documentation for the other operators.
------------------------------
Date: Tue, 01 Dec 1998 13:18:02 -0500
From: "John W. Edl Jr." <edl@lucent.com>
Subject: Perl and Y2K
Message-Id: <366432DA.7F58902E@lucent.com>
I was asked if this version of perl is Y2K compliant. Anyone know for sure?
==> perl -v
This is perl, version 5.003 with EMBED
built under solaris at Feb 7 1997 14:23:04
+ suidperl security patch
Copyright 1987-1996, Larry Wall
Perl may be copied only under the terms of either the Artistic License or the
GNU General Public License, which may be found in the Perl 5.0 source kit.
--
John W. Edl Jr.
IBM Global Services
edl@lucent.com
614-860-6190
------------------------------
Date: Tue, 1 Dec 1998 09:33:18 -0800
From: Colin Kuskie <ckuskie@cadence.com>
To: Keith Paschal <keith_paschal@hp.com>
Subject: Re: Perl for old, outdated, ancient systems
Message-Id: <Pine.GSO.3.96.981201093023.3626A-100000@pdxue150.cadence.com>
[Posted and emailed]
On Mon, 30 Nov 1998, Keith Paschal wrote:
> Aside from going out and spending a few hundred bucks on a newer laptop,
> is there a version of Perl that will run on my clunky old 486/MS-DOS/Win
> 3.1 (Uhhhhgggg dreaded MS) system?
How about installing Linux? It runs like a champ on my 486DX4-100.
Although you can download it for free over the net, (the way I
originally did) my personal recommendation is to but a copy of Red Hat
with the installation guide and user's manual. Once you fly it for a
few months you'll be ready to handle the internet downloads and
upgrades.
You need about 10-15 Meg of diskspace for Linux and not a whole lot
of memory (anywhere from 8Meg on up).
Good luck!
Colin
------------------------------
Date: Tue, 01 Dec 1998 17:09:56 GMT
From: wkw@htc.com
Subject: perlcc; cc complains about undefined sym "runops"
Message-Id: <7417sk$n0e$1@nnrp1.dejanews.com>
Hi,
Have been trying to use the long awaited "perlcc", and
I get the output below, complaining about the undefined
symbol "runops". Funny thing is, though I see runops
references in the Change logs & such, I can't actually
find a reference anywhere in my foo.pl.c. Anyone seen this?
Keith
PS: The Perl version, etc. is ID'd in the output, and the
cc version is Sun's WorkShop Compilers 4.2 30 Oct 1996 C 4.2
Any help much appreciated.
----------------------------------------- Compiling prword.pl:
-----------------------------------------------------------------------------
--- Making C(prword.c) for prword.pl! /usr/local/perl5.005/bin/perl
-I/usr/local/perl5.005/lib/5.00502/sun4-solaris-thread
-I/usr/local/perl5.005/lib/5.00502
-I/usr/local/perl5.005/lib/site_perl/5.005/sun4-solaris-thread
-I/usr/local/perl5.005/lib/site_perl/5.005 -I. -MO=CC,- oprword.c prword.pl
prword.pl syntax OK Compiling C(prword) for prword.pl!
/usr/local/perl5.005/bin/perl
-I/usr/local/perl5.005/lib/5.00502/sun4-solaris-thread
-I/usr/local/perl5.005/lib/5.00502
-I/usr/local/perl5.005/lib/site_perl/5.005/sun4-solaris-thread
-I/usr/local/perl5.005/lib/site_perl/5.005 -I. /tmp/prw ord.pl.tst cc
-I/usr/local/include -O
-I/usr/local/perl5.005/lib/5.00502/sun4-solaris-thread/CORE
/usr/local/perl5.005/lib/5.00502 /sun4-solaris-thread/auto/Fcntl/Fcntl.so -o
prword prword.c -L/usr/local/lib -L/usr/local/perl5.005/lib/5.00502/sun4-s
olaris-thread/CORE -lperl -lsocket -lnsl -lgdbm -ldl -lm -lc -lcrypt
"prword.c", line 6398: warning: statement not reached "prword.c", line 6940:
warning: statement not reached "prword.c", line 7031: warning: statement not
reached "prword.c", line 7380: warning: statement not reached "prword.c",
line 7439: warning: statement not reached "prword.c", line 7728: warning:
statement not reached "prword.c", line 8007: warning: statement not reached
"prword.c", line 8265: warning: statement not reached Undefined first
referenced symbol in file runops prword.o ld: fatal: Symbol referencing
errors. No output written to prword ERROR: In compiling code for prword.c !
-----------== Posted via Deja News, The Discussion Network ==----------
http://www.dejanews.com/ Search, Read, Discuss, or Start Your Own
------------------------------
Date: Tue, 1 Dec 1998 18:43:01 -0000
From: "Craig Horton" <CHorton@STSSystems.com>
Subject: Problems with 'setenv' within .sh and .pl scripts under AIX
Message-Id: <912537883.29169.0.nnrp-02.c1ed09c6@news.demon.co.uk>
I want to change the ORACLE_SID environment variable within a perl script,
so that I can automate the shutdown and startup of 3 instances of our
databases, so we can back them up. However, I have found I can't seem to get
setenv to make the change from within perl, using:
system('setenv ORACLE_SID $instance');
Since we had the same problem after installing Windows NT 4, SP4, we got
around that by calling .cmd files to change the SID each time. If I do it
from the shell prompt, ORACLE_SID is changed.
so I tried doing this with a c-script, so I could then call the c-script
within my perl script which runs the backup each night:
#!/bin/csh
setenv ORACLE_SID instancename
however, while this runs, it does not change the environment variable. but
if I just do a env in the script to list the variables, that works fine. I
thought maybe I needed to export the change, however, if I understand
correct, csh exports ALL variables anyhow.
This is all on a RS6000 F-50 server running AIX 4.3.1
I assume this is a security feature to stop programs making changes? Is
there anyway round this? I'd prefer to implement it within the perl script.
Thanks
Craig
------------------------------
Date: 1 Dec 1998 17:07:40 GMT
From: holzapfe@igd.fhg.de (Roland Holzapfel)
Subject: Q: Installed Modules
Message-Id: <7417os$k81@newssrv.igd.fhg.de>
Hello,
How do I find out which Modules (and their versions) are installed
with my perl executable ?
Please answer by Mail.
Thanks, Roland.
------------------------------
Date: Tue, 01 Dec 1998 18:41:03 GMT
From: theorb@my-dejanews.com
Subject: Re: Reference to eval'd code
Message-Id: <741d7r$rps$1@nnrp1.dejanews.com>
In article <Pine.GSO.4.02A.9811301143440.19172-100000@user2.teleport.com>,
Tom Phoenix <rootbeer@teleport.com> wrote:
> On Mon, 30 Nov 1998 theorb@my-dejanews.com wrote:
> > I have an arbitrary piece of perl in a scalar
> > I want to eval it,
> Well, if you must. But eval of a string is generally better avoided.
It's a toy CGI -- I know it's trivaly insecure (indeed, I'm going to go put a
.htacess password on the whole directory.)
> > Code like $val = \(eval $expr); gives ref($val) always returning 'HASH'.
> > Similarly, $val = \eval $expr; always gives a ref to a scalar.
>
> It looks as if you want to get a reference to something. To what?
The value of $expr, when evaluated (in a list context, I suppose -- it's
generaly more interesting then. I hadn't thought about the context -- I'm new
to this.
> And do those two statements really give different values?
Gach! I could have sworn I double-checked that statement before I sent it.
\eval $expr and \(eval $expr) both return a scalar; the first value on the
list or last value in the hash (tested with @INC and %INC). I was thinking
of \{eval $expr}, which always retruns a ref to a hash. \[eval $expr] gives
a ref to an array. I had thought that {} would indicate precidance there,
which is why I tried them in the first place.
> Do you mean that you want a reference to the data returned by that code?
Yep.
> In scalar or list context?
List, but how do I not force it to be an array or hash (IE, have '@INC' be an
array, but '%INC' be a hash). I basicly am looking for the same behivor as
\@INC or \%INC would give (which was my implementation -- IE using eval('\\' .
$expr), which evaluates an expression that gives a reference, rather then
eval'ing and then taking a reference). But that's ugly.
> my $ref;
> {
> my $value = eval $expr;
> die $@ if $@;
> $ref = \$value; # one way to do it
> }
>
> my $ref = [ eval $expr ]; # one way to do something else
> die $@ if $@;
This code forces you to know in advance the type that will be returned by
$expr.
-=- James Mastros
--
I'm really theorbtwo at yahoo.com.
-----------== Posted via Deja News, The Discussion Network ==----------
http://www.dejanews.com/ Search, Read, Discuss, or Start Your Own
------------------------------
Date: 1 Dec 1998 18:11:46 GMT
From: smithw@cs.itc.hp.com (Walter Smith)
Subject: Sorting an assoc array with a float value
Message-Id: <741bh2$rua$1@nonews.col.hp.com>
Folks,
I'm working on a script that creates an associative array
having a name field as a key, and the values are floats.
After this array is built, I want to go thru and print it
out, in sorted order, like so:
foreach $i (sort keys %value) {
These values will be numbers like 1200.5, or 855.3, etc.
What happens when it runs is that it appears to base the
value like a string...values of 1000.0 print first, then
1001.4, then when the 1000's are done, it starts with the
100's, and up to the 999 range.
Is it possible to make it reflect the sorted values as
floats?
--
Walter Smith
TIS Colorado Springs Platform Support
590-2027
------------------------------
Date: 1 Dec 1998 13:25:27 -0500
From: mjd@op.net (Mark-Jason Dominus)
Subject: Re: Sorting an assoc array with a float value
Message-Id: <741can$c1u$1@monet.op.net>
In article <741bh2$rua$1@nonews.col.hp.com>,
Walter Smith <smithw@cs.itc.hp.com> wrote:
>Is it possible to make it reflect the sorted values as
>floats?
What happens when you read the documentation for the `sort' function?
------------------------------
Date: 01 Dec 1998 13:21:52 -0500
From: David Huggins-Daines <s1204672@aix2.uottawa.ca>
Subject: Tail recursion
Message-Id: <87vhjvhge6.fsf@aix2.uottawa.ca>
On the heels of my (possibly incorrect) followup regarding the
"unwinding" of dynamically-scoped variables in non-local exits, I've
got another Lisp-ish Perl question...
It's well known that Scheme optimizes tail-recursive procedure calls
into gotos. Probably, some other Lisp dialects do too by now.
I'm slightly curious as to whether Perl can also do this or not.
Given the richness of Perl's built-in iterative constructs,
tail-recursion doesm't seem to be very idiomatic, so I'm not clamoring
for Perl to assimilate yet another Lisp feature here.
Since it appears that Perl already sort of recognizes the tail
position (subroutines implicitly return the value of the last
expression, just like in Lisp), it doesn't strike me as impossible to
implement, but I guess there would be some slightly thorny issues
regarding the scope of @_ and lexical variables.
It strikes me that the desired effect would be the same as the
"magical goto" used for autoloads - is this correct?
Cheers
--
perl -e 's/cream/a/ieeeeeeeeeeeeeeeeeeeeeee and die, horribly'
------------------------------
Date: Tue, 01 Dec 1998 09:37:12 -0800
From: Dale Sutcliffe <dales@enhanced-performance.com>
Subject: Re: target help
Message-Id: <36642948.D629314D@enhanced-performance.com>
Your suggestion does work, but only for one of the targets.
I need to be able to specify which target to view the page.
Nnickee wrote:
> On Mon, 30 Nov 1998 19:47:02 -0800, Dale Sutcliffe
> <dales@enhanced-performance.com> wrote:
>
> >I would like the option to display results in either a separate frame or a new window, depending upon the users' selection.
> >I've tried:
> >print "Location: ".$str."\n\ntarget=\"Display\"\n\n";
> >
> >(display is the name of the second frame)
> >and for the new window:
> >
> >print "Content-type: text/html\ntarget=\"_blank\"\n\n";
> >
> >Neither seem to work.
>
> How about in the <form... tag?
>
> <FORM ACTION="cgi-bin/my-ww.pl" target="wwresults" METHOD="POST">
>
> This does work, but is it close enough to what you're wanting?
>
> Nnickee
--
Dale Sutcliffe
Senior Software Engineer
Enhanced Performance Systems
Business Education Military Sport
------------------------------------------
1010 University Ave.
Suite 265
San Diego, CA 92103 USA
Voice: 619.456.8603
Fax: 619.497.0820
--------------------------------------
dales@enhanced-performance.com
www.enhanced-performance.com
------------------------------
Date: 1 Dec 1998 11:19:25 -0600
From: chadbour@news.wwa.com (James Weisberg)
Subject: Terribly simply perl question about qw()
Message-Id: <7418et$3b6@tekka.wwa.com>
Can someone please tell me why the following doesn't work as
expected:
#!/usr/local/bin/perl
$one = "foo";
$two = "bar";
@string = qw($one $two);
print "string: @string\n";
foreach $id (@string) {
print "id: $id\n";
}
$ ./blah.pl
string: $one $two
id: $one
id: $two
Why aren't the variables interpolated inside the qw() function?
This was run with perl 5.003 on an SCO machine.
--
World's Greatest Living Poster
------------------------------
Date: 01 Dec 1998 19:09:57 +0100
From: Jonathan Feinberg <jdf@pobox.com>
To: chadbour@news.wwa.com (James Weisberg)
Subject: Re: Terribly simply perl question about qw()
Message-Id: <m3vhjv68ei.fsf@joshua.panix.com>
chadbour@news.wwa.com (James Weisberg) writes:
> Why aren't the variables interpolated inside the qw() function?
Why would you expect them to be? The docs say otherwise. Perlop:
Customary Generic Meaning Interpolates
'' q{} Literal no
"" qq{} Literal yes
`` qx{} Command yes (unless '' is delimiter)
qw{} Word list no
// m{} Pattern match yes
qr{} Pattern yes
s{}{} Substitution yes
tr{}{} Transliteration no (but see below)
--
Jonathan Feinberg jdf@pobox.com Sunny Brooklyn, NY
http://pobox.com/~jdf
------------------------------
Date: Tue, 01 Dec 1998 13:32:01 -0500
From: "Brandon L. Golm" <br@ndon.com>
To: James Weisberg <chadbour@news.wwa.com>
Subject: Re: Terribly simply perl question about qw()
Message-Id: <36643621.CEC63D5B@ndon.com>
[coutesey cc]
sir,
you need to learn to use your documentation tools that come with perl.
perldoc perldoc ... to find out how:
perldoc perlfaq ... too.
$ perldoc -f qw |pod2text
qw/STRING/
Generalized quotes. See the perlop manpage.
$ perldoc perlop
.... cut ....
Customary Generic Meaning Interpolates
'' q{} Literal no
"" qq{} Literal yes
`` qx{} Command yes
qw{} Word list no
// m{} Pattern match yes
s{}{} Substitution yes
tr{}{} Translation no
...it's easy if you try; many thanks to many who made it so.
.brandon.
James Weisberg wrote:
> Can someone please tell me why the following doesn't work as
> expected:
>
> #!/usr/local/bin/perl
>
> $one = "foo";
> $two = "bar";
> @string = qw($one $two);
> print "string: @string\n";
> foreach $id (@string) {
> print "id: $id\n";
> }
>
> $ ./blah.pl
> string: $one $two
> id: $one
> id: $two
>
> Why aren't the variables interpolated inside the qw() function?
> This was run with perl 5.003 on an SCO machine.
>
> --
> World's Greatest Living Poster
------------------------------
Date: 1 Dec 1998 12:50:01 -0600
From: chadbour@news.wwa.com (James Weisberg)
Subject: Re: Terribly simply perl question about qw()
Message-Id: <741dop$7f8@tekka.wwa.com>
In article <m3vhjv68ei.fsf@joshua.panix.com>,
Jonathan Feinberg <jdf@pobox.com> wrote:
>chadbour@news.wwa.com (James Weisberg) writes:
>
>> Why aren't the variables interpolated inside the qw() function?
>
>Why would you expect them to be? The docs say otherwise. Perlop:
After receiving many [not-so] cordial invitations to RTFM, I
thank all who replied. I suppose this is testimony to the level of
support found here. However, I would have checked the docs if
indeed I had them to look at from where I was hacking.
As for your question, I expected variables to be interpolated
because in my scanning through some of the libraries, I saw many
instances of lines like the following:
@EXPORT = qw(&GetOptions $REQUIRE_ORDER $PERMUTE $RETURN_IN_ORDER);
which can be found in the Getopt/Long.pm file. I thought I
rightfully assumed that my variables should have been interpolated
and that I was doing something wrong. Perl is not my native language,
so I asked here hoping to get a quick response.
--
World's Greatest Living Poster
------------------------------
Date: Tue, 01 Dec 1998 11:09:44 -0600
From: "Chris N. Hinds" <chris.hinds@arm.com>
Subject: Using RCS in Perl scripts
Message-Id: <366422D8.369485D3@arm.com>
Two questions:
1. How can the RCS markers (such as $Revision$) be used in
Perl? I can't seem to find a way to do the following:
print("$Revision$\n") ;
The additional $ at the end of the string causes a syntax
error here and in other attempts, such as creating a
scalar with the string and regexp-ing out the '$'.
2. RCS doesn't maintain the 'execute' mode on the script.
Is there a way to keep it after a ci -u operation?
Thanks!
chris
--
*********************************************************
* Chris N. Hinds <>< 512-314-1055
* ARM Austin Design Center FAX 512-314-1078
* ARM INC chris.hinds@arm.com
*********************************************************
------------------------------
Date: Tue, 1 Dec 1998 17:31:23 GMT
From: Gareth Rees <garethr@cre.canon.co.uk>
Subject: Re: Using RCS in Perl scripts
Message-Id: <sisoezbwgk.fsf@cre.canon.co.uk>
"Chris N. Hinds" <chris.hinds@arm.com> wrote:
> How can the RCS markers (such as $Revision$) be used in Perl?
Use Perl's quoting operator q with $ as the delimiter:
use constant REVISION => q$Revision$;
use constant AUTHOR => q$Author$;
use constant DATE => q$Date$;
(assuming of course that you don't mind the $ not appearing in the
string).
> RCS doesn't maintain the 'execute' mode on the script.
You could try switching to CVS, which does maintain the execute mode.
--
Gareth Rees
------------------------------
Date: Tue, 01 Dec 1998 18:24:55 GMT
From: "LSS" <lss@shaw.wave.ca>
Subject: Using SWIG to create C++ class wrappers.
Message-Id: <XvW82.537$OW.1006617@news.rdc1.ab.wave.home.com>
When creating a SWIG class wrapper, the following errors are reported
building with VC++ 5.0:
example_wrap.obj : error LNK2001: unresolved external symbol
__imp__PL_stack_base
example_wrap.obj : error LNK2001: unresolved external symbol
__imp__PL_markstack_ptr
example_wrap.obj : error LNK2001: unresolved external symbol
__imp__PL_stack_sp
example_wrap.obj : error LNK2001: unresolved external symbol
__imp__PL_sv_yes
Has anyone resolved this issue?
Note:
The Activeware version 507 of perl is also in the mix.
------------------------------
Date: Tue, 01 Dec 1998 17:22:41 GMT
From: snowhare@devilbunnies.org (Snowhare)
Subject: Re: When does CLOSE not FLUSH?
Message-Id: <BBV82.24006$aF1.46191@typhoon-sf.snfc21.pbi.net>
Nothing above this line is part of the signed message.
In article <yl90gspjr1.fsf@windlord.stanford.edu>,
Russ Allbery <rra@stanford.edu> wrote:
>Abigail <abigail@fnx.com> writes:
>
>> As the example on 'perldoc -f flock' tells you, you need to do a seek
>> after you got the lock.
>
>> open FH, ">> /my/file" or die $!;
>> flock FH, LOCK_EX or die $!;
>> seek FH, 2, 0 or die $!; # Seek to the end.
>
>I thought open with a mode of ">>" uses O_APPEND. If it doesn't, that
>strikes me as really odd. If it does, the seek should not be necessary:
It does. Oh _it does_. Drove me crazy one afternoon when I opened
a file for read/write carelessly. I wanted to seek the start of the
file for a write - but it was appending to the end. Took me an hour
to figure out what I had done wrong.
Benjamin Franz
Version: 2.6.2
iQCVAwUBNmQnhejpikN3V52xAQGr9AP/bIXLj91X6tGM5gv53i9fjoqnb3VyDzZJ
hz30om09bDnebPkrAkX7D7xpfyAPPl4+/aZj6j+xsYkybLdcqQx3EYR8CDsfyJsF
OLJiFPSTRbfiNi/xcetxqic+t0eeKE1M85x2LeC6KfUzs+pv1h7MKQwybYMWv8qD
zEktComMrWI=
=i4mi
-----END PGP SIGNATURE-----
------------------------------
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 4333
**************************************