[9525] in Perl-Users-Digest
Perl-Users Digest, Issue: 3119 Volume: 8
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Fri Jul 10 13:08:46 1998
Date: Fri, 10 Jul 98 10:00:20 -0700
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)
Perl-Users Digest Fri, 10 Jul 1998 Volume: 8 Number: 3119
Today's topics:
Re: -w on production code (was Re: better way of gettin (Craig Berry)
Re: Announcing scripts on c.l.p.a [was: Re: new charter <dean@mail.biol.sc.edu>
Re: Bug? shift( split(' ',$_)); won't compile. <dlaser@ermine.ox.ac.uk>
Re: Bug? shift( split(' ',$_)); won't compile. <danboo@negia.net>
Re: Changing password with perl-skript <aperrin@mcmahon.qal.berkeley.edu>
file download in Perl <btate@twa.com>
Re: forking on win32 <jschell@uswest.net>
Re: Getting Yesterday's Date <tchrist@mox.perl.com>
Re: How to access the default NT printer (Jeffrey R. Drumm)
Re: need to code a delete function <quednauf@nortel.co.uk>
Re: NEVER "call warn() and return undef" (Re: question (Peter Scott)
Re: new charter and moderator for comp.lang.perl.announ (Sitaram Chamarty)
Re: new charter and moderator for comp.lang.perl.announ <dgris@rand.dimensional.com>
Re: new charter and moderator for comp.lang.perl.announ <dgris@rand.dimensional.com>
Re: new charter and moderator for comp.lang.perl.announ (John D Groenveld)
Perl CGI under NT4.0 problem <terry.williams@luton.ac.uk>
Problems creating files CGI-Unix <ggarces@arrakis.es>
Problems creating files <ggarces@arrakis.es>
Re: Problems creating files <ggarces@arrakis.es>
Re: question about objects <jdporter@min.net>
Re: remove the first k lines of a string (Craig Berry)
Re: remove the first k lines of a string (Craig Berry)
Re: UNC Filename Open for Output <jdporter@min.net>
xs generates call to XFree (Graue)
Digest Administrivia (Last modified: 8 Mar 97) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: 10 Jul 1998 16:11:43 GMT
From: cberry@cinenet.net (Craig Berry)
Subject: Re: -w on production code (was Re: better way of getting the last modified file?)
Message-Id: <6o5efv$ctf$1@marina.cinenet.net>
Bart Lateur (bart.mediamind@tornado.be) wrote:
: Mike Stok wrote:
: >Why not leave it as it is? People who want warnings can use -w...
:
: Because newbies don't know about -w, while it's the most benificial to
: them. Just look at the PODs. I strongly feel that something that should
: be used by newbies, ought to be the default.
<joke>
How about having each copy of the Perl binary built with -w on by default.
The binary would patch itself to turn -w off by default the first time a
hash of lists of hashes was created successfully.
</joke>
---------------------------------------------------------------------
| Craig Berry - cberry@cinenet.net
--*-- Home Page: http://www.cinenet.net/users/cberry/home.html
| Member of The HTML Writers Guild: http://www.hwg.org/
"Every man and every woman is a star."
------------------------------
Date: 10 Jul 1998 12:08:28 -0400
From: Dean Pentcheff <dean@mail.biol.sc.edu>
Subject: Re: Announcing scripts on c.l.p.a [was: Re: new charter and moderator for comp.lang.perl.announce]
Message-Id: <m3zpehk7sz.fsf@mail.biol.sc.edu>
Randal Schwartz <merlyn@stonehenge.com> writes:
> Shoot, as far as I'm concerned, every single CPAN upload could get a
> separate post... it wouldn't be more than 1-2 messages a day. Most of
> the time, things get added to CPAN with *no* CLPA post... I know, I
> watch the CPAN's RECENT-print pretty closely.
[Just to comment on what is, so far the least important aspect of the
debate:]
Actually, I'd prefer to see a (something like) weekly digest of the
CPAN updates with perhaps a paragraph of description on each item,
website for more info, etc. If the messages come through one at a
time I tend to let them fly by; if they come in a clot then I can get
my mind into "check out these modules" mode and really think about
each one.
One caveat: if the moderator feels up to it, I'd love to have him or
her summarily reject module descriptions of this type: "Veebilitzer
4.5.6.7: Improves hash handling and fixes the Exporter problem. Now
allows full embedding." All summaries should be required to summarize
the module's function for those one or two poor souls out there who
may not have the code hardwired into their brains.
> print "Just another Perl newsgroup moderator,"
print "Just another Perl newsgroup whiner";
-Dean
--
N. Dean Pentcheff <pentcheff@acm.org>
Biological Sciences, Univ. of South Carolina, Columbia SC 29208 (803-777-7068)
------------------------------
Date: 10 Jul 1998 16:58:02 +0100
From: Rob Hutchings <dlaser@ermine.ox.ac.uk>
Subject: Re: Bug? shift( split(' ',$_)); won't compile.
Message-Id: <yk3sok9r94l.fsf@ermine.ox.ac.uk>
John Porter <jdporter@min.net> writes:
> Ronald J Kimball wrote:
> > Perl is telling you exactly why it doesn't compile. What does that say?
> > shift modifies its argument, so it needs a named array, not an anonymous
> > one.
>
> No, it needs an array, not a list.
> Anonymous arrays work fine:
> $x = shift @{[ split ]};
>
But if you're going to throw away the rest of the array, you
migt as well use
$x=(split)[0];
Rob
------------------------------
Date: Fri, 10 Jul 1998 12:40:40 -0400
From: Dan Boorstein <danboo@negia.net>
Subject: Re: Bug? shift( split(' ',$_)); won't compile.
Message-Id: <35A64408.6E8EF9E@negia.net>
Rob Hutchings wrote:
>
> John Porter <jdporter@min.net> writes:
>
> > Ronald J Kimball wrote:
>
> > > Perl is telling you exactly why it doesn't compile. What does that say?
> > > shift modifies its argument, so it needs a named array, not an anonymous
> > > one.
> >
> > No, it needs an array, not a list.
> > Anonymous arrays work fine:
> > $x = shift @{[ split ]};
> >
>
> But if you're going to throw away the rest of the array, you
> migt as well use
>
> $x=(split)[0];
and you might as well limit the split to 2. the longer your potential
list the more you'll benefit from this. try upping the length of
'$toSplit' below and watch how the versions without limits take much
longer while those with limits hardly change at all (until you get
into very long strings (about 'foo ' x 10000 for me)).
use Benchmark;
$toSplit = $toSplit = 'foo ' x 10;
timethese(100000, {
'splitLimit' => '$c = (split " ", $toSplit, 2)[0]',
'split' => '$c = (split " ", $toSplit)[0]',
'shiftLimit' => '$c = shift @{[ split " ", $toSplit, 2 ]}',
'shift' => '$c = shift @{[ split " ", $toSplit ]}',
});
__END__
Benchmark: timing 100000 iterations of shift, shiftLimit, split,
splitLimit...
shift: 5 secs ( 6.34 usr 0.00 sys = 6.34 cpu)
shiftLimit: 4 secs ( 3.16 usr 0.00 sys = 3.16 cpu)
split: 4 secs ( 4.11 usr 0.00 sys = 4.11 cpu)
splitLimit: 2 secs ( 1.60 usr 0.00 sys = 1.60 cpu)
cheers,
--
Dan Boorstein home: danboo@negia.net work: danboo@y-dna.com
"THERE IS AS YET INSUFFICIENT DATA FOR A MEANINGFUL ANSWER."
- Cosmic AC
------------------------------
Date: Fri, 10 Jul 1998 09:21:39 -0700
From: Andrew Perrin <aperrin@mcmahon.qal.berkeley.edu>
To: Oliver Schoenwald <oliver.schoenwald@fernuni-hagen.de>
Subject: Re: Changing password with perl-skript
Message-Id: <35A63F93.215A67FD@mcmahon.qal.berkeley.edu>
You have a number of options here, depending on what you want/need to
do, and how comfortable you are playing with a very security-sensitive
file.
1.) Follow Abigail's advice and just call the passwd command from within
Perl;
2.) Manipulate the /etc/passwd (and/or /etc/shadow) file(s) directly
using Perl, which is actually quite simple but introduces *big* security
concerns; check out the example in the Camel book for starters.
3.) Use expect (http://expect.nist.gov) to handle the communication with
/bin/passwd, which lowers (but certainly doesn't eliminate) security
concerns, and is more portable (i.e., works with NIS, NIS+, etc.), but
requires a separate package.
Regards,
Andrew Perrin
UC Berkeley, Demography
Oliver Schoenwald wrote:
> Hello!
>
> How can I change a user's password under unix (solaris 2.5.1)
> using a perl-script? When using the passwd-command, this programm
> asks for the old an two times the new password. How can the
> perl-script handle this interaction? Or is there a better
> solution? Any functioning example would be welcome!
>
> Thank you in advance,
>
> Oliver.
--
-----------------------------------------------------------------
Andrew J Perrin - aperrin@igc.apc.org - NT/Unix/Access Consulting
255 S Rengstorff Ave #130, Mountain View, California 94040 USA
Phone: 650-938-4740 | http://socrates.berkeley.edu/~aperrin
E-mail wheres-andy@socrates.berkeley.edu to find me.
SEIU1199---------------------------------------------------------
------------------------------
Date: Fri, 10 Jul 1998 11:05:57 -0500
From: "Bob Tate" <btate@twa.com>
Subject: file download in Perl
Message-Id: <35a63aea.0@news.primary.net>
Hello all,
I am seeking help on developing Perl code that would download a file or
files from a web server and store it on the local (user's) PC. any ideas?
------------------------------
Date: Fri, 10 Jul 1998 10:22:42 -0600
From: Joe Schell <jschell@uswest.net>
To: Ted <kolovos_ted@prc.com>
Subject: Re: forking on win32
Message-Id: <35A63FD2.277DA9BE@uswest.net>
Ted wrote:
>
> I noticed that fork is unimplemented on win32, is there
> a way around this, perhaps through a call to the windows createthread
> api
> in kernerl32.dll??
>
I believe I might have the answer: yes and no.
Windows does not support a fork. Consequently, the 'standard' perl
packages (ActiveState and Gurusamy Sarathy's) do not support it.
However, there is a gnu version that runs in a pseudo environment which
does provide forking. It requires the environment (a windows console
shell) and the version of perl. I haven't taken the time to verify this
however. I did was download it and make sure that it ran.
(Unfortunately, I lost the url to the gnu main page.) Presumably the
environment simulates the fork using threads, the perl version just uses
what it provides.
---Joe
------------------------------
Date: 10 Jul 1998 16:05:44 GMT
From: Tom Christiansen <tchrist@mox.perl.com>
Subject: Re: Getting Yesterday's Date
Message-Id: <6o5e4o$75n$1@csnews.cs.colorado.edu>
[courtesy cc of this posting sent to cited author via email]
In comp.lang.perl.misc,
sitaram@diac.com (Sitaram Chamarty) writes:
:perldoc -f time is prolly what Tom meant...
Certainly not. I don't use that program.
--tom
--
"I believe OS/2 is destined to be the most important operating
system, and possibly program, of all time" - Bill Gates, Nov, 1987.
------------------------------
Date: Fri, 10 Jul 1998 16:50:52 GMT
From: drummj@mail.mmc.org (Jeffrey R. Drumm)
Subject: Re: How to access the default NT printer
Message-Id: <35a64474.279236931@news.mmc.org>
[ posted to comp.lang.perl.misc and a courtesy copy was mailed to the cited
author ]
On Fri, 10 Jul 1998 14:43:27 GMT, wilfwilliams@my-dejanews.com wrote:
>Ok I'm Newbie, I have the camel book!
>can anyone tell me ho to get a file/files to go to the default printer
This is one of those things where the Camel is of only marginal use. However,
DejaNews is most definitely useful, since I've answered this question myself
3-4 times here . . .
One last time:
Create a share for the printer (see NT docs)
open PRN, '>//computername/sharename' or die "Uh oh: $!\n";
print PRN "stuff you want to print";
close PRN or die "Couldn't close printer: $!\n";
--
Jeffrey R. Drumm, Systems Integration Specialist
Maine Medical Center - Medical Information Systems Group
drummj@mail.mmc.org
"Broken? Hell no! Uniquely implemented!" - me
------------------------------
Date: Fri, 10 Jul 1998 16:50:48 +0100
From: "F.Quednau" <quednauf@nortel.co.uk>
Subject: Re: need to code a delete function
Message-Id: <35A63858.5B633096@nortel.co.uk>
AACTION Mortgage Webmaster wrote:
>
> also are there issues for not using the close(); at the end or does it
> take care of itself?
AFAIK close is performed at the end of the script or if the file is re-opened.
--
____________________________________________________________
Frank Quednau
http://www.surrey.ac.uk/~me51fq
________________________________________________
------------------------------
Date: 10 Jul 1998 16:08:20 GMT
From: psi@euclid.jpl.nasa.gov (Peter Scott)
Subject: Re: NEVER "call warn() and return undef" (Re: question about objects)
Message-Id: <6o5e9k$fob@netline.jpl.nasa.gov>
In article <899945815.606388@thrush.omix.com>, Zenin <zenin@bawdycaste.org> wrote:
-- As simple as the current eval/die/$@ system
is, it doens't scale well at all. It's also the single argument
that has made some projects I've worked with use Java when Perl
was arguably a better choice for the particular task.
Exactly why I like Graham Barr's Error.pm so much; the semantics are
pretty close to Java. I can just write code like (abbreviated example):
try {
@rows = $db->query ($sql); # Method might throw Exception::SQL w/args
# Do some stuff with @rows which might also throw up
} catch Exception::SQL with {
my $E = shift;
print "SQL Error $E\n";
$db->rollback;
} otherwise {
my $E = shift;
print "Non-SQL error $E\n";
} finally {
$db->disconnect;
}
I created a class which I subclass for exception families just by adding
one line to Exception.pm. This is a joy to use. Finally error handling
is not a pain.
----
This is news. This is your | Peter Scott, NASA/JPL/Caltech
brain on news. Any questions? | (psi@euclid.jpl.nasa.gov)
Disclaimer: These comments are the personal opinions of the author, and
have not been adopted, authorized, ratified, or approved by JPL.
------------------------------
Date: 10 Jul 98 13:57:54 GMT
From: sitaram@diac.com (Sitaram Chamarty)
Subject: Re: new charter and moderator for comp.lang.perl.announce
Message-Id: <slrn6qceqf.ra.sitaram@ltusitaram.unidata.com>
On Fri, 10 Jul 1998 15:10:23 GMT, Daniel Grisinger
<dgris@rand.dimensional.com> wrote:
>Let's see-
>
> IBM is now shipping Apache with some of their e-commerce packages.
> My impression is that it will come with modperl.
>
> Microsoft ships an ancient version of perl with the NT Server
> Resource Kit.
>
> I have an Oracle cd that includes oraperl.
>
> I have a Sybase cd that includes sybperl.
>
>As open source software becomes a more palatable option to the
>Pointy-Hairs we are going to see perl shipping with more and more
>commercial packages; we have to be ready to deal with this (and a
>new clpa charter must take this into account).
I tend to agree. Look at it this way: if someone is using <large
commercial product> for something, it is safe to assume the perl
part is an add-on, for convenience, speed, whatever. The actual
product (be it Oracle or whatever) is the big thing, perl is an
accessory.
People interested in that combination should be able to look for
announcements regarding that in some oracle newsgroup. It is of
no interest to the majority of Perl users what Oracle wants to
announce.
Even non-commercial stuff: I would expect an announcement of a new
version of Apache on some web server newsgroup, not on clpa.
My 2 cents...
------------------------------
Date: Fri, 10 Jul 1998 16:25:17 GMT
From: Daniel Grisinger <dgris@rand.dimensional.com>
Subject: Re: new charter and moderator for comp.lang.perl.announce
Message-Id: <6o5ej2$9le$1@rand.dimensional.com>
[posted to comp.lang.perl.misc and mailed to the cited author]
In article <5qaf6h3exq.fsf@prometheus.frii.com>
Nathan Torkington <gnat@frii.com> wrote:
>I finally realized why this argument makes me grind my teeth--you make
>it sound like an either-or situation. It doesn't have to be this way.
>Subject-tagging and killfiles lets each user have a different view of
>the same newsgroup.
Oops, I wasn't intentionally trying to inflict dental trauma
upon you :-).
It is an either-or situation though. Either the members of the
perl community who are vehemently anti-commercial are satisfied,
or the members who are not anti-commercial are satisfied. That
isn't nice, but I do think that it is true (I also think that it
is becoming a seriously divisive issue in the open-source world,
but this isn't the appropriate place to discuss that).
>Would it make you happy (or happier, at least) if I tagged the
>subjects of non-programming tools posts with [APP]? That way you'd be
>able to killfile it and you'd only ever see a comp.lang.perl.announce
>relevant to perl programming.
Yes. This is sufficient to calm my concerns, thank you.
>I'm nervous about trying to subcategorize--saying [APP][COMMERCIAL] on
>the subject line doesn't appeal to me. I feel like there's only room
>for one tag.
I agree completely. Attempting to properly tag every announcement
to this level of specificity is ridiculous (not to mention how much
tougher it would make it to write an appropriate killfile).
>Can you see this working? Does this fall under the category of can't
>please all the people all the time? Is it worth trying?
Maybe, yes, and yes :-).
>Nat
>Perhaps we could come up with a c.l.p.a code, like the geek code.
> a++c+C++--L++X+W+
>(translation: a big commercial app with no C++, written by Larry Wall
>to do with XML and the web :-)
Hmmm....
+++
(translation: the long awaited DWIM pragma :-)
Regards,
Daniel
(ps- is it supposed to be as miserably hot in Fort Collins today
as it is in Denver (I can't wait for winter))
--
Daniel Grisinger dgris@perrin.dimensional.com
"No kings, no presidents, just a rough consensus and
running code."
Dave Clark
------------------------------
Date: Fri, 10 Jul 1998 16:39:54 GMT
From: Daniel Grisinger <dgris@rand.dimensional.com>
Subject: Re: new charter and moderator for comp.lang.perl.announce
Message-Id: <6o5ffo$9mo$1@rand.dimensional.com>
[posted to comp.lang.perl.misc and mailed to the cited author]
In article <slrn6qceqf.ra.sitaram@ltusitaram.unidata.com>
sitaram@diac.com (Sitaram Chamarty) wrote:
>People interested in that combination should be able to look for
>announcements regarding that in some oracle newsgroup. It is of
>no interest to the majority of Perl users what Oracle wants to
>announce.
Yes, but if the corporation in question produces a new perl interface
to their product, that is of interest to perl programmers. API
revisions should be on topic.
>Even non-commercial stuff: I would expect an announcement of a new
>version of Apache on some web server newsgroup, not on clpa.
Yes, but I'd expect that a new version of mod_perl would be announced
on clpa.
Regards,
Daniel
--
Daniel Grisinger dgris@perrin.dimensional.com
"No kings, no presidents, just a rough consensus and
running code."
Dave Clark
------------------------------
Date: 10 Jul 1998 12:54:40 -0400
From: groenvel@cse.psu.edu (John D Groenveld)
Subject: Re: new charter and moderator for comp.lang.perl.announce
Message-Id: <6o5h0g$dll$1@tholian.cse.psu.edu>
In article <m31zrunsbk.fsf@windlord.Stanford.EDU>,
Russ Allbery <rra@stanford.edu> wrote:
>There is no possible substitute here for moderator judgement.
There is no possible substitute for an explicit charter.
Its clear that I am outnumbered in my opinion. If Randal must
rewrite the charter, I hope he agrees to the suggestions to
label commercial post in the subject line and that he will be
explicit in what types of commercial posts he thinks are
appropriate: conferences, books, IDEs, etc. The charter
should allow a moderator who has no experience with Perl
to make quick decisions on whether a post should be
accepted.
John
groenveld@acm.org
------------------------------
Date: Fri, 10 Jul 1998 16:56:37 +0100
From: Terry Williams <terry.williams@luton.ac.uk>
Subject: Perl CGI under NT4.0 problem
Message-Id: <35A639B5.1944@luton.ac.uk>
Tony,
here's the basic information that you need to post - I'll see if
there's a couple of other places I can post this tonight
I would like some help configuring a netscape Enterprise server to
recognise and run perl programs to do CGI forms validation.
It seems that the unix version does this automatically but there is
something missing (or I haven't done) to do this for the Netscape
Enterprise server for NT4.0
Here's what I have in terms of software
PERL 5.003 for win32
Windows NT 4.0 build 1381
Netscape Enterprise Server 3.00
Here is what I have done so far
created a CGI directory for Netscape
/cgi-bin which maps to a directory
C:/tops-server/cgi-bin
I have several executables in the directory written in c and they
are all detected as CGI programs and execute okay so this is a perl
interpreter problem.
I have installed a very recent version of Perl for Win32, the
installation
created the path okay and associated the pl file extension with the
perl executable located in c:\perl\bin. Again this seems okay as I can
run
Perl programs from the command line okay.
I have tried two basic tests which have both failed.
1) created a basic hello world program
print "Content-type: text/html\n\n";
print "<html>\n";
print "<head>\n";
print "<title>My hello world program</title>\n";
print "</head>\n";
print "<body>\n";
print "Hello world\n";
print "</body>\n;
print "</html>\n";
saved it in the cgi directory and ran it thus
http://tops.rsc.org/cgi-bin/hello.pl (this is an internal standalone
webserver for
development so you can't try it for yourselves).
it falls over with a Server misconfiguration error
Server Error
This server has encountered an internal error which prevents it from
fulfilling
you request. The most likely cause is a misconfiguration. Please ask the
administrator
to look for messages in the server's error log.
and the error log on the webserver gives the following error
failure: for host [ip withheld] trying to GET /cgi-tops/hello.pl,
send-cgi reports: could not
send new process (File Not Found Error)
failure: cgi-send:cgi_start_exec c:\tops-server\cgi-tops\hello.pl failed
Initially I suspected that it needed the hashbang as the first line to
tell the server
where to find perl.exe so I added a line to hello.pl
#!c:\perl\bin\perl.exe
but this had no effect on the error.
2) I tried accessing it from a FORM
the HTML looked like this,
<FORM ACTION="/cgi-tops/hello.pl" METHOD=POST>
This threw a similar error to above with the slight difference in the
error log
of (Unknown Error Number) rather than (File Not Found Error).
I believe it to be an association problem in as much as the server
doesn't know where
to find Perl.exe. I have noticed Servers running IIS have the .pl
extension associated in
a PERLIIS.DLL file, I cannot however find an equivalent DLL for
netscape.
I have come to the end of available documentation and would appreciate
som ehelp. I an contactable
through the following email addresses.
williamst@rsc.org
fozdyke@hotmail.com
Thank you for your time and trouble.
Terry Williams
Senior Analyst/Programmer
Turpin Distribution Services
Royal Society of Chemistry
http:/www.turpin-distribution.com/
------------------------------
Date: Fri, 10 Jul 1998 18:09:36 +0200
From: "Guillermo Garcis" <ggarces@arrakis.es>
Subject: Problems creating files CGI-Unix
Message-Id: <35a63d82.0@news.arrakis.es>
I can4t create files putting: open NEW, "+>$PAGE" or die "Error
opening$PAGE\n$!";
i don4t know if the name is too long or i have to give permissions.
I tried too: open NEW, ">$PAGE" or die "Error opening $PAGE\n$!"; but it
don4t works....
When i try to create files appears the next error: Permission denied
What i have to do?
Thanks.
------------------------------
Date: Fri, 10 Jul 1998 18:08:36 +0200
From: "Guillermo Garcis" <ggarces@arrakis.es>
Subject: Problems creating files
Message-Id: <35a63d46.0@news.arrakis.es>
I can4t create files putting: open NEW, "+>$PAGE" or die "Error
opening$PAGE\n$!";
i don4t know if the name is too long or i have to give permissions.
I tried too: open NEW, ">$PAGE" or die "Error opening $PAGE\n$!"; but it
don4t works....
When i try to create files appears the next error: Permission denied
What i have to do?
Thanks.
------------------------------
Date: Fri, 10 Jul 1998 18:07:09 +0200
From: "Guillermo Garcis" <ggarces@arrakis.es>
Subject: Re: Problems creating files
Message-Id: <35a63cee.0@news.arrakis.es>
I can4t create files putting: open NEW, "+>$PAGE" or die "Error
opening$PAGE\n$!";
i don4t know if the name is too long or i have to give permissions.
I tried too: open NEW, ">$PAGE" or die "Error opening $PAGE\n$!"; but it
don4t works....
When i try to create files appears the next error: Permission denied
What i have to do?
Thanks.
------------------------------
Date: Fri, 10 Jul 1998 16:08:43 GMT
From: John Porter <jdporter@min.net>
Subject: Re: question about objects
Message-Id: <35A63E4F.166D@min.net>
John Porter wrote:
>
sub quadrant {
my $self = shift;
> return 1 if ($self->x() > 0) && ($self->y() > 0);
> return 2 if ($self->x() < 0) && ($self->y() > 0);
> return 3 if ($self->x() < 0) && ($self->y() < 0);
> return 4 if ($self->x() > 0) && ($self->y() < 0);
> return 0;
}
Not content with the brevity of that form, I offer this:
sub quadrant {
my $self = shift;
my $x = $self->x() >= 0;
my $y = $self->y() >= 0;
$x && $y and 1
or
!$x && $y and 2
or
!$x && !$y and 3
or
$x && !$y and 4
}
--
John Porter
------------------------------
Date: 10 Jul 1998 16:21:14 GMT
From: cberry@cinenet.net (Craig Berry)
Subject: Re: remove the first k lines of a string
Message-Id: <6o5f1q$ctf$3@marina.cinenet.net>
Tad McClellan (tadmc@flash.net) wrote:
: Database and tools for Uniweb (uwtools@cse.cuhk.edu.hk) wrote:
: : I have a string consisting of certain number of lines. I want to remove
: : the first k lines from it.
:
: : E.g., $str = "1st\n2nd\n3rd\n4th\n5th\n";
:
: : after removal of the first 3 lines, $str eq "4th\n5th\n";
:
: $str =~ s/(.*\n){3}//; # delete the first three lines
You might want to make that quantifier {1,3} so that removing the first 3
lines of a 1- or 2-line string results in the appropriate empty string.
---------------------------------------------------------------------
| Craig Berry - cberry@cinenet.net
--*-- Home Page: http://www.cinenet.net/users/cberry/home.html
| Member of The HTML Writers Guild: http://www.hwg.org/
"Every man and every woman is a star."
------------------------------
Date: 10 Jul 1998 16:19:41 GMT
From: cberry@cinenet.net (Craig Berry)
Subject: Re: remove the first k lines of a string
Message-Id: <6o5eut$ctf$2@marina.cinenet.net>
Database and tools for Uniweb (uwtools@cse.cuhk.edu.hk) wrote:
: I have a string consisting of certain number of lines. I want to remove
: the first k lines from it.
:
: E.g., $str = "1st\n2nd\n3rd\n4th\n5th\n";
:
: after removal of the first 3 lines, $str eq "4th\n5th\n";
$str =~ s/(?:.*\n){1,$k}//;
---------------------------------------------------------------------
| Craig Berry - cberry@cinenet.net
--*-- Home Page: http://www.cinenet.net/users/cberry/home.html
| Member of The HTML Writers Guild: http://www.hwg.org/
"Every man and every woman is a star."
------------------------------
Date: Fri, 10 Jul 1998 15:55:52 GMT
From: John Porter <jdporter@min.net>
Subject: Re: UNC Filename Open for Output
Message-Id: <35A63B4C.308B@min.net>
wilfwilliams@my-dejanews.com wrote:
>
> $index_page ='> //DITLU21/DATA$/inetpub/wwwroot/TCP/index.html';
> open(INDEX,$index_page) || die "ERROR:Cannot open $index_page !!\n";
>
> Can anyone suggest how to do this ?
Two tips:
1. Don't put the '>' in the filename string. Add it in the open call.
2. Include $! in the error message.
In summary:
$index_page = '//DITLU21/DATA$/inetpub/wwwroot/TCP/index.html';
open( INDEX, "> $index_page" ) or
die "ERROR: Cannot open $index_page: $!\n";
--
John Porter
------------------------------
Date: 10 Jul 1998 16:59:02 GMT
From: andrewa@unixg.ubc.ca (Graue)
Subject: xs generates call to XFree
Message-Id: <6o5h8m$o1c$1@nntp.ucs.ubc.ca>
I have some c code that requires a pointer to an unsigned long.
The C code alters the value that is pointed to, and so I want to
be able to see the altered value from Perl. My xs file looks
like:
...
void
translate(str, res)
char * str
unsigned long * res
CODE:
xxxtrasnlate(str, res);
OUTPUT:
res
...
One of the lines in the generated .c file is the following:
sv_setpvn(ST(1), (char *)res, sizeof(*res)), XFree((char *)res);
But from the documentation in perlguts, sv_setpvn only takes 3
arguments. Also, if I try to run make test, I get the error
Can't load...symbol not found XFree
So what is going on? I'm running version 1.9505 of xsubpp and
my perl config is
Summary of my perl5 (5.0 patchlevel 4 subversion 4) configuration:
Platform:
osname=solaris, osvers=2.5, archname=sun4-solaris
uname='sunos atria 5.5 generic sun4m sparc sunw,sparcstation-5 '
hint=recommended, useposix=true, d_sigaction=define
bincompat3=y useperlio=undef d_sfio=undef
Compiler:
cc='gnucc', optimize='-O', gccversion=2.7.2
cppflags='-I/usr/local/include'
ccflags ='-I/usr/local/include'
stdchar='unsigned char', d_stdstdio=define, usevfork=false
voidflags=15, castflags=0, d_casti32=define, d_castneg=define
intsize=4, alignbytes=8, usemymalloc=y, prototype=define
Linker and Libraries:
ld='gnucc', ldflags =' -L/usr/local/lib'
libpth=/usr/local/lib /lib /usr/lib /usr/ccs/lib
libs=-lsocket -lnsl -ldl -lm -lc -lcrypt
libc=/lib/libc.so, so=so
useshrplib=false, libperl=libperl.a
Dynamic Linking:
dlsrc=dl_dlopen.xs, dlext=so, d_dlsymun=undef, ccdlflags=' '
cccdlflags='-fpic', lddlflags='-G -L/usr/local/lib'
Thanks,
Andrew.
--
------------------------------
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 3119
**************************************