[6265] in Perl-Users-Digest
Perl-Users Digest, Issue: 887 Volume: 7
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Mon Feb 3 12:47:15 1997
Date: Mon, 3 Feb 97 09:00:23 -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 Mon, 3 Feb 1997 Volume: 7 Number: 887
Today's topics:
Re: 5.002 dies silently on failed socket write (Keith Dreibelbis)
Re: Best locking method for NFS - buffered IO safe? <minaret@sprynet.com>
Calling Perlscript from web-root <arne@digital-hverdag.no>
Re: Calling Perlscript from web-root (Nathan V. Patwardhan)
Re: Commercial success stories using perl. (Christian Kirsch)
Re: Control several programs <seay@absyss.fr>
Re: Creation time and date of file <lewis@thereel.com>
Re: find2perl under Win/NT <mchase@ix.netcom.com>
FYI on perl5.004 beta 2 optimizer testing on sparc Sola (Mark Daku)
Re: help Installing perl <mchase@ix.netcom.com>
Re: HELP: Creating Search Results List (Bennett Todd)
Re: How can I create associative arrays from variables? (Mike Stok)
Re: How can I create associative arrays from variables? <Patrick.Hayes.CAP_SESA@renault.fr>
Re: How do I strip out all characters including newline (Chris Nandor)
Re: MacPerl FAQ? (Bob Wilkinson)
Re: multi dimensional arrays (Chris Nandor)
Re: multiline replacements (Jeffrey)
Need CGI or Java database script (Suzanne L.)
Perl & C++ <euamyo@uab.ericsson.se>
perl and linux?? plan9@inetworld.net
Re: perl and linux?? (Nathan V. Patwardhan)
Re: perl and linux?? (Mike Stok)
Re: perl and linux?? <seay@absyss.fr>
Re: perl and linux??? (Bennett Todd)
Perl regexes are *not* greedy (was Pattern Matching Que (Jeffrey)
Re: Q: opening a file RW without deleting it. (Bennett Todd)
Re: regex for printcap for longest alias (Will Morse)
Re: Shell "case" command in perl (Mike Stok)
Substitute with function (Alberto Grazi)
Re: Substitute with function (Dave Thomas)
Re: Substitute with function (Mike Stok)
Digest Administrivia (Last modified: 8 Jan 97) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: 3 Feb 1997 15:41:26 GMT
From: dribbs@netspace.org (Keith Dreibelbis)
Subject: Re: 5.002 dies silently on failed socket write
Message-Id: <5d50v6$2lg@cocoa.brown.edu>
Thank you Mark-Jason for your thorough and understandable answer, but I do
have one point I'd like someone to clarify:
Mark-Jason Dominus (mjd@plover.com) wrote:
[Responding to me doing a -w SOCKET to see if a socket filehandle was
closed or no longer writable.]
: 3. The `-w' thing you mentioned is bizarre, and I suspect it's not doing
: what you think it is doing.
It seems to be working; do you think it's doing something wrong? I
figured it was testing the socket to see if it was writable, but I want to
make sure it won't have any weird side-effects.
- Keith D
dribbs@netspace.org
------------------------------
Date: 3 Feb 1997 15:31:24 GMT
From: "Geoff Mottram" <minaret@sprynet.com>
Subject: Re: Best locking method for NFS - buffered IO safe?
Message-Id: <01bc11e6$f2f7af00$67b9aec7@cactus>
Someone told me about a bug in NFS that prevents the use of the EXCL flag
in creating lock files. Their solution was to "stat" the file to determine
if it existed.
--
Geoff Mottram
minaret@sprynet.com
------------------------------
Date: 3 Feb 1997 14:15:35 GMT
From: "Arne Unneland" <arne@digital-hverdag.no>
Subject: Calling Perlscript from web-root
Message-Id: <01bc11dc$6d671240$16d1eac2@dh3>
If you have a url like this:
http://www.somecorp.com/
Can you call a perl-script from this location without using any
redirect/location methods. Can you set the webserver to do this
automatically?
Arne Unneland
digital hverdag as
arne@digital-hverdag.no
------------------------------
Date: 3 Feb 1997 14:46:17 GMT
From: nvp@shore.net (Nathan V. Patwardhan)
Subject: Re: Calling Perlscript from web-root
Message-Id: <5d4tnp$1g9@fridge-nf0.shore.net>
Arne Unneland (arne@digital-hverdag.no) wrote:
: Can you call a perl-script from this location without using any
: redirect/location methods. Can you set the webserver to do this
: automatically?
Yes, but with a caveat. Implementation depends on what server you're
using. I've always used NCSA and Apache where the server can be configured
to execute index.cgi, or index.shtml will execute a CGI script (the former
method being preferred).
You should follow-up to comp.infosystems.www.servers.misc and ask a
more specific question about your server there.
--
N Patwardhan
nvp@shore.net
[news:alt.fan.jwz]
------------------------------
Date: 2 Feb 1997 12:02:10 GMT
From: ck@held.mind.de (Christian Kirsch)
Subject: Re: Commercial success stories using perl.
Message-Id: <5d1vo2$6on@held.mind.de>
I know of a company in Berlin (Germany) that uses Perl in document
preparation. They are providing several newspapers with ready-to-print
versions of daily the TV program. Perl comes in very early in the
process, when the RTF files coming from the TV companies are
pre-processed and analyzed.
--
Christian Kirsch
ck@held.mind.de ck@ix.heise.de
Tel +49-30-78702288 +49-511-5352-590
Fax +49-30-78702289
------------------------------
Date: Mon, 03 Feb 1997 15:02:54 +0000
From: Douglas SEAY <seay@absyss.fr>
To: baasch@tu-harburg.d400.de
Subject: Re: Control several programs
Message-Id: <32F5FE1E.21E3@absyss.fr>
Peter Baasch wrote:
>
> Hi!
> I have several instances of the same program, running
> at the same time and interacting with eachother via
> sockets. The instances are controlled via std[in|out],
> which means till now one xterm per instance. I'd like
> to have on frontend for all instances, showing a table
> with their states and buttons to control them. This
> should run on UNIX as on Windows-NT.
>
> Peter.
Doesn't sound too hard. Look into select() with 4 parms,
not the 1 parm verison.
doug seay
seay@absyss.fr
------------------------------
Date: Mon, 03 Feb 1997 10:08:19 -0800
From: Lewis Taylor <lewis@thereel.com>
Subject: Re: Creation time and date of file
Message-Id: <32F62993.2846@thereel.com>
Petr Prikryl wrote:
>
> Petr Prikryl (prikryl@dcse.fee.vutbr.cz) wrote:
> >Parmeshta Jain (jain@bcstec.ca.boeing.com) wrote:
> >>I need to be able to print out the creation time and date of a file in
> >>the following format. Can someone help me with this?
> >>The format is: 24 JAN 1997 AT 00:02:10 AM
>
> >I would recommend stat() and localtime() functions. The stat() function
> >takes the name of the file and returns also time of the creation; however,
> >usage of "time of modification" is more useful, in my opinion (also
> >returned by stat()). The time is in seconds from 1 Jan 1970. You can
> >pass this to localtime() to convert it to year, day, month, hour, minute,
> >sec... (basicaly the numbers). Then it is quite easy to convert the
> >numbers into strings like JAN, etc.
>
> Oops! Tad McClellan is right in this thread. There is nothing like
> creation time. The ctime is "inode change time". My fault.
> Nevertheless, Parmeshta Jain definitely wants "modification time" ;-)
>
> Petr
>
> --
> Petr Prikryl (prikryl@dcse.fee.vutbr.cz) http://www.fee.vutbr.cz/~prikryl/
> TU of Brno, Dept. of Computer Sci. & Engineering; tel. +42-(0)5-7275 218
I have tried to access the modification date in the same way:
$info=(stat($file))[9];
but revtrieve
a 9-digit integer. How do I go about converting this into something
useful of human-readable?
Thanks in advance,
Lewis Taylor (nexus@nexusint.com)
------------------------------
Date: 3 Feb 1997 14:23:06 GMT
From: "Michael A. Chase" <mchase@ix.netcom.com>
Subject: Re: find2perl under Win/NT
Message-Id: <01bc116d$66924260$LocalHost@mchase.ix.netcom.com>
It's not in Build 302. Try looking in CPAN. You can download a recent
source distribution if you can't find find2perl by itself.
Mac :})
Lars Schylberg <Lars.Schylberg@enator.se> wrote in article
<32EE0B53.28DC@enator.se>...
> I been looking for the command find2perl under my win/nt distribution
> of perl5
> but I can't find the program. I have also tried to look for it on the
> net. Could someone give me a hint here.
>
> Lars
>
> EMail: lars.schylberg@enator.se
------------------------------
Date: 03 Feb 1997 11:37:45 -0500
From: daku@nortel.ca (Mark Daku)
Subject: FYI on perl5.004 beta 2 optimizer testing on sparc Solaris 2.5.1
Message-Id: <esqg1zdc0bq.fsf@nortel.ca>
Hello all,
I have run a test of perl with optimizer at -xO5.
Why? Well why not let the compiler make a more efficient perl for us.
For those of us using perl for a little of everything a little CPU
savings could go a long way.
-------------------------------------------------------------------------
-xO5 results
perl size (just perl): 1216268 bytes
old perl size (just perl): 984344 bytes
Time to run test suite: 4.03 minutes
Errors in test suite: NONE
-------------------------------------------------------------------------
What does this mean.
Well perl ran the test suite faster than I have ever seen before.
It usually took several minutes. The longest part was the autosplit
of the lib.
The only operation, on visual inspection that took any length of
time are the OS interactions. This is to be expected.
Thus in conclusion it is safe to turn up the speed. This will help
in areas like the web.
Note: I have not tested everything just the standard test suite that
came with perl.
Mark Daku
daku@nortel.ca
system specs:
Summary of my perl5 (5.0 patchlevel 3 subversion 24) configuration:
Platform:
osname=solaris, osvers=2.5.1, archname=sun4-solaris
uname='sunos bcarsdea 5.5.1 generic sun4m sparc sunw,sparcstation-5 '
hint=previous, useposix=true, d_sigaction=define
bincompat3=y useperlio= d_sfio=
Compiler:
cc='cc-4.0', optimize='-xO5', gccversion=
cppflags='-I/usr/local/include -I/users/daku/local/include'
ccflags ='-I/usr/local/include -I/users/daku/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, randbits=15
Linker and Libraries:
ld='ld', ldflags ='-L/usr/local/lib -L/users/daku/local/lib'
libpth=/usr/local/lib /lib /usr/lib /usr/ccs/lib /users/daku/local/lib
libs=-lsocket -lnsl -ldb -ldl -lm -lc -lcrypt -lgdbm
libc=/lib/libc.so, so=so
useshrplib=false, libperl=libperl.a
Dynamic Linking:
dlsrc=dl_dlopen.xs, dlext=none, d_dlsymun=, ccdlflags=' '
cccdlflags='-Kpic', lddlflags='-G -L/usr/local/lib -L/users/daku/local/lib'
Characteristics of this binary (from libperl):
Built under solaris
Compiled at Feb 3 1997 10:23:58
@INC:
/opt/perl5/lib/sun4-solaris/5.00324
/opt/perl5/lib
/opt/perl5/lib/site_perl/sun4-solaris
/opt/perl5/lib/site_perl
.
------------------------------
Date: 3 Feb 1997 14:23:08 GMT
From: "Michael A. Chase" <mchase@ix.netcom.com>
Subject: Re: help Installing perl
Message-Id: <01bc116e$745da460$LocalHost@mchase.ix.netcom.com>
Your installation appears to be fine. Perl is a case-sensitive language,
Print is not print.
Mac :})
==================
Gary A. Sylvia <atm4news@wsii.com> wrote in article
<32EE1CC0.5D3D@wsii.com>...
> I've been having the usual problem any novice would have I with perl
> win95 learned alot in a short time FAQs this is strange to my: this is
> were I'm at win95 installation
>
> Thanks G Sylvia
> C:\> perl C:\woa\hello.pl
> String found where operator expected at C:\woa\hello.pl line 1, near
"Print "how
> dy, world!\n""
> (Do you need to predeclare Print?)
> syntax error at C:\woa\hello.pl line 1, next token ???
> Execution of C:\woa\hello.pl aborted due to compilation errors.
------------------------------
Date: Mon, 3 Feb 1997 13:58:44 GMT
From: bet@nospam.interactive.net (Bennett Todd)
Subject: Re: HELP: Creating Search Results List
Message-Id: <slrn5fbrok.1pd.bet@onyx.interactive.net>
I'd just walk through the text file, building a list of byte offsets to the
beginning of each 10-record block. Write these to a file. I'd personally write
'em as 4-byte raw integers, myself. Then, to output the N-th page of results,
what you do is open the index file, seek (N-1)*4 into it, read two ints; the
first one is how far to seek into the data file, and the number of bytes to
read is (the second)-(the first). This same hack is also dynamite for writing
a fortune(1) program.
-Bennett
------------------------------
Date: 3 Feb 1997 14:10:39 GMT
From: mike@stok.co.uk (Mike Stok)
Subject: Re: How can I create associative arrays from variables?
Message-Id: <5d4rkv$7uv@news-central.tiac.net>
In article <5d4o5n$cd@coli-gate.coli.uni-sb.de>,
Noemi Preissner <noemi@coli.uni-sb.de> wrote:
>the answer might be easy, but after having tried a lot of
>things I feel quite helpless now:
>
>How can I create an associative array from variables, i.e.
>if I have a variable $1 with value x and another variable $2
>with value y, I would like to create an associative array
>named after the value of $1 (%x) with the value of $2 as one
>of its keys ...
>I am interested in something like ${$2}{$1} = "yes";
>(which obviously is not the right way to do it ... )
If you're using perl 5 then you can say (in the debugger for this example)
DB<1> "hash key" =~ /(\S+)\s+(\S+)/ and ${$1}{$2} = 'yes'
DB<2> X hash
%hash = (
'key' => 'yes'
)
which uses $1 as a symbolic reference, in older perls (and perl 5 too)
you can use type globs e.g.
DB<3> if ("hash newkey" =~ /(\S+)\s+(\S+)/) {local (*GLOB) = $1; $GLOB{$2} = 'yes';}
DB<4> X hash
%hash = (
'key' => 'yes'
'newkey' => 'yes'
)
Be careful if you start experimenting with packages and doing this sort
of thing - it's not difficult but you have to be aware of what you're
doing :-)
Hope this helps,
Mike
--
mike@stok.co.uk | The "`Stok' disclaimers" apply.
http://www.stok.co.uk/~mike/ | PGP fingerprint FE 56 4D 7D 42 1A 4A 9C
http://www.tiac.net/users/stok/ | 65 F3 3F 1D 27 22 B7 41
stok@psa.pencom.com | Pencom Systems Administration (work)
------------------------------
Date: 03 Feb 1997 16:51:51 +0100
From: Patrick Hayes <Patrick.Hayes.CAP_SESA@renault.fr>
Subject: Re: How can I create associative arrays from variables?
Message-Id: <vxjpvyhzy3s.fsf@goblin.pdj.renault.fr>
Noemi Preissner <noemi@coli.uni-sb.de> writes:
> if I have a variable $1 with value x and another variable $2
> with value y, I would like to create an associative array
> named after the value of $1 (%x) with the value of $2 as one
> of its keys ...
What you're describing is called "Symbolic References" in Perl 5. Symbolic
references are somewhat deprecated because they're very easy to abuse and much
that they're useful for can be done safer/easier with hard references. Many
modules outlaw their useage with 'use strict vars' for this reason. See the
chapter on references in the Blue Camel and p. 254 of same for info on
symbolics.
> What can I write instead of
> $x{y} = "yes";
The following will give you what you want:
$$x{$y} = "yes";
Cheers,
Pat
--
--------------------------------------------------------
Patrick.Hayes.CAP_SESA@renault.fr (33) 01.41.04.64.20
--------------------------------------------------------
------------------------------
Date: Mon, 03 Feb 1997 10:15:13 -0500
From: pudge@pobox.com (Chris Nandor)
Subject: Re: How do I strip out all characters including newlines?
Message-Id: <pudge-ya023480000302971015130001@news.idt.net>
In article <5d4ksd$8s@news-central.tiac.net>, mike@stok.co.uk wrote:
# >The . matches any character EXCEPT a new line. So you have to use
# >something like s#</a>[.|\n]*#<a>#
#
# That probably doesn't do what you want, inside a character class the
# meanings of various special characters change, you might want
#
# s#</a>(.|\n)*#<a>#;
I would recommend using the s option ... since it is there and all ...
Yes, . DOES include newline with the s option.
$line = "This has </a> and \n new lines \n in it.<a> Woo-hoo!</a> \n You
go!<a> Woo-hoo!";
$line =~ s|</a>.*?<a>||sg;
print $line;
#================================================================
Chris Nandor pudge@pobox.com
PGP Key 1024/B76E72AD http://pudge.net/
Keyfingerprint = 08 24 09 0B CE 73 CA 10 1F F7 7F 13 81 80 B6 B6
------------------------------
Date: Mon, 03 Feb 1997 14:17:17 -0500
From: b.wilkinson@pindar.co.uk (Bob Wilkinson)
Subject: Re: MacPerl FAQ?
Message-Id: <b.wilkinson-0302971417170001@ip57-york.pindar.co.uk>
In article <32F28786.4E06@orca.alaska.edu>, snsbg@orca.alaska.edu wrote:
>
> Does anyone know how to install and setup MacPerl and/or where to find a
> MacPerl FAQ?
MacPerl FAQ is at http://www.connection.co.uk/bob/perl/MacPerlFAQ.html
Bob
--
All is flux, nothing is still; nothing endures but change
- Heraclitus
------------------------------
Date: Mon, 03 Feb 1997 10:20:18 -0500
From: pudge@pobox.com (Chris Nandor)
Subject: Re: multi dimensional arrays
Message-Id: <pudge-ya023480000302971020180001@news.idt.net>
In article <32F5E874.41C6@let.kun.nl>, Albert Russel <russel@let.kun.nl> wrote:
# Hi,
#
# How can I print a multi dimensional associative array
# with a foreach construction? I think it is something
# like:
#
# for ($i=1 ; $i<10 ; $i++) {
# foreach $x keys(%aa{}[$i]) {
# print $x,$aa{$x}[$i];
# }
# }
$xs{'hello'}{'goodbye'} = 'aloha';
$xs{'yo'}{'hey'} = 'whassup';
foreach $x (keys %xs) {
foreach $q (keys %{$xs{$x}}) {
print "$x = $q = $xs{$x}{$q}\n";
}
}
#================================================================
Chris Nandor pudge@pobox.com
PGP Key 1024/B76E72AD http://pudge.net/
Keyfingerprint = 08 24 09 0B CE 73 CA 10 1F F7 7F 13 81 80 B6 B6
------------------------------
Date: 03 Feb 1997 14:49:42 GMT
From: jfriedl@tubby.nff.ncl.omron.co.jp (Jeffrey)
To: rboucher@focalink.com
Subject: Re: multiline replacements
Message-Id: <JFRIEDL.97Feb3234942@tubby.nff.ncl.omron.co.jp>
rboucher <rboucher@focalink.com> wrote:
|> Unfortunately, there are other substitutions that don't like having $/
|> set to undef. Is there a way to do multiple-line replacements without
|> setting $/? If so, could you please provide an example?
I think your confusion lies in thinking that there's some relationship
between $/ and matching.
$/ has exactly *nothing* to do with matching (or anything except file input).
You can *always*, anytime, wheveryoulik, apply a match or
search-and-replace to multi-line text. How you get multiline text into a
variable is up to you (using $/ is one way, but that's unrelated to what
you do with it once you've got it).
On an related note, perl provides the /s and /m modifiers. They, too, have
nothing to do with *how* you get multi-line text into a variable, or even
*if* you can work with such text (you *always* can). /s simply means that
dot can match a newline (it doesn't otherwise), while /m means that ^ and $
can match at non-ending newlines.
Again, other than guilt by association, there's no necessiary relationship
among:
$/
matching against multi-line text
/s
/m
Jeffrey
(PS: the "Jeffrey" is my name, not the last item in the list :-)
----------------------------------------------------------------------------
Jeffrey Friedl <jfriedl@omron.co.jp> Omron Corp, Nagaokakyo, Kyoto 617 Japan
O'Reilly & Associates' _Mastering Regular Expressions_
http://enterprise.ic.gc.ca/~jfriedl/regex/
------------------------------
Date: Mon, 03 Feb 1997 15:37:49 GMT
From: suzanne@intrepid.axess.com (Suzanne L.)
Subject: Need CGI or Java database script
Message-Id: <5d50uu$94g@news.axess.com>
I Need CGI or Java database script to put databases on my homepages.
If anyone can be of assistance please email me!
I found one called WODA but am having trouble making it work. Perhaps
someone can try to help.? please email me
------------------------------
Date: Mon, 03 Feb 1997 15:48:02 +0100
From: Yayo Malek <euamyo@uab.ericsson.se>
Subject: Perl & C++
Message-Id: <32F5FAA2.2939@uab.ericsson.se>
Hello
I'm a new user of perl and I wonder if there are any good
examples of calling C++ library methods from Perl.
I have a library written in C++ code and I wish to call the
class methods in the library from Perl.
I've tried to use the man page perlxs and the perlXStut, it didn't
work for me (example 4 at
http://www.metronet.com/perlinfo/doc/manual/html/perlxstut.html).
Now I wonder if there is a more complete example of code published
and available on WWW?
Regards Malek
------------------------------
Date: Sun, 02 Feb 1997 18:33:05 GMT
From: plan9@inetworld.net
Subject: perl and linux??
Message-Id: <32f4ddd2.2720554@news.inetworld.net>
is it possible to run perl thru linux? I ask because I don't have
access to a shell that offers access to /usr/bin/perl and thus i'm
screwed if I ever wanna learn how to program in perl ( which I really
want to do), So as I see it I can instal FreeBSD ( which is what my
server runs ( I know that it will run perl) or install Linux ( the
more favorable option). Can someone enlighten me here please?
Thanks
-plan9
------------------------------
Date: 3 Feb 1997 14:42:30 GMT
From: nvp@shore.net (Nathan V. Patwardhan)
Subject: Re: perl and linux??
Message-Id: <5d4tgm$1g9@fridge-nf0.shore.net>
plan9@inetworld.net wrote:
: is it possible to run perl thru linux? I ask because I don't have
: access to a shell that offers access to /usr/bin/perl and thus i'm
: screwed if I ever wanna learn how to program in perl ( which I really
Linux runs Perl, yes. If you're running Slackware, the Perl distribution
should be part of the development package. Otherwise, pick up latest.tar.gz
from ftp://ftp.cdrom.com/pub/perl/CPAN/src/latest.tar.gz
Make sure you have all the gcc kit fully installed if you're going to
build Perl yourself.
--
N Patwardhan
nvp@shore.net
[news:alt.fan.jwz]
------------------------------
Date: 3 Feb 1997 15:11:46 GMT
From: mike@stok.co.uk (Mike Stok)
Subject: Re: perl and linux??
Message-Id: <5d4v7i$c4g@news-central.tiac.net>
In article <32f4ddd2.2720554@news.inetworld.net>, <plan9@inetworld.net> wrote:
>is it possible to run perl thru linux? I ask because I don't have
>access to a shell that offers access to /usr/bin/perl and thus i'm
>screwed if I ever wanna learn how to program in perl ( which I really
>want to do), So as I see it I can instal FreeBSD ( which is what my
>server runs ( I know that it will run perl) or install Linux ( the
>more favorable option). Can someone enlighten me here please?
Perl can be compiled and run on most unix-like platforms and some others
too. If you get a packged linux distribution then perl is usually
available as a pre-compiled installable component.
Hope this helps,
Mike
--
mike@stok.co.uk | The "`Stok' disclaimers" apply.
http://www.stok.co.uk/~mike/ | PGP fingerprint FE 56 4D 7D 42 1A 4A 9C
http://www.tiac.net/users/stok/ | 65 F3 3F 1D 27 22 B7 41
stok@psa.pencom.com | Pencom Systems Administration (work)
------------------------------
Date: Mon, 03 Feb 1997 17:24:52 +0000
From: Douglas SEAY <seay@absyss.fr>
To: plan9@inetworld.net
Subject: Re: perl and linux??
Message-Id: <32F61F64.241F@absyss.fr>
plan9@inetworld.net wrote:
>
> is it possible to run perl thru linux? I ask because I don't have
> access to a shell that offers access to /usr/bin/perl and thus i'm
> screwed if I ever wanna learn how to program in perl ( which I really
> want to do), So as I see it I can instal FreeBSD ( which is what my
> server runs ( I know that it will run perl) or install Linux ( the
> more favorable option). Can someone enlighten me here please?
>
> Thanks
>
> -plan9
I'm somewhat confused here. I use perl on linux 2.0.18 (RH4.0) all
time. I would guess that you mis-installed something or you have made
some sort of simple blunder.
What do you mean by "I don't have access to a shell that offers access
to /usr/bin/perl"? Which shell are you using? Most linux users use
bash,
and you don't have to tell bash about perl. Does /usr/bin/perl really
exist? Maybe it is in /usr/local/bin/perl? Do you have execute
permission on this file? Is your pound-bang (shebang) line messed up?
Can you execute your script with
/usr/bin/perl -w ./my_script
If that doesn't work, create the file "perltest" with the two lines
#!/usr/bin/perl -w
print "howdy, world\n";
and execute the command
chmod a+rx perltest
to set the read and execute bits, followed by
./perltest
If you do not see
howdy world
on your screen, please tell me what error message[s] you do see.
doug seay
seay@absyss.fr
------------------------------
Date: Mon, 3 Feb 1997 15:12:15 GMT
From: bet@nospam.interactive.net (Bennett Todd)
Subject: Re: perl and linux???
Message-Id: <slrn5fc02f.h98.bet@onyx.interactive.net>
On Sun, 02 Feb 1997 18:33:32 GMT, plan9@inetworld.net <plan9@inetworld.net> wrote:
>is it possible to run perl thru linux?
Yes indeedy. Works like a champ.
>[...] So as I see it I can instal FreeBSD ( which is what my server runs ( I
>know that it will run perl) or install Linux ( the more favorable option).
FreeBSD also works fine. If you wanted to run FreeBSD because it's what your
server runs (a reasonable justification, if you didn't want to have to learn a
slightly different system) that would also be quite reasonable.
Today, there remain differences between Linux and FreeBSD, but overall I don't
think it's reasonable to say one's better than the other; each is stronger in
certain areas, and by and large those areas change over time, as each camp
happily incorportes innovations and enhancements pioneered in the other.
-Bennett
------------------------------
Date: 03 Feb 1997 14:26:41 GMT
From: jfriedl@tubby.nff.ncl.omron.co.jp (Jeffrey)
To: bill@sover.net.no.junkmail (Bill)
Subject: Perl regexes are *not* greedy (was Pattern Matching Question)
Message-Id: <JFRIEDL.97Feb3232641@tubby.nff.ncl.omron.co.jp>
|> Perl does greedy expression matching by default, which means it tries to
|> match as much as possible with your pattern.
This is a common misconception, but it's not really true.
For example,
/super|supercalifragiscicantspellforcrap/
will match only: ``supercalifragiscicantspellforcrap'' even though it could
all match. ~~~~~
Awk, egrep, and lex, for example, provide regular expressions that *are*
truly greedy -- given the above example they *will* match the whole thing.
What's true about Perl is that it's (what I call) ``regex directed'', and
within that framework, the quantifiers (*, +, ?, and {x,y}) are greedy.
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
The ?-appended versions are ungreedy, of course.
But the expression, as a whole, is neither greedy nor ungreedy. It ``is''.
There are times when using a non-greedy quantifier can actually result in
a longer overall match! (There is an example of something like this in my
article in the current issue of _The Perl Journal_ (http://www.tpj.com/tpj).
Jeffrey
----------------------------------------------------------------------------
Jeffrey Friedl <jfriedl@omron.co.jp> Omron Corp, Nagaokakyo, Kyoto 617 Japan
O'Reilly & Associates' _Mastering Regular Expressions_
http://enterprise.ic.gc.ca/~jfriedl/regex/
------------------------------
Date: Mon, 3 Feb 1997 14:08:31 GMT
From: bet@nospam.interactive.net (Bennett Todd)
Subject: Re: Q: opening a file RW without deleting it.
Message-Id: <slrn5fbsav.1pd.bet@onyx.interactive.net>
On 02 Feb 1997 15:41:34 -0700, Randal Schwartz <merlyn@stonehenge.com> wrote:
>>>>>> "Mike" == Mike Stok <mike@stok.co.uk> writes:
>Mike> scalar <FILE>;
>Mike> scalar <FILE>;
>
>What are those "scalars" doing in there?
>Works just fine without them. It's misleading this way.
I dunno what Mike's doing with them. I know why _I_ used to use them, until I
got FileHandle and was able to use the getline() method.
Problem is, the clever Perl <> magic does wildly, rabidly different things
depending on whether it's called in a scalar or array context; unlike just
about all the rest of the perl scalar -vs- array context magic, this one
will totally ruin your day if you get it wrong. So whenever I want to do
anything with a <HANDLE> file read, I stick it in an explicit scalar(); the
only exceptions that come to mind are $varname = <HANDLE> --- it's pretty
obvious that a scalar context is being set up there --- and while(<HANDLE>),
since it's such an idiom.
-Bennett
------------------------------
Date: 3 Feb 1997 09:36:28 -0600
From: will@Starbase.NeoSoft.COM (Will Morse)
Subject: Re: regex for printcap for longest alias
Message-Id: <5d50ls$7d3@Starbase.NeoSoft.COM>
In article <32F1A34C.7E2B@uab.ericsson.se>,
Michael Salmon <Michael.Salmon@uab.ericsson.se> wrote:
>Will Morse wrote:
>>
>> Hi,
>>
>> I have been scratching my head over this one for a while and I
>> think it is time to ask the world.
>>
>> I have a program that finds the longest alias among the aliases
>> in a printcap file. My program, which I am not real proud of,
---
>
>Sounds like Maslow's law (or a corollary) at work here. Why use regexps
>when split will do the job much better. First split on : to get only the
>printer names (there is no requirement on not having just one line for a
>printcap entry) then use foreach and split to get the longest and
>shortest names.
I got several replies to this effect, and this is what I am going to do.
I got a little fixated on regex (when you have a hammer -- :-)) and
missed the obvious choice.
Thanks to all.
Will
--
# Copyright 1997 Will Morse. Internet repost/archive freely permitted.
# Hardcopy newspaper, magazine, etc. quoting requires permission.
#
# Gravity, # Will Morse
# not just a good idea, # Houston, Texas
# it's the law. # will@starbase.neosoft.com
#
# These are my views and do not necessarly reflect anyone else/
------------------------------
Date: 3 Feb 1997 14:29:44 GMT
From: mike@stok.co.uk (Mike Stok)
Subject: Re: Shell "case" command in perl
Message-Id: <5d4soo$92s@news-central.tiac.net>
In article <5d4jmk$onc@leech.urbi.com.br>,
Jan-Patrick Perisse Sys. Admin <perisse@urbi.com.br> wrote:
>How would a bash "case" look like in perl?
> I've been reading the book and found nothing about it.
Which book have you been reading? Case makes it into the index of the 2nd
edition of the "camel book" (programming Perl by Larry Wall, Tom
Christiansen and Randal Schwartz) and it's at the end of the Statements
section of The Gory Details in the first edition (programming Perl by
Larry Wall and Randal Schwartz)
The manual page has been carved up for perl 5, the perlsyn
documewntation contains:
[...]
The BLOCK construct is particularly nice for doing case structures.
SWITCH: {
if (/^abc/) { $abc = 1; last SWITCH; }
if (/^def/) { $def = 1; last SWITCH; }
if (/^xyz/) { $xyz = 1; last SWITCH; }
$nothing = 1;
}
There is no official switch statement in Perl, because there are already
several ways to write the equivalent. In addition to the above, you could
write
SWITCH: {
$abc = 1, last SWITCH if /^abc/;
$def = 1, last SWITCH if /^def/;
$xyz = 1, last SWITCH if /^xyz/;
$nothing = 1;
}
[...]
Hope this helps,
Mike
--
mike@stok.co.uk | The "`Stok' disclaimers" apply.
http://www.stok.co.uk/~mike/ | PGP fingerprint FE 56 4D 7D 42 1A 4A 9C
http://www.tiac.net/users/stok/ | 65 F3 3F 1D 27 22 B7 41
stok@psa.pencom.com | Pencom Systems Administration (work)
------------------------------
Date: Mon, 03 Feb 1997 13:59:30 GMT
From: grazi@smart.it (Alberto Grazi)
Subject: Substitute with function
Message-Id: <5d4qst$fju@sirio.cineca.it>
I'd like to perform something like this
$VAR =~ s/(abc)__(something)__(def)/$1&function($2)$3/eg;
What's the problem ?
Thanks in advance and please answer in mail too !
------------------------------
Date: 3 Feb 1997 14:58:00 GMT
From: dave@fast.thomases.com (Dave Thomas)
Subject: Re: Substitute with function
Message-Id: <slrn5fbv39.f56.dave@fast.thomases.com>
On Mon, 03 Feb 1997 13:59:30 GMT, Alberto Grazi <grazi@smart.it> wrote:
> I'd like to perform something like this
>
> $VAR =~ s/(abc)__(something)__(def)/$1&function($2)$3/eg;
^^^^^^^^^^^^^^^^^
This isn't a valid expression
Try something like
$VAR =~ s/(abc)__(something)__(def)/"$1" . &function($2) . "$3"/eg;
Dave
--
_________________________________________________________________________
| Dave Thomas - Dave@Thomases.com - Unix and systems consultancy - Dallas |
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
------------------------------
Date: 3 Feb 1997 15:43:48 GMT
From: mike@stok.co.uk (Mike Stok)
Subject: Re: Substitute with function
Message-Id: <5d513k$e4l@news-central.tiac.net>
In article <5d4qst$fju@sirio.cineca.it>, Alberto Grazi <grazi@smart.it> wrote:
>I'd like to perform something like this
>
> $VAR =~ s/(abc)__(something)__(def)/$1&function($2)$3/eg;
>
>What's the problem ?
The right hand side needs to be a valid expression, would
$x = $1&function($2)$3;
work? You could try
$VAR =~ s/(abc)__(something)__(def)/$1 . &function($2) . $3/eg;
which uses the . operator to join the strings together e.g. (in the
debugger)
DB<1> sub function { reverse shift }
DB<2> $VAR = '>>>abc__something__def<<<'
DB<3> $VAR =~ s/(abc)__(something)__(def)/$1 . &function ($2) . $3/eg
DB<4> X VAR
$VAR = '>>>abcgnihtemosdef<<<'
Hope this helps,
Mike
--
mike@stok.co.uk | The "`Stok' disclaimers" apply.
http://www.stok.co.uk/~mike/ | PGP fingerprint FE 56 4D 7D 42 1A 4A 9C
http://www.tiac.net/users/stok/ | 65 F3 3F 1D 27 22 B7 41
stok@psa.pencom.com | Pencom Systems Administration (work)
------------------------------
Date: 8 Jan 97 21:33:47 GMT (Last modified)
From: Perl-Request@ruby.oce.orst.edu (Perl-Users-Digest Admin)
Subject: Digest Administrivia (Last modified: 8 Jan 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.
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 V7 Issue 887
*************************************