[8874] in Perl-Users-Digest
Perl-Users Digest, Issue: 2491 Volume: 8
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Mon May 4 13:06:36 1998
Date: Mon, 4 May 98 10:00:28 -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 Mon, 4 May 1998 Volume: 8 Number: 2491
Today's topics:
Re: 1701 days hath September (was: Re: rename funciton) (John Stanley)
Re: Adding 600 users to a Linux password file <wiebe@worldcom.nl>
Re: Adding 600 users to a Linux password file <brianm@kodak.com>
Re: cd with a perl-script <jandrea@iosat.com>
Re: Creating a text file from form variables <rootbeer@teleport.com>
Re: ctime.pl <rootbeer@teleport.com>
Ever Wonder Why Not Everyone Uses Modules? <upsetter@shore.net>
Re: Ever Wonder Why Not Everyone Uses Modules? <tchrist@mox.perl.com>
Re: Ever Wonder Why Not Everyone Uses Modules? <brianm@kodak.com>
Re: How do I print an array in the format I want it? (Kevin Reid)
How To Concatenate Discrete Elements <nospam@thank.you>
If Perl had immediate subroutines... jll@skynet.be
Re: If Perl had immediate subroutines... (John Porter)
Image Cache angelok@usa.net
Re: Image Cache <rootbeer@teleport.com>
Re: Include libs from current CGI path NT4 IIS4?? <rootbeer@teleport.com>
Re: Length of a variable <danboo@negia.net>
Re: Max length of a string (Kevin Reid)
Re: Newbie config CGI question (Bernhard Muenzer)
Re: Perl and Emacs question - perl debugging mode & cp xian@spooky.cimedia.com
Perl bug(?): do ne eval `cat` <oren@capella.co.il>
Re: Perl2Exe file for Unix? <rootbeer@teleport.com>
Printing dwight@allmedia.com
Re: Printing <rootbeer@teleport.com>
Re: Ref to an LVALUE??? I expected a simple SCALAR ref (John Porter)
Re: Regex Question <jdf@pobox.com>
Re: Regex Question (Kevin Reid)
Re: Regex Question chris+usenet@netmonger.net
Re: Regex Question <danboo@negia.net>
Re: s///g skips possible matches <jdf@pobox.com>
Re: Splain a regex to me chris+usenet@netmonger.net
Re: Using executable pathname to define include path <David.Boyce@fmr.com>
Digest Administrivia (Last modified: 8 Mar 97) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: 4 May 1998 15:31:46 GMT
From: stanley@skyking.OCE.ORST.EDU (John Stanley)
Subject: Re: 1701 days hath September (was: Re: rename funciton)
Message-Id: <6ikn12$9oq$1@news.NERO.NET>
In article <genepoolEsFHCA.F1z@netcom.com>,
Jim Michael <genepool@netcom.com> wrote:
>John Stanley (stanley@skyking.OCE.ORST.EDU) wrote:
>
>: Yes, the idea of paying for yet another account has already been
>: suggested. You apparently missed the part where it involves paying for
>: another account.
>
>Then use one of the free email services.
The "free" email services require internet access, which in most places
costs money.
------------------------------
Date: Mon, 04 May 1998 17:46:28 +0200
From: Wiebe de Wolf <wiebe@worldcom.nl>
Subject: Re: Adding 600 users to a Linux password file
Message-Id: <354DE2D4.917BE28E@worldcom.nl>
Hi to everybody, and thanks... but.......
Got some answers, which could be quite usefull to a trained Perl
programmer.
First of all: I have to use the Perl4 which is provided by my Internet
provider (we have a virtual server).
Second: I am not familliar with modules and libraries.
Once again I would like to ask you if there isn't a simple answer - like
the one I discribed.
So please,......
Wiebe de Wolf wrote:
> Hi there,
>
> I have to add 600 users (abo's) to a Linux password file. I have a
> list
> with the users and the passwords I like to use as a parameter.
>
> My idea was to use htpasswd in a perl script, but Perl is rather new
> to
> me
>
> exec "htpasswd /usr/local/conf/.valid_users NEW_USER";
>
> So far.... no problem
> But now I need to know the syntax to do something like
>
> IF program askes me "New password:"
> echo NEW_USER_PASSWORD
> ENDIF
>
> (and
> IF program askes me "Re-type new password:"
> echo NEW_USER_PASSWORD
> ENDIF )
>
> For you this must be a peace of cake, so please.....!
>
> Thanks. Kind regards
>
> Wiebe de Wolf
------------------------------
Date: Mon, 04 May 1998 12:13:02 -0400
From: Brian Mathis <brianm@kodak.com>
To: Wiebe de Wolf <wiebe@worldcom.nl>
Subject: Re: Adding 600 users to a Linux password file
Message-Id: <354DE90E.59C1AD1C@kodak.com>
Wiebe de Wolf wrote:
>
> Hi to everybody, and thanks... but.......
>
> Got some answers, which could be quite usefull to a trained Perl
> programmer.
>
> First of all: I have to use the Perl4 which is provided by my Internet
> provider (we have a virtual server).
> Second: I am not familliar with modules and libraries.
>
> Once again I would like to ask you if there isn't a simple answer - like
> the one I discribed.
>
> So please,......
I don't know what other kind of answer you would like. Short of writing
the whole thing for you (which isn't going to happen), you have gotten
some answers. If you still need more help, you are probably in over
your head, and should hire someone to do it for you (You can send me
email, my rates are reasonable :).
As for being stuck with perl4, all that can be said is either: get them
to upgrade, or get a new provider. If they aren't willing to cater to
your needs, there are plenty of other ISPs who are happy to do it. No
sense in getting a headache over their ignorance.
Brian Mathis
orev
------------------------------
Date: Mon, 04 May 1998 13:11:32 -0300
From: John Andrea <jandrea@iosat.com>
Subject: Re: cd with a perl-script
Message-Id: <354DE8B4.4323@iosat.com>
> > Can anybody tell me how i can change the directory of the shell from
> > wich I'm starting the perl script ?
perl has a chdir function
isn't that what's wanted ?
------------------------------
Date: Mon, 04 May 1998 16:29:51 GMT
From: Tom Phoenix <rootbeer@teleport.com>
To: Matt McKenzie <jasmatt@es.co.nz>
Subject: Re: Creating a text file from form variables
Message-Id: <Pine.GSO.3.96.980504092625.13084D-100000@user2.teleport.com>
On Tue, 5 May 1998, Matt McKenzie wrote:
> ok....here's a tricky one
>
> 1. I want to take two variables from a form. i.e $username and $password
Nothing tricky about that, if you use a module.
> 2. Use a small perl script to create a .txt file named after the
> $username. i.e. username.txt.
Okay, that's easy to do with Perl's open command.
> 2. chmod the text file to 666
Yes, Perl can do that. chmod is a built-in.
> 3. insert 2 lines into the .txt file containing the $username and
> $password.
No sweat. That's just printing.
> 4. place this file in a specified dir.
You probably did this back in step two. So, it's a snap. But if not, you
could either use the rename built-in, or you could use a module to do the
work. (But it's easier to put the file in the right place to start.)
> I've had some documentation to do this, but for the life of me I can't
> find it again.
If you need help on any of the functions I've mentioned, try the perlfunc
manpage. Hope this helps!
--
Tom Phoenix Perl Training and Hacking Esperanto
Randal Schwartz Case: http://www.rahul.net/jeffrey/ovs/
------------------------------
Date: Mon, 04 May 1998 16:49:53 GMT
From: Tom Phoenix <rootbeer@teleport.com>
To: Max <pyz@panix.com>
Subject: Re: ctime.pl
Message-Id: <Pine.GSO.3.96.980504093854.13084F-100000@user2.teleport.com>
On 4 May 1998, Max wrote:
> Where can I find a copy of ctime.pl?
It's probably on your system, if Perl is properly installed. If it's not
there, it comes with the Perl source. But you should know that it's
included there merely for compatibility with very old Perl scripts, and
will one day be removed. It hasn't been significantly updated since the
days when George Bush was President.
Any old code looking like this...
$date = &ctime(time);
...should probably be modernized, something like this:
$date = localtime(time); # or omit the parameter
If calling localtime in a scalar context isn't doing just what you want,
there are more than enough Date modules on CPAN. One of those should give
you what you need. Hope this helps!
--
Tom Phoenix Perl Training and Hacking Esperanto
Randal Schwartz Case: http://www.rahul.net/jeffrey/ovs/
------------------------------
Date: 4 May 1998 15:28:38 GMT
From: Art Cohen <upsetter@shore.net>
Subject: Ever Wonder Why Not Everyone Uses Modules?
Message-Id: <6ikmr6$1s6@fridge.shore.net>
I'm trying to use Net::SMTP, as most of the gurus on this group recommend
it over piping commands to sendmail directly.
Since I don't have root access, I'm trying to install a local copy in the
directory where I'm writing my perl scripts.
My first try failed because it didn't install a module called
"Net::Config". There doesn't appear to be any mention of it in the
by-modules/Net directory of CPAN, so maybe it's generated by the install
process, but it's not being installed in my case.
I delete everything and try to intstall again. I notice an error message
telling me that I need "Data::Dumper" to be installed. So I ftp back to
CPAN and download Data::Dumper.
As I try to install Data::Dumper, I get this message:
gcc: installation problem, cannot exec `cpp': No such file or directory
*** Error code 1
make: Fatal error: Command failed for target `Dumper.o'
I've now been working on this for an hour and I still can't run a two-line
test script. If I were actually working on something that needed to be
finished any time soon, I would have abandoned this approach about a half
an hour ago and just written the code to communicate with sendmail.
Is it any wonder why a lot of perl developers don't use pre-written
modules? Modules are *supposed* to make it easier to accomplish certain
tasks without getting bogged down in the minutiae of your operating system
but in this case, it's exactly the opposite. Whereas I could have written
the "raw" perl code to accomplish the task at hand in about five minutes,
I've now spent an hour fruitlessly trying to install a module that's
supposed to make my life easier.
End of rant.
--Art
National Ska/Reggae Calendar: www.ziplink.net/~upsetter/ska/calendar.html
Boston Ska Home Page: www.ziplink.net/~upsetter/ska/index.html
------------------------------
Date: 4 May 1998 15:55:52 GMT
From: Tom Christiansen <tchrist@mox.perl.com>
Subject: Re: Ever Wonder Why Not Everyone Uses Modules?
Message-Id: <6ikoe8$8tv$1@csnews.cs.colorado.edu>
[courtesy cc of this posting sent to cited author via email]
In comp.lang.perl.misc, Art Cohen <upsetter@shore.net> writes:
:I'm trying to use Net::SMTP, as most of the gurus on this group recommend
:it over piping commands to sendmail directly.
Not this one.
--tom
--
Tom Christiansen tchrist@jhereg.perl.com
"I will always write it the second way, so if you're optimizing for
contrariness, it's obviously better to do it the second way."
--Larry Wall
------------------------------
Date: Mon, 04 May 1998 12:16:37 -0400
From: Brian Mathis <brianm@kodak.com>
Subject: Re: Ever Wonder Why Not Everyone Uses Modules?
Message-Id: <354DE9E5.FE7AF649@kodak.com>
Tom Christiansen wrote:
>
> [courtesy cc of this posting sent to cited author via email]
>
> In comp.lang.perl.misc, Art Cohen <upsetter@shore.net> writes:
> :I'm trying to use Net::SMTP, as most of the gurus on this group recommend
> :it over piping commands to sendmail directly.
>
> Not this one.
>
> --tom
Just curious, why? It would seem to be quite a bit safer then piping to
sendmail -t or mail or some other method. What are the pros, cons?
Brian Mathis
------------------------------
Date: Mon, 4 May 1998 11:18:04 -0400
From: kpreid@ibm.net (Kevin Reid)
Subject: Re: How do I print an array in the format I want it?
Message-Id: <1d8h7wu.pa0b84lacjk0N@slip166-72-108-160.ny.us.ibm.net>
Larry Rosler <lr@hpl.hp.com> wrote:
> Randal Schwartz wrote in message <8c7m43jotr.fsf@gadget.cscaper.com>...
> ...
> >I'd probably try something like this:
> >
> > sub pad_ip {
> > my $ip = shift;
> > sprintf "%3d.%3d.%3d.%3d", split /\./, $ip;
> > }
> >
> >That's pretty clean, and it doesn't introduce all that extra
> >verbosity.
>
> ...
>
> Or, even pithier,
>
> sub pad_ip {
> sprintf "%3d.%3d.%3d.%3d", split /\./, shift;
> }
>
> But who would want to engage in a pithing contest with Randal
> Schwartz???
Myself, I prefer to use $_[0], because it doesn't break when you use it
twice. I would also add a prototype of ($) to the subroutine.
Also:
sub pad_ip ($) {(my$ip=$_[0])=~s/(\b\d+\b)/' 'x(3-length($1)).$1/ge;$ip}
I ran Benchmark, and I'm puzzled by the results: why is the sprintf
faster? Is it because of the /e in mine?
--
Kevin Reid. | Macintosh.
"I'm me." | Think different.
------------------------------
Date: Mon, 04 May 1998 12:51:20 -0400
From: Frank Blanchard <nospam@thank.you>
Subject: How To Concatenate Discrete Elements
Message-Id: <354DF208.3FF1@thank.you>
this code concatenates each
non-empty $field with a <br>
but i only want to concatenate
the fifth and seventh $field
(or any combination) in the row
any help greatly appreciated!
-fb
fb@clark.net
= = = = = = = =
foreach $field (@row) {
if ($field ne "") {
$search_results .= "$field <br>";
}
next;
}
$search_results .= "<br><br>";
------------------------------
Date: Mon, 04 May 1998 11:06:11 -0600
From: jll@skynet.be
Subject: If Perl had immediate subroutines...
Message-Id: <6ikp1j$554$1@nnrp1.dejanews.com>
(note: my ISP seemingly dropped a previous post of this article; if
it ends up appearing twice, please accept my apologies - jl)
Does anybody here remember Forth? That very peculiar - and powerful -
language had a notion of 'immediate' subroutines: they would be
executed at parse time. Forth was implemented mostly in itself thanks
to similar facilities.
Migrated to Perl, the concept might look like this: a sub marked as
immediate (by prefixing its definition with the 'immediate' keyword,
for example) would be called by the parser. The isub's return value,
which should be a (possibly empty) string, would replace the isub call
in the parse stream. The isub's arguments, if any, would implicitly be
quoted, as if enclosed in q{}.
I have built a simple emulation of this using `eval' and `s//', and
tried a few interesting applications. Given the following isubs:
immediate sub comment
{
return '';
}
immediate sub compile_if
{
my ($pred, $code) = @_;
return eval($pred) ? $code : '';
}
immediate sub max
{
my ($expr1, $expr2) = @_;
return "eval { my (\$_max_1, \$_max_2) = (($expr1), ($expr2)); \
\$_max_1 > \$_max_2 ? \$_max_1 : \$_max_2 }";
}
...the following fragment:
BEGIN
{
$DEBUG = 1;
}
sub test
{
comment
{
this block
has been
commented out
};
compile_if $DEBUG, { print "debug build!\n" };
print max 1, 2 + 3;
}
...would be transformed into something like:
sub test
{
{ print "debug build!\n" }
print eval { my ($_max_1, $_max_2) = (( 1), ( 2 + 3));
$_max_1 > $_max_2 ? $_max_1 : $_max_2 }
}
Calling `test' would print:
debug build!
5
IOW, isubs would bring native macros, inline functions, conditional
compilation, multiline comments (limited to q{}-quotable text), and
what else, to Perl...without resorting to a different, perhaps
less-powerful language (` la cpp).
Has this idea already been explored in the past?
Jean-Louis Leroy
http://ourworld.compuserve.com/homepages/jl_leroy/
-----== Posted via Deja News, The Leader in Internet Discussion ==-----
http://www.dejanews.com/ Now offering spam-free web-based newsreading
------------------------------
Date: Mon, 04 May 1998 16:50:59 GMT
From: jdporter@min.net (John Porter)
Subject: Re: If Perl had immediate subroutines...
Message-Id: <MPG.fb7bd7881d1c0129896a2@news.min.net>
On Mon, 04 May 1998 11:06:11 -0600,
in article <6ikp1j$554$1@nnrp1.dejanews.com>,
jll@skynet.be (jll@skynet.be) wrote:
>
> Migrated to Perl, the concept might look like this: a sub marked as
> immediate (by prefixing its definition with the 'immediate' keyword,
> for example) would be called by the parser. The isub's return value,
> which should be a (possibly empty) string, would replace the isub call
> in the parse stream. The isub's arguments, if any, would implicitly be
> quoted, as if enclosed in q{}.
That's way nifty, except that it isn't necessary for those who
think in perl when writing perl.
At least for the examples you gave, there exist native perl ways
of doing what you're trying to do.
> BEGIN
> {
> $DEBUG = 1;
> }
>
> sub test
> {
> comment
> {
> this block
> has been
> commented out
> };
# create a sub on the fly. discard the ref.
# call it a comment if you want.
sub {
print "this code doesn't get executed, right?\n";
};
> compile_if $DEBUG, { print "debug build!\n" };
$DEBUG && do { print "debug build!\n" };
$DEBUG || do { print "non-debug build!\n" };
> print max 1, 2 + 3;
print &{ sub { ( $_[0] > $_[1] ) ? $_[0] : $_[1]; } }( 1, 2 + 3 );
Or, if you're gonna use it more than once:
# define it:
my $max_macro = sub { ( $_[0] > $_[1] ) ? $_[0] : $_[1]; }
# use it:
print &$max_macro( 3, 1 + 2 );
All with no nasty string evals.
Can you think of any other potential uses of this "immediate sub"
feature which isn't so easily done in plain perl?
John Porter
------------------------------
Date: Mon, 04 May 1998 10:06:26 -0600
From: angelok@usa.net
Subject: Image Cache
Message-Id: <6iklhi$tm$1@nnrp1.dejanews.com>
Here is the problem...I would like to force the browser to read images that
have
been stored in the cache.
A user hits my site and has 3 images on the page. They fill
out this form, the
data gets posted form the server with the same images returned
but they repeat
5 times. The browser however, instead of reading the images
from the cache
downloads them again when the form is returned form the server.
Does anyone have a script that will force a browser to use the
images in the
cache depsite the fact that the server is posting them again?
Make sense?
-----== Posted via Deja News, The Leader in Internet Discussion ==-----
http://www.dejanews.com/ Now offering spam-free web-based newsreading
------------------------------
Date: Mon, 04 May 1998 16:55:37 GMT
From: Tom Phoenix <rootbeer@teleport.com>
To: angelok@usa.net
Subject: Re: Image Cache
Message-Id: <Pine.GSO.3.96.980504095315.13084G-100000@user2.teleport.com>
On Mon, 4 May 1998 angelok@usa.net wrote:
> Here is the problem...I would like to force the browser to read images
> that have
> been stored in the cache.
(I think there's also a problem with the way your newsreader formats text,
to be sure. :-)
You can't force a browser to do anything. The most you can do is to ask
nicely. To ask a browser to do something, use the proper protocol. If you
aren't sure about the protocol, you should read the protocol
specification. If you've read it and you're still not sure, you should ask
in a newsgroup about the protocol.
Hope this helps!
--
Tom Phoenix Perl Training and Hacking Esperanto
Randal Schwartz Case: http://www.rahul.net/jeffrey/ovs/
------------------------------
Date: Mon, 04 May 1998 16:36:36 GMT
From: Tom Phoenix <rootbeer@teleport.com>
To: patrick <netset@powerup.com.au>
Subject: Re: Include libs from current CGI path NT4 IIS4??
Message-Id: <Pine.GSO.3.96.980504093106.13084E-100000@user2.teleport.com>
On Mon, 4 May 1998, patrick wrote:
> My Perl CGI script will not include .pm files from the same directory as
> the script itself resides.
Why are you storing your modules in your script directory? The
usual method is to make a directory for your own modules and put them
there. The FAQ tells about doing this.
> I believe this can work without me adding each of my cgi-bin paths to
> the @INC.
If you won't know the directory name until runtime, you could use a BEGIN
block to add it to @INC. If you can't figure it out at runtime, Perl
probably won't be able to do so, either. :-)
Hope this helps!
--
Tom Phoenix Perl Training and Hacking Esperanto
Randal Schwartz Case: http://www.rahul.net/jeffrey/ovs/
------------------------------
Date: Mon, 04 May 1998 10:54:55 -0400
From: Dan Boorstein <danboo@negia.net>
Subject: Re: Length of a variable
Message-Id: <354DD6BF.DC1120C7@negia.net>
Ronald J Kimball wrote:
>
> Brian Roach wrote:
> >
> > niting@cyberdude.com wrote:
> > >
> > > Is there any function in PERL which will return the
> > > length of a variable?
> >
[SNIP]
>
> Not true. There are plenty of other functions in Perl which will return the
> length of a variable.
>
[SNIP]
>
> $length = () = split //, $_;
>
oops, this look familiar. may i recommend this instead:
$length = () = split //, $_, length $_;
;-)
--
Dan Boorstein home: danboo@negia.net work: danboo@y-dna.com
"THERE IS AS YET INSUFFICIENT DATA FOR A MEANINGFUL ANSWER."
- Cosmic AC
------------------------------
Date: Mon, 4 May 1998 11:18:08 -0400
From: kpreid@ibm.net (Kevin Reid)
Subject: Re: Max length of a string
Message-Id: <1d8i1b9.f1rwba1am5ri8N@slip166-72-108-160.ny.us.ibm.net>
Kjetil Skotheim <kjetil.skotheim@usit.uio.no> wrote:
> Watch out for:
> On the unix-system I use there is a per process limit at about 65MB.
>
>
> Strange phenomenon:
>
> perl5 -e '$a=('K' x 20000000)'
> Results in 'Out of memory!'.
>
> But:
> perl5 -e 'for(1..50){ push(@a, ('K' x 1000000)) }'
> ...works fine.
>
> In short: Using one 20MB string fails, but 50 1MB strings is ok.
>
> Any explaination to this?
Perhaps your system does not like making one large allocation, but can
do many small ones?
--
Kevin Reid. | Macintosh.
"I'm me." | Think different.
------------------------------
Date: Mon, 04 May 1998 14:34:01 GMT
From: bmuenzer@compuserve.com (Bernhard Muenzer)
Subject: Re: Newbie config CGI question
Message-Id: <O2Jqzn2d9GA.122@nih2naab.prod2.compuserve.com>
In article <354BF951.35B96DC5@ix.netcom.com>, qazmlp <qazmlp@ix.netcom.com> wrote:
>#!/usr/bin/perl
>use CGI;
>$q = new CGI;
>$q->header;
try:
print $q->header;
--
int m,u,e=0;float l,_,I;main(){for(;1840-e;putchar((++e>907&&942>e?
61-m:u)["\n)moc.isc@rezneumb(rezneuM drahnreB"]))for(u=_=l=0;79-(m=
e%80)&&I*l+_*_<6&&26-++u;_=2*l*_+e/80*.09-1,l=I)I=l*l-_*_-2+m/27.;}
------------------------------
Date: 04 May 1998 10:28:11 -0500
From: xian@spooky.cimedia.com
Subject: Re: Perl and Emacs question - perl debugging mode & cperl-mode vs perl-mode??
Message-Id: <m2af8yt5ro.fsf@spooky.cimedia.com>
Jason Stewart <jasons@cs.unm.edu> writes:
> mode. It was designed for use with GNU Emacs and some things don't
> work as well with XEmacs as they do with Emacs, Ilya doesn't waste his
> time supporting both :-(
>
> jas.
Is one of these unsupported 'things' ang-ftp in conjunction with
perldb (in XEmacs)?
I get an error when I try to debug a script that resides on a
different machine (no such file or dir) though I know the
path/filename is correct...
thnx,
xian
------------------------------
Date: Mon, 4 May 1998 18:20:04 +0300
From: "Oren Ben-Kiki" <oren@capella.co.il>
Subject: Perl bug(?): do ne eval `cat`
Message-Id: <6ikmkk$42i$1@news.netvision.net.il>
In the Camel book (2nd edition), page 158, "do 'stat.pl'" is said to be
equivalent to "eval `cat stat.pl`", except for being more efficient (and
locating the file for you). Well... this turns out NOT to be the case.
If there is a 'die' in 'stat.pl', $EVAL_ERROR ($@) does NOT get set in the
calling script. This was not fun, since I needed the error string. I ended
having to prefix each '.pl' script with code to install a '__DIE__' handler
which set a global '$DO_ERROR' variable, then called 'die' again. Yuch.
I tried this on both Win32 and Linux, in different versions of Perl, with
the same results. Any idea whether this is a bug, a feature, a wart or what?
Any chance of it being fixed in a future version?
---
Oren Ben-Kiki oren@capella.co.il
"Life is tough and the hard ships are many"
------------------------------
Date: Mon, 04 May 1998 16:18:24 GMT
From: Tom Phoenix <rootbeer@teleport.com>
To: Tan <tan@jettech.dircon.co.uk>
Subject: Re: Perl2Exe file for Unix?
Message-Id: <Pine.GSO.3.96.980504091758.13084C-100000@user2.teleport.com>
On Mon, 4 May 1998, Tan wrote:
> Is there any way that I can convert a Perl script into an executable under
> unix?
The FAQ talks about this. Hope this helps!
--
Tom Phoenix Perl Training and Hacking Esperanto
Randal Schwartz Case: http://www.rahul.net/jeffrey/ovs/
------------------------------
Date: Mon, 04 May 1998 10:11:18 -0600
From: dwight@allmedia.com
Subject: Printing
Message-Id: <6iklqm$1bc$1@nnrp1.dejanews.com>
Hello,
I am trying to print a string to a laser printer through a windows
application and so far I've had no success. The following is a snippet
of my code.
$ptrName = '>'."LPT1:";
open (PTR, $ptrName);
$testString = "This is a test. \n\r\f"
select(PTR);
print $testString;
close PTR;
Any suggestions? Thank you in advance!
-Dwight
-----== Posted via Deja News, The Leader in Internet Discussion ==-----
http://www.dejanews.com/ Now offering spam-free web-based newsreading
------------------------------
Date: Mon, 04 May 1998 16:57:18 GMT
From: Tom Phoenix <rootbeer@teleport.com>
To: dwight@allmedia.com
Subject: Re: Printing
Message-Id: <Pine.GSO.3.96.980504095635.13084H-100000@user2.teleport.com>
On Mon, 4 May 1998 dwight@allmedia.com wrote:
> $ptrName = '>'."LPT1:";
> open (PTR, $ptrName);
Even when your script is "just an example" (and perhaps especially in that
case!) you should _always_ check the return value after opening a file.
Thanks!
--
Tom Phoenix Perl Training and Hacking Esperanto
Randal Schwartz Case: http://www.rahul.net/jeffrey/ovs/
------------------------------
Date: Mon, 04 May 1998 15:10:44 GMT
From: jdporter@min.net (John Porter)
Subject: Re: Ref to an LVALUE??? I expected a simple SCALAR ref!
Message-Id: <MPG.fb7a5fac7580a5d9896a1@news.min.net>
On Sat, 02 May 1998 23:50:56 -0400,
in article <354BE9A0.42D76D0E@zeegee.com>,
eryq@zeegee.com (Eryq) wrote:
>...
Keep going up the chain. This code is not where the
problem is being generated. Some value is being
passed to set() which has an LVALUE ref in it.
John Porter
------------------------------
Date: 04 May 1998 11:17:34 -0500
From: Jonathan Feinberg <jdf@pobox.com>
To: tthomas@chubb.com
Subject: Re: Regex Question
Message-Id: <3eeq80yp.fsf@mailhost.panix.com>
Tod Thomas <tthomas@chubb.com> writes:
> String contains: Test User (this is a test)
>
> I want to end up with Test User only. It looks easy but I've tried
> everything.
Trying "everything" is NP-complete. Have you read the documentation
that accompanies perl, which explains the use of the Perl language?
(You do so by typing "perldoc perl", which will tell you where to go
from there.) Have you bought and read _Learning Perl_ which gently
introduces you to the same? Here's one answer:
/^([^(]*)/;
--
Jonathan Feinberg jdf@pobox.com Sunny Brooklyn, NY
------------------------------
Date: Mon, 4 May 1998 11:18:12 -0400
From: kpreid@ibm.net (Kevin Reid)
Subject: Re: Regex Question
Message-Id: <1d8i1z1.1w5zg28i5tt78N@slip166-72-108-160.ny.us.ibm.net>
Tod Thomas <tthomas@chubb.com> wrote:
> I have a string value that contains special characters. I want to pull
> out all of the characters up to the first special character, excluding
> it and any character following. For example:
>
> String contains: Test User (this is a test)
>
> I want to end up with Test User only. It looks easy but I've tried
> everything. Any help would be greatly appreciated.
>
> Tod Thomas
> The Chubb Corporation
($result) = $string =~ /^([^(]*)/;
^
Put your special characters into the character class.
--
Kevin Reid. | Macintosh.
"I'm me." | Think different.
------------------------------
Date: 4 May 1998 15:38:26 GMT
From: chris+usenet@netmonger.net
Subject: Re: Regex Question
Message-Id: <6ikndi$oev$2@schenectady.netmonger.net>
In article <354DCA00.4C05261B@chubb.com>,
Tod Thomas <tthomas@chubb.com> wrote:
> I have a string value that contains special characters. I want to pull
> out all of the characters up to the first special character, excluding
> it and any character following. For example:
>
> String contains: Test User (this is a test)
>
> I want to end up with Test User only. It looks easy but I've tried
> everything. Any help would be greatly appreciated.
What have you tried?
--
Christopher Masto <chris+usenet@netmonger.net>
Director of Operations, NetMonger Communications, Inc.
"Behold the Power of Cheese"
------------------------------
Date: Mon, 04 May 1998 11:14:53 -0400
From: Dan Boorstein <danboo@negia.net>
Subject: Re: Regex Question
Message-Id: <354DDB6D.94233DCA@negia.net>
Tod Thomas wrote:
>
> I have a string value that contains special characters. I want to pull
> out all of the characters up to the first special character, excluding
> it and any character following. For example:
>
> String contains: Test User (this is a test)
>
> I want to end up with Test User only. It looks easy but I've tried
> everything. Any help would be greatly appreciated.
in the future, posting some of your attempts would be helpful both in
solving your specific problem and helping you understand the concepts
that will lead to greater programming independence.
s/\s* # potential leading whitespace
\( # the first left parenthesis
.* # rest of the the string
//xs;
Test User (this is a test)
^^^^^^^^^^^^^^^^^
removes the above characters. i added the first part about leading space,
but it may not be appropriate. if your string was ' (this is a test)',
the whole thing would go away.
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: 04 May 1998 11:02:45 -0500
From: Jonathan Feinberg <jdf@pobox.com>
To: bart.mediamind@tornado.be (Bart Lateur)
Subject: Re: s///g skips possible matches
Message-Id: <67jm81ne.fsf@mailhost.panix.com>
bart.mediamind@tornado.be (Bart Lateur) writes:
> I've noticed that my current Perl port (5.004001, I think)
You are using an old version of perl. Both expressions you provide
work fine for me in 5.004_02 (which is itself two versions old).
> s/\{(\{|(\w+))\}/defined $2? $hash{$2}:$1/ge;
> s/\{(\{|(\w+)\=?)\}/defined $2? $hash{$2}:$1/ge;
Why all of the backwhacks? That just makes it hard to read. The only
backwhack you need is for the \w character class.
--
Jonathan Feinberg jdf@pobox.com Sunny Brooklyn, NY
------------------------------
Date: 4 May 1998 15:37:56 GMT
From: chris+usenet@netmonger.net
Subject: Re: Splain a regex to me
Message-Id: <6iknck$oev$1@schenectady.netmonger.net>
In article <6ikjdn$u0j$1@nnrp1.dejanews.com>, <kathryn.nelson@usa.net> wrote:
> I have been learning Perl for about a month now and while reading a lot of
> code from various places, it would be very helpful if there was a script
> which would take as input a regex and output a sentence describing what
> this regex would match.
>
> i.e. /[ab].+:(\s*)/
> "starts with the letter a or b followed by one or more characters followed
> by a colon and zero or more whitespaces which are remembered as $1..."
To most of us, it is much harder to understand that sentence than it
is to understand the regular expression. Not to mention that when
they get much more complicated, it's almost impossible to write an
unambiguous sentence describing them. English's grouping and nesting
is limited (unless you start using lots of parenthesis (which rather
defeats the point (assuming that punctuation (used excessively, anyway)
is what you don't like about the regex in the first place))).
--
Christopher Masto <chris+usenet@netmonger.net>
Director of Operations, NetMonger Communications, Inc.
"Behold the Power of Cheese"
------------------------------
Date: Mon, 04 May 1998 12:03:19 -0400
From: David Boyce <David.Boyce@fmr.com>
Subject: Re: Using executable pathname to define include path
Message-Id: <354DE6C7.3DBA3899@fmr.com>
Andy Glew wrote:
>
> Can the following can be done in Perl:
> discovery of the pathname of the executable, for use in defining module paths?
>
> The perennial issue of software installations is "What is the path to the
> libraries?" If you don't want to rely on user environment variables or
> rc files, you typically hardwire them into an isolated submodule.
>
> Another way, however, is to say "if you find the executable at
> ...path.../bin/executable, then the libraries are at ...path.../lib/...,
> or some similar name convention. This has the advantage that
> you can move the module around as a block, and if you type in
> a full pathname to execute a program ...path.../bin/executable,
> then it just works, with no other installation.
Perhaps the FindBin module on CPAN would do the trick for you.
> Please respond by email; I don't read this group.
Tom Phoenix has addressed this well.
-David
------------------------------
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 2491
**************************************