[13864] in Perl-Users-Digest
Perl-Users Digest, Issue: 1274 Volume: 9
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Thu Nov 4 00:05:30 1999
Date: Wed, 3 Nov 1999 21:05:09 -0800 (PST)
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)
Message-Id: <941691909-v9-i1274@ruby.oce.orst.edu>
Content-Type: text
Perl-Users Digest Wed, 3 Nov 1999 Volume: 9 Number: 1274
Today's topics:
child I/O pitfalls? (Jim Thomason)
Re: child I/O pitfalls? (Alan Curry)
Re: File Access (Pathnames) (David Efflandt)
Flock functionality <preble@ipass.net>
Re: HELP:Elements in an array have a space in front of <ltl@rgsun40.viasystems.com>
Re: HELP:Elements in an array have a space in front of <rootbeer@redcat.com>
History of Perl <rmnesu@ptd.net>
Re: History of Perl <uri@sysarch.com>
Re: How can I set reg. expresion to anchor at the end o <ltl@rgsun40.viasystems.com>
Re: How can I set reg. expresion to anchor at the end o <ltl@rgsun40.viasystems.com>
Re: Keeping %blah in a uri string <rootbeer@redcat.com>
Re: mirror command <bedesign@webspan.net>
Re: Need nifty code for displaying Web Graphics <revjack@radix.net>
Re: Need nifty code for displaying Web Graphics (Neko)
O, sorry... <reembar@netvision.net.il>
Re: Perl and commonsense part 2 <ltl@rgsun40.viasystems.com>
Re: Perl and commonsense part 2 (Kragen Sitaker)
Re: Perl and Excel Charting <tpitts@mediaone.net>
replace " " with <ab@cd.com>
Re: replace " " with (David Efflandt)
Re: Selective require <ltl@rgsun40.viasystems.com>
Re: Simple translation, doesnt work!!! (Ken Bandes)
Web Site Development (PROs ONLY PLEASE) graduate@mail.com
Re: Web Site Development (PROs ONLY PLEASE) <ltl@rgsun40.viasystems.com>
Re: Who is worse: Cops or Criminals <meowatilla@usenet-performance-art.org>
Re: Why am I getting an undefined subroutine error? (Kragen Sitaker)
Digest Administrivia (Last modified: 16 Sep 99) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: Wed, 03 Nov 1999 20:24:37 -0500
From: jim3@psynet.net (Jim Thomason)
Subject: child I/O pitfalls?
Message-Id: <jim3-0311992024370001@ppp730.wi.net>
In a nutshell, I want to run 2 different programs, and log stuff about
them to a single file. Here's a simplified version of the code I'm using:
open (LOG, ">>./log.txt");
select((select(LOG), $| = 1)[0]);
if ($pid = fork){
system("some_random_program");
print LOG "I ran some_random_program!\n";
exit;
}
elsif ($pid){
system("some_other_random_program");
print LOG "I ran some_other_random_program!\n";
exit;
else {die "a horrible death"};
close LOG;
And it works like a champ, I haven't encountered any problems at all so far.
But are there any problems I may encounter in the future? i.e., any
reason not to do it this way?
I'm aware of the fact that I can't be guaranteed what order the lines are
printed to the log file, but I don't care about the order (in this case)
so it's not a concern.
Is there anything else that could cause me problems? (over-writing lines,
losing lines, corrupting the file, etc.)
And, slightly broader, is there a better approach to take? Where "better"
means faster, more reliable, etc.
-Jim.
------------------------------
Date: Thu, 04 Nov 1999 02:42:41 GMT
From: pacman@defiant.cqc.com (Alan Curry)
Subject: Re: child I/O pitfalls?
Message-Id: <Bo6U3.26293$23.1377897@typ11.nn.bcandid.com>
In article <jim3-0311992024370001@ppp730.wi.net>,
Jim Thomason <jim3@psynet.net> wrote:
>In a nutshell, I want to run 2 different programs, and log stuff about
>them to a single file. Here's a simplified version of the code I'm using:
>
>open (LOG, ">>./log.txt");
[...]
>Is there anything else that could cause me problems? (over-writing lines,
>losing lines, corrupting the file, etc.)
When you open in append mode, you're guaranteed that you won't overwrite
anything. The only potential problem is long lines being written in multiple
chunks, like this:
print LOG "111111111111111111111111\n"
print LOG "222222222222222222222222\n"
could end up looking like:
1111111111222222222211111111111111
22222222222222
if they were really long (larger than a stdio buffer). If all your lines are
shorter than 1000 bytes, I wouldn't worry about that.
--
Alan Curry |Declaration of | _../\. ./\.._ ____. ____.
pacman@cqc.com|bigotries (should| [ | | ] / _> / _>
--------------+save some time): | \__/ \__/ \___: \___:
Linux,vim,trn,GPL,zsh,qmail,^H | "Screw you guys, I'm going home" -- Cartman
------------------------------
Date: 4 Nov 1999 04:24:11 GMT
From: efflandt@xnet.com (David Efflandt)
Subject: Re: File Access (Pathnames)
Message-Id: <slrn8222j9.2r5.efflandt@efflandt.xnet.com>
On Wed, 3 Nov 1999 23:47:09 -0000, Martin Elliott
<martin@mert.globalnet.co.uk> wrote:
>I have my first script up and running, hoorah!
>
>It basically manipulates flat file databases, which up until now I have had
>to place in my cgi-bin. Now, after testing, I would like to move the files
>to another location, but there's something wrong, this is how I try to do
>it:
>
>open FILE "> /path1/path2/path3/file.txt"
>
>This code doeswn't seem to work, is there something I have missed?
Punctuation, like maybe a comma or semicolon, besides a test to see why
it didn't open if you did have proper syntax, but not proper permission.
--
David Efflandt efflandt@xnet.com http://www.xnet.com/~efflandt/
http://www.de-srv.com/ http://cgi-help.virtualave.net/
http://thunder.prohosting.com/~cv-elgin/
------------------------------
Date: Wed, 3 Nov 1999 23:57:51 -0500
From: "E. Preble" <preble@ipass.net>
Subject: Flock functionality
Message-Id: <Ok8U3.1004$A3.2110@news.ipass.net>
I have a general question about the flock command. When one
script opens a file, and flocks it, what actually happens
when another script tries to get at the file? Does it wait
for the file to be unflocked, or does it simply fail?
Is there a way to control this behavior and protect against
the second script failing by having it retry the file after
a wait period, or is this a bad idea (could lead to infinite
looping)?
Suggestions on "good programming techniques" and "flames for
stupidity" will be read with enthusiasm.
Thanks ahead.
Edward Preble
--
Datatrend Software
http://www.datatrendsoftware.com
mailto:info@datatrendsoftware.com
Grab It! Graph Digitizer for MS Excel
Double Check It Products
AutoMail Scripts for Website Automation
----------------------------------------------------
------------------------------
Date: 4 Nov 1999 02:19:47 GMT
From: lt lindley <ltl@rgsun40.viasystems.com>
Subject: Re: HELP:Elements in an array have a space in front of them
Message-Id: <7vqqg3$44f$3@rguxd.viasystems.com>
Ed Berry <ehberry@uswest.com> wrote:
:>The double quotes around the array was the problem!! I removed them and
:>it works great! Thanks!
Damn. All those other guys have better PSI::ESP modules than I do.
--
// Lee.Lindley /// I used to think that being right was everything.
// @bigfoot.com /// Then I matured into the realization that getting
//////////////////// along was more important. Except on usenet.
------------------------------
Date: Wed, 3 Nov 1999 18:55:49 -0800
From: Tom Phoenix <rootbeer@redcat.com>
Subject: Re: HELP:Elements in an array have a space in front of them
Message-Id: <Pine.GSO.4.10.9911031854540.29670-100000@user2.teleport.com>
On Wed, 3 Nov 1999, David Cassell wrote:
> Tom Phoenix wrote:
> >
> > On Wed, 3 Nov 1999, Ed Berry wrote:
> >
> > > The first element is correct but all the following elements have a space
> > > in the first character. What am I doing wrong?
> >
> > Look at your print statement. You didn't include it in your message, and I
> > couldn't read it with the Usenet::ESP module.
> I think you meant the PSI::ESP module.
Maybe you need to upgrade to the latest version of Usenet::ESP. Ah, I see
that you do.
--
Tom Phoenix Perl Training and Hacking Esperanto
Randal Schwartz Case: http://www.rahul.net/jeffrey/ovs/
------------------------------
Date: Thu, 04 Nov 1999 02:56:57 GMT
From: Richard Neidermyer <rmnesu@ptd.net>
Subject: History of Perl
Message-Id: <3820F72C.15548134@ptd.net>
Can anyone direct me to some good online refrences for the history of
Perl?
Thanks
------------------------------
Date: 03 Nov 1999 22:15:06 -0500
From: Uri Guttman <uri@sysarch.com>
Subject: Re: History of Perl
Message-Id: <x7yacf6j7p.fsf@home.sysarch.com>
>>>>> "RN" == Richard Neidermyer <rmnesu@ptd.net> writes:
RN> Can anyone direct me to some good online refrences for the history of
RN> Perl?
history.perl.org
(this is not linked from www.perl.com; it should be)
http://www.perl.com/pub/doc/manual/html/pod/perlhist.html
the book programming perl
uri
--
Uri Guttman --------- uri@sysarch.com ---------- http://www.sysarch.com
SYStems ARCHitecture, Software Engineering, Perl, Internet, UNIX Consulting
The Perl Books Page ----------- http://www.sysarch.com/cgi-bin/perl_books
The Best Search Engine on the Net ---------- http://www.northernlight.com
------------------------------
Date: 4 Nov 1999 01:57:12 GMT
From: lt lindley <ltl@rgsun40.viasystems.com>
Subject: Re: How can I set reg. expresion to anchor at the end of a string?
Message-Id: <7vqp5o$44f$1@rguxd.viasystems.com>
Neko <tgy@chocobo.org> wrote:
:>On 2 Nov 1999 23:24:32 -0600, abigail@delanet.com (Abigail) wrote:
:>>Vincent Murphy (vincent.murphy@cybertrust.gte.com) wrote on MMCCLV
:>>September MCMXCIII in <URL:news:xjgu2n4fceg.fsf@gamora.ndhm.gtegsc.com>:
:>>,,
:>>,, Simply do:
:>>,,
:>>,, perl -e '$string="123424";$tmp=reverse $string; @stnemele=$tmp=~/(?:(\d{4}|\d+))/g; \
:>>,, @elements= map { $n=reverse($_); $n } @stnemele; print join(", ", @elements), "\n";'
:>>,,
:>>
:>>A short, but quadratic solution:
:>>
:>> split /(?=(?:....)*$)/;
:>My first try was also quadratic. Actually, it was just "going to do a whole
:>lot of work to get each match", but after seeing Abigail's code/comment and
:>thinking about it some, I've decided to just call it "quadratic" as well. :)
:> my @a = /.+?(?=(?:....)*\z)/gs;
:>My second try is less quadratic:
Only less quadratic by the last iteration (though I guess
you could arguue that 1 less is less :-). I don't think the
definition of quadratic works that way. This solution would
continue to increase in cost quadratically as the length
of the string increased. If I am wrong about that, somebody
explain it to me please.
:> my @a = /(?!^)....|.+?(?=(?:....)*\z)/gs;
When looking at Abigail and Neko's "solutions" I kept seeing pos() go
backwards and getting confused. :-) I kept trying to figure out how
to throw \G into that thing to make it better, but pos() only travels
in one direction. So I think quadratic is the only way to do it
with a non-intrusive regexp.
I think this is one of those times where a less Perlish solution is
in order. I kept thinking "this would be so easy in C".
$_ = '1234245678';
my @x;
for (my $curpos = length($_) - 4;; $curpos -= 4) {
if ($curpos < 0) {
unshift @x, substr($_, 0, 4 + $curpos);
last;
}
unshift @x, substr($_, $curpos, 4);
}
print "@x\n";
# Or if you don't mind destroying your string, a more perlish solution
# that is not quadratic and is perhaps (just guessing) more efficient than
# the reverse/map/reverse answers.
my @y;
unshift @y, $1 while (s/(.{1,4}$)//g);
print "@y\n";
__END__
12 3424 5678
12 3424 5678
I agree with Larry Rosler's sentiment that a regexp /r (r for reverse)
modifier could be fun.
So is there a need for a counterpart to \G that means
"anchor the match at the last pos()" like $ anchors at the end
of the string (or \n for the pendantic)? Probably not needed
if the enhancements Ilya has been describing come to fruition.
--
// Lee.Lindley /// I used to think that being right was everything.
// @bigfoot.com /// Then I matured into the realization that getting
//////////////////// along was more important. Except on usenet.
------------------------------
Date: 4 Nov 1999 03:22:27 GMT
From: lt lindley <ltl@rgsun40.viasystems.com>
Subject: Re: How can I set reg. expresion to anchor at the end of a string?
Message-Id: <7vqu5j$44f$5@rguxd.viasystems.com>
lt lindley <ltl@rgsun40.viasystems.com> wrote:
:>$_ = '1234245678';
:>my @x;
:>for (my $curpos = length($_) - 4;; $curpos -= 4) {
:> if ($curpos < 0) {
Oops. Should be <= 0. Got to watch those end cases closely.
:> unshift @x, substr($_, 0, 4 + $curpos);
:> last;
:> }
:> unshift @x, substr($_, $curpos, 4);
:>}
:>print "@x\n";
--
// Lee.Lindley /// I used to think that being right was everything.
// @bigfoot.com /// Then I matured into the realization that getting
//////////////////// along was more important. Except on usenet.
------------------------------
Date: Wed, 3 Nov 1999 18:56:31 -0800
From: Tom Phoenix <rootbeer@redcat.com>
Subject: Re: Keeping %blah in a uri string
Message-Id: <Pine.GSO.4.10.9911031856120.29670-100000@user2.teleport.com>
On Thu, 4 Nov 1999 crackbaby1@my-deja.com wrote:
> I send data to a cgi script and need to capture the data in a variable.
> Netscape can't handle this but IE can.
If you're following the proper protocol but some browser or server doesn't
cooperate, then it's the other program's fault. If you're not following
the protocol, then it's your fault. If you aren't sure about the protocol,
you should read the protocol specification. If you've read it and you're
still not sure, you should ask in a newsgroup about the protocol.
Hope this helps!
--
Tom Phoenix Perl Training and Hacking Esperanto
Randal Schwartz Case: http://www.rahul.net/jeffrey/ovs/
------------------------------
Date: Wed, 3 Nov 1999 22:55:21 -0500
From: "bruce" <bedesign@webspan.net>
Subject: Re: mirror command
Message-Id: <s220h8u324267@corp.supernews.com>
> > that it can't find LWP/simple.pm,
>
> Have you seen what perldiag has to say about the "massage" that you're
> getting?
(so much for spell checkers)
here's the message:
Can't locate LWP/simple.pm in @inc
which I've attempted to solve using use LIB /mydir
and loading simple.pm to mydir.
thanks.
------------------------------
Date: 4 Nov 1999 03:44:45 GMT
From: revjack <revjack@radix.net>
Subject: Re: Need nifty code for displaying Web Graphics
Message-Id: <7vqvfd$d3k$1@news1.Radix.Net>
Keywords: Hexapodia as the key insight
brian d foy explains it all:
:In article <7vq9k0$fr9$1@nnrp1.deja.com>, NOSPAMajm@antopia.com wrote:
:>AJ
:>Webmaster
:>Antopia Herpes Network
:sorry - don't need a membership to such a website.
Yet. Life is funny.
--
hey/don't look now/but there goes god/in sexy pants/with a sausage
dog/and he can't stand beelzebub/coz he looks so good in black
revjack@radix.net
------------------------------
Date: Wed, 03 Nov 1999 20:12:57 -0800
From: tgy@chocobo.org (Neko)
Subject: Re: Need nifty code for displaying Web Graphics
Message-Id: <Wf8gOAU8Y9EQ=1M4G8B925yjenFg@4ax.com>
On Thu, 04 Nov 1999 00:16:36 GMT, mgjv@comdyn.com.au (Martien Verbruggen)
wrote:
>On Thu, 04 Nov 1999 09:16:14 +1030,
> Henry Penninkilampi <spamfree@metropolis.net.au> wrote:
>> In article <m3puxrgs82.fsf@projdirc.literacy.upenn.edu>, Steve Linberg
>> <linberg@literacy.upenn.edu> wrote:
>
>> > No. HTML doesn't support in-line image data.
>>
>> Hmmm...
>>
>> var fred = 'GIF89a\1\0\1\0\200[...]\1\0;'
>> ...
>> <IMG SRC="javascript:fred">
>
>That is not HTML.
Here's some HTML that may not be HTML:
<html><title>Perl Mongers</title>
<img src="data:image/gif;base64,
R0lGODlhPwAbALP/AP///wgICBgYGCkpKTk5OVJSUlpaWnNzc4SEhJycnK2trb29vc7Ozt7e3u/v
7wAAACwAAAAAPwAbAAAE/xDISaud7aDNlbvglWhI8lHOclLMmDTW8sz0HBxrCB50cC6MxcGgqCQI
h0PBZHEMZgXA4vkY5HSWxEzwcSQSCwOisJgoAoKCwXAoWwgzg4QRmB2wIcX21EggGAgDCBIKAwEE
YoBMFVRyEgUzAxgLCjASDg0OmgANHgB6DwIUCwQIQwkAgX5sCgwKCEUVcA+OADxVmAZ1dWQABg91
BGehDqBcE0MbB4AEYK4LCw1BCQyMcROQDwUNAsAevwEqWqEDVNB7lwYjBQcNAwcermAKC36xE7OO
dDMJvw+oABjMIBCQBqpmn9ABcMAKnoIlRRo0gJag1ZccVAq06KZtQZ0Hbv8cdAvAoIGNaieMUTgg
gFI9AgRUMAgCRGKLQfhqAEMoA0qSAx8rbbFESCGABALAAFH1DBoQIQ/vUSEwcwWoKgQGwCxA1SQx
CsZyGNDY6QASBS++DCFQAC1AAPli0HBTQSCwHGFRjFWQdUABWELWDiDiZ0KjJhzfLqxm95iZLU3Q
IkijRoFlJabILMAJ95qFW1YmIHhQ0mjCrxcUCCDQB9ECAVweVizDoMDHNJwn+BtQERI8fwGIEMp2
gy4FpAR1tUMSsFm15ly5DhZhO1TMVFql37GVPaviCUhfZB3ERkISPCA0XUEP4mFZBJpKSBjBvr79
UTjQfuj0vPD9/+j18wHdGFI898lbDZSQxGbLBGRKNLAgYEAZCcKyDINBKLiZfDHc04qBAYE4FkOs
KeGEB8JM1gIBDpTiAFd8OcAAVYgU4kFu4BmYgXEM5HAAKv0cRQRBtohxRwMxHaPAGprxBo8tAuBg
QScTMJCEAQZWshIqEgp5hHlGckLGMWGMNVOPwn1SgCgUdEJXVUBI0IAYI8Dwly1RIMBaTC2+IgcD
A8xowlhTwADGEr5IxCZ49OgAyEweOLBBPQjU04aVbUj6xwiVJJFAFApoUJEGXjwI4KkW9HjUdqi2
ip6eY4AYQgQAOw==" width=126 height=54>
</html>
And here's some nifty code for creating the image source URI:
#!/usr/bin/perl -w
use URI;
undef $/;
open F, 'perl-mongers.gif' or die "No open: $!";
binmode F;
for (new URI 'data:image/gif,') {
$_->data(<F>);
s/(^[^,]+,|.{1,76})/$1\n/g;
print;
}
--
Neko | tgy@chocobo.org | Will hack Perl for a moogle stuffy! =^.^=
------------------------------
Date: Thu, 04 Nov 1999 03:04:49 +0200
From: Re'em Bar <reembar@netvision.net.il>
Subject: O, sorry...
Message-Id: <3820DBB1.1075793C@netvision.net.il>
I'll check those docs.
thank you
--
Re'em
http://snark.co.il
------------------------------
Date: 4 Nov 1999 02:14:50 GMT
From: lt lindley <ltl@rgsun40.viasystems.com>
Subject: Re: Perl and commonsense part 2
Message-Id: <7vqq6q$44f$2@rguxd.viasystems.com>
Craig Berry <cberry@cinenet.net> wrote:
:>One of the reason this is slightly awkward is that there's no good way to
:>deal with which of duplicate-key values to throw out. But to do it
:>"randomly",
:> %c = ( %a, %b );
:>works just fine.
But not randomly. Of course, your "randomly" was in quotes so
perhaps you meant that the result may appear random to the naive user
of this copy statement. The results are well defined.
--
// Lee.Lindley /// I used to think that being right was everything.
// @bigfoot.com /// Then I matured into the realization that getting
//////////////////// along was more important. Except on usenet.
------------------------------
Date: Thu, 04 Nov 1999 03:47:39 GMT
From: kragen@dnaco.net (Kragen Sitaker)
Subject: Re: Perl and commonsense part 2
Message-Id: <vl7U3.26391$23.1387141@typ11.nn.bcandid.com>
In article <If3U3.86$KN4.1769@nsw.nnrp.telstra.net>,
Martien Verbruggen <mgjv@comdyn.com.au> wrote:
>On Wed, 03 Nov 1999 14:42:31 GMT,
> ajmayo@my-deja.com <ajmayo@my-deja.com> wrote:
>
>> Incidentally in Javascript arrays are indexed by either a numeric
>> subscript *or* a key, making them both hashes and arrays. This, on the
>> surface, strikes me as a somewhat more orthogonal approach.
>
>Apart from all the other answers you got:
>
>Comparing JavaScript to Perl is of course nonsensical, but that's
>another issue.
I don't think it's nonsensical at all. Anything that can be done in
one language can be done in the other. Comparing Perl to FORTRAN, C,
Python, Prolog, Scheme, Standard ML, MAD, and APL can yield insights.
Probably the greatest insights come from comparing it to languages that
are very different (Standard ML, Prolog) and languages that are very
similar (Python, Tcl).
It is unfortunate that discussions of such topics frequently generate
flames, because the topics are important.
--
<kragen@pobox.com> Kragen Sitaker <http://www.pobox.com/~kragen/>
Tue Nov 02 1999
6 days until the Internet stock bubble bursts on Monday, 1999-11-08.
<URL:http://www.pobox.com/~kragen/bubble.html>
------------------------------
Date: Wed, 03 Nov 1999 21:47:15 -0500
From: Jester <tpitts@mediaone.net>
Subject: Re: Perl and Excel Charting
Message-Id: <3820F3B3.CEAA1B22@mediaone.net>
I have done quite a bit of this. Here is the basic idea:
Using Excel, I set up an external query. This could be a direct query to
your database using ODBC or an import of a CSV text file. Then using the
graph wizard, I create the graph that I want. The last step is to create
some macros that update the external data and save as HTML. After I save
this, then using Perl and Win32::OLE, I can open my spreadsheet and using
the macros I then update my data and export my html and gifs.
This method works if you have the same graph, but different data so that
you can use the Excel spreadsheet as a template to use over again.
I can post specific code examples if you need them.
Paul Schwotzer wrote:
> Anyone used Perl to access Excel's Automation interface and
> programmatically create charts/graphs from comma-separated data files?
>
> I'm looking to automate a data gathering and display process which
> currently relies upon manually loading Excel, making the graphs and
> exporting them as HTML pages.
>
> Thanks, Paul Schwotzer
------------------------------
Date: Wed, 3 Nov 1999 20:50:19 -0600
From: "Blair Heuer" <ab@cd.com>
Subject: replace " " with
Message-Id: <7vqsed$6am$1@fir.prod.itd.earthlink.net>
I am not too good with simple search and replace, and what i need is not
simple, in my mind, so I hope someone can help me.
I need a line, or lines, of code that will take each element in a list,
check for any leading spaces, and change those into non-breaking spaces
( ).
I know I will need something like:
foreach $item (@list) {
search replace code
}
But I have no clue how to tell it to change all " " to " " until there
is not a " " then stop and go to the next.
Basically if i had the line (without quotes) " Hello World!" I would want
the code to change it to " Hello World!"
I hope that the non-breaking spaces were not interpreted as merely " " so
you can see what i was writing.
Just so you know, this is for a message board script, so if people indent
their paragraphs, it will come out that way in the browser.
Thanks,
Blair
------------------------------
Date: 4 Nov 1999 04:50:19 GMT
From: efflandt@xnet.com (David Efflandt)
Subject: Re: replace " " with
Message-Id: <slrn822449.2r5.efflandt@efflandt.xnet.com>
On Wed, 3 Nov 1999 20:50:19 -0600, Blair Heuer <ab@cd.com> wrote:
>I am not too good with simple search and replace, and what i need is not
>simple, in my mind, so I hope someone can help me.
>
>I need a line, or lines, of code that will take each element in a list,
>check for any leading spaces, and change those into non-breaking spaces
>( ).
>
>I know I will need something like:
>
>foreach $item (@list) {
>
>search replace code
>
>}
>
Perhaps you should start by typing 'perldoc perlre' (without quotes) on a
system with Perl on it. This is a simple search and replace:
foreach (@list) { s/ / /g; }
This uses the temp default variable $_ instead of $item. A working
example for "quoted" strings entered on the command line is:
#!/usr/bin/perl
while ($ARGV[0]) { push @list,shift; }
foreach (@list) { s/ / /g; print "$_\n"; }
--
David Efflandt efflandt@xnet.com http://www.xnet.com/~efflandt/
http://www.de-srv.com/ http://cgi-help.virtualave.net/
http://thunder.prohosting.com/~cv-elgin/
------------------------------
Date: 4 Nov 1999 02:28:32 GMT
From: lt lindley <ltl@rgsun40.viasystems.com>
Subject: Re: Selective require
Message-Id: <7vqr0g$44f$4@rguxd.viasystems.com>
Anthony Lalande <tonyboy@earthling.net> wrote:
:>I have many Perl scripts that call a main support library. This support
:>library, in turn, calls other libraries for use. Depending on where the
:>originating script is located, it may or may not require a certain library.
:>I would like to make it so that all scripts in the foobar directory trigger
:>the calling of a foobar.lib.pl file. I've tried something like:
:>@caller = caller;
:>require "foobar-lib.pl" if ($caller[1] =~ /\/foobar\//i);
:>...and...
:>require "foobar-lib.pl" if ($0 =~ /\/foobar\//i);
:>But these two only return the script name, and not the directory path. Any
:>ideas?
perldoc FindBin
--
// Lee.Lindley /// I used to think that being right was everything.
// @bigfoot.com /// Then I matured into the realization that getting
//////////////////// along was more important. Except on usenet.
------------------------------
Date: Thu, 04 Nov 1999 02:52:19 GMT
From: kbandes@home.com (Ken Bandes)
Subject: Re: Simple translation, doesnt work!!!
Message-Id: <8E73DCB62kbandeshomecom@192.168.123.1>
bababozorg@aol.com wrote in <7vq38l$ag7$1@nnrp1.deja.com>:
>can any one please tell me why this simple translation doesn't work?
>$hamed = qq~<html><body><a href="mysite?
>aaaaa">iojfiowjfiefijief</a></body></html>~;
>$hamed2 = qq~<a href="mysite?aaaaa">iojfiowjfiefijief</a>~;
>$hamed =~ s/$hamed2/ppppppppppppp/g;
>print $hamed;
First of all, are the lines broken this way in your code? Because then
you've got newlines in $hamed that aren't in $hamed2.
But even if not, the ? in $hamed2 is a metacharacter which, in a
pattern match, means the preceding item (here the letter 'e') is
optional. Use \? to get a literal '?' character.
Also, look into here documents (in perldata). Your code will be
a lot neater.
Ken Bandes
------------------------------
Date: Thu, 04 Nov 1999 02:19:37 GMT
From: graduate@mail.com
Subject: Web Site Development (PROs ONLY PLEASE)
Message-Id: <7vqqfo$sb8$1@nnrp1.deja.com>
We are looking for Web developers who are experienced with HTML,
Javascript, Macromedia Flash, Adobe Photoshop, Perl, ASP, Visial basic
and script, ADO, SQL, DreamWeaver, Fusion, cold fusion, databse, etc.
To do a site like collegeclub.com. We must have assure high quality
service, low cost, and quick turnaround. Please let me know how much
you can do this for and time it will take. Go look at the site and tell
me if you can do the same or better.
Sent via Deja.com http://www.deja.com/
Before you buy.
------------------------------
Date: 4 Nov 1999 04:07:26 GMT
From: lt lindley <ltl@rgsun40.viasystems.com>
Subject: Re: Web Site Development (PROs ONLY PLEASE)
Message-Id: <7vr0pu$6a8$1@rguxd.viasystems.com>
graduate@mail.com wrote:
:>We are looking for Web developers who are experienced with HTML,
:>Javascript, Macromedia Flash, Adobe Photoshop, Perl, ASP, Visial basic
:>and script, ADO, SQL, DreamWeaver, Fusion, cold fusion, databse, etc.
:>To do a site like collegeclub.com. We must have assure high quality
:>service, low cost, and quick turnaround. Please let me know how much
:>you can do this for and time it will take. Go look at the site and tell
:>me if you can do the same or better.
You shotgun your requirement to a newsgroup where it is not welcome
and have the nerve to ask that only PROs should respond?
I generally advocate in this group that it is more effective for us
to be nice but you are a form of life that is below my threshold for
respect. I hope your email address is real. You will reap what you
have sown.
On the other hand if you are a legitimate "madame" and are offering
large sums of money (in excess of $100/hour or $200K/year) then we
will make exceptions for your ignorance and coquettishly bat our
eyelashes and perhaps promise even more. I'm not proud; I'll bend
over for anyone with enough cash (figuratively speaking of course :-)
But I'm pretty sure that you are just another lowlife pimp.
Idiot. Just search the job sites on the web with your list of
keywords. If you can't find them on your own, then find another
job. Oh. Recursion. Can't find the job sites so can't find
another job. There's a hole in the bucket, dear Liza, dear Liza...
--
// Lee.Lindley /// I used to think that being right was everything.
// @bigfoot.com /// Then I matured into the realization that getting
//////////////////// along was more important. Except on usenet.
------------------------------
Date: Wed, 3 Nov 1999 20:16:50 -0600
From: Rev. Meowatilla Al' Rashad <meowatilla@usenet-performance-art.org>
Subject: Re: Who is worse: Cops or Criminals
Message-Id: <7vqq5m$8p0$2@nntpd.databasix.com>
In <3820F510.46FE@night.com>, Jamin,CISOL wrote:
> JBP615 wrote:
> >
> > >By the way-- would you believe there are countries in this world where cops
> > >rarely carry side arms? New Zealand is a good example. The cops there don't
> > >
> > >carry guns unless they need them.. They don't train with the Special Forces
> > >to
> > >learn how to best attack a house.
> >
> > Funny you should choose New Zealand. I have a cousin who is one of those cops
> > you seem to admire so much, he is a Sergeant and a prosecutor(The cops perform
> > that function down there). I mentioned to him that it was probably an
> > interesting job, and he replied, " Not really, everyone here pleads guilty."
> > He went on to compare the CITIZENS of New Zealand to Americans (This means
> > YOU). The fundamental urge to scream"I didn't do it" while holding the smoking
> > gun is not a common occurrance, like it is here. In this country, everyone is
> > innocent and the cops are always wrong (according to WAY too many people).
> > In addition, the New Zealand citizenry are not armed as it is here, and the
> > homicide rate of the country is less than most precincts in the US, thus the
> > need to carry is not as important. It is typical that these facts eluded you
> > as you spouted that idiot logic.
> >
> > >They don't cruise the streets like predators
> > >looking for some prey..
> >
> > Thats exactly what cops are paid to do.
> > Moron.
> >
> > I know it pains you to hear it, but whatever you think of cops, the citizens
> > that they protect, in general, are worse.
> >
> Shoot the horse. You can't lead the Rev. to water. His misinformed
> statement was made to suit his purpose. We see many who use half-facts
> such as his to prove their unpopular viewpoints on Usenet.
I prove whatever half-facts I want, fuckhead. But did I tell you you could get
your tongue out of my asshole and speak? GET BACK TO WORK YOU LITTLE SHIT.
This is your last warning.
------------------------------
Date: Thu, 04 Nov 1999 03:59:23 GMT
From: kragen@dnaco.net (Kragen Sitaker)
Subject: Re: Why am I getting an undefined subroutine error?
Message-Id: <vw7U3.26409$23.1386338@typ11.nn.bcandid.com>
In article <x3yvh7jrv2q.fsf@tigre.matrox.com>,
Ala Qumsieh <aqumsieh@matrox.com> wrote:
>"Peter Steele" <psteele@opticalnetworks.com> writes:
>> I have Perl installed on my Windows NT system and am trying to make use of
>> some of packages that are part of the distribution. I tried a very simple
>> script:
>>
>> use Net::ping;
>> print "alive" if pingecho('localhost', 10);
>>
>> but when I run this I get the error
>>
>> Undefined subroutine &main::pingecho called at - line 2
>>
>> Can anyone explain what is causing this error?
>
>You either have a typo in your little snippet above, or you're lying
>to us.
Or you're using a case-insensitive filesystem; given that you're on
Windows NT, that's probably the case.
>The use() statements get executed in compile time. The correct module
>name in Net::Ping. Perl is case-sensitive, even on winblows.
Perl is case-sensitive for package method lookup, but not filename
lookup. But if, on Unix, I have a Net/ping.pm that says:
package Net::Ping;
sub pingecho { 'foo' }
1;
. . . I can happily say
use Net::ping;
and not know that anything is wrong.
>Unless you have a module called Net::ping hidden somewhere in your
>@INC directories, your program should have never compiled, and you
>would've never gotten the error, which happens at run time.
As far as perl can tell (at least by attempting to open() it, which is
what it does on Unix and, I assume, on Windows too), it *is* called
Net/ping.pm.
This guy is the second one today to report this problem, so I suspect
he's not lying.
--
<kragen@pobox.com> Kragen Sitaker <http://www.pobox.com/~kragen/>
Tue Nov 02 1999
6 days until the Internet stock bubble bursts on Monday, 1999-11-08.
<URL:http://www.pobox.com/~kragen/bubble.html>
------------------------------
Date: 16 Sep 99 21:33:47 GMT (Last modified)
From: Perl-Users-Request@ruby.oce.orst.edu (Perl-Users-Digest Admin)
Subject: Digest Administrivia (Last modified: 16 Sep 99)
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.
| NOTE: The mail to news gateway, and thus the ability to submit articles
| through this service to the newsgroup, has been removed. I do not have
| time to individually vet each article to make sure that someone isn't
| abusing the service, and I no longer have any desire to waste my time
| dealing with the campus admins when some fool complains to them about an
| article that has come through the gateway instead of complaining
| to the source.
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.
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 V9 Issue 1274
**************************************