[11919] in Perl-Users-Digest
Perl-Users Digest, Issue: 5519 Volume: 8
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Thu Apr 29 15:07:23 1999
Date: Thu, 29 Apr 99 12: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 Thu, 29 Apr 1999 Volume: 8 Number: 5519
Today's topics:
Re: "learning perl" does not seem to be written well (Randal L. Schwartz)
Re: ANNOUNCE: Data::Locations 5.0 <sb@sdm.de>
Re: Call and exe program from perl mcti@my-dejanews.com
Re: Call and exe program from perl (Larry Rosler)
Re: How to convert perl to C program <cassell@mail.cor.epa.gov>
Re: Is this the best way to get a substring? <jeromeo@atrieva.com>
Re: Is this the best way to get a substring? <uri@sysarch.com>
Need an idea to do Perl-debugging in embedded Perl <office@danubit.at>
Re: Need an idea to do Perl-debugging in embedded Perl (M.J.T. Guy)
Newsfeed and Local Weather <skyward@frognet.net>
Re: perldoc HELP, Was How to use Net::FTP in perl?? <e.h.bogart@larc.nasa.gov>
Re: perldoc HELP, Was How to use Net::FTP in perl?? <tim@timbury.com>
Re: pow() ? to the power of ? <cassell@mail.cor.epa.gov>
Re: Question: Opening and closing files. <cassell@mail.cor.epa.gov>
Re: Searching a Text File by key (Randal L. Schwartz)
Re: Searching a Text File by key <uri@sysarch.com>
simple problem <mali@hrz.tu-chemnitz.de>
Re: simple problem (Brandon Metcalf)
Re: simple problem <uri@sysarch.com>
Re: simple problem (Brandon Metcalf)
Re: simple problem (Larry Rosler)
Re: simple problem <uri@sysarch.com>
Re: simple problem pbyrne@ie.oracle.com
Web BBS, need programming ether1@ix.netcom.com
Re: Web BBS, need programming <uri@sysarch.com>
What's wrong with this code? <tfinn@hotmail.com>
where is strict.pm ??? kmitev@my-dejanews.com
Re: Win95/98 file locking <cassell@mail.cor.epa.gov>
Special: Digest Administrivia (Last modified: 12 Dec 98 (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: 29 Apr 1999 10:00:48 -0700
From: merlyn@stonehenge.com (Randal L. Schwartz)
Subject: Re: "learning perl" does not seem to be written well
Message-Id: <m1vhefl5tr.fsf@halfdome.holdit.com>
>>>>> "Eric" == Eric The Read <emschwar@rmi.net> writes:
Eric> Again, this was Perl 4, so there wasn't any
Eric> perldoc,
Perl[0-4] came with a nice concise single manpage called "man perl".
No need for perldoc, because man found the single page rather nicely.
print "Just another Perl hacker,"
--
Name: Randal L. Schwartz / Stonehenge Consulting Services (503)777-0095
Keywords: Perl training, UNIX[tm] consulting, video production, skiing, flying
Email: <merlyn@stonehenge.com> Snail: (Call) PGP-Key: (finger merlyn@teleport.com)
Web: <A HREF="http://www.stonehenge.com/merlyn/">My Home Page!</A>
Quote: "I'm telling you, if I could have five lines in my .sig, I would!" -- me
------------------------------
Date: 29 Apr 1999 18:48:18 GMT
From: Steffen Beyer <sb@sdm.de>
Subject: Re: ANNOUNCE: Data::Locations 5.0
Message-Id: <7ga9hi$r1l$2@solti3.sdm.de>
In comp.lang.perl.misc, I (Steffen Beyer <sb@sdm.de>) wrote:
> I am glad to announce version 5.0 of my module "Data::Locations":
One of the test scripts (t/02___refcount.t) in the regression test suite fails
under Perl 5.005_03 but succeeds under Perl 5.005_02, 5.004, 5.004_02 and
5.004_04.
The module nevertheless seems to work flawlessly under Perl 5.005_03, as the
other (succeeding) tests demonstrate.
Best regards,
--
Steffen Beyer <sb@engelschall.com>
http://www.engelschall.com/u/sb/whoami/
http://www.engelschall.com/u/sb/download/
http://www.perl.com/CPAN/authors/id/STBEY/
http://www.oreilly.de/catalog/perlmodger/bnp/
------------------------------
Date: Thu, 29 Apr 1999 17:07:33 GMT
From: mcti@my-dejanews.com
Subject: Re: Call and exe program from perl
Message-Id: <7ga3kh$ofb$1@nnrp1.dejanews.com>
Idea #1: Pick up a book Idea #2: Use system('program_name'); where
program_name is the name (full path) of the exe you want to run.
In article <D0BE198B1C7ED111AD1808002BA613F80CEFE5E1@mail1.ntu.edu.sg>,
#VIKRAM BALKRISHNAN NATARAJAN# <U903506@ntu.edu.sg> wrote:
> This message is in MIME format. Since your mail reader does not understand
> this format, some or all of this message may not be legible.
>
> ------_=_NextPart_001_01BE91F3.60BB148A
> Content-Type: text/plain
>
> Hi
> Anyone knows how to cause perl to execute and exe program say in
> c:\vikram ???
> I tried
> chdir "c:\vikram";
> exec "file.exe"
> but it does not work...
> anybody has an idea?/
> Thanks
> Vikram
>
> ------_=_NextPart_001_01BE91F3.60BB148A
> Content-Type: text/html
>
> <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2//EN">
> <HTML>
> <HEAD>
> <META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=us-ascii">
> <META NAME="Generator" CONTENT="MS Exchange Server version 5.5.2232.0">
> <TITLE>Call and exe program from perl</TITLE>
> </HEAD>
> <BODY>
>
> <P><FONT SIZE=2>Hi</FONT>
> <BR><FONT SIZE=2> Anyone knows how to cause perl to execute and
exe program say in c:\vikram ???</FONT>
> <BR><FONT SIZE=2> I tried </FONT>
> <BR><FONT SIZE=2> chdir "c:\vikram";</FONT>
> <BR><FONT SIZE=2> exec "file.exe"</FONT>
> <BR><FONT SIZE=2> but it does not work...</FONT>
> <BR><FONT SIZE=2> anybody has an idea?/</FONT>
> <BR><FONT SIZE=2>Thanks</FONT>
> <BR><FONT SIZE=2>Vikram</FONT>
> </P>
>
> </BODY>
> </HTML>
> ------_=_NextPart_001_01BE91F3.60BB148A--
>
>
-----------== Posted via Deja News, The Discussion Network ==----------
http://www.dejanews.com/ Search, Read, Discuss, or Start Your Own
------------------------------
Date: Thu, 29 Apr 1999 10:46:26 -0700
From: lr@hpl.hp.com (Larry Rosler)
Subject: Re: Call and exe program from perl
Message-Id: <MPG.11923ac9ab59307b989978@nntp.hpl.hp.com>
[Posted and a courtesy copy mailed.]
In article <D0BE198B1C7ED111AD1808002BA613F80CEFE5E1@mail1.ntu.edu.sg>
on Thu, 29 Apr 1999 11:50:09 +0800, #VIKRAM BALKRISHNAN NATARAJAN#
<U903506@ntu.edu.sg> says...
> Anyone knows how to cause perl to execute and exe program say in
> c:\vikram ???
> I tried
> chdir "c:\vikram";
> exec "file.exe"
> but it does not work...
Had you tried this:
chdir "c:\vikram" or die "Couldn't chdir to c:\vikram. $!";
everything would have become very clear.
ALWAYS check the results of your system calls (requests for operating-
system services of some sort). That even includes the 'exec' in your
above example.
--
(Just Another Larry) Rosler
Hewlett-Packard Company
http://www.hpl.hp.com/personal/Larry_Rosler/
lr@hpl.hp.com
------------------------------
Date: Thu, 29 Apr 1999 11:01:58 -0700
From: David Cassell <cassell@mail.cor.epa.gov>
Subject: Re: How to convert perl to C program
Message-Id: <37289E96.DD19BC8A@mail.cor.epa.gov>
id903@iname.com wrote:
>
> Could anyone tell me how to convert perl program to C program ? I know it cannot get a good converted C program. I want to do this for security reason.
[1] Please fix your newsreader so your lines wrap *somewhere*.
Preferably after about 72 chars.
[2] This is a FAQ. Since you have Perl, you should read the FAQ which
is on your system Or use perldoc to get right to the good part.
You could try this command:
perldoc -q hide
[3] If this is only for security reasons, don't do it. Anyone who
is creepy enough to try to get at your source code to do bad things
will be able to lift from the web a disassembler adequate to
walk through your C executable. And there are probably other
attack points at your site anyway.
[4] If you have other reasons, then that is a FAQ also. Try:
perldoc -q compile
to read about Malcolm Beattie's backend compiler, which is
available at CPAN.
[5] After you read the FAQ, please re-think your problem.
Security by obscurity is a losing strategy. Look at all the
Microsoft C++ code which has no available source code. Is it
safe from every M$-hating hacker on the planet? No way.
Just ask in the comp.security.[insert appropriate letters here]
group, and they'll tell you.
David
--
David Cassell, OAO cassell@mail.cor.epa.gov
Senior Computing Specialist phone: (541) 754-4468
mathematical statistician fax: (541) 754-4716
------------------------------
Date: Thu, 29 Apr 1999 10:38:00 -0700
From: Jerome O'Neil <jeromeo@atrieva.com>
To: "Randal L. Schwartz" <merlyn@stonehenge.com>
Subject: Re: Is this the best way to get a substring?
Message-Id: <372898F8.8AE4C7B5@atrieva.com>
Randal L. Schwartz wrote:
> >>>>> "Jerome" == Jerome O'Neil <jeromeo@atrieva.com> writes:
>
> Jerome> $newstring =~ /^(\d+)\D+/;
> Jerome> $digits = $1;
>
> Bad code. Very hard to track down coding error, because it *looks* right.
It's also bad code because I didn't use strict and turn on warnings,
comment it, write a spec and document it, but that's not the point, nor
the answer to the fellow's problem.
It's a good example because it demonstrates the binding operator and
backtracking, which is what the original poster was looking for.
> Hint - what if the regex match fails? What $1 are you getting?
Ahem...
QUOTE
>> Using your example, you could save one or
>> more digits at the begining of a string followed one or more non digits
>> thusly:
/QUOTE
> Right... the PREVIOUS $1 from the PREVIOUS successful match.
There is no previous match. There is no conditional. There is no
loop. (There is no spoon. :> ) There is a defined pattern, and a regex
that will match it. There is an example of the binding operator and
backtracking. All the things necessary to get the guy pointed in the
right directon, so that next time he can catch a fish himself.
> Bad code.
Good Example.
> Never look at $1 unless you are inside a conditionally executed
> chunk of code dependant on the success of your match of interest.
When that particular question is asked, I'll be sure to direct them to
the appropriate documentation for next and unless.
I like my pedantia, too.
--
Jerome O'Neil, Operations and Information Services
Atrieva Corporation, 600 University St., Ste. 911, Seattle, WA 98101
jeromeo@atrieva.com - Voice:206/749-2947
The Atrieva Service: Safe and Easy Online Backup http://www.atrieva.com
------------------------------
Date: 29 Apr 1999 14:04:29 -0400
From: Uri Guttman <uri@sysarch.com>
Subject: Re: Is this the best way to get a substring?
Message-Id: <x7yajb7176.fsf@home.sysarch.com>
>>>>> "JO" == Jerome O'Neil <jeromeo@atrieva.com> writes:
JO> Randal L. Schwartz wrote:
>> >>>>> "Jerome" == Jerome O'Neil <jeromeo@atrieva.com> writes:
>>
Jerome> $newstring =~ /^(\d+)\D+/;
Jerome> $digits = $1;
>>
JO> It's a good example because it demonstrates the binding operator and
JO> backtracking, which is what the original poster was looking for.
JO> that will match it. There is an example of the binding operator and
JO> backtracking. All the things necessary to get the guy pointed in the
what is this backtracking you are refering to? are you demonstrating how
the regex engine keeps track of its internal states and backtracks to a
previous state one when it fails at some later point? or by any chance
do you really mean grabbing (or other synonyms used for () in a regex)?
JO> I like my pedantia, too.
only if you get the terms right. that is not backtracking. it is
grouping with saving, grabbing parens, potentially backreferences, but
most definitely not backtracking.
and it was not a good example as randal says since one of the keys of
grabbing parens is that they could fail and that can be a frustrating
bug for newbie to fix. your simple example would lead the original poster
down the evil path to visual basic and redmondware. we cannot tolerate
such influences here and they must be stopped before they infect more
newbies. do it right the first time. we should go back in time and stop
the conception of matt wright. hell, if we could do that, let's do it
for uncle bill too.
uri
--
Uri Guttman ----------------- SYStems ARCHitecture and Software Engineering
uri@sysarch.com --------------------------- Perl, Internet, UNIX Consulting
Have Perl, Will Travel ----------------------------- http://www.sysarch.com
The Best Search Engine on the Net ------------- http://www.northernlight.com
------------------------------
Date: Thu, 29 Apr 1999 20:08:22 +0200
From: "L. Kovacs" <office@danubit.at>
Subject: Need an idea to do Perl-debugging in embedded Perl
Message-Id: <7ga7ar$qm8$1@fleetstreet.Austria.EU.net>
Hello,
we want to write a Win application that uses embedded Perl to execute
generated Perl-code in a visual environment and we want to offer the
possibility to step through the Perl-code, set breakpoints, view and change
variables etc. We need a breakthrough idea how it can be done.
Thanks.
------------------------------
Date: 29 Apr 1999 18:30:43 GMT
From: mjtg@cus.cam.ac.uk (M.J.T. Guy)
Subject: Re: Need an idea to do Perl-debugging in embedded Perl
Message-Id: <7ga8gj$qme$1@pegasus.csx.cam.ac.uk>
L. Kovacs <office@danubit.at> wrote:
>
>we want to write a Win application that uses embedded Perl to execute
>generated Perl-code in a visual environment and we want to offer the
>possibility to step through the Perl-code, set breakpoints, view and change
>variables etc. We need a breakthrough idea how it can be done.
Run perl with the -d switch, and use the perl debugger.
Or read in perldebug how to write your own custom debugger.
Mike Guy
------------------------------
Date: Thu, 29 Apr 1999 13:18:01 -0400
From: "Skyward Internet Technology" <skyward@frognet.net>
Subject: Newsfeed and Local Weather
Message-Id: <Ls0W2.283$fO5.13515@news14.ispnews.com>
Hello Everybody,
Does anybody know of any Perl scripts available that go out to the Weather
Channel and grab their local forecast? I've seen this done with a Cold
Fusion application and just wondered if anybody had a Perl script to do the
same.
Thanks,
Dave
------------------------------
Date: Thu, 29 Apr 1999 13:05:03 -0400
From: Ed Bogart <e.h.bogart@larc.nasa.gov>
Subject: Re: perldoc HELP, Was How to use Net::FTP in perl??
Message-Id: <3728913F.27F5AC6B@larc.nasa.gov>
Bart Lateur wrote:
>
> Ed Bogart wrote:
>
> >physio% perldoc Net::FTP
> >No documentation found for "Net::FTP".
>
> Nevertheless, THIS is the command line it should have understood.
>
> >The
> >Net::FTP _module_ has been installed, as have all the others I have
> >tried. The problem is that when I try to Read The Documentation(tm)
> >using the 'perldoc PageName|ModuleName|ProgramName' form I get an error
> >msg. The 'perldoc -f perlterm' works fine. I hope that is clearer.
>
> Does it fail for other modules as well? Try
>
> perldoc CGI
>
> and if THAT doesn't work, and it fails for other modules too, then I
> guess your perldoc script is corrupted. Note that it *is* case
> sensitive.
>
> BTW what platform are you on? Maybe the command line gets corrupted
> before the arguumeents get to the script. Try putting quotes around
> them.
>
> Bart.
OOOPS!
Upon more careful examination it appears that I have miss spoke myself.
I was sure that I had used Net::FTP in the past but I was (gasp) wrong.
You led me to it by suggesting trying CGI. It now looks like Net::FTP is
not installed. I've checked all me scripts that contain a 'use whatever'
and 'perldoc whatever' works. Oh well, from now on my sig will be;
Ed -- Often Wrong, Never in Doubt! --
------------------------------
Date: Thu, 29 Apr 1999 13:21:42 -0400
From: "Tim" <tim@timbury.com>
Subject: Re: perldoc HELP, Was How to use Net::FTP in perl??
Message-Id: <925406443.778.16@news.remarQ.com>
I don't know if this will be of any use because I'm on WinNT, not Irix.
When I do a "perldoc -v NET::FTP" (no quotes, of course),
I get "Found as d:\Perl\site\lib/NET/FTP.pm"
My installation, as you can see, is at d:\Perl.
Perhaps you can look for something like
"/usr/local/perl-5.004_04/site/lib/NET/FTP.pm"
or
"/usr/local/perl-5.004_04/lib/NET/FTP.pm"
to verify the files existence. Or, easier, "whereis FTP.pm".
If you can't find the file, neither will perldoc.
Ed Bogart wrote in message <37288CB8.25C3158@larc.nasa.gov>...
>"Stephen O. Lidie" wrote:
>>
>> Ed Bogart <e.h.bogart@larc.nasa.gov> wrote:
>> > Tony Curtis wrote:
>> >>
>> >> Re: perldoc HELP, Was How to use Net::FTP in perl??,
>> >> Ed <e.h.bogart@larc.nasa.gov> said:
>> >>
>> >> Ed> I have asked this before with no answers so here
>> >> Ed> goes again. I am using perl version 5.004_04
>> >> Ed> built for IP19-irix on an SGI 02 and have not
>> >> Ed> been able to get perldoc to work with any
>> >> Ed> modules. Trying the above, using all 3 forms
>> >> Ed> from perldoc perldoc, I get;
>> >>
>> >> Maybe this version of perl was built with no
>> >> documentation installed (you can do this during the
>> >> configuration with the reply "none" at the
>> >> appropriate point)?
>> >>
>> > As I explained in response to the IRA Aggie's post, it looks like all
>> > the modules are installed and perldoc works fine when used in the
>> > 'perldoc -f somefunction' form. It only returns an error when I as for
>> > _module_ information.
>>
>> > I could understand in no docs were included in the build but can some
be
>> > there and not others?
>>
>> Try:
>>
>> perldoc -v
>>
>> That will list exactly where perldoc is searching. On IRIX 6.x perl is
>> bundled with the OS, so the IRIX perldoc may appear in your PATH earlier
>> than the perldoc you think you have, thus, missing all your local
modules.
>>
>> Yell if that doesn't help ....
>
>OK, I tried 'perldoc -v FTP' and got a listing of 70 subdirectories
>(including /usr/local/perl-5.004_04/lib/IP19-irix/5.00404/pod that it
>searcher. It still came up with 'No documentation found for "FTP".'
>
>Ed
------------------------------
Date: Thu, 29 Apr 1999 11:08:51 -0700
From: David Cassell <cassell@mail.cor.epa.gov>
Subject: Re: pow() ? to the power of ?
Message-Id: <3728A033.D787B6E8@mail.cor.epa.gov>
Bill Jones wrote:
>
> In article <372727c6.64949187@news1.mi.home.net>, sweet@enterpriseusa.com
> (Rob Sweet) wrote:
> >
> > $x = 2 ;
> > $y = 3 ;
> >
> > print $x ** $y ;
> >
> Interesting, I haven't been able to find what the ^ is for?
>
> In math is means: X raised to power y...
>
> But, in perl, 4 ^ 2 = 6 (not 16...)
I think you mean: "In Lotus 1-2-3 ^ means raised to the power..." :-)
^ is the XOR [see perlop]
And, of course, pow() is one of the experimental functions in
PSI::ESP::Telekinesis . But don't be mad at anyone nearby when
you're testing it.
David
--
David Cassell, OAO cassell@mail.cor.epa.gov
Senior Computing Specialist phone: (541) 754-4468
mathematical statistician fax: (541) 754-4716
------------------------------
Date: Thu, 29 Apr 1999 11:17:37 -0700
From: David Cassell <cassell@mail.cor.epa.gov>
Subject: Re: Question: Opening and closing files.
Message-Id: <3728A241.13E4F2A6@mail.cor.epa.gov>
Tony Bowden wrote:
>
> Abigail <abigail@fnx.com> wrote:
> > David Cassell (cassell@mail.cor.epa.gov) wrote on MMLXII September
> > MCMXCIII in <URL:news:37210A44.47C2D26A@mail.cor.epa.gov>:
>
> The 2562nd of September 1993?
Sure. It's always September 1993 in Abigail-land.
Not quite like out here in Oregon, where for many people it is
still 1970.
David
--
David Cassell, OAO cassell@mail.cor.epa.gov
Senior Computing Specialist phone: (541) 754-4468
mathematical statistician fax: (541) 754-4716
------------------------------
Date: 29 Apr 1999 09:48:31 -0700
From: merlyn@stonehenge.com (Randal L. Schwartz)
Subject: Re: Searching a Text File by key
Message-Id: <m14slzmkyo.fsf@halfdome.holdit.com>
>>>>> "Tad" == Tad McClellan <tadmc@metronet.com> writes:
Tad> Carl Motors, Inc. (sales@carlmotors.com) wrote:
Tad> : I own
Tad> : "Programming Perl" (Wall/Christenson/Swhwartz) and
Tad> A new and unique way to misspell Randal's name?
Not to mention Tom's name. :)
And actually, over the years, I don't think there's a version
that I haven't seen. <sigh>
With a name like Randal Schwartz, I'm guaranteed to not get it right.
You should have seen the variations on spelling "Randal" and
"Stonehenge" at the O'Reilly Perl Tutorial mini-conference over the
past few days. :) And they even have books with my name on them. :)
print "Just another Perl hacker,"
--
Name: Randal L. Schwartz / Stonehenge Consulting Services (503)777-0095
Keywords: Perl training, UNIX[tm] consulting, video production, skiing, flying
Email: <merlyn@stonehenge.com> Snail: (Call) PGP-Key: (finger merlyn@teleport.com)
Web: <A HREF="http://www.stonehenge.com/merlyn/">My Home Page!</A>
Quote: "I'm telling you, if I could have five lines in my .sig, I would!" -- me
------------------------------
Date: 29 Apr 1999 13:34:47 -0400
From: Uri Guttman <uri@sysarch.com>
Subject: Re: Searching a Text File by key
Message-Id: <x7d80n8h54.fsf@home.sysarch.com>
>>>>> "RLS" == Randal L Schwartz <merlyn@stonehenge.com> writes:
RLS> With a name like Randal Schwartz, I'm guaranteed to not get it right.
i would think you would have learned to spell your own name correctly by
now.
<ducking the beer glass being thrown at me>
and you told us the other night that the missing l was a typo by your
mother!
your spelling of schwartz is the most common variation i know. it is the
dropped l that seems to most folks in trouble.
and i can say these things since i have had my name mangled,
mispronounced and besmirched in countless ways.
uri
--
Uri Guttman ----------------- SYStems ARCHitecture and Software Engineering
uri@sysarch.com --------------------------- Perl, Internet, UNIX Consulting
Have Perl, Will Travel ----------------------------- http://www.sysarch.com
The Best Search Engine on the Net ------------- http://www.northernlight.com
------------------------------
Date: 29 Apr 1999 16:40:07 GMT
From: "Marko Lindner" <mali@hrz.tu-chemnitz.de>
Subject: simple problem
Message-Id: <01be925e$f1a8b860$0b606d86@ml.csn.tu-chemnitz.de>
Hi there.
I have a quite simple question about perls s// operator.
I'm trying to write a bourne shell script. The first
command line parameter ($1) should be stored in some
variable (name). But first the suffix '.tex' should be
cut away. That's what my question is about.
example 1: $1="file.tex" --> name="file"
example 2: $1="/dir1/dir2/file.tex" --> name="/dir1/dir2/file"
My shell script starts like that :
#! /bin/sh
name=`$1 | sed 's/WHATGOESHERE/\1/'`
Could please somebody help me ?
We may suppose the suffix to be '.tex' in every case.
But a more general solution would be welcome of course.
Thanks,
Marko
------------------------------
Date: Thu, 29 Apr 1999 17:33:30 GMT
From: bmetcalf@nortelnetworks.com (Brandon Metcalf)
Subject: Re: simple problem
Message-Id: <3728953c.1981332215@paperboy.corpeast.baynetworks.com>
On 29 Apr 1999 16:40:07 GMT, "Marko Lindner" <mali@hrz.tu-chemnitz.de>
wrote:
>Hi there.
>
>I have a quite simple question about perls s// operator.
>I'm trying to write a bourne shell script. The first
>command line parameter ($1) should be stored in some
>variable (name). But first the suffix '.tex' should be
>cut away. That's what my question is about.
>
>example 1: $1="file.tex" --> name="file"
>example 2: $1="/dir1/dir2/file.tex" --> name="/dir1/dir2/file"
>
>My shell script starts like that :
>
>#! /bin/sh
>name=`$1 | sed 's/WHATGOESHERE/\1/'`
I'll explain how to do it using s/// in perl, but this won't work in
sed. If you want to use sed, go ask elsewhere.
echo $1 | perl -n -e 'print $1 if /^(.*)?\..*$/;'
Brandon
------------------------------
Date: 29 Apr 1999 13:39:57 -0400
From: Uri Guttman <uri@sysarch.com>
Subject: Re: simple problem
Message-Id: <x790bb8gwi.fsf@home.sysarch.com>
>>>>> "ML" == Marko Lindner <mali@hrz.tu-chemnitz.de> writes:
ML> I have a quite simple question about perls s// operator.
ML> I'm trying to write a bourne shell script. The first
ML> command line parameter ($1) should be stored in some
ML> variable (name). But first the suffix '.tex' should be
ML> cut away. That's what my question is about.
before you get flamed to a crisp by others, i will gently ask you is
this a perl question? you seem to be mixing several things here and you
may be asking the wrong group.
ML> example 1: $1="file.tex" --> name="file"
ML> example 2: $1="/dir1/dir2/file.tex" --> name="/dir1/dir2/file"
ML> My shell script starts like that :
ML> #! /bin/sh
ML> name=`$1 | sed 's/WHATGOESHERE/\1/'`
you are using the sed program. so why are you asking about this in perl?
read the sed man page to learn how to use s/// in sed. it is similar to
perl (perl borrowed it from sed) but it is different enough that you
should not confuse the two operations.
ML> Could please somebody help me ?
ML> We may suppose the suffix to be '.tex' in every case.
ML> But a more general solution would be welcome of course.
if you want to do this in perl then ask that, but please don't ask here
how to do it in the shell.
uri
--
Uri Guttman ----------------- SYStems ARCHitecture and Software Engineering
uri@sysarch.com --------------------------- Perl, Internet, UNIX Consulting
Have Perl, Will Travel ----------------------------- http://www.sysarch.com
The Best Search Engine on the Net ------------- http://www.northernlight.com
------------------------------
Date: Thu, 29 Apr 1999 17:43:37 GMT
From: bmetcalf@nortelnetworks.com (Brandon Metcalf)
Subject: Re: simple problem
Message-Id: <37289a14.1982572508@paperboy.corpeast.baynetworks.com>
On Thu, 29 Apr 1999 17:33:30 GMT, bmetcalf@nortelnetworks.com (Brandon
Metcalf) wrote:
>On 29 Apr 1999 16:40:07 GMT, "Marko Lindner" <mali@hrz.tu-chemnitz.de>
>wrote:
>
>>Hi there.
>>
>>I have a quite simple question about perls s// operator.
>>I'm trying to write a bourne shell script. The first
>>command line parameter ($1) should be stored in some
>>variable (name). But first the suffix '.tex' should be
>>cut away. That's what my question is about.
>>
>>example 1: $1="file.tex" --> name="file"
>>example 2: $1="/dir1/dir2/file.tex" --> name="/dir1/dir2/file"
>>
>>My shell script starts like that :
>>
>>#! /bin/sh
>>name=`$1 | sed 's/WHATGOESHERE/\1/'`
>
>I'll explain how to do it using s/// in perl, but this won't work in
>sed. If you want to use sed, go ask elsewhere.
>
>echo $1 | perl -n -e 'print $1 if /^(.*)?\..*$/;'
>
>Brandon
Probably better to say
echo $1 | perl -n -e 'print $1 if /^(.*)\..*$/;'
Brandon
------------------------------
Date: Thu, 29 Apr 1999 10:51:17 -0700
From: lr@hpl.hp.com (Larry Rosler)
Subject: Re: simple problem
Message-Id: <MPG.11923bf1d534eb21989979@nntp.hpl.hp.com>
In article <01be925e$f1a8b860$0b606d86@ml.csn.tu-chemnitz.de> on 29 Apr
1999 16:40:07 GMT, Marko Lindner <mali@hrz.tu-chemnitz.de> says...
> I have a quite simple question about perls s// operator.
> I'm trying to write a bourne shell script. The first
> command line parameter ($1) should be stored in some
> variable (name). But first the suffix '.tex' should be
> cut away. That's what my question is about.
>
> example 1: $1="file.tex" --> name="file"
> example 2: $1="/dir1/dir2/file.tex" --> name="/dir1/dir2/file"
>
> My shell script starts like that :
>
> #! /bin/sh
> name=`$1 | sed 's/WHATGOESHERE/\1/'`
>
> Could please somebody help me ?
> We may suppose the suffix to be '.tex' in every case.
> But a more general solution would be welcome of course.
This is amazing. You ask about the Bourne shell and about sed in a Perl
newsgroup, because Perl and sed each have a s/// operator.
Will wonders never cease?
--
(Just Another Larry) Rosler
Hewlett-Packard Company
http://www.hpl.hp.com/personal/Larry_Rosler/
lr@hpl.hp.com
------------------------------
Date: 29 Apr 1999 13:55:02 -0400
From: Uri Guttman <uri@sysarch.com>
Subject: Re: simple problem
Message-Id: <x71zh38g7d.fsf@home.sysarch.com>
>>>>> "BM" == Brandon Metcalf <bmetcalf@nortelnetworks.com> writes:
BM> echo $1 | perl -n -e 'print $1 if /^(.*)\..*$/;'
it is nice that you wrote this in perl but the suffix is fixed at 'tex' and
your code won't print anything if there is no suffix.
echo $1 | perl -pe 's/\.tex$//'
or in shell:
base=`echo $1 | sed 's/\.tex$//'`
uri
--
Uri Guttman ----------------- SYStems ARCHitecture and Software Engineering
uri@sysarch.com --------------------------- Perl, Internet, UNIX Consulting
Have Perl, Will Travel ----------------------------- http://www.sysarch.com
The Best Search Engine on the Net ------------- http://www.northernlight.com
------------------------------
Date: Thu, 29 Apr 1999 18:16:50 GMT
From: pbyrne@ie.oracle.com
Subject: Re: simple problem
Message-Id: <7ga7mc$sir$1@nnrp1.dejanews.com>
Despite the fact that this is nothing to do with Perl :-
ksh
name=`echo $1 | sed 's/\..*$//'`
in Perl:
$name=~s/\..*$//;
(notice how efficient the Perl version is in comparison)
-----------== Posted via Deja News, The Discussion Network ==----------
http://www.dejanews.com/ Search, Read, Discuss, or Start Your Own
------------------------------
Date: Thu, 29 Apr 1999 12:28:30 -0700
From: ether1@ix.netcom.com
Subject: Web BBS, need programming
Message-Id: <3728B2DE.187089AF@ix.netcom.com>
Hi,
Currently we have a discussion board running on the Web BBS
program. We need to modify it to a certain criteria.
Anyone out there who can do such programming? Please email
me at ether1@ix.netcom.com
Thanks
Gary
------------------------------
Date: 29 Apr 1999 13:47:23 -0400
From: Uri Guttman <uri@sysarch.com>
Subject: Re: Web BBS, need programming
Message-Id: <x74slz8gk4.fsf@home.sysarch.com>
>>>>> "e" == ether1 <ether1@ix.netcom.com> writes:
e> Currently we have a discussion board running on the Web BBS
e> program. We need to modify it to a certain criteria.
e> Anyone out there who can do such programming? Please email
e> me at ether1@ix.netcom.com
i can do it for you in pdp-11 assembly language. do you have RT-11 and a
vt-100 i can use? my rates are commensurate with your chutzpah.
if ( index( lc $msg_body, 'perl' ) < 0 ) {
print "what is your perl question, buddy?\n" ;
}
uri
--
Uri Guttman ----------------- SYStems ARCHitecture and Software Engineering
uri@sysarch.com --------------------------- Perl, Internet, UNIX Consulting
Have Perl, Will Travel ----------------------------- http://www.sysarch.com
The Best Search Engine on the Net ------------- http://www.northernlight.com
------------------------------
Date: Thu, 29 Apr 1999 17:57:24 GMT
From: "tfinn" <tfinn@hotmail.com>
Subject: What's wrong with this code?
Message-Id: <841W2.1202$vY2.15755@c01read01.service.talkway.com>
Hi
Having a bit of a problem trying to work out what's wrong with this.
Does anyone know?
######################################################################
#!/usr/local/bin/perl
@array1=(el1, el2, el3, el4);
open(FILE, "/mydir/myfile") || die "Can't open file: $!\n"; # pb here?
@array2=<FILE>; # pb here?
foreach $element (@array1){
if (grep(/$element/i, @array2)) # if el of array 1 in array 2
{print "There was a match\n"} # then do this
else {print "There wasn't a match\n"}; # else this
} # end of foreach loop
$path=`find . -name myfile -print`; # find where myfile is
push(@myfile, $path); # make $path string into an array
$count=grep(/x/i, @myfile); # count number of times x occurs in path
print $count; # print no. of times x occurs
# end of script
######################################################################
Thanks in advance,
Tim, NZ
--
Posted via Talkway - http://www.talkway.com
Exchange ideas on practically anything (tm).
------------------------------
Date: Thu, 29 Apr 1999 18:13:54 GMT
From: kmitev@my-dejanews.com
Subject: where is strict.pm ???
Message-Id: <7ga7gt$se8$1@nnrp1.dejanews.com>
============
this is the script:
============
$ cat ttt.pl
#!/usr/bin/perl -w
use strict;
print "yes\n";
============ this is the error: ============ Can't locate strict.pm in @INC
(@INC contains: blah blah blah) at ./ttt.pl line 3. BEGIN failed--compilation
aborted at ./ttt.pl line 3.
=============
this is the perl:
=============
$ perl -v
This is perl, version 5.005_02 built for i386-freebsd
===========
this is the directory where I build it:
===========
/root/build/perl5.005_03/
(note the number difference)
I'll admit that I'm dumb - just to spare you the effort of explaining that
to me...
Now that THAT is out of the way, what am I missing ?
--
Kiril
-----------== Posted via Deja News, The Discussion Network ==----------
http://www.dejanews.com/ Search, Read, Discuss, or Start Your Own
------------------------------
Date: Thu, 29 Apr 1999 11:39:08 -0700
From: David Cassell <cassell@mail.cor.epa.gov>
Subject: Re: Win95/98 file locking
Message-Id: <3728A74C.B743BCEE@mail.cor.epa.gov>
Collin Starkweather wrote:
>
> Testing seems to indicate that flock does not work in Win95/98. Is
> there a way to lock a file in Win95/98 that I am unaware of?
Black magic. The ActiveState Perl docs even point this problem out,
along with a couple other NT vs 95/98 issues.
> I can think of cheezy workarounds (e.g., renaming the file), but would
> like to have something that is guaranteed not to survive an unexpectedly
> terminated process.
>
> If anyone has tackled this problem before, I would be grateful for any
> hints or suggestions.
As far as I know, you're stuck if you want to keep this a straight
95/98 system. NT will do file-locking. So will linux and the BSD's.
You could look at Cygwin32 from cygnus.com and build Perl on top
of that. It provides a pretty complete Unix emulation library.
HTH,
David
--
David Cassell, OAO cassell@mail.cor.epa.gov
Senior Computing Specialist phone: (541) 754-4468
mathematical statistician fax: (541) 754-4716
------------------------------
Date: 12 Dec 98 21:33:47 GMT (Last modified)
From: Perl-Request@ruby.oce.orst.edu (Perl-Users-Digest Admin)
Subject: Special: Digest Administrivia (Last modified: 12 Dec 98)
Message-Id: <null>
Administrivia:
Well, after 6 months, here's the answer to the quiz: what do we do about
comp.lang.perl.moderated. Answer: nothing.
]From: Russ Allbery <rra@stanford.edu>
]Date: 21 Sep 1998 19:53:43 -0700
]Subject: comp.lang.perl.moderated available via e-mail
]
]It is possible to subscribe to comp.lang.perl.moderated as a mailing list.
]To do so, send mail to majordomo@eyrie.org with "subscribe clpm" in the
]body. Majordomo will then send you instructions on how to confirm your
]subscription. This is provided as a general service for those people who
]cannot receive the newsgroup for whatever reason or who just prefer to
]receive messages via e-mail.
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 5519
**************************************