[29170] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 414 Volume: 11

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Mon May 7 21:19:22 2007

Date: Mon, 7 May 2007 18:19:16 -0700 (PDT)
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)

Perl-Users Digest           Mon, 7 May 2007     Volume: 11 Number: 414

Today's topics:
        Separate Javascipt code from pure Perl code <nikos1337@gmail.com>
    Re: Separate Javascipt code from pure Perl code <pertti.kosunen@pp.nic.fi>
    Re: Separate Javascipt code from pure Perl code <nikos1337@gmail.com>
    Re: Separate Javascipt code from pure Perl code <pertti.kosunen@pp.nic.fi>
    Re: Separate Javascipt code from pure Perl code <glennj@ncf.ca>
    Re: Separate Javascipt code from pure Perl code <nikos1337@gmail.com>
        Skype 1.4 Alpha released for linux. <fekadumamo@yahoo.com>
        Website programming (search + statistics) <csoon@xilinx.com>
    Re: Website programming (search + statistics) <kwan.jingx@gmail.com>
    Re: Website programming (search + statistics) usenet@DavidFilmer.com
    Re: Website programming (search + statistics) <jgibson@mail.arc.nasa.gov>
    Re: Website programming (search + statistics) <xicheng@gmail.com>
        Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)

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

Date: 7 May 2007 00:58:00 -0700
From: Nikos <nikos1337@gmail.com>
Subject: Separate Javascipt code from pure Perl code
Message-Id: <1178524680.137729.223660@h2g2000hsg.googlegroups.com>

Is there a way to put those 2 javascript snippets that are currently
embedded inside index.pl into 1 or 2 separate files because index.pl
now has gone very huge, but also index.pl to remain functional?

#=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D
my $js =3D <<EOH;
function addFromList() {
    var popup =3D document.getElementById('title');
    var olist =3D document.getElementById('ordered_items');
    for (var i =3D 0; i<popup.options.length;i++) {
        if(popup.options[i].selected) {
            var item =3D popup.options[i].value;
            // if you want to allow multiple instances
            // of the same item in your list, remove the
            // next three lines.
            for(var j =3D 0; j<olist.options.length; j++) {
                if (olist.options[j].value =3D=3D item) return;
            }
            var opt  =3D new Option(item,item,false,false);
            olist.options[olist.options.length] =3D opt;
        }
    }
}
function addFromEntry () {
    var olist =3D document.getElementById('ordered_items');
    var entry =3D document.getElementById('requesttext');
    if(entry.value !=3D '') {
        var opt =3D new Option(entry.value,entry.value, false,false);
        olist.options[olist.options.length] =3D opt;
    }
}
function removeFromList () {
    var olist =3D document.getElementById('ordered_items');
    for (var i =3D olist.options.length - 1; i>=3D0; i--) {
        if (olist.options[i].selected) {
            olist.options[i] =3D null;
        }
    }
    olist.selectedIndex =3D -1;
}
function selectAll() {
    var olist =3D document.getElementById('ordered_items');
    for (var i =3D 0; i<olist.options.length; i++) {
        olist.options[i].selected =3D true;
    }
}
EOH
#=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D

print header( -charset=3D>'utf-8' );
print start_html( -script =3D> $js,
      		  -style=3D>'/data/css/style.css',
                  -title=3D>'Order Project!' );

print a( {href=3D>'/cgi-bin/register.pl'},  img{src=3D>'/data/images/
reg.jpg'} );

my @userlist =3D @{ $db->selectcol_arrayref("SELECT username FROM
users") };

print start_form( action=3D>'/cgi-bin/index.pl' );
    print h1( {class=3D>'lime'},  "=CA=DC=ED=E5 LOGIN =E3=E9=E1 =ED=E1 =E4=
=E5=E9=F2 =F4=E9=F2
=F0=E1=F1=E1=E3=E3=E5=EB=DF=E5=F2 =F3=EF=F5 =EC=DD=F7=F1=E9 =F3=F4=E9=E3=EC=
=DE=F2 =3D> ",
                                popup_menu( -name =3D> 'userlogin', -
values =3D> \@userlist ),
                                submit('=D3=FD=ED=E4=E5=F3=E7!'));
print end_form;


my $userlogin =3D param('userlogin');

if ( param('=D3=FD=ED=E4=E5=F3=E7!') )
{
    unless( grep { $_ eq $userlogin }
@userlist )	                       #Check if userlogin name exists in
the drop down menu
    {
        print br() x 2, h1( {class=3D>'big'}, "=C4=E5=ED =F5=F0=DC=F1=F7=E5=
=E9 =F7=F1=DE=F3=F4=E7=F2 =EC=E5
=FC=ED=EF=EC=E1: $userlogin" );
	exit;
    }

    $select =3D $db->prepare( "SELECT host FROM guestlog WHERE
host=3D?" );
    $select->execute( $host );

    if ($select->rows)
    {
        $select =3D $db->prepare( "SELECT host, DATE_FORMAT(date, '%a %d
%b, %h:%i') AS date, counter FROM guestlog WHERE host=3D?" );
        $select->execute( $host );
        $row =3D $select->fetchrow_hashref;

        $data =3D "=CA=E1=EB=FE=F2 =DE=EB=E8=E5=F2 $userlogin! =D7=E1=DF=F1=
=EF=EC=E1=E9 =F0=EF=F5 =E2=F1=DF=F3=EA=E5=E9=F2 =F4=E7=ED
=F3=E5=EB=DF=E4=E1 =E5=ED=E4=E9=E1=F6=DD=F1=EF=F5=F3=E1.
                 =D4=E5=EB=E5=F5=F4=E1=DF=E1 =F6=EF=F1=DC =DE=F1=E8=E5=F2 =
=E5=E4=FE =F9=F2 $row->{host} =F3=F4=E9=F2 $row-
>{date} !
                 =D0=F1=EF=E7=E3=EF=FD=EC=E5=ED=EF=F2 =E1=F1=E9=E8=EC=FE=ED=
 =E5=F0=E9=F3=EA=DD=F8=E5=F9=ED =3D> $row->{counter}
                 =D4=DF =E8=E1 =F0=DC=F1=E5=E9=F2 =F3=DE=EC=E5=F1=E1 !?";

        $select =3D $db->prepare( "UPDATE guestlog SET date=3D?,
counter=3Dcounter+1 WHERE host=3D?" );
        $select->execute( $date, $host );
    }
}
else
{
    if ($host eq "=CD=DF=EA=EF=F2") {
        $data =3D "=C3=E5=E9=DC =F3=EF=F5 =CD=E9=EA=FC=EB=E1! =D0=FE=F2 =F0=
=DC=ED=E5 =F4=E1 =EA=DD=F6=E9=E1? ;-)";
    }
    else {
    	 $data =3D "=C3=E5=E9=DC =F3=EF=F5 $host!
      	       	 =B8=F1=F7=E5=F3=E1=E9 =E3=E9=E1 1=E7 =F6=EF=F1=DC =E5=E4=FE=
 !!
      		 =C5=EB=F0=DF=E6=F9 =ED=E1 =E2=F1=E5=DF=F2 =FC=EB=EF =F4=EF =EB=EF=
=E3=E9=F3=EC=E9=EA=FC =F0=EF=F5 =E5=F0=E9=E8=F5=EC=E5=DF=F2 :-)";
    }

    unless ($host eq "=CD=DF=EA=EF=F2") {
         $select =3D $db->prepare( "INSERT INTO guestlog (host, date,
counter) VALUES (?, ?, ?)" );
         $select->execute( $host, $date, 1 );
    }
}

for ($data) {
  s/\n/\\n/g;
  s/"/\\"/g;
  tr/\cM//d;
}

#=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D
print <<ENDOFHTML;
<script type=3D'text/javascript'>

var textToShow =3D "$data";
var tm;
var pos =3D 0;
var counter =3D 0;

function init()
{ tm =3D setInterval("type()", 50) }

function type()
{
    if (textToShow.length !=3D pos)
    {
       d =3D document.getElementById("DivText");
       c =3D textToShow.charAt(pos++);

       if (c.charCodeAt(0) !=3D 10)
          d.appendChild(document.createTextNode(c));
       else
          d.appendChild(document.createElement("br"));

       counter++;

       if (counter >=3D 3000 && (c.charCodeAt(0) =3D=3D 10 || c =3D=3D "."))
       {
          d.appendChild(document.createElement("br"));
          d.appendChild(document.createTextNode("Press a key to
continue..."));
          counter =3D 0;
          clearInterval(tm);
          document.body.onkeypress =3D function () {
          document.getElementById("DivText").innerHTML =3D '';

          tm =3D setInterval("type()", 50);
          document.body.onkeypress =3D null; };
       }
    }
    else
       clearInterval(tm);
}
</script>

<body onload=3Dinit()>
   <center>
   <div id=3D"DivText" align=3D"Left" style=3D"
     overflow: auto;
     background-image: url(/data/images/vortex.jpg);
     border: Ridge Magenta 5px;
     width:  1100px;
     height: 100px;
     color: Cyan;
     font-family: Bookman;
     font-size: 16px;">
   </div>
ENDOFHTML
#=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D



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

Date: Mon, 07 May 2007 11:06:09 GMT
From: Pertti Kosunen <pertti.kosunen@pp.nic.fi>
Subject: Re: Separate Javascipt code from pure Perl code
Message-Id: <BKD%h.108$797.75@read3.inet.fi>

Nikos wrote:
> print start_html( -script => $js,
>       		  -style=>'/data/css/style.css',

-script =>
[
	{
		-language=>'JAVASCRIPT',
		-src=>'/scripts/script1.js'
	},
	{
		-language=>'JAVASCRIPT',
		-src=>'/scripts/script2.js'
	}
],
-style...


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

Date: 7 May 2007 04:11:16 -0700
From: Nikos <nikos1337@gmail.com>
Subject: Re: Separate Javascipt code from pure Perl code
Message-Id: <1178536276.678613.117910@e51g2000hsg.googlegroups.com>

On May 7, 2:06 pm, Pertti Kosunen <pertti.kosu...@pp.nic.fi> wrote:
> Nikos wrote:
> > print start_html( -script => $js,
> >                      -style=>'/data/css/style.css',
>
> -script =>
> [
>         {
>                 -language=>'JAVASCRIPT',
>                 -src=>'/scripts/script1.js'
>         },
>         {
>                 -language=>'JAVASCRIPT',
>                 -src=>'/scripts/script2.js'
>         }
> ],
> -style...

Will the variables for example $data will be able to pass from
index.pl => script1.js => index.pl ?! because both javascript snippets
use variabels of index.pl and have action with them....



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

Date: Mon, 07 May 2007 12:08:41 GMT
From: Pertti Kosunen <pertti.kosunen@pp.nic.fi>
Subject: Re: Separate Javascipt code from pure Perl code
Message-Id: <dFE%h.121$797.51@read3.inet.fi>

Nikos wrote:
> Will the variables for example $data will be able to pass from
> index.pl => script1.js => index.pl ?! because both javascript snippets
> use variabels of index.pl and have action with them....

Oh yes, then 'do', 'use' etc. could do it.


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

Date: 7 May 2007 12:10:43 GMT
From: Glenn Jackman <glennj@ncf.ca>
Subject: Re: Separate Javascipt code from pure Perl code
Message-Id: <slrnf3u5q3.i9s.glennj@smeagol.ncf.ca>

At 2007-05-07 07:11AM, "Nikos" wrote:
>  Will the variables for example $data will be able to pass from
>  index.pl => script1.js => index.pl ?! because both javascript snippets
>  use variabels of index.pl and have action with them....

Don't rely on Perl variables.  Pass parameters to your javascript
functions.


-- 
Glenn Jackman
"You can only be young once. But you can always be immature." -- Dave Barry


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

Date: 7 May 2007 09:57:11 -0700
From: Nikos <nikos1337@gmail.com>
Subject: Re: Separate Javascipt code from pure Perl code
Message-Id: <1178557031.719883.36700@e65g2000hsc.googlegroups.com>

On May 7, 2:06 pm, Pertti Kosunen <pertti.kosu...@pp.nic.fi> wrote:
> Nikos wrote:
> > print start_html( -script => $js,
> >                      -style=>'/data/css/style.css',
>
> -script =>
> [
>         {
>                 -language=>'JAVASCRIPT',
>                 -src=>'/scripts/script1.js'
>         },
>         {
>                 -language=>'JAVASCRIPT',
>                 -src=>'/scripts/script2.js'
>         }
> ],
> -style...

Thank you Pertti!

<code>
print header( -charset=>'utf-8' );
print start_html( -script =>
                  [
		     {
		        -language => 'JAVASCRIPT',
                        -src => '/data/scripts/char_by_char.js'
                     },
                     {
		        -language => 'JAVASCRIPT',
                        -src => '/data/scripts/orderlist.js'
		     }
                  ],
      		  -style => '/data/scripts/style.css',
                  -title => 'Order Project!' );
</code>
This is how to call he scripts, if only i had a way to pass the $data
varibale as well including call, can you help with that too perhaps?



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

Date: 6 May 2007 16:19:45 -0700
From: pickylee123 <fekadumamo@yahoo.com>
Subject: Skype 1.4 Alpha released for linux.
Message-Id: <1178493585.643192.320490@n76g2000hsh.googlegroups.com>

Skype 4.1 Alpha has been released for linux users. It has all the
usual features but some has unresolved bugs.

http://www.speedateauction.com/blog/blog_detail?blog_id=74315&user_id=1356



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

Date: Mon, 7 May 2007 08:49:49 +0800
From: "Ken Soon" <csoon@xilinx.com>
Subject: Website programming (search + statistics)
Message-Id: <f1lt94$pa11@cnn.xsj.xilinx.com>

Hi,

I have a trying out a website to have this function. This function will 
allow webusers to search for something in the database of my website and 
then later display the related information. Plus, there is also some 
questions for the users to answer for statistics purposes, such as 
age,monthly income, etc... This is to enable me and probably the users to 
know what kind of information is searched by what kind of people.

I have done quite some perl programming but I have not use perl programming 
for database and webprogramming. How do I go about doing this?
Can anyone help please?

Ken 




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

Date: 6 May 2007 22:50:06 -0700
From: kwan <kwan.jingx@gmail.com>
Subject: Re: Website programming (search + statistics)
Message-Id: <1178517006.310169.105180@l77g2000hsb.googlegroups.com>

On May 6, 5:49 pm, "Ken Soon" <c...@xilinx.com> wrote:
> Hi,
>
> I have a trying out a website to have this function. This function will
> allow webusers to search for something in the database of my website and
> then later display the related information. Plus, there is also some
> questions for the users to answer for statistics purposes, such as
> age,monthly income, etc... This is to enable me and probably the users to
> know what kind of information is searched by what kind of people.
>
> I have done quite some perl programming but I have not use perl programming
> for database and webprogramming. How do I go about doing this?
> Can anyone help please?
>
> Ken

google Perl cgi tutorial, you will get pretty of information



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

Date: 7 May 2007 01:01:43 -0700
From: usenet@DavidFilmer.com
Subject: Re: Website programming (search + statistics)
Message-Id: <1178524903.423298.233050@h2g2000hsg.googlegroups.com>

On May 6, 5:49 pm, "Ken Soon" <c...@xilinx.com> wrote:
> Hi,
>
> I have a trying out a website to have this function. This function will
> allow webusers to search for something in the database of my website and
> then later display the related information.

http://search.cpan.org/~timb/DBI-1.55/DBI.pm

> Plus, there is also some questions for the users to answer for
> statistics purposes, such as age,monthly income, etc...

Run away, run away!!!!

--
David Filmer (http://DavidFilmer.com)



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

Date: Mon, 07 May 2007 10:29:19 -0700
From: Jim Gibson <jgibson@mail.arc.nasa.gov>
Subject: Re: Website programming (search + statistics)
Message-Id: <070520071029199082%jgibson@mail.arc.nasa.gov>

In article <f1lt94$pa11@cnn.xsj.xilinx.com>, Ken Soon
<csoon@xilinx.com> wrote:

> Hi,
> 
> I have a trying out a website to have this function. This function will 
> allow webusers to search for something in the database of my website and 
> then later display the related information. Plus, there is also some 
> questions for the users to answer for statistics purposes, such as 
> age,monthly income, etc... This is to enable me and probably the users to 
> know what kind of information is searched by what kind of people.
> 
> I have done quite some perl programming but I have not use perl programming 
> for database and webprogramming. How do I go about doing this?
> Can anyone help please?

Start with the CGI module for web programming and the DBI module for
database access. There are O'Reilly books on each topic.

<http://www.oreilly.com/catalog/perldbi/index.html>
<http://www.oreilly.com/catalog/cgi2/index.html>

Good luck.

 Posted Via Usenet.com Premium Usenet Newsgroup Services
----------------------------------------------------------
    ** SPEED ** RETENTION ** COMPLETION ** ANONYMITY **
----------------------------------------------------------        
                http://www.usenet.com


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

Date: 7 May 2007 11:04:37 -0700
From: Xicheng Jia <xicheng@gmail.com>
Subject: Re: Website programming (search + statistics)
Message-Id: <1178561077.773446.102840@y5g2000hsa.googlegroups.com>

On May 6, 8:49 pm, "Ken Soon" <c...@xilinx.com> wrote:
> Hi,
>
> I have a trying out a website to have this function. This function will
> allow webusers to search for something in the database of my website and
> then later display the related information. Plus, there is also some
> questions for the users to answer for statistics purposes, such as
> age,monthly income, etc... This is to enable me and probably the users to
> know what kind of information is searched by what kind of people.
>
> I have done quite some perl programming but I have not use perl programming
> for database and webprogramming. How do I go about doing this?
> Can anyone help please?
>
> Ken

CGI is kind of old tech in the current web development. embedding your
Perl code directly into the HTML might make your life much easier. one
of such Perl modules is HTML::Mason, you can check its website and on-
line free book.

  http://masonhq.com/
  http://www.masonbook.com/book/

they have very good documentation and site source code..

Good luck,
Xicheng



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

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 V11 Issue 414
**************************************


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