[25347] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 7592 Volume: 10

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Wed Dec 29 09:10:47 2004

Date: Wed, 29 Dec 2004 06:10:24 -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           Wed, 29 Dec 2004     Volume: 10 Number: 7592

Today's topics:
    Re: Some Programing Needed <joe@inwap.com>
        Strange leading character <sam.wun@authtec.com>
    Re: Strange leading character <dmcbride@naboo.to.org.no.spam.for.me>
        Using perl how do you write a script to copy a remote f (ARGENTINA)
    Re: Using perl how do you write a script to copy a remo <mritty@gmail.com>
        value of param <sam.wun@authtec.com>
    Re: value of param <do-not-use@invalid.net>
    Re: value of param <mritty@gmail.com>
    Re: value of param <sam.wun@authtec.com>
    Re: value of param <sam.wun@authtec.com>
    Re: Why does this work? <joe@inwap.com>
    Re: Why does this work? <bart.lateur@pandora.be>
        Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)

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

Date: Wed, 29 Dec 2004 03:19:41 -0800
From: Joe Smith <joe@inwap.com>
Subject: Re: Some Programing Needed
Message-Id: <j6qdnee1T61TD0_cRVn-tQ@comcast.com>

bigmur77@hotmail.com wrote:
> Joe Smith wrote:
> 
>>Murray J wrote:
>>
>>>I would like to capture the co-ordinates of
>>>the mouse at the instant when it is clicked on the first image,
>>
>>Read up on HTML documentation on the ISMAP attribute of <IMG>.
>>   <a href="xy.cgi"><img src="first-image.png" ismap></a>
> 
> ISMAP sends the co-ordinates to some program on a server.????

Why so many question marks?  The ISMAP attribute has been
around for ages, possibly HTML version 1 or 2.  It was used
over ten years ago by the Xerox PARC Map Viewer
(http://www2.parc.com/istl/projects/mapdocs/).

http://www.htmlhelp.com/reference/html40/special/img.html

Another way of doing it (used by MapQuest and such) is to use
   <input type="image" src="first-image.png">
in the middle of a FORM.

http://www.htmlhelp.com/reference/html40/forms/input.html

   When the graphical submit button is clicked, the coordinates
   of the click are sent with the form submission as name.x=x-value
   and name.y=y-value where name is the value of the NAME attribute,
   x-value is the click's pixels from the left of the image, and
   y-value is the click's pixels from the top of the image.

>>>apply some mathematics based on which 'hot spot' was 
>>>clicked, and come up with a new set of co-ordinates.
>>
>>That's pretty trivial.  What have you tried?
> 
> Trivial only to those who know the answer.

I meant that once you get the coordinates from the browser,
the math is trivial.  Agreed: getting the coordinates can
be daunting if you haven't checked reference material.

>>>When the destination page is opened, I would like the viewport to
>>What's a viewport?
> 
> Screen 800 X 600
> Image 3200 X 2560
> Viewport - that 800 X 600 window I look through.

If you're using a browser, you won't get the full 800x600.
The browser provides a window typically 740 x 500 with scroll
bars.  The position of the browser's scroll bars is not
something under a web server's control.

	-Joe


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

Date: Wed, 29 Dec 2004 13:32:43 +0800
From: sam <sam.wun@authtec.com>
Subject: Strange leading character
Message-Id: <cqth3j$2qlp$1@news.hgc.com.hk>

Jack wrote:

> Jack wrote:
> 
>> Hi,
>>
>>
> Sorry
> 
>> However, if I use the following hard coded assignment, the SQL 
>> statement returns result:
>> # my $mycustcode = "07-2-0057";
>>
>> Here is the SQL statement for MySQL 5.0:
>> $create_view_sql = qq {create view $viewtab as
>>                  select c.custcode, c.custname, c.type, 
>> sum(t.netsales) as sales
>>                  from customer c, transaction t
>>                  where c.custcode = t.custcode
>>                  and date(t.date) >= "$start_date"
>>                  and date(t.date) <= "$end_date"
>>                  and (c.type = "EXPORT" or c.type = "LOCAL")
>>                  and (c.custcode = "$mycustcode")
>>                  group by c.custcode;};
>>
> I just found that the value of $mycustcode contains a leading space, 
> thus sql failed to match the right record.
> This also explained why the first element has  no such problem.
> Sorry for being so careless.
> 
I tried to remove the leading space, but the regular expression failed 
to remove it. It may be not a whitespace, what what is it?
Here is the html string being passed to the $in{'outlets'} perl code:
outlets=07-6-0057%2C&outlets=07-3-0051%2C&outlets=07-2-0036
What is %2C here?

The code I used to strip the white space is:
$str =~s/[ ]//g;

Thanks
Sam

>> Thanks
>> Jack


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

Date: Wed, 29 Dec 2004 06:25:56 GMT
From: Darin McBride <dmcbride@naboo.to.org.no.spam.for.me>
Subject: Re: Strange leading character
Message-Id: <U5sAd.603783$nl.312325@pd7tw3no>

sam wrote:

> Jack wrote:
> 
>> Jack wrote:
>> 
>>> Hi,
>>>
>>>
>> Sorry
>> 
>>> However, if I use the following hard coded assignment, the SQL
>>> statement returns result:
>>> # my $mycustcode = "07-2-0057";
>>>
>>> Here is the SQL statement for MySQL 5.0:
>>> $create_view_sql = qq {create view $viewtab as
>>>                  select c.custcode, c.custname, c.type,
>>> sum(t.netsales) as sales
>>>                  from customer c, transaction t
>>>                  where c.custcode = t.custcode
>>>                  and date(t.date) >= "$start_date"
>>>                  and date(t.date) <= "$end_date"
>>>                  and (c.type = "EXPORT" or c.type = "LOCAL")
>>>                  and (c.custcode = "$mycustcode")
>>>                  group by c.custcode;};
>>>
>> I just found that the value of $mycustcode contains a leading space,
>> thus sql failed to match the right record.
>> This also explained why the first element has  no such problem.
>> Sorry for being so careless.
>> 
> I tried to remove the leading space, but the regular expression failed
> to remove it. It may be not a whitespace, what what is it?
> Here is the html string being passed to the $in{'outlets'} perl code:
> outlets=07-6-0057%2C&outlets=07-3-0051%2C&outlets=07-2-0036
> What is %2C here?

%2C == the comma character.

> The code I used to strip the white space is:
> $str =~s/[ ]//g;

Better:

  $str =~ s/\s+//g;

You may also want to try passing the string through Data::Dumper to
make sure you know exactly what character it is (if it's non-printable,
Data::Dumper may translate it to printable for you).

Also, you really should stop putting values in your SQL.  As much as
possible, that is.

$create_view_stmt = qq{create view $viewtab as
  select c.custcode, c.custname, c.type, sum(t.netsales) as sales from
  customer c, transaction t
  where c.custcode = t.custcode
  and date(t.date) >= ?
  and date(t.date) <= ?
  and c.type in (?,?)
  and c.custcode = ?
  group by c.custcode};


Then, when you go to execute this:

$res = $sth->execute($start_date,
                     $end_date,
                     qw(EXPORT LOCAL),
                     $mycustcode);

Then you don't need to worry about special character as much.  (Stray
characters are a different problem no matter how you do things.)

I would prefer putting a placeholder in for the view name, too, but I
doubt many (if any?) database vendors support that.  If any do, it's
unlikely MySQL does.

Then again, MySQL may not even support this much for a create statement
- I'm not too sure.  Then I presume you're using the DBI 'quote'
function to hide special characters properly?


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

Date: 29 Dec 2004 05:10:08 -0800
From: sjprec@yahoo.com (ARGENTINA)
Subject: Using perl how do you write a script to copy a remote file into your own site
Message-Id: <f2747eca.0412290510.f238d00@posting.google.com>

Using perl how do you write a script to copy a remote file into your
own site. In my situation want to copy a rss feed from
http://remoteserver/news.xml for example.

Marcos


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

Date: Wed, 29 Dec 2004 13:18:48 GMT
From: "Paul Lalli" <mritty@gmail.com>
Subject: Re: Using perl how do you write a script to copy a remote file into your own site
Message-Id: <Y8yAd.11780$113.3241@trndny03>

"ARGENTINA" <sjprec@yahoo.com> wrote in message
news:f2747eca.0412290510.f238d00@posting.google.com...
> Using perl how do you write a script to copy a remote file into your
> own site. In my situation want to copy a rss feed from
> http://remoteserver/news.xml for example.

http://search.cpan.org is usually a good place to start.

For just saving a file off the web, I would recommend using LWP::Simple.
For working with RSS feeds, go to the above site and search for RSS, and
use whichever module looks best suited to your task.

Paul Lalli



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

Date: Wed, 29 Dec 2004 20:16:18 +0800
From: sam <sam.wun@authtec.com>
Subject: value of param
Message-Id: <cqu8ob$4m3$1@news.hgc.com.hk>

Hi,

I have a problem with using CGI module in perl to keep track which 
submit button was pressed.

use CGI;
use CGI::Carp qw/fatalsToBrowser/;
$query = new CGI;

if (!$query->param) {
     print $query->startform(-target=>'_new');
     print "<table border width=100% >\n";
 .....

     print $query->submit(but1);
}
elsif ($query->param(but1)) {
	print "param: $query->param(but1),"<br>\n";
}

When I press the submit button "but1", the "elsif" clause does not execute.

Thanks
Sam



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

Date: 29 Dec 2004 13:23:38 +0100
From: Arndt Jonasson <do-not-use@invalid.net>
Subject: Re: value of param
Message-Id: <yzdacrxi985.fsf@invalid.net>


sam <sam.wun@authtec.com> writes:
> 
> I have a problem with using CGI module in perl to keep track which
> submit button was pressed.
> 
> use CGI;
> use CGI::Carp qw/fatalsToBrowser/;
> $query = new CGI;
> 
> if (!$query->param) {
>      print $query->startform(-target=>'_new');
>      print "<table border width=100% >\n";
> .....
> 
>      print $query->submit(but1);
> }
> elsif ($query->param(but1)) {
> 	print "param: $query->param(but1),"<br>\n";
> }
> 
> When I press the submit button "but1", the "elsif" clause does not execute.

There is something wrong on the last 'print' line: it has three
double quote characters.


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

Date: Wed, 29 Dec 2004 13:11:31 GMT
From: "Paul Lalli" <mritty@gmail.com>
Subject: Re: value of param
Message-Id: <72yAd.23475$Ff3.15628@trndny04>

"sam" <sam.wun@authtec.com> wrote in message
news:cqu8ob$4m3$1@news.hgc.com.hk...
> Hi,
>
> I have a problem with using CGI module in perl to keep track which
> submit button was pressed.
>
> use CGI;
> use CGI::Carp qw/fatalsToBrowser/;
> $query = new CGI;

you forgot to print $query->header();

you forgot to print the starting html

>
> if (!$query->param) {
>      print $query->startform(-target=>'_new');
>      print "<table border width=100% >\n";
> .....
>
>      print $query->submit(but1);

you forgot to print the end of the form

> }
> elsif ($query->param(but1)) {
> print "param: $query->param(but1),"<br>\n";

malformed print statement.

> }
>

you forgot to print the ending html

> When I press the submit button "but1", the "elsif" clause does not
execute.

No one can help you if you don't post your actual code.  Copy and paste
what you're actually using, don't retype it.  Have you seen the posting
guidelines that are posted here twice a week?

An example of your code with the two major errors corrected works
perfectly for me:
#!/usr/bin/perl
use strict;
use warnings;
use CGI;
use CGI::Carp qw/fatalsToBrowser/;
my $query = new CGI;

print $query->header();

if (!$query->param) {
     print $query->startform(-target=>'_new');
#     print "<table border width=100% >\n";
#.....

     print $query->submit(but1);
}
elsif ($query->param(but1)) {
     print "param: ", $query->param(but1),"<br>\n";
}

__END__


Please post your actual code, and perhaps someone can help.

Paul Lalli


>
> Thanks
> Sam
>



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

Date: Wed, 29 Dec 2004 21:36:40 +0800
From: sam <sam.wun@authtec.com>
Subject: Re: value of param
Message-Id: <cqudf2$6vi$1@news.hgc.com.hk>

Paul Lalli wrote:
> "sam" <sam.wun@authtec.com> wrote in message
> news:cqu8ob$4m3$1@news.hgc.com.hk...
> 
>>Hi,
>>
>>I have a problem with using CGI module in perl to keep track which
>>submit button was pressed.
>>
>>use CGI;
>>use CGI::Carp qw/fatalsToBrowser/;
>>$query = new CGI;
> 
> 
> you forgot to print $query->header();
> 
> you forgot to print the starting html
> 
> 
>>if (!$query->param) {
>>     print $query->startform(-target=>'_new');
>>     print "<table border width=100% >\n";
>>.....
>>
>>     print $query->submit(but1);
> 
> 
> you forgot to print the end of the form
> 
> 
>>}
>>elsif ($query->param(but1)) {
>>print "param: $query->param(but1),"<br>\n";
> 
> 
> malformed print statement.
> 
> 
>>}
>>
> 
> 
> you forgot to print the ending html
> 
> 
>>When I press the submit button "but1", the "elsif" clause does not
> 
> execute.
> 
> No one can help you if you don't post your actual code.  Copy and paste
> what you're actually using, don't retype it.  Have you seen the posting
> guidelines that are posted here twice a week?
> 
> An example of your code with the two major errors corrected works
> perfectly for me:
> #!/usr/bin/perl
> use strict;
> use warnings;
> use CGI;
> use CGI::Carp qw/fatalsToBrowser/;
> my $query = new CGI;
> 
> print $query->header();
> 
> if (!$query->param) {
>      print $query->startform(-target=>'_new');
> #     print "<table border width=100% >\n";
> #.....
> 
>      print $query->submit(but1);
> }
> elsif ($query->param(but1)) {
>      print "param: ", $query->param(but1),"<br>\n";
> }
> 
> __END__
> 
> 
Thanks, it works.
Since I m writing a module for webmin. If I include this module in the 
webmin "enviornment", I will need to include webmin's libaries files 
which actually makes the value of "but1" goes to somewhere, probably 
consumed by the webmin header files.
The file and function I used in this webmin module are:
do '../web-lib.pl';
&init_config();
&ReadParse();

I m thinking how to keep the webmin headings appear while preserved the 
CGI functionality of my module.

Thanks
Sam

> Please post your actual code, and perhaps someone can help.
> 
> Paul Lalli
> 
> 
> 
>>Thanks
>>Sam
>>
> 
> 


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

Date: Wed, 29 Dec 2004 22:02:07 +0800
From: sam <sam.wun@authtec.com>
Subject: Re: value of param
Message-Id: <cqueup$7j8$1@news.hgc.com.hk>

sam wrote:

> Paul Lalli wrote:
> 

>> An example of your code with the two major errors corrected works
>> perfectly for me:
>> #!/usr/bin/perl
>> use strict;
>> use warnings;
>> use CGI;
>> use CGI::Carp qw/fatalsToBrowser/;
>> my $query = new CGI;
>>
>> print $query->header();
>>
>> if (!$query->param) {
>>      print $query->startform(-target=>'_new');
>> #     print "<table border width=100% >\n";
>> #.....
>>
>>      print $query->submit(but1);
>> }
>> elsif ($query->param(but1)) {
>>      print "param: ", $query->param(but1),"<br>\n";
>> }
>>
>> __END__
>>
>>
> Thanks, it works.
> Since I m writing a module for webmin. If I include this module in the 
> webmin "enviornment", I will need to include webmin's libaries files 
> which actually makes the value of "but1" goes to somewhere, probably 
> consumed by the webmin header files.
> The file and function I used in this webmin module are:
> do '../web-lib.pl';
> &init_config();
> &ReadParse();
> 
> I m thinking how to keep the webmin headings appear while preserved the 
> CGI functionality of my module.
> 
I just managed to fix the problem by removing the init_config() function 
call in the lib.pl file in my module.

Sam.

> Thanks
> Sam
> 
>> Please post your actual code, and perhaps someone can help.
>>
>> Paul Lalli
>>
>>
>>
>>> Thanks
>>> Sam
>>>
>>
>>


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

Date: Wed, 29 Dec 2004 02:35:27 -0800
From: Joe Smith <joe@inwap.com>
Subject: Re: Why does this work?
Message-Id: <q7SdnZya-v7tFU_cRVn-ig@comcast.com>

Brian McCauley wrote:
> A. Sinan Unur wrote:
> 
>> I have been pulling my hair out trying to remember where this behavior 
>> is described, but I remember seeing a note somewhere regarding the 
>> autoquoting of words that start with a dash.

The => operator is documented as quoting the previous bareword,
and if that bareword is preceded by a hyphen, it too is quoted.

> They are not fully autoquoted
> 
> $ perl -e"print -shift, 666" foo
> -foo666
> $ perl -e"print -shift => 666" foo
> -shift666
> 
> I would consider the behaviour described in this thread to be a 
> (non-serious) bug in Perl

It is not a bug.  It is a feature that was deliberately added to
the language and is documented.
	-Joe


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

Date: Wed, 29 Dec 2004 13:04:51 GMT
From: Bart Lateur <bart.lateur@pandora.be>
Subject: Re: Why does this work?
Message-Id: <tna5t0p1eu4hiuvhvncru8a31pnksig0g4@4ax.com>

Joe Smith wrote:

>Brian McCauley wrote:

>> I would consider the behaviour described in this thread to be a 
>> (non-serious) bug in Perl

>It is not a bug.  It is a feature that was deliberately added to
>the language and is documented.

You're missing the point.

	use strict; print -force

prints:

	-force

both in 5.6.1 as in 5.8.3. For some reason, strict seems to be too
relaxed here. Maybe that is by design too, to allow for emulation of
named parameters more easily.

-- 
	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.  

NOTE: due to the current flood of worm email banging on ruby, the smtp
server on ruby has been shut off until further notice. 

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


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