[18553] in Perl-Users-Digest
Perl-Users Digest, Issue: 721 Volume: 10
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Thu Apr 19 14:11:01 2001
Date: Thu, 19 Apr 2001 11:10:16 -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: <987703816-v10-i721@ruby.oce.orst.edu>
Content-Type: text
Perl-Users Digest Thu, 19 Apr 2001 Volume: 10 Number: 721
Today's topics:
Placing text over a gif to create new gif? (Ted Wart)
Re: Placing text over a gif to create new gif? <gus@black.hole-in-the.net>
problem <mattegg@globalnet.co.uk>
problem <mattegg@globalnet.co.uk>
Re: Regular Expressions (again) <mjcarman@home.com>
Re: Regular Expressions (again) (Tad McClellan)
Re: Regular Expressions (again) (Christopher Pound)
seeking craps (dice game) perl script phil@NOSPAMbestlit.com
Re: subroutine prototypes and require question <bart.lateur@skynet.be>
Suggestions for "OR" compares??? (Bob Mariotti)
Re: Suggestions for "OR" compares??? <thelma@alpha2.csd.uwm.edu>
Re: Suggestions for "OR" compares??? <bart.lateur@skynet.be>
Re: Suggestions for "OR" compares??? <mjcarman@home.com>
Re: Suggestions for "OR" compares??? <bart.lateur@skynet.be>
Re: Suggestions for "OR" compares??? nobull@mail.com
Uploading Files via HTTP under NT <s.warhurst@rl.ac.uk>
Re: Using boundaries within regexps <g_adams27@hotSPAMISBADmail.com>
Re: using Unicode::String -- ordinals <bart.lateur@skynet.be>
Re: using Unicode::String -- ordinals <motivus_BLAHdiBLAH@hotmail.com>
Re: using Unicode::String -- ordinals <motivus_BLAHdiBLAH@hotmail.com>
Re: using Unicode::String -- ordinals <motivus_BLAHdiBLAH@hotmail.com>
Re: using Unicode::String -- ordinals <bart.lateur@skynet.be>
Re: using Unicode::String -- ordinals <motivus_BLAHdiBLAH@hotmail.com>
Re: using Unicode::String -- ordinals <bart.lateur@skynet.be>
Re: verifying write to file using "tie" nobull@mail.com
want to format and email web page form (anonymous)
Re: want to format and email web page form <bcoon@sequenom.com>
What is wrong here? <bcoon@sequenom.com>
Re: What is wrong here? <hillr@ugs.com>
Re: What is wrong here? <joe+usenet@sunstarsys.com>
Re: Why Perl? <cyberjeff@sprintmail.com>
Re: Why Perl? (Tad McClellan)
Re: workaround for sourcing file from perlscript <r.diwan@india.ti.com>
xoring bits <tom@hotversion.com>
Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: Thu, 19 Apr 2001 13:41:41 GMT
From: t_wart@hotmail.com (Ted Wart)
Subject: Placing text over a gif to create new gif?
Message-Id: <3adee9f7.251777181@netnews.worldnet.att.net>
Howdy,
I'm looking for a tool that will allow me to
read in a graphic image, place text on top of it as a
label and write the graphic out to a new file. Gif/Jpeg/
maybe tiff are acceptable formats. Any one know of a
module or method that'd facilitate this? TIA, TW
---------------------------------------------------------
Ted Wart t_wart@hotmail.com
Government Tech. Support/AUAAC - Austin-818 extention 121
---------------------------------------------------------
------------------------------
Date: Thu, 19 Apr 2001 15:07:56 GMT
From: Gus <gus@black.hole-in-the.net>
Subject: Re: Placing text over a gif to create new gif?
Message-Id: <987692876.11198.0.nnrp-14.c29f015a@news.demon.co.uk>
Ted Wart <t_wart@hotmail.com> wrote:
>
> I'm looking for a tool that will allow me to
> read in a graphic image, place text on top of it as a
> label and write the graphic out to a new file. Gif/Jpeg/
> maybe tiff are acceptable formats. Any one know of a
> module or method that'd facilitate this? TIA, TW
LDS's 'GD' and ImageMagic will both allow you to do this. See CPAN.
--
gus@black.hole-in-the.net
0x58E18C6D
82 AA 4D 7F D8 45 58 05 6D 1B 1A 72 1E DB 31 B5
http://black.hole-in-the.net/gus/
------------------------------
Date: Thu, 19 Apr 2001 15:36:57 +0100
From: "Matt" <mattegg@globalnet.co.uk>
Subject: problem
Message-Id: <tdu76pqcde6oe5@xo.supernews.co.uk>
I am setting up a ezine and have 2 problems. I have installed the script but
cannot have a non-browser-accesable space to store the email addresses and
password file, whats the best way to protect this data now? can you
recommend any good scripts (free if possible)
the second area i need help in is as follows :- i need to send mailings
automatically, randomly picking a joke (for it a joke ezine!) from a text
file, and then sending it to the jokes however all the scripts i have found
for mailing lists require you to type the mail in and then press send... a
lot of hastle. anybody got a link to a script I can modify- any ideas?
andbody have a good link where i can "bone-up" on the CRON daemon ?
Thanks a lot you lovely helpful people :p
matt (who would owe you one for your help)
------------------------------
Date: Thu, 19 Apr 2001 18:15:33 +0100
From: "Matt" <mattegg@globalnet.co.uk>
Subject: problem
Message-Id: <tdu76s5m9cpqe6@xo.supernews.co.uk>
I am setting up a ezine and have 2 problems. I have installed the script but
cannot have a non-browser-accesable space to store the email addresses and
password file, whats the best way to protect this data now? can you
recommend any good scripts (free if possible)
the second area i need help in is as follows :- i need to send mailings
automatically, randomly picking a joke (for it a joke ezine!) from a text
file, and then sending it to the jokes however all the scripts i have found
for mailing lists require you to type the mail in and then press send... a
lot of hastle. anybody got a link to a script I can modify- any ideas?
andbody have a good link where i can "bone-up" on the CRON daemon ?
Thanks a lot you lovely helpful people :p
matt (who would owe you one for your help)
------------------------------
Date: Thu, 19 Apr 2001 08:02:58 -0500
From: Michael Carman <mjcarman@home.com>
Subject: Re: Regular Expressions (again)
Message-Id: <3ADEE202.4ACD979E@home.com>
S Warhurst wrote:
>
> I have a string of data in the following format:
>
> -----------------
> person1@RHUL.AC.UK John Smith1 3AEAQABWEBWG////
> person2@SALFORD.AC.UK John Smith2
> 3AEAQABWmBVI//// person3@EXETER.AC.UK John Smith3
> 3AEAQABWmBVI//// person4@BATHSPA.AC.UK John Smith4
> 3AFAQABWrBWt//// person5@ASTON.AC.UK John Smith5
> -----------------
Er, are you sure it's a string (the whole thing in one big scalar!) or
is it a file?
> What I want to do is extract JUST the email addresses
Okay, so we'll drop the name and the 3A.../// stuff.
> [...] there are thousands of addresses to pull out of various files.
So we do have files.
> With regular expressions, I *guess* I would need to extract all the
> email addresses (and delimit them somehow), then split the string
> into an array.
Now you're back to a string again. Are you slurping the file? If so,
why?
> Can you tell me the regular expression would do this?
Here's a simple example which should be easily adaptable to your
situation. All it does is copy out the non-whitespace chars around the @
symbol.
#!/usr/local/bin/perl5 -w
use strict;
while (<DATA>) {
(my $email) = (/(\S+@\S+)/);
print $email, "\n";
}
__DATA__
person1@RHUL.AC.UK John Smith1 3AEAQABWEBWG////
person2@SALFORD.AC.UK John Smith2
3AEAQABWmBVI//// person3@EXETER.AC.UK John Smith3
3AEAQABWmBVI//// person4@BATHSPA.AC.UK John Smith4
3AFAQABWrBWt//// person5@ASTON.AC.UK John Smith5
-mjc
------------------------------
Date: Thu, 19 Apr 2001 08:57:54 -0400
From: tadmc@augustmail.com (Tad McClellan)
Subject: Re: Regular Expressions (again)
Message-Id: <slrn9dto6i.2pd.tadmc@tadmc26.august.net>
nobull@mail.com <nobull@mail.com> wrote:
>my @addresses = $string =~ /(\S+\@\S+)/sg;
^
^ a distracting NO-OP
--
Tad McClellan SGML consulting
tadmc@augustmail.com Perl programming
Fort Worth, Texas
------------------------------
Date: 19 Apr 2001 14:57:12 GMT
From: pound@is.rice.edu (Christopher Pound)
Subject: Re: Regular Expressions (again)
Message-Id: <9bmuc8$nkt$1@joe.rice.edu>
In article <9bjsd8$18m0@newton.cc.rl.ac.uk>,
S Warhurst <s.warhurst@rl.ac.uk> wrote:
>I have a string of data in the following format:
>-----------------
>person1@RHUL.AC.UK John Smith1 3AEAQABWEBWG////
>person2@SALFORD.AC.UK John Smith2
>3AEAQABWmBVI//// person3@EXETER.AC.UK John Smith3
Is this a LISTSERV list? I believe the fullname field could theoretically
contain an @ sign or email address (most often as a result of subscriber
error, but it could be intentional). IIRC, listserv subscriptions are really
undelimited fixed-length (100 character?) records in which the first field
always contains the email address and the last field always contains
subscription details, everything in between being the fullname field.
So, a general solution would take that into account.
--
Christopher Pound (pound@rice.edu)
Dept. of Anthropology, Rice University
------------------------------
Date: Thu, 19 Apr 2001 17:10:08 GMT
From: phil@NOSPAMbestlit.com
Subject: seeking craps (dice game) perl script
Message-Id: <QZED6.3170$D4.311574@www.newsranger.com>
Does anyone have an old perl script lying around that allows you to play craps?
I don't care if the interface sucks, I really just want to modify the script to
test different strategies.
Surely someone did this for an old computer science project or something...
thanks,
Phil
ps. Remove NOSPAM for a working email address.
------------------------------
Date: Thu, 19 Apr 2001 13:21:23 GMT
From: Bart Lateur <bart.lateur@skynet.be>
Subject: Re: subroutine prototypes and require question
Message-Id: <4hptdt0af23lj03be1tl2bt6isk9k19brf@4ax.com>
David Donovan wrote:
>I'm trying to place a subroutine definition with prototypes like
>
>sub mysub(\%) {
> perl code here;
>}
>
>in a separate file which will be "require"d by my main perl script.
>however,
>it seems that in order for the subroutine to work, i need to declare it
>first before i use it in the main script,
Yes and no. Your error is in that "require". Use "use" instead. So yes,
you'll have to replace a ".pl" extension for the file with ".pm", but
there's nothing more to it.
The problem is, of course, that perl needs to know about the subroutine
prototype *before* compiling the rest of the script. With "require", the
library file is only loaded at runtime, which is too late. "use" fixes
that.
--
Bart.
------------------------------
Date: Thu, 19 Apr 2001 13:37:46 GMT
From: bobm@financialdatacorp.com (Bob Mariotti)
Subject: Suggestions for "OR" compares???
Message-Id: <3adee9a9.7119454@news.earthlink.net>
I have been using perl for about 4-5 years now and just love it.
However, I have always been confused about how to code a comparison
for an OR condition so I thought I would ask some opinions. The FAQ's
are not that clear on this issue.
Lets say there is a field called $FIELD and it can have a value of "A"
or "B" or even "C" but anything else might be in there.
How would one code a logic block that states:
If $FIELD is EQ to either "A" or "B" or "C" then do this block.
There's got to be a simpler way than what I have been using.
Thanks for your suggestions....
------------------------------
Date: 19 Apr 2001 14:25:21 GMT
From: Thelma Lubkin <thelma@alpha2.csd.uwm.edu>
Subject: Re: Suggestions for "OR" compares???
Message-Id: <9bmsgh$eui$1@uwm.edu>
Bob Mariotti <bobm@financialdatacorp.com> wrote:
: Lets say there is a field called $FIELD and it can have a value of "A"
: or "B" or even "C" but anything else might be in there.
: How would one code a logic block that states:
: If $FIELD is EQ to either "A" or "B" or "C" then do this block.
: There's got to be a simpler way than what I have been using.
: Thanks for your suggestions....
I think you're looking for a regular expression match:
the code below matches only if the field value contains
a or b or c and nothing else.
#!/usr/bin/perl -w
use strict;
my @fields = ('hereiam','a','b'); ## Possible field values
foreach (@fields)
{ my $result = ($_ =~/^(a|b|c)$/) ? ## ok only if fieldvalue begins:^ w/
'succeeds':'fails'; ## a,b or c & ends:$ there too
print "$_ $result\n";
if($result eq 'fails') ## Just to illustrate an if in use
{ print "...too bad\n"; }
}
--thelma
------------------------------
Date: Thu, 19 Apr 2001 15:07:56 GMT
From: Bart Lateur <bart.lateur@skynet.be>
Subject: Re: Suggestions for "OR" compares???
Message-Id: <bjvtdt8fh8qf4gegd7jtgqtca1vm3p1i2f@4ax.com>
Bob Mariotti wrote:
>Lets say there is a field called $FIELD and it can have a value of "A"
>or "B" or even "C" but anything else might be in there.
>
>How would one code a logic block that states:
>
>If $FIELD is EQ to either "A" or "B" or "C" then do this block.
Using a hash?
%accept = ( A => 1, B => 1, C => 1);
if($accept{$FIELD}) {
print "Accepted!\n";
}
You can either use different hash values for different conditions, or go
even a step further, and use a reference to the code to execute.
$accept{A} = $accept{B} = $accept{C} = sub {
print "Accepted!\n";
}; #don't forget the semicolon
&{$accept{$FIELD} || sub {} };
# or:
($accept{$FIELD} || sub {})->();
--
Bart.
------------------------------
Date: Thu, 19 Apr 2001 11:06:41 -0500
From: Michael Carman <mjcarman@home.com>
Subject: Re: Suggestions for "OR" compares???
Message-Id: <3ADF0D11.666C4871@home.com>
Bob Mariotti wrote:
>
> I have always been confused about how to code a comparison
> for an OR condition so I thought I would ask some opinions.
> The FAQ's are not that clear on this issue.
>
> Lets say there is a field called $FIELD and it can have a value of "A"
> or "B" or even "C" but anything else might be in there.
>
> How would one code a logic block that states:
>
> If $FIELD is EQ to either "A" or "B" or "C" then do this block.
Heh, you want a syntax that will DWIM this:
if ($field eq 'A' || 'B' || 'C') {
# ...
}
Perl doesn't, of course. That parses as
if (($field eq 'A') || 'B' || 'C') {
# ...
}
which isn't what you want here.
> There's got to be a simpler way than what I have been using.
The straightforward solution is this:
if ($field eq 'A' ||
$field eq 'B' ||
$field eq 'C' ) {
# ...
}
That's is how I usually do it. Using a regex may look neater:
if ($field =~ /^(?:A|B|C)$/) {
#...
}
but it gets messy with longer strings. I'd expect it to be slower as
well due to the alternation. You can benchmark it if you're curious. Use
regexes for pattern matches, not for exact matches.
As another option, it's trivial to write a subroutine to do this for
you:
sub any_of {
my $var = shift;
my @values = @_;
foreach (@values) {
return(1) if $var eq $_;
}
}
if (any_of($field, 'A', 'B', 'C')) {
# ...
}
There are other solutions for special cases. For your example (which has
only single-character values to match against):
if ($field =~ tr/ABC/ABC/) {
#...
}
If you really want to have fun, look into the Quantum::Superpositions
module.
-mjc
------------------------------
Date: Thu, 19 Apr 2001 16:59:38 GMT
From: Bart Lateur <bart.lateur@skynet.be>
Subject: Re: Suggestions for "OR" compares???
Message-Id: <pb6udt0f0621q80f4gc3upi3ckteiu8ock@4ax.com>
Michael Carman wrote:
>sub any_of {
> my $var = shift;
> my @values = @_;
> foreach (@values) {
> return(1) if $var eq $_;
> }
>}
if(grep { $field eq $_ } 'A', 'B', 'C') {
...
}
and don't start those nonsense of grep() doing too much work, again.
Yes, grep() does indeed count the number of matches. If it's not there,
this makes no difference.
--
Bart.
------------------------------
Date: 19 Apr 2001 17:57:41 +0100
From: nobull@mail.com
Subject: Re: Suggestions for "OR" compares???
Message-Id: <u9ae5cg73u.fsf@wcl-l.bham.ac.uk>
bobm@financialdatacorp.com (Bob Mariotti) writes:
> I have been using perl for about 4-5 years now and just love it.
> However, I have always been confused about how to code a comparison
> for an OR condition so I thought I would ask some opinions. The FAQ's
> are not that clear on this issue.
When you say "are not that clear on this issue" could you be more
precise about exactly what part of the wording you find unclear - that
way we may be able to do something about it.
> Lets say there is a field called $FIELD and it can have a value of "A"
> or "B" or even "C" but anything else might be in there.
>
> How would one code a logic block that states:
>
> If $FIELD is EQ to either "A" or "B" or "C" then do this block.
I'll assume you don't want pedantic the answer:
$FIELD =~ /^[A-C]$/
So it would appear your question is "How can I tell whether a value is
one of the ones in a certain list?".
This is, of course, exactly equivalent to the FAQ "How can I tell
whether a list or array contains a certain element?"
If this is your question please can you explain what part of the
wording in the FAQ answer do you find unclear?
--
\\ ( )
. _\\__[oo
.__/ \\ /\@
. l___\\
# ll l\\
###LL LL\\
------------------------------
Date: Thu, 19 Apr 2001 16:37:17 +0100
From: "S Warhurst" <s.warhurst@rl.ac.uk>
Subject: Uploading Files via HTTP under NT
Message-Id: <9bn0o6$1a2k@newton.cc.rl.ac.uk>
Hi
I have searched all over the place for this but am having problems finding
anything. Everywhere I look I see scripts for uploading files, but they are
all big scripts with various options to exclude extensions, password
protection, html for reporting differennt error conditions.
All I want is the basic core code to upload a file under NT, so I can
understand exactly how it works. I managed to strip one of those
aforementioned scripts down to the basic components, but it doesn't work
properly. Here it is:
The box on the HTML page is named "FILE" and the file to upload is, say,
"data.txt"
sub upload()
{
use CGI qw(:cgi-lib);
&ReadParse;
$file = $in{FILE};
open (OUTFILE, ">c:\working\data.txt");
binmode(OUTFILE);
while ($bytesread = read($file, $buffer, 1024))
{
print OUTFILE $buffer;
}
close (OUTFILE);
}
Now that code actually creates the output file "data.txt" but it doesn't
contain any bytes. Cna you tell me what I am doing wrong please?
Thanks
Spencer
------------------------------
Date: Thu, 19 Apr 2001 10:42:36 -0400
From: "George Adams" <g_adams27@hotSPAMISBADmail.com>
Subject: Re: Using boundaries within regexps
Message-Id: <9bmtgu$h3m$1@taliesin.netcom.net.uk>
> try a zero-width lookahead:
Excellent! Thanks to xris and Craig for the lookahead information - another
good tool to add to my Perl toolbox.
> And not to criticize your html, but you really should close those
> <option> tags with </option>, just to make sure that all browsers handle
> them properly (I know it's not required, but it's a good idea).
Customer's HTML, not mine. You should see what ELSE I have to work with.
:-(
------------------------------
Date: Thu, 19 Apr 2001 13:12:48 GMT
From: Bart Lateur <bart.lateur@skynet.be>
Subject: Re: using Unicode::String -- ordinals
Message-Id: <8sotdt4v3ul6cvadk61h3cdn9fgmm9jhnc@4ax.com>
Alan J. Flavell wrote:
>I understand that you're attempting to represent masculine ordinals in
>your posting. Apparently you are mistaken: the original contains
>feminine ordinals.
>
>> This correctly transliterated most of the characters; however, the ordinals
>> got turned into these:
>>
>> 6ª Calle entre 3ª y 4ª Avenidas, Zona 1
>
>Feminine ordinals, as in the original.
>
>> Does anyone know how I can properly convert these ordinal characters as well
>> as the other Latin-1 chars?
>
>It seems you already did.
So it's time to pull in some text correcting tricks.
s/(?<=\d)\xAA/\xBA/g;
Ain't Perl nice.
--
Bart.
------------------------------
Date: 19 Apr 2001 16:41:19 GMT
From: "bmm" <motivus_BLAHdiBLAH@hotmail.com>
Subject: Re: using Unicode::String -- ordinals
Message-Id: <9bn4ff$mr0@dispatch.concentric.net>
"Alan J. Flavell" wrote in message
news:Pine.LNX.4.30.0104191403530.12952-100000@lxplus003.cern.ch...
> > Does anyone know how I can properly convert these ordinal characters as
well
> > as the other Latin-1 chars?
>
> It seems you already did.
>
what do you know! i guess i did. and thanks for the spanish lesson.
brian
------------------------------
Date: 19 Apr 2001 16:52:03 GMT
From: "bmm" <motivus_BLAHdiBLAH@hotmail.com>
Subject: Re: using Unicode::String -- ordinals
Message-Id: <9bn53j$mqp@dispatch.concentric.net>
"Bart Lateur" wrote in message
news:8sotdt4v3ul6cvadk61h3cdn9fgmm9jhnc@4ax.com...
> >I understand that you're attempting to represent masculine ordinals in
> >your posting. Apparently you are mistaken: the original contains
> >feminine ordinals.
> >
> >> This correctly transliterated most of the characters; however, the
ordinals
> >> got turned into these:
> >>
> >> 6ª Calle entre 3ª y 4ª Avenidas, Zona 1
> >
> >Feminine ordinals, as in the original.
> >
> >> Does anyone know how I can properly convert these ordinal characters as
well
> >> as the other Latin-1 chars?
> >
> >It seems you already did.
>
> So it's time to pull in some text correcting tricks.
>
> s/(?<=\d)\xAA/\xBA/g;
>
> Ain't Perl nice.
>
I don't understand. What's to correct? I've put this line in my code... just
to see what it does... and I don't see any difference in the transliterated
text. What does this do? (I'm not yet fluent in RegEx-ese.)
brian
------------------------------
Date: 19 Apr 2001 16:54:16 GMT
From: "bmm" <motivus_BLAHdiBLAH@hotmail.com>
Subject: Re: using Unicode::String -- ordinals
Message-Id: <9bn57o$mr1@dispatch.concentric.net>
"Alan J. Flavell" wrote in message
news:Pine.LNX.4.30.0104191403530.12952-100000@lxplus003.cern.ch...
> I understand that you're attempting to represent masculine ordinals in
> your posting. Apparently you are mistaken: the original contains
> feminine ordinals.
>
> > This correctly transliterated most of the characters; however, the
ordinals
> > got turned into these:
> >
> > 6ª Calle entre 3ª y 4ª Avenidas, Zona 1
>
> Feminine ordinals, as in the original.
>
> > Does anyone know how I can properly convert these ordinal characters as
well
> > as the other Latin-1 chars?
>
> It seems you already did.
>
So, does this mean that it is pointless for me to use the Unicode::String
module, since I can achieve the desired transliteration with
tr/\0-\x{FF}//UC; # UTF-8 to latin1 (8-bit)
?
Brian
------------------------------
Date: Thu, 19 Apr 2001 17:03:39 GMT
From: Bart Lateur <bart.lateur@skynet.be>
Subject: Re: using Unicode::String -- ordinals
Message-Id: <ih6udtcgnasiptp4ssvsktc4fgiqq77igs@4ax.com>
bmm wrote:
>> s/(?<=\d)\xAA/\xBA/g;
>>
>> Ain't Perl nice.
>>
>
>I don't understand. What's to correct? I've put this line in my code... just
>to see what it does... and I don't see any difference in the transliterated
>text. What does this do? (I'm not yet fluent in RegEx-ese.)
It does assume that your text is in $_. And it turns "ª" into "º", but
only if it immediately follows a digit. For those who can't see those
special characters: the former is a tiny "a", the latter a tiny "o".
--
Bart.
------------------------------
Date: 19 Apr 2001 17:41:45 GMT
From: "bmm" <motivus_BLAHdiBLAH@hotmail.com>
Subject: Re: using Unicode::String -- ordinals
Message-Id: <9bn80p$mqm@dispatch.concentric.net>
"Bart Lateur" wrote in message
> >> s/(?<=\d)\xAA/\xBA/g;
> >
> >I don't understand. What's to correct? I've put this line in my code...
just
> >to see what it does... and I don't see any difference in the
transliterated
> >text. What does this do? (I'm not yet fluent in RegEx-ese.)
>
> It does assume that your text is in $_. And it turns "ª" into "º", but
> only if it immediately follows a digit. For those who can't see those
> special characters: the former is a tiny "a", the latter a tiny "o".
>
So what are the rules for using "ª" or "º"? The regex will convert a
feminine ordinal to a masculine one when the feminine ordinal follows a
digit, but that is the situation I have: feminine ordinals following digits.
Not to be dense, but I still don't understand the correction angle.
Brian
------------------------------
Date: Thu, 19 Apr 2001 17:56:56 GMT
From: Bart Lateur <bart.lateur@skynet.be>
Subject: Re: using Unicode::String -- ordinals
Message-Id: <ql9udts1tu8isntdksb12nltsufuh23or3@4ax.com>
bmm wrote:
>So what are the rules for using "ª" or "º"? The regex will convert a
>feminine ordinal to a masculine one when the feminine ordinal follows a
>digit, but that is the situation I have: feminine ordinals following digits.
>
>Not to be dense, but I still don't understand the correction angle.
Well, *you* complained that you got feminine ordinals ("a") following
digits, and that you wanted masculine ordinals ("o") instead. so this is
what this gives you. I'm pretty sure you probably don't want *every*
instance of the feminine ordinals replaced. That's why I built in the
limitation.
--
Bart.
------------------------------
Date: 19 Apr 2001 18:00:58 +0100
From: nobull@mail.com
Subject: Re: verifying write to file using "tie"
Message-Id: <u966g0g6yd.fsf@wcl-l.bham.ac.uk>
Kim C <kimmfc@mydeja.com> writes:
> Is there a way to verify whether or not a tied hash has successfully
> been able to write to a file?
Never tried it myself but according to the manual:
if ( tied(%hash)->sync ) { warn "Error writing %hash to disk: $!" }
(This assumes that the hash is tied via a DB_File derived object).
Sic: the DB_File methods return true on failure!
--
\\ ( )
. _\\__[oo
.__/ \\ /\@
. l___\\
# ll l\\
###LL LL\\
------------------------------
Date: Thu, 19 Apr 2001 16:17:33 GMT
From: quikscor@ix.netcom.com (anonymous)
Subject: want to format and email web page form
Message-Id: <3adf0f95.3496490@nntp.ix.netcom.com>
The form in question is at
http://geocities.com/barakatwo/contact.htm
When the user chooses 'buyer' or 'seller,' I want the irrelevant parts
of the form to be disabled. Like if 'seller' is chosen, then 'my
price range' would be disabled. Can this be done with Perl, or do I
need to go to the JavaScript board?
Then, I want to email the form to the owner of the site. I want to
add a little formatting. Right now, I'm using the submit button and
a mailto URL which just sends the contents of the fields without
identifying them. I want to write a script to use the identifiers from
the fields to add some readability to the email, like
The person who contacted you via your realty site is a
buyer
In Perl Cookbook pg 698 there is code for saving the form contents to
a pipe. But, I have no inkling about email programs. Can you tell me
how to go about doing this? Are there resources in Perl/UNIX to do
it? I would prefer not spending money on software.
Let me know if I'm unclear, or you need more info.
My background: I'm very good at C++ and HTML. I dabbled in Perl a
couple of years ago, to save form info to a file, and using JavaScript
to validate data entered into a form. I have a decent working
knowedge of UNIX. I'll be working from a shell account at my local
ISP. I may not be up to speed on the fine points of UNIX.
If I could get some guidance on how to go about this, I'd be very
grateful.
------------------------------
Date: Thu, 19 Apr 2001 09:45:52 -0700
From: Bryan Coon <bcoon@sequenom.com>
Subject: Re: want to format and email web page form
Message-Id: <3ADF1640.7DF90A86@sequenom.com>
anonymous wrote:
> The form in question is at
> http://geocities.com/barakatwo/contact.htm
>
> When the user chooses 'buyer' or 'seller,' I want the irrelevant parts
> of the form to be disabled. Like if 'seller' is chosen, then 'my
> price range' would be disabled. Can this be done with Perl, or do I
> need to go to the JavaScript board?
What exactly do you mean by disabled? The pop up menu vanishes, or is
simply immovable? The only reasonable option (that I know of) is to
render it immovable.
But javascript is the way to do this. For text boxes you can use
window.blur(), or even reset the element value to null onChange.
For your popup, you can either reset the array to 0 or 1 elements, or
just ignore it when processing your form to email.
>
>
> Then, I want to email the form to the owner of the site. I want to
> add a little formatting. Right now, I'm using the submit button and
> a mailto URL which just sends the contents of the fields without
> identifying them. I want to write a script to use the identifiers from
> the fields to add some readability to the email, like
>
> The person who contacted you via your realty site is a
> buyer
>
> In Perl Cookbook pg 698 there is code for saving the form contents to
> a pipe. But, I have no inkling about email programs. Can you tell me
> how to go about doing this? Are there resources in Perl/UNIX to do
> it? I would prefer not spending money on software.
>
I think the Cookbook p 698 you refer to is the answer to your own
question. You just need to integrate that with your form data.
i.e. use CGI qw(:standard);
my $email = param("email"); # Email address from form
etc.
Then follow the cookbook to actually mail the thing.
Hope that helps
Bryan
------------------------------
Date: Thu, 19 Apr 2001 09:23:15 -0700
From: Bryan Coon <bcoon@sequenom.com>
Subject: What is wrong here?
Message-Id: <3ADF10F3.3766A55A@sequenom.com>
I have read usenet, read the perldocs on perlsub, perlmod, perlmodlib,
and I still cant figure out why I get a complaint here... according to
all I have read, this is the correct way to do this:
### global.pm ###
our $test = "http://1.2.3.4/";
1;
### test.pl ###
#!/usr/bin/perl -w
require "global.pm";
print $test, "\n";
The result is this:
Name "main::test" used only once: possible typo at ./test.pl line 5.
http://1.2.3.4/
What is wrong? $test is successfully initialized and read by test.pl
via the require statement. So why the complaint? I am just trying to
set up a global config file here to store some local common settings
(see my earlier post too).
Anyone?
Bryan
------------------------------
Date: Thu, 19 Apr 2001 09:51:29 -0700
From: Ron Hill <hillr@ugs.com>
Subject: Re: What is wrong here?
Message-Id: <3ADF1791.BAD19688@ugs.com>
Bryan Coon wrote:
>
[snipped]
>
> ### global.pm ###
> our $test = "http://1.2.3.4/";
> 1;
>
> ### test.pl ###
> #!/usr/bin/perl -w
>
> require "global.pm";
>
> print $test, "\n";
>
> The result is this:
> Name "main::test" used only once: possible typo at ./test.pl line 5.
> http://1.2.3.4/
>
> What is wrong? $test is successfully initialized and read by test.pl
> via the require statement. So why the complaint? I am just trying to
> set up a global config file here to store some local common settings
> (see my earlier post too).
Hello,
The require or use statements both pull a module into your program,
although their semantics are slightly different. require loads modules
at runtime, with a check to avoid the redundant loading of a given
module. use is like require, with two added properties: compile-time
loading and automatic importing.
if you change the require global.pm; to use global; this will elimate
the error for the reasons above.
I hope this helps
Ron Hill
------------------------------
Date: 19 Apr 2001 13:09:55 -0400
From: Joe Schaefer <joe+usenet@sunstarsys.com>
Subject: Re: What is wrong here?
Message-Id: <m3n19cx1cs.fsf@mumonkan.sunstarsys.com>
Bryan Coon <bcoon@sequenom.com> writes:
> ### global.pm ###
> our $test = "http://1.2.3.4/";
> 1;
>
> ### test.pl ###
> #!/usr/bin/perl -w
>
> require "global.pm";
^^^^^^^^^^^^^^^^^^^^
A run-time load.
>
> print $test, "\n";
>
> The result is this:
> Name "main::test" used only once: possible typo at ./test.pl line 5.
^^^^^^^^^^^^^^^^
A compile-time warning.
> http://1.2.3.4/
>
% cat global.pm
our $test = "http://1.2.3.4"
% perl -wle 'BEGIN{require "global.pm"} print $test'
http://1.2.3.4
%
HTH
--
Joe Schaefer "I hate a country witout a derrick."
--Mark Twain
------------------------------
Date: Thu, 19 Apr 2001 14:01:29 GMT
From: Jeff Thies <cyberjeff@sprintmail.com>
Subject: Re: Why Perl?
Message-Id: <39D34EBA.DAA33D58@sprintmail.com>
> saves me a TON of time cleaning up code in my html pages (fixing case to
> my preference, adding "" around values, etc).
How do you add (missing) quotes to html values? The closing quote (if
the value had a space in it) would seem to be the tough one. Replacing
missing end tags would be another, I can't think of a way to do this
that isn't terribly complex. (still thinking though...)
Jeff
------------------------------
Date: Thu, 19 Apr 2001 09:24:15 -0400
From: tadmc@augustmail.com (Tad McClellan)
Subject: Re: Why Perl?
Message-Id: <slrn9dtpnv.2sj.tadmc@tadmc26.august.net>
Jeff Thies <cyberjeff@sprintmail.com> wrote:
>> saves me a TON of time cleaning up code in my html pages (fixing case to
>> my preference, adding "" around values, etc).
>
>How do you add (missing) quotes to html values?
I run 'htmltidy' on it.
http://www.w3.org/People/Raggett/tidy/
>The closing quote (if
>the value had a space in it) would seem to be the tough one.
Unquoted attribute values are not allowed to contain spaces for
pretty much that very reason :-)
If it "had a space in it" (and was unquoted), then it was not HTML
to begin with.
>Replacing
>missing end tags would be another, I can't think of a way to do this
>that isn't terribly complex. (still thinking though...)
That wheel has already been invented, spend your grey-matter cycles
on something else :-)
--
Tad McClellan SGML consulting
tadmc@augustmail.com Perl programming
Fort Worth, Texas
------------------------------
Date: Fri, 20 Apr 2001 07:03:51 +0530
From: Ritesh Diwan <r.diwan@india.ti.com>
Subject: Re: workaround for sourcing file from perlscript
Message-Id: <3ADF91FF.891457FB@india.ti.com>
You use system or backsticks it runs in the other shell and hence those
executables
are not visible from the shell as source has been done in other shell.
i have found one workaround but i would love know some thing better
what i have got is
put this source abc in shell script and run perl programme from inside the shell
script this will source
the file abc as well as the perl script in one shell .
my shell script is as follows
#!/usr/bin/csh -f
source abc
perl cfcore.pl $1 $2 $3
and executables are being called from perl programme cfcore.pl
Tad McClellan wrote:
> Ritesh Diwan <r.diwan@india.ti.com> wrote:
> >
> >I want to use put this command in perl script
> > source abc
> > executable argument
> >
> >where abc is file which when sourced sets some variable
> >and allow to use some executables
> >but if i put this in perl script and runs it.
>
> Errr, _how_ are you running it? system() or backticks, I assume?
> Got any Perl code showing how you run it?
>
> Those methods use the Bourne shell, but "source" is a csh thingie.
> sh isn't going to grok "source", it uses "." for that.
>
> >it source the file in new
> >shell and hence all those executables can't be run as they are run in
> >different shell .
>
> Err, so run them in the _same_ shell then:
>
> !system ". abc; executable argument" or die "problem running system()";
> ^
> ^
>
> :-)
>
> >Can any body tell the workaround
>
> If you want to run csh, then run csh from the sh that system() gives you:
>
> !system "/bin/csh <some csh syntax here>" or die "problem running system()";
>
> --
> Tad McClellan SGML consulting
> tadmc@augustmail.com Perl programming
> Fort Worth, Texas
--
-----------------------------------------------------------------------
RITESH DIWAN Ph(O)-- 5099555
Group - Alit Ph(R)-- 5215583
H.no.3134 13th cross 6th C main
HAL IInd stage Indranagar Bangalore INDIA
-----------------------------------------------------------------------
------------------------------
Date: Thu, 19 Apr 2001 15:15:20 GMT
From: "Tom" <tom@hotversion.com>
Subject: xoring bits
Message-Id: <ciDD6.21775$BU4.35704@news1.blktn1.nsw.optushome.com.au>
hi guys,
I'm trying to ^ 8bits 10000001 and 10001101, I'd like to have 8bits returned
as the result but instead I get 420 when I ^ the two is there someway of
returning the 8bits xor-ed ?
thanks
Tom
------------------------------
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 721
**************************************