[8212] in Perl-Users-Digest
Perl-Users Digest, Issue: 1830 Volume: 8
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Sat Feb 7 19:08:04 1998
Date: Sat, 7 Feb 98 16: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 Sat, 7 Feb 1998 Volume: 8 Number: 1830
Today's topics:
Re: cmp CONUNDRUM <rjk@coos.dartmouth.edu>
Re: comparing dates (Michael Ward)
Create new file on NT50? <kenny@weng.dk>
Re: Decent Perl books <palincss@nicom.com>
Re: Find ^M in file <doug@tc.net>
Floor function? (Brandi Weed)
Re: Floor function? <rjk@coos.dartmouth.edu>
floor() again... (Brandi Weed)
Re: Generating customer ID (Joshua J. Kugler)
Good perl editor? <don@whtech.com>
Re: Good Perl editors (Pedro Branco)
Re: How do I post to cgi from PERL script? (Michael Ward)
Re: Is file locking necessary? (Jonathan Nicholson)
Is it possible to create a vector in a hash and tie it <webmaster@profind.com>
Re: Is Perl 5 year 2000 compliant? <metallica@metal.net>
Locations for Newbies to Perl <mpollum@op.net>
Re: Locations for Newbies to Perl <jrj120@psu.edu>
Re: MacPerl_not_even_newbie (John Moreno)
Perl documentation (was re: Perl Year 2000 ...) (Michael Wang)
Perl on IIS4 <stuartg.pcrsys@minorplanet.com>
Perl Question (Bill Krahmer)
pulling variables out of multi-line syslog entries <frank_gorishek@email.msn.com>
Re: Regular expression expander <rjk@coos.dartmouth.edu>
Re: replacement for ls command? <shimpei+this+address+is+NOT+munged+.mil+.gov@socrates.caltech.edu>
Re: replacement for ls command? (Michael Wang)
search and replace <wallsr@jcave.com>
Re: The Specified module can not be found. <sgordon@athena.lbl.gov>
Re: Year 2000 Compliance: Lawyers, Liars, and Perl (Ol'Timer)
Digest Administrivia (Last modified: 8 Mar 97) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: Sat, 07 Feb 1998 13:24:08 -0500
From: Chipmunk <rjk@coos.dartmouth.edu>
Subject: Re: cmp CONUNDRUM
Message-Id: <34DCA6C9.F53CCF7@coos.dartmouth.edu>
[posted but not mailed - munged addresses are annoying]
k y n n wrote:
>
> Is there any value that I can give to $x such that, for all $y != $x,
> the expression $x cmp $y is *less* than 0?
In other words, you want the string which comes before all other strings
in the ASCII collating sequence.
That would probably be "", the null string.
Chipmunk
------------------------------
Date: Sat, 07 Feb 1998 10:43:05 -0800
From: mward@veelos.com (Michael Ward)
Subject: Re: comparing dates
Message-Id: <mward-ya023580000702981043050001@news.slip.net>
In article <34D7A643.97722C07@ispi.net>, Monte Ohrt <monte@ispi.net> wrote:
>Is there an easy way to get the difference between two dates (in seconds
>preferrably)
>without the need of installing a perl module? I'm writing a script
>that I want to redistribute, and I do not want the end user to hassle with
>installing
>a module just for this one function. (I know I can use date_time_difference in
>Date::Calc to do this)
TIME::LOCAL comes with the perl distribution (and so should be available to
everyone), and contains timelocal(), which converts date/time to
seconds-since-epoch.
--
Michael Ward
mward@veelos.com
------------------------------
Date: Sat, 7 Feb 1998 18:53:15 +0100
From: <kenny@weng.dk>
Subject: Create new file on NT50?
Message-Id: <6bi73f$4v4$1@news1.inet.tele.dk>
I can't seem to create a new file on Windows NT50 with Perl5
It seems the I have to upload an empty file before :
open(FILE,">$newfile")
works. The access rights is set to read and write for that directory.
Do you know why?
------------------------------
Date: Sat, 07 Feb 1998 16:54:43 -0800
From: Steve Palincsar <palincss@nicom.com>
Subject: Re: Decent Perl books
Message-Id: <34DD0253.428E@nicom.com>
Well, not to nag or anything, but I'm sure I'm not the only one
to value your recommendations highly enough to buy a book sight
unseen based solely on your awarding of large numbers of camels!
Fortunately, I did catch your posting on the _Companion_ and
had the opportunity to examine the online chapters of _Effective_,
so I haven't missed out on those two excellent additions to my
Perl library.
Tom Christiansen wrote:
>
> [courtesy cc of this posting sent to cited author via email]
>
> In comp.lang.perl.misc,
> joseph@5sigma.com writes:
> :Tom's Camel Critiques page is currently out of date, and the faq
> :list is very brief and also out of date. I wish you folks would
> :stop pointing people there and point them to reference.perl.com
> :instead.
>
> That's a dirty way to make me move my butt.
>
> --tom
------------------------------
Date: 07 Feb 1998 12:55:34 -0500
From: Douglas McNaught <doug@tc.net>
Subject: Re: Find ^M in file
Message-Id: <m23ehvnvu1.fsf@ono.tc.net>
gabor@vmunix.com (Gabor) writes:
> In comp.lang.perl.misc, SJL <perl@nospam.larson4.demon.co.uk> wrote :
> # Can you expand a bit on this? Specifically, if I'm using perl to read
> # from a binary data file (such as a PCM sampled .wav file) should
> # I do buffered reading rather than a byte-at-a-time? (or should I not
> # be using perl to manipulate such files?). Once upon a time I suppose
> # it was more efficient to do buffered i/o in C but I think nowadays
> # it's safe to assume the compiler is doing it for you. From your
> # statement, I take it that it is not safe to assume the same of perl?
>
> Well it depends. If you use sysread in perl you get C's write
^^^^^ read
> primitive which will actually read a byte at a time, if you use read
> in perl then you don't have to worry because although you get one byte
> at a time the I/O is actually buffered.
True enough. In response to SJL's question, doing things a byte at a
time *will* be slower, due to loop and function call overhead, maybe
much slower. If you're processing large chunks of data, it makes more
sense to read in large chunks and write in large chunks, for which
buffered vs. non-buffered i/o doesn't make much of a difference,
especially if you make your programs's buffer size a large integral
multiple of your filesystem's block size (in which case sysread will
likely be faster).
Also, at least on Unix systems, sysread won't actually hit the disk
for every byte, because of the kernel's buffer cache. It'll still be
slower than buffered i/o because of the system call overhead.
-Doug
--
sub g{my$i=index$t,$_[0];($i%5,int$i/5)}sub h{substr$t,5*$_[1]+$_[0],1}sub n{(
$_[0]+4)%5}$t='encryptabdfghjklmoqsuvwxz';$c='fxmdwbcmagnyubnyquohyhny';while(
$c=~s/(.)(.)//){($w,$x)=g$1;($y,$z)=g$2;$w==$y&&($p.=h($w,n$x).h($y,n$z))or$x==
$z&&($p.=h(n$w,$x).h(n$y,$z))or($p.=h($y,$x).h($w,$z))}$p=~y/x/ /;print$p,"\n";
------------------------------
Date: Sat, 07 Feb 1998 19:09:51 GMT
From: brandi@wheel.dcn.davis.ca.us (Brandi Weed)
Subject: Floor function?
Message-Id: <34dcb128.9495307@news.cwnet.com>
I'm having a hard time looking up how Perl rounds numbers with int(),
and what I need for this program is the floor() function, which
returns the largest integer less than or equal to the value of the
argument, ie floor(58.2) = 58, but so does floor(58.9) when some
things would round up to 60.
Will int() do this on its own?
--
Brandi Weed
brandi@wheel.dcn.davis.ca.us
http://www.dcn.davis.ca.us/~brandi/
------------------------------
Date: Sat, 07 Feb 1998 16:28:25 -0500
From: Chipmunk <rjk@coos.dartmouth.edu>
To: Brandi Weed <brandi@wheel.dcn.davis.ca.us>
Subject: Re: Floor function?
Message-Id: <34DCD1FA.35104421@coos.dartmouth.edu>
[posted and mailed]
Brandi Weed wrote:
>
> I'm having a hard time looking up how Perl rounds numbers with int(),
> and what I need for this program is the floor() function, which
> returns the largest integer less than or equal to the value of the
> argument, ie floor(58.2) = 58, but so does floor(58.9) when some
> things would round up to 60.
>
> Will int() do this on its own?
Well, let's find out, shall we?
~> perl -e 'print int(58.2), "\n"'
58
~> perl -e 'print int(58.9), "\n"'
58
~>
It sure looks like int() does what you want. But...
~> perl -e 'print int(-58.9), "\n"'
58
~>
So, int() is not implemented as either round() or floor().
It is in fact implemented as truncate().
Now that we've figured that out, why don't you look at the perlfaq?
>From perlfaq4:
Does perl have a round function? What about ceil() and floor()? Trig functions?
`man perlfaq4` or <http://www.perl.com/perl/faq/>
Chipmunk
------------------------------
Date: Sat, 07 Feb 1998 19:22:14 GMT
From: brandi@wheel.dcn.davis.ca.us (Brandi Weed)
Subject: floor() again...
Message-Id: <34dcb441.10288431@news.cwnet.com>
Before you all tell me RTFFAQ... well, I just did. I was still trying
to look it up when I posted. Sorry!
--
Brandi Weed
brandi@wheel.dcn.davis.ca.us
http://www.dcn.davis.ca.us/~brandi/
------------------------------
Date: Sat, 07 Feb 1998 22:29:29 GMT
From: jkugler@inreach.com (Joshua J. Kugler)
Subject: Re: Generating customer ID
Message-Id: <34dce035.15212851@news.inreach.com>
If the value of the unique ID doesn't matter, use the current time and
current PID of the process. And just to make sure the script doesn't
run too fast :) put a sleep(1) at the end.
j----- k-----
On 7 Feb 1998 14:12:53 GMT, mark666769@aol.com (Mark666769) wrote:
()Hi,
()
()Can anyone point me to some sample Perl code
()that can generate a unique Customer ID value
()suitable for a cookie?
()
()The value generated should be guaranteed unique,
()yet also be readable by the users and not total
()gibberish.
()
()Thanks in advance.
()
I read this group. Sometimes my ISP doesn't. Please e-mail too.
Joshua J. Kugler
Computer Consultant--Web Developer
jkugler@inreach.com
http://www.cwebpages.com/jkugler
Every knee shall bow, and every tongue confess, in heaven, on earth, and under the earth, that Jesus Christ is LORD -- Count on it!
------------------------------
Date: Sat, 7 Feb 1998 14:02:21 -0800
From: "Don O'Neil" <don@whtech.com>
Subject: Good perl editor?
Message-Id: <6biltp$ng5$1@usenet48.supernews.com>
Does anyone know of a good windows or unix (X-Windows) based perl editor w/
context sensitive coloring, auto indent, etc...??? I've tried Win Edit, but
it does not have built in Perl syntax, I could add it, but that's a pain.
I'm looking for something along the order of the editors that come w/ MS C
and Borland C.
Thanks!!
------------------------------
Date: Sat, 07 Feb 1998 21:02:04 GMT
From: f.branco@mail.telepac.pt (Pedro Branco)
Subject: Re: Good Perl editors
Message-Id: <34ddcb5b.2091945@news>
On Tue, 03 Feb 1998 13:28:39 -0600, Wes Gamble
<weyus@worldnet.att.net> wrote:
>Hi all,
>
>I am beginning to reacquaint myself with Perl and I was interested if
>there were a preferred editor(s) that people out in Perl-land use for
>coding. I have downloaded a demo copy of Codewright, but it doesn't
>seem to have built in support for Perl right off the bat (has anyone
>created rules for Codewright to edit Perl to their satisfaction, or
>knows how that might be done).
>
>I am quite adept at vi, so please none of those comments - however, I'd
>like to have something that automatically indents, italicizes, etc. to
>make my code easier to scan through quickly.
>
>Any ideas are welcomed.
>
>Thanks,
>Wes Gamble
I use XWPE
xwpe is a X-window programming environment designed to use
on UNIX-systems. It is similar to 'Borland C++ or Turbo Pas-
cal' environment.
xwpe has syntax highlighting, and you can easly set it up for perl.
I don't remember the url, search 'xwpe' over the net and
you'll find it.
happy coding
Pedro Branco
____________________________________________________________________
Pedro Feliciano Branco ISEL . AE -Portugal-
Email: pedrofb@aeisel.aeisel.pt
f.branco@mail.telepac.pt
http://www.aeisel.pt/~pedrofb
------------------------------
Date: Sat, 07 Feb 1998 10:53:55 -0800
From: mward@veelos.com (Michael Ward)
Subject: Re: How do I post to cgi from PERL script?
Message-Id: <mward-ya023580000702981053550001@news.slip.net>
Check out the LWP module. Better yet, read "Web Client Programming with
Perl" (ISBN 1-56592-214-X)
--
Michael Ward
mward@veelos.com
------------------------------
Date: 7 Feb 1998 12:30:42 -0000
From: jono@nospam.nowhere.noorg (Jonathan Nicholson)
Subject: Re: Is file locking necessary?
Message-Id: <6bhk5i$ap2$1@acme.demon.co.uk>
In article <6b887e$i1o$1@news1.iamerica.net>,
Bill Genzer <bill@fathead.net> wrote:
>I am very new at PERL and I have just started writing my own CGI scripts
>(really editing other scripts). I have to admit it seems very simple and
>easy to learn. My question is if it is necessary to lock files before
>reading or writing to files? If it is necessary, how do you do it? I've
>seen a few ways other people do it, but it seems very complicated, I've
>heard of using something called flock? But not knowing hardly anything
>about PERL I have no Idea how to use it.
File locking is very important if multiple writes are going to occur at
the same time. Here's a bit of perl that I've written to demonstrate file
locking. It doesn't use the modules (File::Flock) as they don't support
locking over NFS which is where I need the locking. I wrote this program
to test out the lock daemons on multiple machines quickly.
It may be interesting to know that nfs locking is a bit of a bitch,
especially when Digital advise you to install a patch that stops nfs
locking from working - grr!
#!/usr/local/bin/perl
use Fcntl;
use POSIX;
if(@ARGV != 1) {
print "Usage: $_[0] [directory to test]\n";
exit;
}
$testdir = shift;
$testfile = $testdir ."/locktest.$$." . time;
open(TMP,">$testfile") || die "Failed to open testfile\n";
open(FH, ">&TMP") || die "Failed to dup : $!\n";
print "Dupped ok attempting lock\n";
&dolock(&F_WRLCK);
print TMP "Testing testing testing\n";
&dolock(&F_UNLCK);
print "Lock cleared, removing test file:-\n";
unlink $testfile;
sub dolock {
local ($mode) = @_;
local ($flock);
$flock = pack('iilli', $mode, 0, 0, 0, $$);
print "Assigning lock\n";
fcntl(FH, &F_SETLKW, $flock);
print "Done\n";
}
--
| Jonathan Nicholson (jono at acme dot demon dot co dot uk) 0973 199 983 |
| TV doesn't rule my life, it just has a casting vote |
------------------------------
Date: Thu, 05 Feb 1998 20:29:20 -0500
From: Philip Kallerman <webmaster@profind.com>
Subject: Is it possible to create a vector in a hash and tie it to permanent storage?
Message-Id: <34DA6770.7897@profind.com>
Hi,
I am wondering if anyone has any experience of tying a hash, containing
ordinary vectors to a disk drive, and/or if this is at all possible, and
what the performance on something like that is.
So, any ideas are appreciated.
/Philip
------------------------------
Date: Sat, 7 Feb 1998 14:26:51 -0500
From: "John Alderson" <metallica@metal.net>
Subject: Re: Is Perl 5 year 2000 compliant?
Message-Id: <6bic5j$80h@news-central.tiac.net>
Gary L. Smith wrote in message ...
>Have you ever used a Microsoft product? A good deal of what's worth
>knowing is not in any documentation, and when it is there, you often
>can't find it. Responding to a question with "look in the documentation
>under strange-term-you'd-never-come-up-with-on-your-own" can be
>trememdously helpful.
>
>--
>
>Gary L. Smith gls@infinet.com
>Columbus, Ohio Gary_Smith@oclc.org
MS's docs are as good as any others, although it is quite trendy to hack on
MS. For instance, with little programming background (Fortran and Basic...
does Basic even count?), I taught myself how to design and build Access db
applications using only the Help file. Same with VBA and Excel. Are they
perfect? Surely not. Have I seen any others that are? Nope.
As for Perl's docs, being new to Perl, I have found them to be well done.
Am I as comfortable navigating them as I am with a packaged help file? No,
but so what. Adapt. I'll learn to be proficient with Perl and this style
of documentation too.
Because you couldn't find what you were looking for on the first try hardly
constitutes bad documentation. If having different ways to refer to things
between products or platforms annoys you, you must be often annoyed. Root
around a bit more in the resources available for most products and ye shall
be rewarded.
------------------------------
Date: 7 Feb 1998 19:52:22 GMT
From: "MDP" <mpollum@op.net>
Subject: Locations for Newbies to Perl
Message-Id: <01bd3401$ea815cc0$45c698d1@mpollum>
Being my first visit to this group, it appears to be geared for those who
have an advanced understanding of the perl language. Are there other
locations and groups for those of us who are at the entry level. Any
futher information will be greatly appreciated.
Michael Pollum
mpollum@op.net
Thank you for taking the time to read this message.
------------------------------
Date: Sat, 07 Feb 1998 17:20:43 +0000
From: James Juran <jrj120@psu.edu>
To: MDP <mpollum@op.net>
Subject: Re: Locations for Newbies to Perl
Message-Id: <34DC97EB.7A35DC00@psu.edu>
[posted & mailed]
MDP wrote:
>
> Being my first visit to this group, it appears to be geared for those who
> have an advanced understanding of the perl language. Are there other
> locations and groups for those of us who are at the entry level. Any
> futher information will be greatly appreciated.
In my opinion, the best things to do would be to (listed in order):
1. Buy _Learning Perl_, the canonical book for beginning programming in
Perl. It should be available from your local bookstore, or from
http://www.ora.com.
2. Read the FAQ's available at http://www.perl.com
3. Read the documentation that comes with Perl: man perltoc and
perldoc perldoc will get you started (the former may not be available on
non-UNIX systems)
Any questions you have will likely be answered in one of those three
places. If there's something you have tried to find in the
documentation and can't find, or there's something you don't understand
in the documentation, then by all means, ask here. However, questions
where it's obvious that the asker has put absolutely no effort into
finding the answer for himself are generally not appreciated (both in
this group, in Usenet in general, and everywhere else).
The people in this group are here for the most part because they want to
learn and they want to help others. They don't mind helping people, but
expect them to put some effort into finding the answer themselves. If
you do that, you should get helpful replies to your questions.
Good luck,
James Juran
------------------------------
Date: Sat, 7 Feb 1998 15:29:34 -0500
From: phenix@interpath.com (John Moreno)
Subject: Re: MacPerl_not_even_newbie
Message-Id: <1d43612.1urh37ng30dz4N@roxboro0-024.dyn.interpath.net>
Ddarras <ddarras@aol.com> wrote:
> chomp(), chop() ? won't compile. Didn't see anything
> in the MacPerl faqs to that effect.
You want to post some code to go along with that? I've never had any
problems.
--
John Moreno
------------------------------
Date: 7 Feb 1998 23:01:28 GMT
From: mwang@alhena.ibk.ml.com (Michael Wang)
Subject: Perl documentation (was re: Perl Year 2000 ...)
Message-Id: <6bip48$rce$1@news.ml.com>
John Alderson <metallica@metal.net> wrote:
>As for Perl's docs, being new to Perl, I have found them to be well done.
>Am I as comfortable navigating them as I am with a packaged help file? No,
>but so what. Adapt. I'll learn to be proficient with Perl and this style
>of documentation too.
It would be helpful to have a man page for each perl functions, like
C does. Because sometimes people just want to find the syntax.
As I do not understand texinfo, neither do I understand perldoc format.
------------------------------
Date: Sat, 7 Feb 1998 18:24:46 -0000
From: "Stuart Grimshaw" <stuartg.pcrsys@minorplanet.com>
Subject: Perl on IIS4
Message-Id: <6bi9io$9cd$1@svr-c-01.core.theplanet.net>
Has anyone managed to succesfully install and run perl on IIS4 beta 2?
I have had/am having major problems with both popular versions of Perl for
Win32. One version simply refuses to work at all, and the other is unable to
run any scripts sucessfully.
----------------------------------------------
Stuart M. Grimshaw Network Manager
Minorplanet Systems PLC
stuartg.pcrsys@minorplanet.com
(+44) 0113 2511600
Check out the NEW webcam at
http://stubby.minorplanet.com
----------------------------------------------
------------------------------
Date: Sat, 07 Feb 1998 20:01:10 GMT
From: FaxMail@ElectraSoft.com (Bill Krahmer)
Subject: Perl Question
Message-Id: <6biep5$spc$1@synthemesc.insync.net>
I am new to Perl. Is there a way to run a perl script that would, by
itself, make a reference to a web page? Say that when a page loads, I
want it to run a Perl script to load another page. Is this posible?
Kind Regards,
Bill Krahmer, ElectraSoft
Get newest version of FaxMail for Windows or FaxMail Network for NT, free:
http://www.ElectraSoft.com/ or http://www.blkbox.com/~jonk/
http://www.ElectraSoft.com/10GoodReasons/
FaxMail@ElectraSoft.com or jonk@blkbox.com Author member of ASP
------------------------------
Date: Sat, 7 Feb 1998 16:37:08 -0600
From: "Frank Gorishek" <frank_gorishek@email.msn.com>
Subject: pulling variables out of multi-line syslog entries
Message-Id: <ejfnsjBN9GA.239@upnetnews02.moswest.msn.net>
*warning newbie question*
I'm trying to find and parse a multiple line message out of all the other
stuff in syslog. The entry looks like:
192.168.1.254: Enterprise Specific Trap (21) Uptime: 34 days, 23:48:14
enterprises.alliedTelesyn.atiTrapAttrs.atiTrapIntruderModuleNumber = 1
enterprises.alliedTelesyn.atiTrapAttrs.atiTrapIntruderPortNumber = 24
enterprises.alliedTelesyn.atiTrapAttrs.atiTrapIntruderMacAddress = Hex: 00
40 96 11 C3 CF
I want to grab the ip address, module number, port number and mac address
fields. The following code works, but is it really the best way to go about
parsing muli-line records?
while (<>) {
if (/(\d+.\d+.\d+.\d+): Enterprise/) {
$hubip = $1;
$_ = <>;
next unless (/ModuleNumber = (\d+)/);
$hubmodule = $1;
$_ = <>;
next unless (/PortNumber = (\d+)/);
$hubport = $1;
$_ = <>;
next unless (/Hex: (\d{2} \d{2} \d{2} \d{2})/);
$macaddr = $1;
print "hub $hubip, module $hubmodule, port $hubport, mac $macaddr\n"
}
}
--frank
frank_gorishek@msn.com
------------------------------
Date: Sat, 07 Feb 1998 13:29:16 -0500
From: Chipmunk <rjk@coos.dartmouth.edu>
Subject: Re: Regular expression expander
Message-Id: <34DCA7FE.B5BF7E1B@coos.dartmouth.edu>
Chipmunk wrote:
>
> Anyway, for what it's worth, here is matcher.pl
> It generates a match for a regular expression. It's worked for
> the ones I've tried it on so far. Note that it does not handle
> Perl's extended regular expression syntax: (?...).
> Aside from that, feel free to find regexes where it screws up.
As Dean Inada pointed out, there are several other things that matcher.pl
does not handle. So, let me amend the above by saying that it also does not
handle any of the zero-width assertions (^, $, \A, \Z, \b, \B, (?=), (?!), etc.).
Anything else I've overlooked?
Chipmunk
------------------------------
Date: 7 Feb 1998 19:24:56 GMT
From: Shimpei Yamashita <shimpei+this+address+is+NOT+munged+.mil+.gov@socrates.caltech.edu>
Subject: Re: replacement for ls command?
Message-Id: <6bice8$6cc@gap.cco.caltech.edu>
Tom Christiansen <tchrist@mox.perl.com> writes:
>
> [courtesy cc of this posting sent to cited author via email]
>
>In comp.lang.perl.misc,
> Shimpei Yamashita
><shimpei+this+address+is+NOT+munged+.mil+.gov@socrates.caltech.edu>
>writes:
>:Well, if you really want ls, you can have it.
>:#! /opt/bin/perl
>:use Shell qw(ls);
>:@found=ls(<*>);
>:print "output of ls:\n", @found;
>
>While this is correct, one questions just how different that
>result is from
>
> @found = <*>;
>
>The answer, of course, lies in the newlines, but perhaps a broader
>solution could have been given .:-)
Oh, picky, picky, picky. Here's a somewhat more useful example.
use Shell qw(ls);
@found=ls("-l",<*>);
print "output of ls -l *:\n", @found;
I'm not exactly sure what this would be useful for, but if you want
to use some esoteric feature of ls without coding it in perl, it's
there.
--
Shimpei Yamashita <http://www.patnet.caltech.edu/%7Eshimpei/>
The address I have listed in the headers is a working address. It just
looks like it's an invalid address in order to fool spammers collecting
addresses from newsgroups.
------------------------------
Date: 7 Feb 1998 22:54:14 GMT
From: mwang@alhena.ibk.ml.com (Michael Wang)
Subject: Re: replacement for ls command?
Message-Id: <6biomm$rc5$1@news.ml.com>
Shimpei Yamashita <shimpei+this+address+is+NOT+munged+.mil+.gov@socrates.caltech.edu> wrote:
>
>Oh, picky, picky, picky. Here's a somewhat more useful example.
>
>use Shell qw(ls);
>@found=ls("-l",<*>);
>print "output of ls -l *:\n", @found;
Or you can use find, which can handle complicated directory structures:
@found=`cd /some/dir && find . -type f -print`
------------------------------
Date: 7 Feb 1998 21:23:13 GMT
From: "Rob W. Walls" <wallsr@jcave.com>
Subject: search and replace
Message-Id: <01bd340e$8178b540$644347ce@robwalls>
Having trouble with searching lines in text file and replacing with
lowercase version.
I WANT the code below to read a line of text from file and change any text
between quotes to lowercase.
Starting with a test file (the html is broke but it's just a test!):
<A HREF="THIS IS A TEST">blah BLAH<IMG SRC="../abcd/XYZ.GIF"></A>
result:
<A HREF="this is a test">blah blah<img src="../abcd/xyz.gif"></A>
so the script operates on all text between the 1st and LAST quotes on the
line instead of BETWEEN PAIRS of quotes on a line.
the script also makes backup of orig file...
---------
#!/usr/bin/perl
$I="~";
$filename=$ARGV[0];
if($filename)
{
print "$filename\n";
$temp="$filename$I";
rename($filename,"$temp");
open(INFILE,"$temp");
open(OUTFILE,">$filename");
select(OUTFILE);
while ($line = <INFILE>)
{
$line=~ s/\042(.*)\042/\042\L\1\E\042/g;
print $line;
}
close(OUTFILE);
close(INFILE);
}
-------------
I tried the line below but it replaces all '.' with '"':
$line=~ s/\042{1}(.*)\042{1}/\042\L\1\E\042/g;
Any ideas?
PS - thanks for the suggestions from my related post 'converting href and
src tags...', but I'm afraid they are beyond me at this point in my
'unixness'. Maybe someday...
wallsr@jcave.com
------------------------------
Date: Sat, 07 Feb 1998 14:44:19 +0000
From: Shawn Gordon <sgordon@athena.lbl.gov>
To: Stuart Grimshaw <stuartg.pcrsys@minorplanet.com>
Subject: Re: The Specified module can not be found.
Message-Id: <34DC7342.5F99E757@athena.lbl.gov>
> The script works fine if run from a DOS box, so why do I keep getting
> that
> error in my browser?
>
So, I assume you are saying that it will run from the command line, but
when it runs from the server, you get the error that a module cannot be
found.
The likely problem is that the search path used by perl to load modules
is
different between the server and your shell. The most straitforward way
of solving this problem is the 'use lib' pragma.
An example, say you have a cgi script called
/home/username/public_html/cgi/foo.cgi
and a module in /home/username/perllibs/, which foo.cgi needs. To
guarantee that
the cgi script knows where to look at compile time for the module, you
include
the following in your cgi script:
#!/usr/bin/perl
use lib qw(/home/username/perllibs);
use 'foo'; # or whatever you module is
# the rest of the code
Of course there is more than one way - see the FAQs or the camel book.
Shawn
------------------------------
Date: Sat, 7 Feb 1998 09:57:42 -0800
From: nospam@anonymous.com (Ol'Timer)
Subject: Re: Year 2000 Compliance: Lawyers, Liars, and Perl
Message-Id: <MPG.f4640757ea53b39896a8@news.teleport.com>
<Add Bozo Bin, Author=Tom Christiansen> </>
--
Ol'Timer
Old age is better than the alternative
(provided you don't like worms)
------------------------------
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 1830
**************************************