FAQ
I have to modify a script to upload different data to a server,


until now i did and script that ask you a question and capture the variable
into a hash (see below), now, i would like to modify it and make something
that allows me to ask different questions using the same script

how can i do this?

Thanks

#! /usr/bin/perl
#use strict;
use CGI::Ajax;
use CGI;

my $q = new CGI;

my $concatter = sub {

my $buffer = $ENV{'QUERY_STRING'};

my @pairs = split( /&/, $buffer );

foreach my $pair (@pairs) {

my ( $name, $value ) = split( /=/, $pair );

$name =~ tr/+/ /;

$name =~ s/%([a-fA-F0-9][a-fA-F0-9])/pack("C", hex($1))/eg;

$value =~ tr/+/ /;

$value =~ s/%([a-fA-F0-9][a-fA-F0-9])/pack("C", hex($1))/eg;

$Variables{$name} = $value;
}


print "<html><head></head><body>";
foreach (%Variables) {print "$_\n"}

print "</head></html>";


return ;
};


my $Show_Form = sub {

my $html = "";

$html = <<EOT
<HTML>
<HEAD><title>CGI::Ajax Multiple Return Value Example</title>
</HEAD>
<BODY>
<input type="hidden" id="item" size="6">
<input type="hidden" id="namedItem" size="6">
<form>
<input type="text" id="val1" size="6"><br/>
<br/>

<button onclick='jsFunc(formDump());return false' > Submit </button>
</form>
</BODY>
</HTML>
EOT
;

return $html;
};

my $Show_Form2 = sub {

my $html = "";

$html = <<EOT
<HTML>
<HEAD><title>CGI::Ajax Multiple Return Value Example</title>
</HEAD>
<BODY>
<h1>form2</h1>
</BODY>
</HTML>
EOT
;

return $html;
};


my $pjx = CGI::Ajax->new( 'jsFunc' => $concatter);

$pjx->JSDEBUG(1);

$pjx->DEBUG(1);
print $pjx->build_html($q,$Show_Form); # this outputs the html for the page



--
Pau Marc Muñoz Torres

Laboratori de Biologia Computacional
Institut de Biotecnologia i Biomedicina Vicent
Villar
Universitat Autonoma de Barcelona
E-08193 Bellaterra (Barcelona)

telèfon: 93 5812807
Email : paumarc.munoz@bioinf.uab.cat

Search Discussions

  • Pau Marc Munoz Torres at Apr 8, 2008 at 2:53 pm
    I have to modify a script to upload different data to a server,


    until now i did and script that ask you a question and capture the variable
    into a hash (see below), now, i would like to modify it and make something
    that allows me to ask different questions using the same script

    how can i do this?

    Thanks

    #! /usr/bin/perl
    #use strict;
    use CGI::Ajax;
    use CGI;

    my $q = new CGI;

    my $concatter = sub {

    my $buffer = $ENV{'QUERY_STRING'};

    my @pairs = split( /&/, $buffer );

    foreach my $pair (@pairs) {

    my ( $name, $value ) = split( /=/, $pair );

    $name =~ tr/+/ /;

    $name =~ s/%([a-fA-F0-9][a-fA-F0-9])/pack("C", hex($1))/eg;

    $value =~ tr/+/ /;

    $value =~ s/%([a-fA-F0-9][a-fA-F0-9])/pack("C", hex($1))/eg;

    $Variables{$name} = $value;
    }


    print "<html><head></head><body>";
    foreach (%Variables) {print "$_\n"}

    print "</head></html>";


    return ;
    };


    my $Show_Form = sub {

    my $html = "";

    $html = <<EOT
    <HTML>
    <HEAD><title>CGI::Ajax Multiple Return Value Example</title>
    </HEAD>
    <BODY>
    <input type="hidden" id="item" size="6">
    <input type="hidden" id="namedItem" size="6">
    <form>
    <input type="text" id="val1" size="6"><br/>
    <br/>

    <button onclick='jsFunc(formDump());return false' > Submit </button>
    </form>
    </BODY>
    </HTML>
    EOT
    ;

    return $html;
    };

    my $Show_Form2 = sub {

    my $html = "";

    $html = <<EOT
    <HTML>
    <HEAD><title>CGI::Ajax Multiple Return Value Example</title>
    </HEAD>
    <BODY>
    <h1>form2</h1>
    </BODY>
    </HTML>
    EOT
    ;

    return $html;
    };


    my $pjx = CGI::Ajax->new( 'jsFunc' => $concatter);

    $pjx->JSDEBUG(1);

    $pjx->DEBUG(1);
    print $pjx->build_html($q,$Show_Form); # this outputs the html for the page



    --
    Pau Marc Muñoz Torres

    Laboratori de Biologia Computacional
    Institut de Biotecnologia i Biomedicina Vicent
    Villar
    Universitat Autonoma de Barcelona
    E-08193 Bellaterra (Barcelona)

    telèfon: 93 5812807
    Email : paumarc.munoz@bioinf.uab.cat

    --
    Pau Marc Muñoz Torres

    Laboratori de Biologia Computacional
    Institut de Biotecnologia i Biomedicina Vicent
    Villar
    Universitat Autonoma de Barcelona
    E-08193 Bellaterra (Barcelona)

    telèfon: 93 5812807
    Email : paumarc.munoz@bioinf.uab.cat
  • Jenda Krynicky at Apr 8, 2008 at 10:21 pm
    From: "Pau Marc Munoz Torres" <paumarc.munoz@bioinf.uab.cat>
    #! /usr/bin/perl
    #use strict;
    use CGI::Ajax;
    use CGI;

    my $q = new CGI;

    my $concatter = sub {

    my $buffer = $ENV{'QUERY_STRING'};

    my @pairs = split( /&/, $buffer );

    foreach my $pair (@pairs) {

    my ( $name, $value ) = split( /=/, $pair );

    $name =~ tr/+/ /;

    $name =~ s/%([a-fA-F0-9][a-fA-F0-9])/pack("C", hex($1))/eg;

    $value =~ tr/+/ /;

    $value =~ s/%([a-fA-F0-9][a-fA-F0-9])/pack("C", hex($1))/eg;

    $Variables{$name} = $value;
    }
    Do not, repeat, do NOT parse the querystring yourself. Let CGI.pm,
    CGI::Lite or CGI::Deurl do that for you. Safely.

    Jenda
    ===== Jenda@Krynicky.cz === http://Jenda.Krynicky.cz =====
    When it comes to wine, women and song, wizards are allowed
    to get drunk and croon as much as they like.
    -- Terry Pratchett in Sourcery
  • Lou Hernsen at Apr 9, 2008 at 5:12 pm
    Hallo

    I have an array
    @Treasures
    and I want to match anywhere in it for
    /:1:2:3:/
    can I
    if (@Treasures =~ /:1:2:3:/){}
    or do i have to change (@Treasures to $Treasures and then
    $Treasures = @Treasures ;
    if ($Treasures =~ /:1:2:3:/){}

    Just thought I'd ask first, I have to take mother in law to Dr. so I don't
    have time to test right now...
    I'll check email in a few hours...
    thanks
    Lou
  • Jeff Pang at Apr 10, 2008 at 11:31 am

    On Thu, Apr 10, 2008 at 1:07 AM, Lou Hernsen wrote:
    Hallo

    I have an array
    @Treasures
    and I want to match anywhere in it for
    /:1:2:3:/
    can I
    if (@Treasures =~ /:1:2:3:/){}
    or do i have to change (@Treasures to $Treasures and then
    $Treasures = @Treasures ;
    if ($Treasures =~ /:1:2:3:/){}
    You can use a 'grep', like:

    use strict;
    my @x = (11,22, ':1:2:3:xxx', 'ab','cd', 'test:1:2:3:dd:ee');
    my @seen = grep {/:1:2:3:/} @x;

    print "@seen";


    Good luck with your family.
  • Itshardtogetone at Apr 10, 2008 at 1:19 pm
    Hi,
    How about this :-

    foreach (@Treasures){
    if ($_=~ /:1:2:3:/){
    print "do your stuffs here\n":
    }
    }

    ----- Original Message -----
    From: "Lou Hernsen" <lhernsen1015@wowway.com>
    To: <beginners@perl.org>; <beginners-cgi@perl.org>
    Sent: Thursday, April 10, 2008 1:07 AM
    Subject: Testing an array for a match

    Hallo

    I have an array
    @Treasures
    and I want to match anywhere in it for
    /:1:2:3:/
    can I
    if (@Treasures =~ /:1:2:3:/){}
    or do i have to change (@Treasures to $Treasures and then
    $Treasures = @Treasures ;
    if ($Treasures =~ /:1:2:3:/){}

    Just thought I'd ask first, I have to take mother in law to Dr. so I don't
    have time to test right now...
    I'll check email in a few hours...
    thanks
    Lou


    --
    To unsubscribe, e-mail: beginners-unsubscribe@perl.org
    For additional commands, e-mail: beginners-help@perl.org
    http://learn.perl.org/

Related Discussions

Discussion Navigation
viewthread | post
Discussion Overview
groupbeginners @
categoriesperl
postedApr 8, '08 at 2:51p
activeApr 10, '08 at 1:19p
posts6
users6
websiteperl.org

People

Translate

site design / logo © 2022 Grokbase