[19145] in Perl-Users-Digest
Perl-Users Digest, Issue: 1340 Volume: 10
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Fri Jul 20 06:05:31 2001
Date: Fri, 20 Jul 2001 03:05:08 -0700 (PDT)
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)
Message-Id: <995623507-v10-i1340@ruby.oce.orst.edu>
Content-Type: text
Perl-Users Digest Fri, 20 Jul 2001 Volume: 10 Number: 1340
Today's topics:
Re: (long) advice needed: how robust is this script ? a <jmccrea@guideguide.com>
Re: (long) advice needed: how robust is this script ? a <pne-news-20010720@newton.digitalspace.net>
Re: Academic exercise - string/variable interpolation f (Anno Siegel)
cgi variables in French <chcaron@videotron.ca>
Re: cgi variables in French <godzilla@stomp.stomp.tokyo>
Re: Disabling IE toolbar (Jean-Louis MOREL)
Re: don't laugh <james@zephyr.org.uk>
Re: don't laugh (Tad McClellan)
FAQ: How can I get "#!perl" to work on [MS-DOS,NT,...]? <faq@denver.pm.org>
Re: ide for perl? <pne-news-20010720@newton.digitalspace.net>
Re: Insecure dependency in require error? nobull@mail.com
Re: Insecure dependency in require error? (Anno Siegel)
Re: regexp question <goldbb2@earthlink.net>
Removing Tags <osbornelee@hotmail.com>
Re: Request for Comments ... ConvertColorspace.pm <pne-news-20010720@newton.digitalspace.net>
Re: Request for Comments ... ConvertColorspace.pm <hafner-usenet@ze.tu-muenchen.de>
Review of Tutorial Critique Appreciated (5-i's)
Re: Review of Tutorial Critique Appreciated (Randal L. Schwartz)
Search and replace using perl <reply-to-group@please.com>
Re: Strange thing happened today! (Martien Verbruggen)
Re: tab sperated line to named hash? <mnemotronic@mind\no-spam/spring.com>
Re: winzip <peter@perfectlink.com.hk>
Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: Fri, 20 Jul 2001 10:57:36 +0100
From: Jasper McCrea <jmccrea@guideguide.com>
Subject: Re: (long) advice needed: how robust is this script ? and other questions :)
Message-Id: <3B580090.7775345B@guideguide.com>
Kev wrote:
>
> Hi All
>
> I am new to perl, and request the advice /
> assistance of you seasoned pro's.
>
> Any assistance very gratefully appreciated.
>
And I thought I wrote unmaintainable code. This is horrible.
But I did enjoy reading the 'offensive' words category. And I found it
interesting that you wouldn't send mail including the words
'endorsement', 'advertisement', 'wristwatch', never mind 'suck'.
Jasper
--
split//,'019617511192'.
'17011111610114101114'.
'21011141011840799901'.
'17101174';
foreach(0..
$#_){$_[$_
++]^=$_[$_
--]^=$_[$_
]^=$_[++ $_]if!($_%
2)}$g.=$_ ,chr($g)=~
/(\w)/&&($o.=$1and
$g='')foreach@_;
print"$o\n"
------------------------------
Date: Fri, 20 Jul 2001 06:28:01 +0200
From: Philip Newton <pne-news-20010720@newton.digitalspace.net>
Subject: Re: (long) advice needed: how robust is this script ? and other questions :)
Message-Id: <03cflt8ltrrdst996lpr7b891o3ollh3iu@4ax.com>
On Fri, 20 Jul 2001 01:06:28 GMT, NOSPAMlekkerinsydney@ozemail.com.au
(Kev) wrote:
> 4. The script seems to be slow. Is there anyway
> of "speeding" it up ?
It doesn't even compile, because you wrapped the lines so that not all
comments start with a '#' sign.
And the shebang line doesn't start with a '#' sign so your first line
gets a syntax error:
syntax error at D:\Lang\Perl\tryit.pl line 1, near "/usr/local"
Bareword found where operator expected at D:\Lang\Perl\tryit.pl line 1,
near "/bin/perl"
(Missing operator before perl?)
D:\Lang\Perl\tryit.pl had compilation errors.
And you're not using -w. Did you use -w at least during testing? (Some
people advocate switching off -w in production code after it's been
thoroughly tested.)
> # sub: Retrieve the system date and time
> sub RetrieveDate
> {
> my @months =
> ("January","February","March","April","May","
> June","July","August","September","October","
> November","December");
> my @weekdays =
> ("Sunday","Monday","Tuesday","Wednesday","Thu
> rsday","Friday","Saturday");
> my
> ($sec,$min,$hour,$mday,$month,$year,$wday,$yd
> ay,$dst) = localtime(time);
I wonder what $wday, $yday, and $dst are for? They don't seem to be
used. Someone's perhaps read the manpage...
> $Time = "$hour\:$min\:$sec";
> if ($year < 98) { $year += 2000; }
> else { $year += 1900; }
...but not well enough <giggle>. Good thing noone was using this code
five years ago or they would have been surprised to live in 2096.
> $Date = "$weekdays[$wday], $months[$month]
> $mday, $year";
> } # sub RetrieveDate
[snip]
> # sub: Check if names, addresses, or message
> contain possibly offensive terms
> sub CheckForOffensiveTerms
"Bible", "Christ", and "bathroom" are offensive? Give me a break!
(There's also Regexp::Common, which already does this particular wheel.)
> # sub: Send e-mail to the person the
> website/page was recommended to
> sub SendFriendMail
[snip]
> # sub: Send e-mail to the person 2 the
> website/page was recommended to
> sub SendFriendMail2
[snip]
> # sub: Send e-mail to the person 3 the
> website/page was recommended to
> sub SendFriendMail3
[snip]
> # sub: Send e-mail to the person 4 the
> website/page was recommended to
> sub SendFriendMail4
[snip]
Looks like badly designed data structures to me.
Then there's lots of backslashes in quoted strings rather than switching
the qq() or q() delimiter and/or using heredocs.
Truly the hallmarks of high-quality code. I recommend you continue using
it[1].
Cheers,
Philip
[1] Ensure your newsreader correctly handles the invisible <sarcasm> ...
</sarcasm> tags.
--
Philip Newton <nospam.newton@gmx.li>
That really is my address; no need to remove anything to reply.
If you're not part of the solution, you're part of the precipitate.
------------------------------
Date: 20 Jul 2001 09:34:04 GMT
From: anno4000@lublin.zrz.tu-berlin.de (Anno Siegel)
Subject: Re: Academic exercise - string/variable interpolation for arrays
Message-Id: <9j8tuc$8hu$1@mamenchi.zrz.TU-Berlin.DE>
According to Mr. Sunray <djberge@uswest.com>:
[...]
> All I'm trying to do is push a name onto separate arrays based on the
> the first
> letter of that name. See the code below - it's pretty short.
[code involving symrefs snipped]
It has been pointed out why your code didn't work as expected.
The usual way around the use of symrefs is a hash. In this
case, the solution would involve a hash where keys are the
initial letters of each name and values are anonymous lists
of the corresponding names:
my @lastnames = qw(Alberts Brown Cringle, Brutus, Archimedes, Caesar);
my %name_table;
push @{ $name_table{ lc substr $_, 0, 1}}, $_ for @lastnames;
To print them all out in order:
for ( sort keys %name_table ) {
print "$_: ", join( ', ', @{ $name_table{ $_}}), "\n";
}
Anno
------------------------------
Date: Thu, 19 Jul 2001 22:12:43 -0400
From: Christian Caron <chcaron@videotron.ca>
Subject: cgi variables in French
Message-Id: <3B57939B.18640C6D@videotron.ca>
Hello all,
don't know if it's the right place to ask this question, but anyhow, I'm
sure there are experts here...
I installed Apache and now want to display the last modified date of a
page with a SSI. I would like to do it in French (on the fly, without
changing the server language).
In the web page, I tried:
<!--#exec cmd="LANG=fr_CA.ISO_8859-1;export LANG;echo '$LAST_MODIFIED'"
-->
(on one line)
and it's always printing the last modified date in English...
I assume the web server is running sh shell as I can print the actual
date in French with:
<!--#exec cmd="LANG=fr_CA.ISO_8859-1;export LANG;echo '+%A, le %d %B
%Y'" -->
(on one line)
Thanks for any help!
Christian
(and if someone is aware of a good site where they discuss about
cutomization of cgi variables, well... show it to me because I've looked
almost everywhere and never found one...)
------------------------------
Date: Thu, 19 Jul 2001 23:12:02 -0700
From: "Godzilla!" <godzilla@stomp.stomp.tokyo>
Subject: Re: cgi variables in French
Message-Id: <3B57CBB2.610882E3@stomp.stomp.tokyo>
Godzilla! wrote:
> Christian Caron wrote:
(serious snippage)
> <!DOCTYPE HTML PUBLIC \"-//IETF//DTD HTML 2.0//EN\">
> <HTML>
> <META HTTP-EQUIV=\"Content-Type\" CONTENT=\"text/html; charset=ISO-8859-1\">
Remove my escaping left slashes just before
each quote mark \" as needed. I copied this
header information from a script and neglected
to remove those escaping left slashes.
Modify or remove my content type print
from my test script as needed for your
server's needs. Usually text/plain is
required for many servers to prevent
an error log entry but will not effect
the operation of the script; it will work
without a content type print, most often.
Test your server on this.
Godzilla! Queen Of Left Handed Escapes.
------------------------------
Date: 20 Jul 2001 02:44:07 GMT
From: jl_morel@bribes.org (Jean-Louis MOREL)
Subject: Re: Disabling IE toolbar
Message-Id: <9j85tn$1s59$1@news5.isdnet.net>
Dans l'article <3B568D00.E22380DE@europarl.eu.int>, hmacdonald@europarl.eu.int a dit...
>
>Can anyone tell me how to disable/enable the IE4 toolbar from a Perl
>script.
>
>And where can I find info on controlling the browser from a Perl Script
>generally.
>
>Thanks
>Harry
>
You can use OLE module. For methods/properties available see :
http://msdn.microsoft.com/library/default.asp?url=/workshop/browser/webbrowser/reflist_vb.asp
(IE events don't works with OLE module yet)
#!perl -w
use strict;
use Win32::OLE;
my $url='http://www.perl.com';
my $ie = Win32::OLE->new('InternetExplorer.Application');
$ie->{ToolBar}= 0; # no toolbar
$ie->{Visible} = 1;
$ie->Navigate($url);
__END__
--
J-L.M.
------------------------------
Date: Fri, 20 Jul 2001 04:00:45 +0100
From: James Coupe <james@zephyr.org.uk>
Subject: Re: don't laugh
Message-Id: <Fd6haNld75V7EwMx@gratiano.zephyr.org.uk>
In message <9j7nr8$pfa$1@dinkel.civ.utwente.nl>, carlos <carlos@plant.st
udent.utwente.nl> writes
>what everyone else said, plus:
>@ARGV[$NUM] should be $ARGV[$NUM] , as perl would have told you of you'd
>used the -w switch.
It's an array slice, so it'll "work" even if it isn't pretty.
--
James Coupe PGP Key: 0x5D623D5D
EBD690ECD7A1F
She twirled a lock of hair around her forefinger and smiled B457CA213D7E6
faintly. "Actually, I'd settle for a small Greek." 68C3695D623D5D
------------------------------
Date: Fri, 20 Jul 2001 00:51:24 -0400
From: tadmc@augustmail.com (Tad McClellan)
Subject: Re: don't laugh
Message-Id: <slrn9lfe6c.iou.tadmc@tadmc26.august.net>
James Coupe <james@zephyr.org.uk> wrote:
>In message <9j7nr8$pfa$1@dinkel.civ.utwente.nl>, carlos <carlos@plant.st
>udent.utwente.nl> writes
>>what everyone else said, plus:
>>@ARGV[$NUM] should be $ARGV[$NUM] , as perl would have told you of you'd
>>used the -w switch.
>
>It's an array slice, so it'll "work" even if it isn't pretty.
The point is that it only "works" _sometimes_.
Maybe it works for your case, but there _are_ cases where it
matters, so it is a Bad Habit to get into.
$ARGV[$NUM] = <>; # read one line
@ARGV[$NUM] = <>; # read all lines, store the 1st one, discard all others
In the second case, the classic symptom is something like:
"Where did all my input go?"
But such timewasting never happens to the clever programmers,
because they have warnings turned on, and they listen to what
it says. :-)
--
Tad McClellan SGML consulting
tadmc@augustmail.com Perl programming
Fort Worth, Texas
------------------------------
Date: Fri, 20 Jul 2001 06:17:37 GMT
From: PerlFAQ Server <faq@denver.pm.org>
Subject: FAQ: How can I get "#!perl" to work on [MS-DOS,NT,...]?
Message-Id: <52Q57.11$zH9.210409984@news.frii.net>
This message is one of several periodic postings to comp.lang.perl.misc
intended to make it easier for perl programmers to find answers to
common questions. The core of this message represents an excerpt
from the documentation provided with every Standard Distribution of
Perl.
+
How can I get "#!perl" to work on [MS-DOS,NT,...]?
For OS/2 just use
extproc perl -S -your_switches
as the first line in "*.cmd" file ("-S" due to a bug in cmd.exe's
`extproc' handling). For DOS one should first invent a corresponding
batch file and codify it in "ALTERNATIVE_SHEBANG" (see the INSTALL file
in the source distribution for more information).
The Win95/NT installation, when using the ActiveState port of Perl, will
modify the Registry to associate the ".pl" extension with the perl
interpreter. If you install another port, perhaps even building your own
Win95/NT Perl from the standard sources by using a Windows port of gcc
(e.g., with cygwin or mingw32), then you'll have to modify the Registry
yourself. In addition to associating ".pl" with the interpreter, NT
people can use: "SET PATHEXT=%PATHEXT%;.PL" to let them run the program
"install-linux.pl" merely by typing "install-linux".
Macintosh Perl programs will have the appropriate Creator and Type, so
that double-clicking them will invoke the Perl application.
*IMPORTANT!*: Whatever you do, PLEASE don't get frustrated, and just
throw the perl interpreter into your cgi-bin directory, in order to get
your programs working for a web server. This is an EXTREMELY big
security risk. Take the time to figure out how to do it correctly.
-
Documents such as this have been called "Answers to Frequently
Asked Questions" or FAQ for short. They represent an important
part of the Usenet tradition. They serve to reduce the volume of
redundant traffic on a news group by providing quality answers to
questions that keep coming up.
If you are some how irritated by seeing these postings you are free
to ignore them or add the sender to your killfile. If you find
errors or other problems with these postings please send corrections
or comments to the posting email address or to the maintainers as
directed in the perlfaq manual page.
Answers to questions about LOTS of stuff, mostly not related to
Perl, can be found by pointing your news client to
news:news.answers
or to the many thousands of other useful Usenet news groups.
Note that the FAQ text posted by this server may have been modified
from that distributed in the stable Perl release. It may have been
edited to reflect the additions, changes and corrections provided
by respondents, reviewers, and critics to previous postings of
these FAQ. Complete text of these FAQ are available on request.
The perlfaq manual page contains the following copyright notice.
AUTHOR AND COPYRIGHT
Copyright (c) 1997-1999 Tom Christiansen and Nathan
Torkington. All rights reserved.
This posting is provided in the hope that it will be useful but
does not represent a commitment or contract of any kind on the part
of the contributers, authors or their agents.
03.24
--
This space intentionally left blank
------------------------------
Date: Fri, 20 Jul 2001 06:10:22 +0200
From: Philip Newton <pne-news-20010720@newton.digitalspace.net>
Subject: Re: ide for perl?
Message-Id: <5jbfltkjmnqfdvj661i1ups3ieifse6fm0@4ax.com>
On 19 Jul 2001 21:03:44 GMT, uthinkxxuthink@yahoo.com (Mike Erickson)
wrote:
> Check out Ultraedit[1], NoteTab[2], and PFE[3], just to name a few.
Note that PFE has not been maintained for quite a while now, just in
case that matters.
(My guess is that the maintainer was fed up with requests for "Y2K
compliant" certification, or perhaps with requests for support.)
It's not a bad editor, though, and it's free, to boot. (One thing I
particularly noticed when I switched to another editor is that PFE's
"run task and capture output" feature allows you to interact with the
program -- you get a console window opening, see the program's output,
and can type in input in response to prompts. What I'm using now doesn't
show the program running and if it wants input, you have a problem.)
Cheers,
Philip
--
Philip Newton <nospam.newton@gmx.li>
That really is my address; no need to remove anything to reply.
If you're not part of the solution, you're part of the precipitate.
------------------------------
Date: 20 Jul 2001 00:05:03 +0100
From: nobull@mail.com
Subject: Re: Insecure dependency in require error?
Message-Id: <u9lmlkuh43.fsf@wcl-l.bham.ac.uk>
Hemant Shah <shah@typhoon.xnet.com> writes:
> Insecure dependency in require while running setuid at
> /s3/gblcode/cob/sec/codedb/CodeDB_COBOL line 19.
> use lib "$ENV{FCICSGBLCODE}/cob/sec/dynlib";
All entries in %ENV are initially tainted. The above code therefore
puts a tainted value into @INC
> require "codedb_lib.pm"; # This is line 19.
This is presumably trying to load codedb_lib.pm from the tainted path.
> I looked at perlsec man page, but was not able to find out how to fix the
> problem.
Launder $ENV{FCICSGBLCODE} - assuming you are totally confident that
no unauthorised person could have set a value there.
use lib "@{[ $ENV{FCICSGBLCODE} =~ /(.*)/ ]}/cob/sec/dynlib";
> How can I find out waht is tainted so I can fix the code.
I do not know of any way to trace the back the cause of a tainting
other than manual analysis.
> Is there other documentation about writing secure code/modules.
May of the luminaries of this group have their own web sites (and
books) of fine tutorials on a range of Perl subjects. I'm sure they
won't miss this chance to plug their wares!
--
\\ ( )
. _\\__[oo
.__/ \\ /\@
. l___\\
# ll l\\
###LL LL\\
------------------------------
Date: 20 Jul 2001 09:39:50 GMT
From: anno4000@lublin.zrz.tu-berlin.de (Anno Siegel)
Subject: Re: Insecure dependency in require error?
Message-Id: <9j8u96$8hu$2@mamenchi.zrz.TU-Berlin.DE>
According to <nobull@mail.com>:
> Hemant Shah <shah@typhoon.xnet.com> writes:
> > Is there other documentation about writing secure code/modules.
>
> May of the luminaries of this group have their own web sites (and
> books) of fine tutorials on a range of Perl subjects. I'm sure they
> won't miss this chance to plug their wares!
Then, of course, there is perldoc perlsec.
Anno
------------------------------
Date: Thu, 19 Jul 2001 23:42:12 -0400
From: Benjamin Goldberg <goldbb2@earthlink.net>
Subject: Re: regexp question
Message-Id: <3B57A894.8DC73D2C@earthlink.net>
Matt D wrote:
>
> there's probably a 'doh! of course!' answer to this, but it's eluding
> me at the moment...
>
> i want to capture a keyword and up to 3 words either side of it from a
> block of text (keyword could potentially be at the beginning, end or
> anywhere in the middle).
>
> my block of text is a single space-delimited list of words.
>
> i can do this:
>
> $text =~ /(\S*\s*\S*\s*\S*\s*)($keyword)(\s*\S*\s*\S*\s*\S*)/i;
> $match = "$1$2$3";
>
> which kind of works but it can be very slow on big lists of words.
> i'm sure there's a much more efficient way to do it.. can some kind
> soul point me in the right direction please?
($match) = $text =~ /((?:\S+\s+){0,3}$keyword(?:\s+\S+){0,3})/;
--
The longer a man is wrong, the surer he is that he's right.
------------------------------
Date: Fri, 20 Jul 2001 09:37:07 +0100
From: "Lee Osborne" <osbornelee@hotmail.com>
Subject: Removing Tags
Message-Id: <995618325.596.0.nnrp-01.c2de1f0e@news.demon.co.uk>
Hi all,
Does someone have some code that removes HTML tags from a string? I don't
want to use a module from cpan. I can use the RE:
/(<[^>]>)/g
To grab any tag available. I have tried to write a recursive aglorithm to
grab sub tags when a tag was found but failed miserably (pride swallowed
here!).
An algorithm or code would be ideal.
Any suggestions or consideration would be appreciated,
Thanks in advance,
Lee.
------------------------------
Date: Fri, 20 Jul 2001 05:53:34 +0200
From: Philip Newton <pne-news-20010720@newton.digitalspace.net>
Subject: Re: Request for Comments ... ConvertColorspace.pm
Message-Id: <1faflts891t84k1v74ktp9ovit0pf0bclo@4ax.com>
On Thu, 19 Jul 2001 10:12:51 -0700, Melissa Niles <mniles@itm.com>
top-posted full-quoted:
> To answer your question, there are 255 values for each RGB color, which
> is 0-254.
I would have thought that there are 256 possible values, from 0..255.
That is, all the possible values that can fit into one byte. Is there a
reason why the value '255' is not permitted?
Cheers,
Philip
--
Philip Newton <nospam.newton@gmx.li>
That really is my address; no need to remove anything to reply.
If you're not part of the solution, you're part of the precipitate.
------------------------------
Date: 20 Jul 2001 08:38:56 +0200
From: Walter Hafner <hafner-usenet@ze.tu-muenchen.de>
Subject: Re: Request for Comments ... ConvertColorspace.pm
Message-Id: <srjr8vcyuin.fsf@w3proj1.ze.tu-muenchen.de>
anno4000@lublin.zrz.tu-berlin.de (Anno Siegel) writes:
> Out of curiosity, is 254 really the correct denominator here? Negative
> $K, and all?
Hmmm ... let's see what I can remember from my "color classification"
time:
There isn't such a thing as THE RGB and THE CMYK color space!
There's linear RGB, gamma corrected RGB, RGB_601, RGB_709 (ITU
standards, the color standards organisation of ISO), and so on. In
technical video e.g., only the values 31-238 (i think. It's been a long
time) of RGB space are used, the rest is capped. That's why "color
management" and "color calibration" in printers and monitors is so
important. The big players (Canon, Kodak, Xerox, ...) all have their own
departments that do nothing beside designing clever ways of colorspace
conversions. :-)
And there's such a thing as "gamut". No, I won't explain it here. :-)
For simple conversions all this isn't necessary of course, but I still
want to mention it. For a full blown conversion module as the OP
intended, it HAS to be taken into consideration!
Have a look at:
http://www.inforamp.net/~poynton/notes/colour_and_gamma/ColorFAQ.html
Especially point 24 !
As I said: Poynton is a very good source to get a basic grasp of
"color". His FAQ shows why PROPER conversions are so complicated!
Regards
-Walter [nitpicking here, I know. But "color" really WAS my main
occupation for a few years]
------------------------------
Date: Fri, 20 Jul 2001 03:43:27 GMT
From: fiveyes@iiiii.com (5-i's)
Subject: Review of Tutorial Critique Appreciated
Message-Id: <3b59a591.144754116@news.msy.bellsouth.net>
I recently encountered an on-line Perl CGI tutorial that I had a
number of misgivings about. The author of it, after being contacted
privately regarding some of the mistakes, has chosen to publicly
attack me. In defense, I am having to publish a detailed accounting
of the problems I found with his work.
Keeping in mind that the critique is meant for an audience that is
(mostly) perl illiterate: If anyone would care to review
http://www.fiveyes.com/ and comment on errors or omissions on my part,
or suggest any changes, I'd appreciate it.
------------------------------
Date: 19 Jul 2001 21:51:27 -0700
From: merlyn@stonehenge.com (Randal L. Schwartz)
Subject: Re: Review of Tutorial Critique Appreciated
Message-Id: <m1wv54td80.fsf@halfdome.holdit.com>
>>>>> "5-i's" == 5-i's <fiveyes@iiiii.com> writes:
5-i's> I recently encountered an on-line Perl CGI tutorial that I had a
5-i's> number of misgivings about. The author of it, after being contacted
5-i's> privately regarding some of the mistakes, has chosen to publicly
5-i's> attack me. In defense, I am having to publish a detailed accounting
5-i's> of the problems I found with his work.
5-i's> Keeping in mind that the critique is meant for an audience that is
5-i's> (mostly) perl illiterate: If anyone would care to review
5-i's> http://www.fiveyes.com/ and comment on errors or omissions on my part,
5-i's> or suggest any changes, I'd appreciate it.
I shouldn't get into this, but after reading two of the eight tutorial
sections for myself, I caught so many errors that I can safely say
that these online tutorials belong in the same category as nearly any
book that has a time unit in them, or perhaps the word "dummies".
Yes, as the phrase goes, "it ain't scottish, it's _____". You can
fill in the blank, I'm sure.
The sad thing is when the blind leads the blind, neither of them see
the oncoming pit of despair. :)
Thanks for the heads up.
--
Randal L. Schwartz - Stonehenge Consulting Services, Inc. - +1 503 777 0095
<merlyn@stonehenge.com> <URL:http://www.stonehenge.com/merlyn/>
Perl/Unix/security consulting, Technical writing, Comedy, etc. etc.
See PerlTraining.Stonehenge.com for onsite and open-enrollment Perl training!
------------------------------
Date: Fri, 20 Jul 2001 11:25:50 +0200
From: Loke <reply-to-group@please.com>
Subject: Search and replace using perl
Message-Id: <2NS57.36$vO5.940@news3.oke.nextra.no>
Hello,
I want to search for a string pattern in several files (several occurances
in file also possible) in several directories and subdirectories, and
replace every occurance with another string.
However, files ending with ,v should not be altered (RCS files) Also,
symlinks should not be followed. I have tried the following, but cannot
make it work properly:
grep -r /local/net-status/mping * | grep -v ,v | xargs perl -i.bak -pe
s%/local/net-status/mping/%/jalla/test%
On alt. would be using just:
perl -i.bak -pe s%/local/net-status/mping/%/jalla/test% * dir1/* dir2/*
and so on. I can then specify what directories to change, and thus avoid
the symlink. But then files ending with ,v would be altered also...
Any suggestions?
Thanks!
------------------------------
Date: Fri, 20 Jul 2001 02:56:07 GMT
From: mgjv@tradingpost.com.au (Martien Verbruggen)
Subject: Re: Strange thing happened today!
Message-Id: <slrn9lf7e7.1rf.mgjv@verbruggen.comdyn.com.au>
On Thu, 19 Jul 2001 00:18:43 GMT,
millside <millettNOSPAM@lblueyonder.co.uk> wrote:
[ATTRIBUTION INSERTED]
> tadmc@augustmail.com (Tad McClellan) wrote:
>> You are looking for the problem in the wrong place.
>>
>> Your problem has nothing to do with Perl.
>>
> No I agree, nothing at all to do with "Perl" you say? shouldn't that be
> "perl"? Just thought I'd share the experience since it was a perl program I
No. It can be either, both meaning something different. If you talk
about a 'Perl program', the first letter should be uppercase. If you
talk about _the_ perl program, it should be lowercase.
Perl FAQ, section 1 explains the difference.
Martien
--
Martien Verbruggen |
Interactive Media Division | In a world without fences, who needs
Commercial Dynamics Pty. Ltd. | Gates?
NSW, Australia |
------------------------------
Date: Thu, 19 Jul 2001 22:36:13 -0600
From: pt <mnemotronic@mind\no-spam/spring.com>
Subject: Re: tab sperated line to named hash?
Message-Id: <3B57B53C.B178507C@mindspring.com>
Twan Kogels wrote:
> Greetings,
>
> How can i optimize the following code snippet:
>
> --------------------------------
> chomp($dataline);
> my @data=split("\t", $dataline);
>
> %forumprop=();
> $forumprop{'forum_title'}=$data[0];
> $forumprop{'bg_header'}=$data[1];
> $forumprop{'tb_normal_tags'}=$data[2];
> $forumprop{'fg_header'}=$data[3];
> $forumprop{'font_name'}=$data[4];
> $forumprop{'font_color'}=$data[5];
> $forumprop{'bg_page'}=$data[6];
> $forumprop{'smiley_extra'}=$data[9];
I suggest an approach that provides mapping information between a
name, like 'forum_title', and the @data array index with which that
value is associated, 0. This information could be after the __END__
token:
__END__
forum_title,0
bg_header,1
tb_normal_tags,2
fg_header,3
font_name,4
font_color,5
bg_page,6
smiley_extra,9
...lots more of these....
#end
Read this with something like
while (<DATA>)
{
last if /^#\s*end/ ;
my ($key,$idx) = split /,/ ;
# here's where you would store $key and $idx .....
}
You now need to provide a data structure that will contain the names
and indices. The type of data structure depends on how you want to get
the data into, and more importantly out of, '%forumprop'.
Possibilities:
1. Make each value of %forumprop a 2 element array. One element
would contain the index of @data, the other element would contain the
actual data. You can then iterate the keys of %forumprop and assign
data from @data. This has the benefit of being self contained, but the
drawback of inefficient data retrieval, since every place you get a data
item must include an array index.
2. An independent data structure (either a hash or array)
containing the name and index. There are several possibilities.
This will allow you to assign all elements of @data using a simple loop,
instead of several hundred assignment lines.
Remove the obvious anti-spam to reply.
------------------------------
Date: Fri, 20 Jul 2001 11:10:27 +0800
From: Peter Tang <peter@perfectlink.com.hk>
Subject: Re: winzip
Message-Id: <3B57A123.22CB4AB9@perfectlink.com.hk>
thanks Bart.
peter
Bart Lateur wrote:
>
> Peter Tang wrote:
>
> >Do you have an idea how can Perl handle files made by winzip. It seems
> >that all the modules available can only unzip files made by gzip etc.
>
> Archive::Zip should do what you want.
>
> --
> Bart.
------------------------------
Date: 6 Apr 2001 21:33:47 GMT (Last modified)
From: Perl-Users-Request@ruby.oce.orst.edu (Perl-Users-Digest Admin)
Subject: Digest Administrivia (Last modified: 6 Apr 01)
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.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 V10 Issue 1340
***************************************