[13813] in Perl-Users-Digest
Perl-Users Digest, Issue: 1223 Volume: 9
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Fri Oct 29 18:05:54 1999
Date: Fri, 29 Oct 1999 15:05:29 -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: <941234728-v9-i1223@ruby.oce.orst.edu>
Content-Type: text
Perl-Users Digest Fri, 29 Oct 1999 Volume: 9 Number: 1223
Today's topics:
"MS VB-like" perl editor? <afalley@emusic.com>
Re: $formdata=~s/\s+$//; ? (Tad McClellan)
*HTML Component timing (TedDaniell)
Re: [offtopic] English <aqumsieh@matrox.com>
adding admin feature to poll script <Paone@mediaone.net>
AP module subroutines not available??? richardstands@my-deja.com
Change group permissions to match user permissions <vtc@us.ibm.com>
close() is expensive <sakalauk@ssc.usm.edu>
Re: Como Puedo trabajar con archivos de Foxpro <cassell@mail.cor.epa.gov>
DBI prepare error when running select stmt slicks78@my-deja.com
Re: decode $ENV{'HTTP_WEFERER'}? <emschwar@rmi.net>
Re: hashing <cassell@mail.cor.epa.gov>
Help with regular expression webmaster@vaticanart.com
How do you compare like grep does? <clarencehj@yahoo.com>
Re: How do you compare like grep does? <theglauber@my-deja.com>
Re: How do you strip spaces? <lr@hpl.hp.com>
Re: How do you strip spaces? (Abigail)
Re: How do you strip spaces? <uri@sysarch.com>
Digest Administrivia (Last modified: 16 Sep 99) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: Fri, 29 Oct 1999 12:50:34 -0700
From: Andreas Falley <afalley@emusic.com>
Subject: "MS VB-like" perl editor?
Message-Id: <3819FA8A.89D8FCEE@emusic.com>
Hi I'm wondering if anybody out there knows of any editor that does
things like keeps an index
of subroutines or methods such that you can just click on one and go to
that part of the
code. That was one thing I always liked about the Visual Basic
environment...uh ...back
when I did that sorta thing and dreamt of working for a company with a
clue....uh before you
start to hiss.
Thanks!
-Andreas
------------------------------
Date: Fri, 29 Oct 1999 10:04:53 -0400
From: tadmc@metronet.com (Tad McClellan)
Subject: Re: $formdata=~s/\s+$//; ?
Message-Id: <5i9cv7.8k.ln@magna.metronet.com>
Yeong Mo/Director Hana co. (hmaster@factory.co.kr) wrote:
: Then, What is for $line=~s/!(\d+)!/$fields[$1]/g; ?
It finds digit characters between exclamation marks and
replaces them with whatever they index in the @fields array.
--
Tad McClellan SGML Consulting
tadmc@metronet.com Perl programming
Fort Worth, Texas
------------------------------
Date: 29 Oct 1999 21:46:34 GMT
From: teddaniell@aol.comIh8spam (TedDaniell)
Subject: *HTML Component timing
Message-Id: <19991029174634.01158.00000139@ng-ch1.aol.com>
I've been looking for a tool that will parse an HTML page, and return the
download times for certain components (images and frames mainly). It seems
that most of the HTML parser articles are in the Perl, so i was wondering if
anyone knows of such programs that will accomplish this.
A nice tool actually exists at http://www.webperfcenter.com/loadtesting.html.
However I don't think the tool is officially released yet and the demo crashes
a lot.
Thanks in advance for your help.
Ted
------------------------------
Date: Fri, 29 Oct 1999 13:15:10 -0400
From: Ala Qumsieh <aqumsieh@matrox.com>
Subject: Re: [offtopic] English
Message-Id: <x3yemee84wx.fsf@tigre.matrox.com>
Stephen Lee - Post replies please <nobody@nowhere.net> writes:
> In article <s0vb2a37r0184@corp.supernews.com>,
> Craig Berry <cberry@cinenet.net> wrote:
> >paranoid (genlabs@gmx.net) wrote:
> >: Craig Berry <cberry@cinenet.net> schrieb in im Newsbeitrag:
> >: s0uk275er0159@corp.supernews.com...
> >: > paranoid (genlabs@gmx.net) wrote:
> >: > : Ì hope anyone of you can answer my question,
> >: > : and mildly ignore it's dumbness .
^^^^
^^^^
^^^^
> >: >
> >: > If and only if you pledge never to place an apostrophe in possessive
> >: > 'its', ever again, so long as you shall live.
> >:
> >: Excuse me ? Is this comp.lang.perl.misc ? I'm relieved , for a moment I
> >: thought it was
> >: alt.languages.english.grammar . Arrogancy could be taken for a lack of
> >: self-esteem...
> >
> >Not arrogance, frustration. If English is not your first language, I
> >apologize. But this simple mistake is becoming infuriatingly common. I
> >did try to phrase my comment in an amusing way. Sorry it didn't come
> >across as intended.
>
> Sorry for being off-topic, but can you explain why you are frustrated?
> I don't see any possessive "its" in the original quote...
I highlighted it for you. Look up :)
--Ala
------------------------------
Date: Fri, 29 Oct 1999 17:30:27 -0400
From: Paone <Paone@mediaone.net>
Subject: adding admin feature to poll script
Message-Id: <381A11F3.FE8C7C4B@mediaone.net>
Hello, i was wondering if someone could help me add an admin feature to
a poll that i got off the net. I want the admin feature to edit these 2
parts of the script. this would be:
# This variable is the question you are asking in your quiz.
$question = "What is most important to you in a website?";
# @choices represents the possible answers people can give. It should
# be formatted as shown.
@choices = ("Design","Content","I don't know");
I would want it to add/change the answers of the poll and change the
question. Here is the are the scripts needed - poll.cgi script:
#!/usr/bin/perl
# This is the "stub file" that contains all the configuration variables
# needed to customize a quiz. You will need one of these for each quiz
# you create -- they'll each call the main file surveysays.pl to do the
# processing.
# This uses the full path to the surveysays.pl script that came with the
# distribution.
require "surveysays.cgi";
# This is the path to the data file the script will use to store
results.
# The script must either have permissions to write to the directory the
# file will be stored in (and it will create the file itself on first
run),
# or you can create the file yourself (as a 0-byte file), and just give
# the script permission to write to the file.
$datafile = "/home/www/datapoll/data.txt";
# If your system can use "flock" for file-locking, leave this variable
set
# to 1. If not, set it to 0. (If you aren't sure, try 1 first and
switch
# to 0 if the script fails.)
$file_lock = 1;
# This is the URL needed to call the script directly.
$script_url = "/poll/poll.cgi";
# This is the "name" of your quiz. It should only be a few words long.
$quiz_name = "Survey";
# These variables control the look of your poll. $top_color is the
color
# at the top of the poll, where the $quiz_name will be. $bot_color is
the
# color of the bottom of the poll. $font_color is the color the text
will
# be, and $font_size is how big it will be. $font_face controls the font
# that is used by the poll. $table_width controls how wide your poll
will
# be (I recommend keeping the default values as given for $font_size and
# $table_width).
$top_color = "#FFBD00";
$font_face="Arial,Helvetica";
$bot_color = "#ffffff";
$font_color = "#000000";
$font_size = "-2";
$table_width = "125";
# This variable is the question you are asking in your quiz.
$question = "What is most important to you in a website?";
# @choices represents the possible answers people can give. It should
# be formatted as shown.
@choices = ("Design","Content","I don't know");
# If $graphical is set to 1, a 'bar graph' of sorts will be printed
along
# side percentages when the results are shown (set it to 0 to report
only
# percentages). If used, $gr_file is the URL to call the "dot" that is
# used to create the bars (feel free to replace the default purple one).
# $gr_height is the height in pixels the bar should be, and $gr_scale
helps
# control the width (when set to 1, an answer with 25% of the vote would
# have a bar 25 pixels wide; if set to 2, 25% would yield a 50 pixel
bar
# and so on).
$graphical = 1;
$gr_file = "/poll/dot.gif";
$gr_scale = 1;
$gr_height = 10;
# If you want the total number of votes received to be reported with the
# results, set this to 1. Else, set it to 0.
$report_total_votes = 1;
# In order to keep people from voting repeatedly, a cached of the most
# recent IPs that voted is kept. A value between 5 and 10 is
recommended.
$ips_cached = 10;
# If your poll is working properly, leave this undefined. As a last
# resort, if your poll consistently puts the results on a separate page,
# define this as the URL of the page containing the poll.
$panic_url = "";
# This variable, if set to 1, may help alleviate problems with browsers
and
# proxy servers caching your page and not displaying poll results. Do
not
# set this to 1 if you have multiple polls on the same page; weird
# behavior will result if you do.
$suppress_cache = 1;
# This variable, if set to 1, adds a second button to the poll, which
# allows the user to see the poll results without voting.
$without_vote = 1;
# Do Not Edit Below This
&SurveySays;
exit;
This is the end of poll.cgi. Now theres another file called
surveysays.cgi which looks like this:
#!/usr/bin/perl
sub SurveySays {
&decode_form;
# Handle First Call To Script
if ((!-e "$datafile") || (-z "$datafile")) {
&initialize_data;
}
# Cache Supression Code
if ($suppress_cache) { $add_on = "?survey";
} else { $add_on = ""; }
# Handle absence of HTTP_REFERER if possible
if ((!$ENV{'HTTP_REFERER'}) && ($panic_url)) {
$ENV{'HTTP_REFERER'} = $panic_url;
}
# If person has already voted, return results
&check_for_vote;
# Take Care of the Vote, if any
if ($ENV{'QUERY_STRING'} eq "voted") {
®ister_vote;
}
# If none of the above, return quiz
&return_quiz;
}
sub initialize_data {
my($numchoices,$i);
$numchoices = @choices;
if ($file_lock) { flock(FILE,2); }
open (FILE, ">$datafile") || die "Couldn't Open data file!";
print FILE "CHOICES|||";
for ($i=1; $i<= $numchoices; $i++) {
print FILE "0";
if ($i != $numchoices) { print FILE "|||"; }
}
print FILE "\nIPS|||";
for ($i=1; $i <= $ips_cached; $i++) {
print FILE "0.0.0.0";
if ($i != $ips_cached) { print FILE "|||"; }
}
if ($file_lock) { flock(FILE,8); }
close (FILE);
}
sub check_for_vote {
my($check1,$check2,@totals,$totals,@ips,$ips,$one);
# Get Data
if ($file_lock) { flock(FILE,1); }
open(FILE,"<$datafile") || &error;
$totals = <FILE>; $totals =~ s/\n$//;
$ips = <FILE>; $ips =~ s/\n$//;
if ($file_lock) { flock(FILE,8); }
close (FILE);
($check1, @totals) = split(/\|\|\|/,$totals);
($check2, @ips) = split(/\|\|\|/,$ips);
# Error Checking
if (($check1 ne "CHOICES") || ($check2 ne "IPS")) { &error; }
foreach $one (@ips) {
if ($one eq $ENV{'REMOTE_ADDR'}) {
if ((($F{'VOTE_CHECK'} eq "voted") || ($F{'RESULTS_ONLY'} eq
"yes")) && ($ENV{'HTTP_REFERER'})) {
$F{'VOTE_CHECK'} = "double";
print "Location: $ENV{'HTTP_REFERER'}?double \n\n";
} else {
&return_results;
}
}
}
}
sub register_vote {
my($check1,$check2,$discard,@ips,@totals,$totals,$numchoices);
# Decode Form
# Get Data
if ($file_lock) { flock(FILE,2); }
open(FILE,"<$datafile") || &error;
$totals = <FILE>; $totals =~ s/\n$//;
$ips = <FILE>; $ips =~ s/\n$//;
if ($file_lock) { flock(FILE,8); }
close (FILE);
($check1, @totals) = split(/\|\|\|/,$totals);
($check2, $discard, @ips) = split(/\|\|\|/,$ips);
# Error Checking
if (($check1 ne "CHOICES") || ($check2 ne "IPS")) { &error; }
$numchoices = @choices;
for ($i=1; $i<=$numchoices; $i++) {
if ($i == $F{'quiz'}) {
$totals[$i-1]++;
last;
}
}
if ($file_lock) { flock(FILE,2); }
open(FILE2,">$datafile") || &error("DF");
print FILE2 "CHOICES|||";
print FILE2 join("|||",@totals), "\n";
print FILE2 "IPS|||";
print FILE2 join("|||",@ips), "|||$ENV{'REMOTE_ADDR'}";
if ($file_lock) { flock(FILE2,8); }
close (FILE2);
print "Location: $ENV{'HTTP_REFERER'}$add_on \n\n";
exit;
}
sub return_quiz {
my($numchoice,$ncinfile,$check,$totals,@totals,$i);
# Get Data
if ($file_lock) { flock(FILE,1); }
open(FILE,"<$datafile") || &error;
$totals = <FILE>;
if ($file_lock) { flock(FILE,8); }
close (FILE);
($check, @totals) = split (/\|\|\|/,$totals);
# Error Checking
if ($check ne "CHOICES") { &error("CHOICE"); }
$numchoice = @choices;
$ncinfile = @totals;
if ($numchoice != $ncinfile) { &error("NUMCHOICE"); }
# Return Table
print "Content-type: text/html", "\n\n";
print "<table border=0 width=$table_width cellspacing=0
cellpadding=2><tr>";
print "<td valign=center align=middle bgcolor=\"$top_color\"><font
face=\"$font_face\" color=\"$font_color\"
size=\"$font_size\"><b>$quiz_name</b></font></td></tr>\n";
print "<tr><td valign=top align=left bgcolor=\"$bot_color\">\n";
print "<font face=\"$font_face\" size=\"$font_size\"
color=\"$font_color\">";
print "$question<p>\n";
print "<form method=post action=\"$script_url?voted\">\n";
print "<input type=hidden name=\"VOTE_CHECK\" value=\"voted\">\n";
for ($i=1; $i<=$numchoice; $i++) {
print "<input type=radio name=quiz value=\"$i\">
$choices[$i-1]<br>\n";
}
print "<p><center><input type=submit
value=\"Vote!\"></center></form><p>\n";
if ($without_vote) {
print "<center><form method=post action=\"$script_url?voted\">\n";
print "<input type=hidden name=\"RESULTS_ONLY\" value=\"yes\">\n";
print "<input type=submit value=\"View
Results\"></form></center><p>\n";
}
print "<center>Copyright (c) 1999 LiveFtp.com<center></center>\n";
print "</font></td></tr></table>\n";
exit;
}
sub return_results {
my($check,$totals,@totals,$ips,@ips,$numchoices,$i,@processed,@raw,$one,$mastertotal,$tmp,$tmp2);
# Get Data
if ($file_lock) { flock(FILE,1); }
open(FILE,"<$datafile") || &error;
$totals = <FILE>; $totals =~ s/\n$//;
if ($file_lock) { flock(FILE,8); }
close (FILE);
($check, @totals) = split(/\|\|\|/,$totals);
# Error Checking
if ($check ne "CHOICES") { &error; }
$numchoices = @choices;
$mastertotal = 0;
for ($i=0; $i<$numchoices; $i++) {
$mastertotal += $totals[$i];
push(@raw,"$totals[$i]|||$choices[$i]");
}
@processed = sort {$a <=> $b} (@raw);
print "Content-type: text/html", "\n\n";
print "<table border=0 width=$table_width cellspacing=0
cellpadding=2><tr>";
print "<td valign=center align=middle bgcolor=\"$top_color\"><font
face=\"$font_face\" color=\"$font_color\"
size=\"$font_size\"><b>$quiz_name</b></font></td></tr>\n";
print "<tr><td valign=top align=left bgcolor=\"$bot_color\">\n";
print "<font face=\"$font_face\" size=\"$font_size\"
color=\"$font_color\">";
print "$question<p>\n";
for ($i=$numchoices-1; $i>=0; $i--) {
($num,$what) = split(/\|\|\|/,$processed[$i]);
$tmp = ($num/$mastertotal) * 100;
$tmp = sprintf("%3.2f",$tmp);
if ($graphical) {
$tmp2 = int($tmp);
print "<img align=absmiddle src=\"$gr_file\" height=$gr_height
width=$tmp2><br>";
}
print "$what: $tmp\%<br>\n";
}
if ($report_total_votes) {
print "<p><center>Total Votes: $mastertotal</center>\n";
}
print "<p><center>Copyright (c) 1999 LiveFtp.com<center>\</center>\n";
print "</font></td></tr></table>\n";
exit;
}
sub error {
print "Content-type: text/html","\n\n";
print "ERROR!! $_[0]";
exit;
}
sub decode_form {
read(STDIN, $buffer, $ENV{'CONTENT_LENGTH'});
@couples = split(/&/, $buffer);
foreach $couple (@couples) {
($called, $equalto) = split(/=/, $couple);
$equalto =~ tr/+/ /;
$equalto =~ s/%([a-fA-F0-9][a-fA-F0-9])/pack("C", hex($1))/eg;
$equalto =~ s/<!--(.|\n)*-->//g;
$equalto =~ s/<([^>]|\n)*>//g;
$F{$called} = $equalto;
}
}
return 1;
Please e-mail me at ma1lbox@aol.com if you can help.
------------------------------
Date: Fri, 29 Oct 1999 21:35:26 GMT
From: richardstands@my-deja.com
Subject: AP module subroutines not available???
Message-Id: <7vd3uu$dhj$1@nnrp1.deja.com>
I looked for questions concerning this problem and although I found
some none seemed to point to specific solutions for my problem(man, I
hope it's not one of those no brainers - I read the book :o) I had Perl
5 for Win32(NT SP4) installed and was not able to call subs from
imported mods such as CARP:
#!/usr/bin/perl -w
BEGIN
{
unshift( @INC,"D:\\Perl\\lib" );
}
use CARP;
croak( "croaking" );
exit 1;
Running this gave this:
Undefined subroutine &main::croak called at test.pl line 7.
Curiously, when I add CGI to it that part works:
#!/usr/bin/perl -w
BEGIN
{
unshift( @INC,"D:\\Perl\\lib\\CGI" );
unshift( @INC,"D:\\Perl\\lib" );
}
use CGI;
use CARP;
my $q = new CGI('');
$q->param('foo','bar');
print $q->param('foo'),"\n";
croak( "croaking" );
exit 1;
Running this gave:
bar
Undefined subroutine &main::croak called at test.pl line 15.
Now I know that CGI is a "true"(right word?) module i.e. CGI objects
can be created/methods called whereas CARP is just a package of
subroutines but I fail to see why I can't get the carp subs to be
called from my script. I would love any help here. Thanks!
-Rich
Sent via Deja.com http://www.deja.com/
Before you buy.
------------------------------
Date: Fri, 29 Oct 1999 17:56:54 -0400
From: Tom Cockerline <vtc@us.ibm.com>
Subject: Change group permissions to match user permissions
Message-Id: <381A1826.1A990D02@us.ibm.com>
Need to change the permissions for all directories and files beneath my
home directory so the group permissions will be the same as the user
permissions.
Can get the mode with stat. Can't figure out how to bit-manipulate it to
get the group bits equal to the user bits, so I can then chmod the file
or directory with the new mode.
I'm running AIX 4.2.1.
------------------------------
Date: Fri, 29 Oct 1999 15:12:30 -0500
From: Peter Sakalaukus <sakalauk@ssc.usm.edu>
Subject: close() is expensive
Message-Id: <3819FFAE.A2EECEC@ssc.usm.edu>
I wrote a script to parse a data file and write out 1 record at a time
to a temporary file. Via a system() call, another program is run with
the temporary file as the input.
By removing the close OUT; statement from my code, it ran significantly
faster. Why is close() so costly?
...Pete
------------------------------
Date: Fri, 29 Oct 1999 14:24:30 -0700
From: David Cassell <cassell@mail.cor.epa.gov>
Subject: Re: Como Puedo trabajar con archivos de Foxpro
Message-Id: <381A108E.FFADD2B4@mail.cor.epa.gov>
Proyecto Conford wrote:
>
> Proyecto Conford wrote in message <7v9vbh$5413@eccws12.dearborn.ford.com>...
> >A quien pueda interesar
> >
> >Necesito para ver quien puede ayudarme con respestos a como manipular
> >archivos DBF, IDX, CDX
If you want to read and write .dbf files, you can use the DBI
module with the DBD::Xbase driver. You can get both using the
ppm program from the ActiveState archives:
ppm install DBI DBD-Xbase
But... this driver does not work with indices.
David
--
David Cassell, OAO cassell@mail.cor.epa.gov
Senior computing specialist
mathematical statistician
------------------------------
Date: Fri, 29 Oct 1999 19:44:54 GMT
From: slicks78@my-deja.com
Subject: DBI prepare error when running select stmt
Message-Id: <7vctfm$8ds$1@nnrp1.deja.com>
I am having a prepare error returned when trying to run a SQL select
statement to SQL Server. The SQL is dynamically generated. Some of the
input is coming from a multi line select box w/ values appended with
commas for parsing. I think this might be some of the problem.
The code:
sub getMemberID
{
local($sMemberIDSql, @Results,$ListofNames,$name);
$ListofNames = shift;
$ListofNames =~ s/,/','/isg;
$ListofNames = "'" . $ListofNames . "'";
$sMemberIDSql = qq|SELECT tblMember.MemberId FROM tblMember
WHERE tblMember.MemberName in ($ListofNames);|;
@Results = &executeSQLStatement($sMemberIDSql);
return @Results;
}
executeSQLStatement performs a DBI prepare and execute statement and
then returns an array of results.
ERROR printed to web page:
SELECT tblMember.MemberId FROM tblMember WHERE tblMember.MemberName in
('Colin Dangel','Darrell Cheng','Douglas McCracken');DBD::ODBC::db
prepare failed: [Microsoft][ODBC SQL Server Driver][SQL Server]Unclosed
quotation mark before the character string ''. (SQL-37000) [Microsoft]
[ODBC SQL Server Driver][SQL Server]Line 1: Incorrect syntax near ''.
(SQL-37000) [Microsoft][ODBC SQL Server Driver][SQL Server]Statement(s)
could not be prepared. (SQL-37000)(DBD: st_prepare/SQLPrepare err=-1)
at C:/Perl/site/lib/Workbench.pl line 503. [Microsoft][ODBC SQL Server
Driver][SQL Server]Unclosed quotation mark before the character string
''. (SQL-37000) [Microsoft][ODBC SQL Server Driver][SQL Server]Line 1:
Incorrect syntax near ''. (SQL-37000) [Microsoft][ODBC SQL Server
Driver][SQL Server]Statement(s) could not be prepared. (SQL-37000)(DBD:
st_prepare/SQLPrepare err=-1)Executive Dashboard
Status Reporting
Key Milestones
Project Planning
Administration
Issue Management
Readiness Assessment
Deliverables Library
Contacts
Calendars
Organization Charts
Sent via Deja.com http://www.deja.com/
Before you buy.
------------------------------
Date: 29 Oct 1999 14:04:19 -0600
From: Eric The Read <emschwar@rmi.net>
Subject: Re: decode $ENV{'HTTP_WEFERER'}?
Message-Id: <xkfu2nac4sc.fsf@valdemar.col.hp.com>
Vadim Kulakov <vadim@sns.ru> writes:
> How can I decode the string (Apache/1.3.4 (Unix)):
> HTTP_WEFERER=HYUCDDJBLVLMHAALPTCXLYRWTQTIPWIGYOKSTT
Use the module HTTP::Wascawwy::Wabbits
-=Eric
--
"Cutting the space budget really restores my faith in humanity. It
eliminates dreams, goals, and ideals and lets us get straight to the
business of hate, debauchery, and self-annihilation."
-- Johnny Hart
------------------------------
Date: Fri, 29 Oct 1999 14:35:26 -0700
From: David Cassell <cassell@mail.cor.epa.gov>
Subject: Re: hashing
Message-Id: <381A131E.56E7A80E@mail.cor.epa.gov>
Jerry Preston wrote:
>
> Tom, the hash is working well. Setting it up is no problem.
> I do not understand who to get $name out if the hash when I
> know the $number. Do you know how??
> I have tried this:
>
> $name = $who{ $number };
>
> But I get nothing. I know that the data exits in the hash.
> I can print it out.
Jerry, I don't understand. You say you can 'print it out',
yet you can't get a result? How are you doing the 'print'
part then? Maybe you could show us the *exact* code [cut-
and-pasted, not copied] and what you get when you run it.
You should be able to do something like:
#!/usr/bin/perl -w
use strict;
my %who = (cat => 'Tom',
mouse => 'Jerry',
dog => 'Spike',
virus => 'David');
my $species = 'mouse';
print $who{$species};
__END__
Are you initializing $number in your example?
David
--
David Cassell, OAO cassell@mail.cor.epa.gov
Senior computing specialist
mathematical statistician
------------------------------
Date: Fri, 29 Oct 1999 20:30:18 GMT
From: webmaster@vaticanart.com
Subject: Help with regular expression
Message-Id: <7vd04q$am9$1@nnrp1.deja.com>
I have recently developed an application for a website that allows
members to email each other using member id's instead of their real
email address. Basically jon@doe.com would be member-5@my_domain.com
and when another member would send an email to member-5@my_domain.com,
the email gets piped to a perl script which parses the email header,
validates the sender and the receiver, replaces the real email address
with a member address and forwards the email along to the real email
address.
Thus far this has worked great, until I discovered a flaw in the
process: if the member replies to an email that was sent, the member's
real email address will be in the quoted reply field, thus since my
program only parses the email header, the real email address gets
emailed along in the body of the message, causing a security hole
(since members do not want their real email addresses released without
their explicit aok)
I thought the simple solution would be to take the @body_msg and do a
substitution of the real email address for the member email address
throughout the entire body.....but... if a member actually WANTED to
send their real email address along to another member...yup, it would
get replaced. Then I tried the following reg exp:
$z =~ s/(To:.*)$from_email/$1$from/s;
But this does not seem to work correctly. I believe the problem is
because that email can be in text or html:
To: jon@doe.com -could really be- <b>To:</b> <a
href="mailto:jon@doe.com">jon@doe.com</a> etc...,etc..,etc..
Does anyone have a good solution for this? Do I have to conceive of
every possible To: format and then accomodate this in the reg exp ?
Also, should I loop through the @body_msg with a foreach $z, or should
I assign $z to @body_msg with a join for doing the reg exp ?
Any help with this is greatly appreciated.
~Jason
Sent via Deja.com http://www.deja.com/
Before you buy.
------------------------------
Date: Fri, 29 Oct 1999 19:47:57 GMT
From: Coolc <clarencehj@yahoo.com>
Subject: How do you compare like grep does?
Message-Id: <7vctlc$8gm$1@nnrp1.deja.com>
Is is possible to do a grep like search in perl. I mean,
I want to see if the value of $value is anywhere in the
line $line. But the sytax below doesnt work.
open INFILE, "$inputfile" or die "$inputfile : $!";
while ( $line = <INFILE> ) {
if ($value =~ /$line/ ) {
$line=~s/rti[0-9]/YYYYYY/g;
print "line = $line ";
}
}
close INFILE;
Thanks!!
clarencehj@yahoo.com
Sent via Deja.com http://www.deja.com/
Before you buy.
------------------------------
Date: Fri, 29 Oct 1999 20:28:28 GMT
From: The Glauber <theglauber@my-deja.com>
Subject: Re: How do you compare like grep does?
Message-Id: <7vd017$acp$1@nnrp1.deja.com>
In article <7vctlc$8gm$1@nnrp1.deja.com>,
Coolc <clarencehj@yahoo.com> wrote:
> Is is possible to do a grep like search in perl. I mean,
> I want to see if the value of $value is anywhere in the
> line $line. But the sytax below doesnt work.
>
> open INFILE, "$inputfile" or die "$inputfile : $!";
> while ( $line = <INFILE> ) {
> if ($value =~ /$line/ ) {
I think you got it backwards. It should be:
if ($line =~ /$value/o) {
[...]
HTH
--
Glauber Ribeiro
theglauber@my-deja.com
"Opinions stated are my own and not representative of Experian"
Sent via Deja.com http://www.deja.com/
Before you buy.
------------------------------
Date: Fri, 29 Oct 1999 13:01:37 -0700
From: Larry Rosler <lr@hpl.hp.com>
Subject: Re: How do you strip spaces?
Message-Id: <MPG.12839cfd70e83a4398a15d@nntp.hpl.hp.com>
[Rearranged so question precedes response, as in all normal human
discourse.]
In article <7vcg98$tvl$1@nnrp1.deja.com> on Fri, 29 Oct 1999 15:59:38
GMT, dragnovich@my-deja.com <dragnovich@my-deja.com> says...
> In article <Pine.LNX.4.10.9910290858360.22062-100000@fnord.io.com>,
> Poohba <poohba@io.com> wrote:
> > I am trying to strip all spaces more than one. I want to delete all
> > of the spaces except for one space. How is this done?
<SNIP> of gratuitously requoted signature
> It is simple try:
>
> while($string =~ / /) { $string =~ s/ / /g; }
Well, indeed it is a simple try, and at least it works correctly. But
there are Better (i.e., much faster) Ways To Do It.
#!perl -w
use strict;
use Benchmark;
use vars '$x';
$x = ' x y z w ';
timethese(1 << (shift || 0), {
Regex0 => 'my $string = $x;
while ($string =~ / /) { $string =~ s/ / /g; }',
Regex1 => '(my $string = $x) =~ s/ +/ /g',
Tr => '(my $string = $x) =~ tr/ //s',
});
__END__
Benchmark: timing 65536 iterations of Regex0, Regex1, Tr...
Regex0: 7 wallclock secs ( 7.28 usr + 0.00 sys = 7.28 CPU)
Regex1: 0 wallclock secs ( 1.47 usr + 0.00 sys = 1.47 CPU)
Tr: 1 wallclock secs ( 0.59 usr + 0.00 sys = 0.59 CPU)
> --
If you put a magic invisible space after those dashes, well-behaved
newsreaders will automatically strip your signature, which is what
should happen.
...
--
(Just Another Larry) Rosler
Hewlett-Packard Laboratories
http://www.hpl.hp.com/personal/Larry_Rosler/
lr@hpl.hp.com
------------------------------
Date: 29 Oct 1999 16:50:33 -0500
From: abigail@delanet.com (Abigail)
Subject: Re: How do you strip spaces?
Message-Id: <slrn81k5ka.66b.abigail@alexandra.delanet.com>
Poohba (poohba@io.com) wrote on MMCCL September MCMXCIII in
<URL:news:Pine.LNX.4.10.9910290858360.22062-100000@fnord.io.com>:
<> I am trying to strip all spaces more than one. I want to delete all of
<> the spaces except for one space. How is this done?
s/ (.*)/;
local $_ = $1;
y; ;;d;
$_;
/xs;
Abigail
--
perl -wle 'print "Prime" if ("m" x shift) !~ m m^\m?$|^(\m\m+?)\1+$mm'
-----------== Posted via Newsfeeds.Com, Uncensored Usenet News ==----------
http://www.newsfeeds.com The Largest Usenet Servers in the World!
------== Over 73,000 Newsgroups - Including Dedicated Binaries Servers ==-----
------------------------------
Date: 29 Oct 1999 18:04:44 -0400
From: Uri Guttman <uri@sysarch.com>
Subject: Re: How do you strip spaces?
Message-Id: <x7ogdhdds3.fsf@home.sysarch.com>
>>>>> "A" == Abigail <abigail@delanet.com> writes:
A> s/ (.*)/;
A> local $_ = $1;
A> y; ;;d;
A> $_;
A> /xs;
^^
shouldn't the modifier be sex?
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: 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 1223
**************************************