[22525] in Perl-Users-Digest

home help back first fref pref prev next nref lref last post

Perl-Users Digest, Issue: 4746 Volume: 10

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Sat Mar 22 21:06:29 2003

Date: Sat, 22 Mar 2003 18:05:05 -0800 (PST)
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)

Perl-Users Digest           Sat, 22 Mar 2003     Volume: 10 Number: 4746

Today's topics:
    Re: doubts on \n <bart.lateur@pandora.be>
    Re: doubts on \n <bart.lateur@pandora.be>
    Re: doubts on \n <bart.lateur@pandora.be>
        e-mail attachment. <trond@bwsnett.no>
    Re: e-mail attachment. <mbudash@sonic.net>
    Re: e-mail attachment. <trond@bwsnett.no>
    Re: e-mail attachment. <mbudash@sonic.net>
    Re: e-mail attachment. (Randal L. Schwartz)
    Re: e-mail attachment. <me@privacy.net>
        Floating Point, pack, Random Access Files (Dr. Laurence Leff)
    Re: Floating Point, pack, Random Access Files <bwalton@rochester.rr.com>
    Re: Perl querystring encoding question <flavell@mail.cern.ch>
    Re: Perl querystring encoding question <mbudash@sonic.net>
        Really weird?!? (Ryan Ritten)
    Re: Really weird?!? <please@no.spam>
    Re: Really weird?!? <ndronen@io.frii.com>
    Re: Really weird?!? <mbudash@sonic.net>
    Re: Really weird?!? <bart.lateur@pandora.be>
        Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)

----------------------------------------------------------------------

Date: Sat, 22 Mar 2003 23:33:26 GMT
From: Bart Lateur <bart.lateur@pandora.be>
Subject: Re: doubts on \n
Message-Id: <uhsp7v8mdp0e5vdkjbujo4jpg8qbr9c3ak@4ax.com>

Helgi Briem wrote:

>But linebreaks have nothing whatsoever to do with Perl
>and everything to do with operating systems and their
>conventions.

I can not agree. The conversion of CRLF to "\012" when reading from a
text file, and vice versa, is typical for perl on Windows- and DOS-like
systems. (I say typical for "perl", not for "Perl".) I don't think there
are many other programming languages for DOS/Windows that do the same.

-- 
	Bart.


------------------------------

Date: Sat, 22 Mar 2003 23:47:41 GMT
From: Bart Lateur <bart.lateur@pandora.be>
Subject: Re: doubts on \n
Message-Id: <unsp7v0tps0t7p1p0d3f2icp2go4621vhd@4ax.com>

Jürgen Exner wrote:

>But the linefeed is standardized.
>Well, at least as long as you are talking about ASCII and ASCII-based
>character sets.
>LF is 0x0Am nothing else.

But the equivalence between LF and "\n" is coincidental. Well, in
practise they're a bit  intertwined... but "\n" is definitely more
abstract than LF.

-- 
	Bart.


------------------------------

Date: Sat, 22 Mar 2003 23:53:57 GMT
From: Bart Lateur <bart.lateur@pandora.be>
Subject: Re: doubts on \n
Message-Id: <jitp7vcqprape7qtfjt1b6cqhkt8mv5qvp@4ax.com>

Benjamin Goldberg wrote:

>> Yes; within Perl \n is \012, regardless of platform.
>
>No.  On macintosh, \n is \010.  On Mac, no newline translation is done
>when printing or reading, regardless of binmode.

And I don't know what it is on EBCDIC, but I doubt if it's  chr(10).

According to this table, LF is 37:

	<http://www.natural-innovations.com/computing/asciiebcdic.html>

I have no idea about the connection between "\n" and LF.

>However, the length of "\n" is still 1.

Same remark.

-- 
	Bart.


------------------------------

Date: Sat, 22 Mar 2003 21:43:26 +0100
From: "Trond Johansen" <trond@bwsnett.no>
Subject: e-mail attachment.
Message-Id: <b5ihu9$29r702$1@ID-175630.news.dfncis.de>

Hi.

I have made a script that is sending e-mails with specified
informations to several persons.

I want to send them a html file that is created by the script I have made.
The variable of the attachment is
$attach
The url of the file is: http://www.mysite.com/docs/news.html

The e-mail script is:
$recip = "me\@mysite.com" ;

open (MAIL, "|$mail_prog -t");
print MAIL "To: $recip\n";
print MAIL "Reply-to: test\@mysite.com\n";
print MAIL "From: test\@mysite.com\n";
print MAIL "Subject: Info $info1, $info2\n";
print MAIL "\n\n";
print MAIL "New web document for you in the attachment:\n" ;
print MAIL "\n" ;
print MAIL "\n\n";
close (MAIL);

Anyone who can give me the right code for attaching the web document?

-Trond Johansen




------------------------------

Date: Sat, 22 Mar 2003 20:48:33 GMT
From: Michael Budash <mbudash@sonic.net>
Subject: Re: e-mail attachment.
Message-Id: <mbudash-85F277.12483222032003@typhoon.sonic.net>

In article <b5ihu9$29r702$1@ID-175630.news.dfncis.de>,
 "Trond Johansen" <trond@bwsnett.no> wrote:

> Hi.
> 
> I have made a script that is sending e-mails with specified
> informations to several persons.
> 
> I want to send them a html file that is created by the script I have made.
> The variable of the attachment is
> $attach
> The url of the file is: http://www.mysite.com/docs/news.html
> 
> The e-mail script is:
> $recip = "me\@mysite.com" ;
> 
> open (MAIL, "|$mail_prog -t");
> print MAIL "To: $recip\n";
> print MAIL "Reply-to: test\@mysite.com\n";
> print MAIL "From: test\@mysite.com\n";
> print MAIL "Subject: Info $info1, $info2\n";
> print MAIL "\n\n";
> print MAIL "New web document for you in the attachment:\n" ;
> print MAIL "\n" ;
> print MAIL "\n\n";
> close (MAIL);
> 
> Anyone who can give me the right code for attaching the web document?
> 
> -Trond Johansen
> 
> 

not sure whether you're talking about sending an email in HTML format, 
or sending the HTML as an attachment, but either way:

use MIME::Lite;

hth-

-- 
Michael Budash


------------------------------

Date: Sat, 22 Mar 2003 21:53:49 +0100
From: "Trond Johansen" <trond@bwsnett.no>
Subject: Re: e-mail attachment.
Message-Id: <b5iihq$2a0qai$1@ID-175630.news.dfncis.de>

Hi.

I'm talking about sending the HTML as an attachment.

"Michael Budash" <mbudash@sonic.net> skrev i melding
news:mbudash-85F277.12483222032003@typhoon.sonic.net...
> In article <b5ihu9$29r702$1@ID-175630.news.dfncis.de>,
>  "Trond Johansen" <trond@bwsnett.no> wrote:
>
> > Hi.
> >
> > I have made a script that is sending e-mails with specified
> > informations to several persons.
> >
> > I want to send them a html file that is created by the script I have
made.
> > The variable of the attachment is
> > $attach
> > The url of the file is: http://www.mysite.com/docs/news.html
> >
> > The e-mail script is:
> > $recip = "me\@mysite.com" ;
> >
> > open (MAIL, "|$mail_prog -t");
> > print MAIL "To: $recip\n";
> > print MAIL "Reply-to: test\@mysite.com\n";
> > print MAIL "From: test\@mysite.com\n";
> > print MAIL "Subject: Info $info1, $info2\n";
> > print MAIL "\n\n";
> > print MAIL "New web document for you in the attachment:\n" ;
> > print MAIL "\n" ;
> > print MAIL "\n\n";
> > close (MAIL);
> >
> > Anyone who can give me the right code for attaching the web document?
> >
> > -Trond Johansen
> >
> >
>
> not sure whether you're talking about sending an email in HTML format,
> or sending the HTML as an attachment, but either way:
>
> use MIME::Lite;
>
> hth-
>
> --
> Michael Budash




------------------------------

Date: Sat, 22 Mar 2003 21:00:48 GMT
From: Michael Budash <mbudash@sonic.net>
Subject: Re: e-mail attachment.
Message-Id: <mbudash-5A746B.13004722032003@typhoon.sonic.net>

In article <b5iihq$2a0qai$1@ID-175630.news.dfncis.de>,
 "Trond Johansen" <trond@bwsnett.no> wrote:

> "Michael Budash" <mbudash@sonic.net> skrev i melding
> news:mbudash-85F277.12483222032003@typhoon.sonic.net...
> > In article <b5ihu9$29r702$1@ID-175630.news.dfncis.de>,
> >  "Trond Johansen" <trond@bwsnett.no> wrote:
> >
> > > Hi.
> > >
> > > I have made a script that is sending e-mails with specified
> > > informations to several persons.
> > >
> > > I want to send them a html file that is created by the script I have
> made.
> > > The variable of the attachment is
> > > $attach
> > > The url of the file is: http://www.mysite.com/docs/news.html
> > >
> > > The e-mail script is:
> > > $recip = "me\@mysite.com" ;
> > >
> > > open (MAIL, "|$mail_prog -t");
> > > print MAIL "To: $recip\n";
> > > print MAIL "Reply-to: test\@mysite.com\n";
> > > print MAIL "From: test\@mysite.com\n";
> > > print MAIL "Subject: Info $info1, $info2\n";
> > > print MAIL "\n\n";
> > > print MAIL "New web document for you in the attachment:\n" ;
> > > print MAIL "\n" ;
> > > print MAIL "\n\n";
> > > close (MAIL);
> > >
> > > Anyone who can give me the right code for attaching the web document?
> >
> > not sure whether you're talking about sending an email in HTML format,
> > or sending the HTML as an attachment, but either way:
> >
> > use MIME::Lite;
>
> I'm talking about sending the HTML as an attachment.
> 

then...

use MIME::Lite;

install it, be happy.

-- 
Michael Budash


------------------------------

Date: Sat, 22 Mar 2003 22:08:03 GMT
From: merlyn@stonehenge.com (Randal L. Schwartz)
To: "Trond Johansen" <trond@bwsnett.no>
Subject: Re: e-mail attachment.
Message-Id: <b7057b5c52006fc21fb9c8ad4ea9fd8e@news.teranews.com>

>>>>> "Trond" == Trond Johansen <trond@bwsnett.no> writes:

Trond> I have made a script that is sending e-mails with specified
Trond> informations to several persons.

Trond> I want to send them a html file that is created by the script I
Trond> have made.

Hooo boy.  Did you already *ask* all these people if they wanted HTML
in their email?

I know that if you tried to do that to me (or most of the addresses in
the stonehenge.com domain), you'd get back the polite bounce message
of:

    You recently sent mail to $ADDRESS that contained something
    other than plain text.  Perhaps you used "attachments", or enabled
    "quoted printable" or "send as HTML".  Your message has been rejected
    by the recipient.  Please resend the message as plain text.

    For assistance in configuring your mailer, please see

      http://www.expita.com/nomime.html

    Thank you,
    Randal L. Schwartz
    postmaster@stonehenge.com

HTML is *not* for email, unless specifically requested.

print "Just another Perl hacker,"
-- 
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: Sun, 23 Mar 2003 11:48:01 +1100
From: "Tintin" <me@privacy.net>
Subject: Re: e-mail attachment.
Message-Id: <b5j081$2admvi$1@ID-172104.news.dfncis.de>


"Michael Budash" <mbudash@sonic.net> wrote in message
news:mbudash-85F277.12483222032003@typhoon.sonic.net...
> In article <b5ihu9$29r702$1@ID-175630.news.dfncis.de>,
>  "Trond Johansen" <trond@bwsnett.no> wrote:
>
> > Hi.
> >
> > I have made a script that is sending e-mails with specified
> > informations to several persons.
> >
> > I want to send them a html file that is created by the script I have
made.
> > The variable of the attachment is
> > $attach
> > The url of the file is: http://www.mysite.com/docs/news.html
> >
> > The e-mail script is:
> > $recip = "me\@mysite.com" ;
> >
> > open (MAIL, "|$mail_prog -t");
> > print MAIL "To: $recip\n";
> > print MAIL "Reply-to: test\@mysite.com\n";
> > print MAIL "From: test\@mysite.com\n";
> > print MAIL "Subject: Info $info1, $info2\n";
> > print MAIL "\n\n";
> > print MAIL "New web document for you in the attachment:\n" ;
> > print MAIL "\n" ;
> > print MAIL "\n\n";
> > close (MAIL);
> >
> > Anyone who can give me the right code for attaching the web document?
> >
> > -Trond Johansen
> >
> >
>
> not sure whether you're talking about sending an email in HTML format,
> or sending the HTML as an attachment, but either way:
>
> use MIME::Lite;

or MIME::Lite::HTML for sending an HTML page.





------------------------------

Date: 21 Mar 2003 18:06:51 -0600
From: mflll@wiu.edu (Dr. Laurence Leff)
Subject: Floating Point, pack, Random Access Files
Message-Id: <b5g9er$o26$1@ecom1.wiu.edu>

I am having trouble with floating point data, pack, and random access files.
This is in Perl 5.8.0 on Red Hat Linux 8.0 (Kernel 2.4.18).

My first program (perlRC) reads information from the file InputAscii
representing student name, ID, and GPA.  After pattern matching it into
three variables, it is put into a packed data and put into the array.
The ID number serves as the position into the random file, OutputBinary.  
That is, I multiply the ID number by the size of the record to get 
the position in bytes for sysseek.

The second program (perlRD) solicits id numbers from the user.  It 
determines the offset into OutputBinary by multiplying the ID by the size of 
the record.   It then sysseek's and reads the information.

Unfortunately, the second program is not reading the information in properly.
See the sample output below.

I tried many variations but they did not help:
1) I played with the template for pack including using j and d 
   instead of i and f.
2) I used $Config to get the the sizes for the integer and real number.
3) I tried multiply $GPA by 1.0 to force PERL to consider it a floating
   point number.

It did help if I hard coded the gpa rather than match it with a pattern,
(See the commented-out $GPA = 2.75 in perlRC)

Here is the perlRC program that converts the ASCII file to a binary random
access file.

#!/usr/bin/perl
# store data into random access file
# put it in packed format
# format of ascii file
#    name (name)
#    Id Number (int)
#    gpa (float)
#
$OpenReturnCode = open (A,@ARGV[0]) ;
if (undef $OpenReturnCode ) {
  print "ascii file did not open",$!,"\n";
}
use Fcntl;
$OpenReturnCode = sysopen (B,"OutputBinary",O_RDWR | O_CREAT| O_TRUNC); 
if (!$OpenReturnCode) {
  print "binary file did not open " , $!, "\n";
}
while (<A>) {
  ($Name,$ID,$GPA) = /(\S+)\s+(\S+)\s+(\S+)/ ;
  # testing
  #$GPA = 2.75;
  $GPA = $GPA * 1.0;
  print "ID is ",$ID," my GPA is |",$GPA,"|\n";
  $PackedStudent = pack ("A40if",$Name,$ID,$GPA);
  $size = length $PackedStudent;
  sysseek B,$size*$ID,0;
   
  $temp1 = syswrite B,$PackedStudent, $size;
  print "processed ",$temp1,"\n";
  if (undef $temp1) {
     print "syswrite gave error !$ \n";
  }
}
use Config;
  $OtherSize = $Config{intsize} + 4 + 40;
  print "size " , $size, "Size from Config" ,$OtherSize,"\n";

*** Here is the perlRD program that allow the user to query the binary
file

#!/usr/bin/perl
# read binary file
use Fcntl;
$OpenReturnCode = sysopen (B,"OutputBinary",O_RDONLY); 
if (!$OpenReturnCode) {
  print "binary file did not open " , $!, "\n";
}
use Config;
$RecordSize = $Config{intsize} + 4 + 40;
$temp1=$RecordSize;
while ($ID=<STDIN>) {
  chomp $ID;
  $temp1=sysseek B,$ID*$RecordSize,0;
  $temp2=sysread B,$PackedStudent,$RecordSize;
  print "temp2 is ",$temp2,"\n";
  if ($temp2==$RecordSize) {
    ($Name,$ID,$GPA) =  unpack ("A40if",$PackedStudent);
    print "Name ",$Name, " ID ", $ID, " GPA ",$GPA,"\n";
  }
  elsif ($temp2!=0) {
    print "sysread gave Error $! \n";
  }
}

This shows how the proram looks when it is run.

perlRC InputAscii
ID is 2 my GPA is |2.4|
processed 48
ID is 3 my GPA is |3.4|
processed 48
ID is 1 my GPA is |2.2|
processed 48
ID is 4 my GPA is |2.3|
processed 48
size 48Size from Config48
-bash-2.05b$ perlRD
3
temp2 is 48
Name Robert ID 3 GPA -2.0121636037097e-23
4
temp2 is 48
Name Doug ID 4 GPA 2.29999995231628
2
temp2 is 48
Name
     @hn ID 2 GPA -2.0121636037097e-23
1
temp2 is 48
Name Smith ID 1 GPA -3.01298268634123e-31

Here is the InputAscii file that I am using:

John 2 2.4
Robert 3 3.4
Smith 1 2.2
Doug 4 2.3


Dr. Laurence Leff  Western Illinois University, Macomb IL 61455 ||(309) 298-1315
Stipes 447 Assoc. Prof. of Computer Sci. Pager: 309-367-0787 FAX: 309-298-2302 
Secretary: The OASIS Legal XML Member Section Court Filing Technical Committee 
and Electronic Contracts Technical Committee


------------------------------

Date: Sun, 23 Mar 2003 00:57:34 GMT
From: Bob Walton <bwalton@rochester.rr.com>
Subject: Re: Floating Point, pack, Random Access Files
Message-Id: <3E7D029B.9040803@rochester.rr.com>

Dr. Laurence Leff wrote:

> I am having trouble with floating point data, pack, and random access files.
> This is in Perl 5.8.0 on Red Hat Linux 8.0 (Kernel 2.4.18).
> 
> My first program (perlRC) reads information from the file InputAscii
> representing student name, ID, and GPA.  After pattern matching it into
> three variables, it is put into a packed data and put into the array.
> The ID number serves as the position into the random file, OutputBinary.  
> That is, I multiply the ID number by the size of the record to get 
> the position in bytes for sysseek.
> 
> The second program (perlRD) solicits id numbers from the user.  It 
> determines the offset into OutputBinary by multiplying the ID by the size of 
> the record.   It then sysseek's and reads the information.
> 
> Unfortunately, the second program is not reading the information in properly.
> See the sample output below.
> 
> I tried many variations but they did not help:
> 1) I played with the template for pack including using j and d 
>    instead of i and f.
> 2) I used $Config to get the the sizes for the integer and real number.
> 3) I tried multiply $GPA by 1.0 to force PERL to consider it a floating
>    point number.
> 
> It did help if I hard coded the gpa rather than match it with a pattern,
> (See the commented-out $GPA = 2.75 in perlRC)


Note:  2.75 has an exact representation in binary floating point; the 
other gpa examples do not have an exact representation in binary 
floating point.  Thus 2.75 will pass through the "f" pack/unpack code 
without modification, while the remainder of the examples will be rounded.


> 
> Here is the perlRC program that converts the ASCII file to a binary random
> access file.

 ...

When I run the OP's original code (on Windoze 98SE, Perl 5.6.1 AS build 
633), I get different results:

D:\junk>perl junk274a.pl junk274.txt
ID is 2 my GPA is |2.4|
processed 48
ID is 3 my GPA is |3.4|
processed 48
ID is 1 my GPA is |2.2|
processed 48
ID is 4 my GPA is |2.3|
processed 48
size 48Size from Config48

D:\junk>perl junk274b.pl
3
temp2 is 48
Name Robert ID 3 GPA 3.40000009536743
4
temp2 is 48
Name Doug ID 4 GPA 2.29999995231628
2
temp2 is 48
Name John ID 2 GPA 2.40000009536743
1
temp2 is 48
Name Smith ID 1 GPA 2.20000004768372

D:\junk>

One possible reason for different results is:  System dependent behavior 
of sysseek/syswrite when asked to seek past the end of the existing file 
prior to writing.  Pre-writing a file to equal or past the highest ID 
number intended should solve that problem if that is it.

Other than that, the OP's results showed the first two characters of the 
name field of record 2 (the first one written) getting clobbered, and 
the floating point value of all but record 4 (the last one written and 
the last one in the file) getting clobbered.  There does not appear to 
be any problem with computing record indices, so the reason for the 
clobbered data is not apparent.  It doesn't happen on my system, even 
when I use huge record numbers.  Giving non-integer ID's to the second 
program generates garbage, of course.

It's not clear how the name field of record 2 got changed to the 
apparent <nl><tab>@ , as it appears only two characters got clobbered.

Regarding the floating point rounding:  I replaced the given code with a 
simple example of same problem:

$gpa='2.4'; #a typical gpa, given as a string.  Perl will automatically
             #convert to a float when needed in pack.
$name='Joe E. Student';
$id=23;
$packed=pack 'A40if',$name,$id,$gpa;
print "length=".length($packed)."\n";
($n,$i,$g)=unpack 'A40if',$packed;
print "Name=$n, id=$i, grade=$g\n";

The results of running this may be system dependent.  On my system 
(Windoze 98SE with AS Perl build 633), one gets:

D:\junk>perl junk274c.pl
length=48
Name=Joe E. Student, id=23, grade=2.40000009536743

D:\junk>

One can see that the floating point number got rounded off to single 
precision.  Typically Perl stores its floats as "double precision", 
whatever that may mean on a given system.  Using the "d" pack/unpack 
code should store and retrieve a more accurate value:

$gpa='2.4'; #a typical gpa, given as a string.  Perl will automatically
             #convert to a float when needed in pack.
$name='Joe E. Student';
$id=23;
$packed=pack 'A40id',$name,$id,$gpa;
print "length=".length($packed)."\n";
($n,$i,$g)=unpack 'A40id',$packed;
print "Name=$n, id=$i, grade=$g\n";

D:\junk>perl junk274c.pl
length=52
Name=Joe E. Student, id=23, grade=2.4

D:\junk>

Note that packed binary information like this will in general not be 
portable across different computing platforms.  Also note that the 
binary information expands to 52 bytes when the "d" pack/unpack code is 
used.  The original program ran fine when the "d" code was used, 
provided I changed the record size to 52 in both programs.  I was unable 
to duplicate the "garbage" values the OP got in three out of four of his 
cases, running his original unmodified code.  As far as I can tell, 
binmode should not be necessary when using syswrite.

In general, one could ask the question:  Why not use some of Perl's 
other facilities (that work without so much hassle) to do this job or 
similar jobs?  For example, a hash tied to DB_File or SDBM_File or 
similar would make quick work of this.  Or DBI with DBD::CSV or a 
database.  Or leaving the info in its original ASCII flat file.  And 
mostly it would run faster and save space, since the "record number 
seek" option is unbuffered and will require a disk I/O per record no 
matter what; and it uses 40 bytes for each name, which will be wasteful 
most of the time but not enough sometimes.  Some of those solutions 
would generate good cross-platform behavior, too.

 ...

> Dr. Laurence Leff ...
 ...

-- 
Bob Walton



------------------------------

Date: Sat, 22 Mar 2003 19:33:47 +0100
From: "Alan J. Flavell" <flavell@mail.cern.ch>
Subject: Re: Perl querystring encoding question
Message-Id: <Pine.LNX.4.53.0303221915050.4366@lxplus009.cern.ch>

On Sat, Mar 22, Michael Budash inscribed on the eternal scroll:

[lotsa quotage snipped]

>  Sharon Grant <peakpeek@purethought.com> wrote:

> > and the HTML validator which Wolf Behrenhoff mentioned elsewhere in
> > this thread, which is how I originally struck this issue, later
> > clarified for me by Alan J. Flavell's discussion in the 1999 thread
> > mentioned above

Must admit I'd forgotten that particular discussion, but it still
looks about right to me.  XML has brought (or at least is supposed to
have brought) some additional stringency.

> well file this one under "you learn something new every day"... i've
> been writing stuff like this for years, and it never bit me (thank god)
> even tho it was invalid:
>
> <a href="/script.cgi?this=that&these=those">

At least an HTML validator would report an error on that.  The joke is
that it's _worse_ if it's valid... Consider this example (recalling
that in HTML the terminating semicolon for entities can be optional):

   ?request=print&lang=en&copy=2

Both &lang and &copy are valid HTML4 entities, therefore this URL
would pass HTML syntax validation.  Although I couldn't find a browser
which interpreted &lang as the left angle bracket, _most_ of the
browsers tested were found to interpret &copy as the copyright
character, and thus the submission produced the wrong results.

More details on this at
http://ppewww.ph.gla.ac.uk/~flavell/www/formgetbyurl.html

all the best


------------------------------

Date: Sat, 22 Mar 2003 19:20:38 GMT
From: Michael Budash <mbudash@sonic.net>
Subject: Re: Perl querystring encoding question
Message-Id: <mbudash-197428.11203922032003@typhoon.sonic.net>

In article <Pine.LNX.4.53.0303221915050.4366@lxplus009.cern.ch>,
 "Alan J. Flavell" <flavell@mail.cern.ch> wrote:

> On Sat, Mar 22, Michael Budash inscribed on the eternal scroll:
> 
> [lotsa quotage snipped]
> 
> >  Sharon Grant <peakpeek@purethought.com> wrote:
> 
> > > and the HTML validator which Wolf Behrenhoff mentioned elsewhere in
> > > this thread, which is how I originally struck this issue, later
> > > clarified for me by Alan J. Flavell's discussion in the 1999 thread
> > > mentioned above
> 
> Must admit I'd forgotten that particular discussion, but it still
> looks about right to me.  XML has brought (or at least is supposed to
> have brought) some additional stringency.
> 
> > well file this one under "you learn something new every day"... i've
> > been writing stuff like this for years, and it never bit me (thank god)
> > even tho it was invalid:
> >
> > <a href="/script.cgi?this=that&these=those">
> 
> At least an HTML validator would report an error on that.  The joke is
> that it's _worse_ if it's valid... Consider this example (recalling
> that in HTML the terminating semicolon for entities can be optional):
> 
>    ?request=print&lang=en&copy=2
> 
> Both &lang and &copy are valid HTML4 entities, therefore this URL
> would pass HTML syntax validation.  Although I couldn't find a browser
> which interpreted &lang as the left angle bracket, _most_ of the
> browsers tested were found to interpret &copy as the copyright
> character, and thus the submission produced the wrong results.
> 
> More details on this at
> http://ppewww.ph.gla.ac.uk/~flavell/www/formgetbyurl.html
> 
> all the best

thank you very much for that explanation and the link.

-- 
Michael Budash


------------------------------

Date: 22 Mar 2003 15:19:21 -0800
From: sparticusREMOVE@thesparticusarena.com (Ryan Ritten)
Subject: Really weird?!?
Message-Id: <f4d27a4f.0303221519.b1c7b04@posting.google.com>

I don't get it... all I want is to check to see if the string $key
contains the string of characters represented by table$table!

so for example... if $table was equal to 4 .... it would check $key
and see if the string table4! was found within it... here is my code:


print "key=$key\n";
print "table=$table\n";
if($key =~ /table$table!/)
{
        print "I'm in\n";
}

if I run this... for example... I'd get :

key=blahtable4!
table=4

the if statement doesn't validate to true .... any ideas why?  it
should... I've tried chomping the data to remove any weird characters
at the end... with no luck... am I missing something stupid?

thanx

-Ryan


------------------------------

Date: Sat, 22 Mar 2003 23:23:27 +0000
From: Chris Lowth <please@no.spam>
Subject: Re: Really weird?!?
Message-Id: <nh6fa.7$v6.24796@newsfep2-gui>

Ryan Ritten wrote:

> I don't get it... all I want is to check to see if the string $key
> contains the string of characters represented by table$table!
> 
> so for example... if $table was equal to 4 .... it would check $key
> and see if the string table4! was found within it... here is my code:
> 
> 
> print "key=$key\n";
> print "table=$table\n";
> if($key =~ /table$table!/)
> {
>         print "I'm in\n";
> }
> 
> if I run this... for example... I'd get :
> 
> key=blahtable4!
> table=4
> 
> the if statement doesn't validate to true .... any ideas why?  it
> should... I've tried chomping the data to remove any weird characters
> at the end... with no luck... am I missing something stupid?
> 
> thanx
> 
> -Ryan

Problem is syntax of the "if($key..." line.

Fix thus...

$key = "blahtable4";
$table = 4;
print "key=$key\n";
print "table=$table\n";
if($key =~ m{table$table})
{
        print "I'm in\n";
}

Chris

-- 
My real address is: chris at lowth dot sea oh em
Author of "protector" (http://protector.sourceforge.net)
 -- OpenSource (free) e-mail virus protection


------------------------------

Date: 22 Mar 2003 23:28:41 GMT
From: Nicholas Dronen <ndronen@io.frii.com>
Subject: Re: Really weird?!?
Message-Id: <3e7cf1a9$0$198$75868355@news.frii.net>

Ryan Ritten <sparticusREMOVE@thesparticusarena.com> wrote:
RR> I don't get it... all I want is to check to see if the string $key
RR> contains the string of characters represented by table$table!

RR> print "key=$key\n";
RR> print "table=$table\n";
RR> if($key =~ /table$table!/)
RR> {
RR>         print "I'm in\n";
RR> }

RR> if I run this... for example... I'd get :

RR> key=blahtable4!
RR> table=4

RR> the if statement doesn't validate to true .... any ideas why?  it
RR> should... I've tried chomping the data to remove any weird characters
RR> at the end... with no luck... am I missing something stupid?

The regular expression matches $key on my system using either
5.6.1 or 5.8.0.

Regards,

Nicholas


-- 
"Why shouldn't I top-post?"    http://www.aglami.com/tpfaq.html
"Meanings are another story."  http://www.ifas.org/wa/glossolalia.html


------------------------------

Date: Sat, 22 Mar 2003 23:38:47 GMT
From: Michael Budash <mbudash@sonic.net>
Subject: Re: Really weird?!?
Message-Id: <mbudash-EC86B1.15384722032003@typhoon.sonic.net>

In article <nh6fa.7$v6.24796@newsfep2-gui>,
 Chris Lowth <please@no.spam> wrote:

> Ryan Ritten wrote:
> 
> > I don't get it... all I want is to check to see if the string $key
> > contains the string of characters represented by table$table!
> > 
> > so for example... if $table was equal to 4 .... it would check $key
> > and see if the string table4! was found within it... here is my code:
> > 
> > 
> > print "key=$key\n";
> > print "table=$table\n";
> > if($key =~ /table$table!/)
> > {
> >         print "I'm in\n";
> > }
> > 
> > if I run this... for example... I'd get :
> > 
> > key=blahtable4!
> > table=4
> > 
> > the if statement doesn't validate to true .... any ideas why?  it
> > should... I've tried chomping the data to remove any weird characters
> > at the end... with no luck... am I missing something stupid?
> > 
> > thanx
> > 
> > -Ryan
> 
> Problem is syntax of the "if($key..." line.
> 
> Fix thus...
> 
> $key = "blahtable4";
> $table = 4;
> print "key=$key\n";
> print "table=$table\n";
> if($key =~ m{table$table})
> {
>         print "I'm in\n";
> }

huh? there's nothing wrong with his syntax. these are equivalent:

/table$table!/

m{table$table!}

however, you changed his regex in the process - you left out the 
exclamation point at the end...

-- 
Michael Budash


------------------------------

Date: Sat, 22 Mar 2003 23:57:52 GMT
From: Bart Lateur <bart.lateur@pandora.be>
Subject: Re: Really weird?!?
Message-Id: <v2up7vs0ub8l5c2jhrm1p0qqec3eavdh3l@4ax.com>

Ryan Ritten wrote:

>the if statement doesn't validate to true .... 

For me it does:

	$key = 'blahtable4!';
	$table = 4;

	print "key=$key\n";
	print "table=$table\n";
	if($key =~ /table$table!/)
	{
	    print "I'm in\n";
	}

Result:

	key=blahtable4!
	table=4
	I'm in	

-- 
	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 4746
***************************************


home help back first fref pref prev next nref lref last post