CGI/Perl Guide | Learning Center | Forums | Advertise | Login
Site Search: in

  Main Index MAIN
INDEX
Search Posts SEARCH
POSTS
Who's Online WHO'S
ONLINE
Log in LOG
IN

Home: Perl Programming Help: Advanced:
MVC with perl?

 



hydpm
User

Mar 13, 2010, 3:28 AM

Post #1 of 4 (2456 views)
MVC with perl? Can't Post

Hi,

I'm looking for building custom MVC application sample with perl.

Not with catalyst. To simulate with perl the controller, model and view .

Any Helloworld example with MVC in perl?

Thanks,
Raj


murugaperumal
Novice


Mar 14, 2010, 11:20 PM

Post #2 of 4 (2412 views)
Re: [hydpm] MVC with perl? [In reply to] Can't Post

Refer the following link
http://codediaries.blogspot.com/2009/02/mvc-example-using-struts-2-and-tomcat-6.html


hydpm
User

Mar 17, 2010, 1:02 AM

Post #3 of 4 (2350 views)
Re: [murugaperumal] MVC with perl? [In reply to] Can't Post

Murugavel,

Thanks much for the response. I asked not with Struts which is done with Java implementaion.

I would like to do with perl with out using any frameworks. I mean to say , writing every thing [model, view, controller] in perl.



Thanks,

Raj


7stud
Enthusiast

Mar 18, 2010, 4:37 AM

Post #4 of 4 (2329 views)
Re: [hydpm] MVC with perl? [In reply to] Can't Post


Quote
Any Helloworld example with MVC in perl?



Code
package View; 

use strict;
use warnings;
use 5.010;

sub new {
my $self = {};

$self->{OUTPUT} = undef;
$self->{INPUT} = undef;

bless $self;
return $self;
}

sub display_output {
my $self = shift;
$self->{OUTPUT} = shift;

say "computer says: $self->{OUTPUT}";

return undef;
}

sub retrieve_input {
my $self = shift;

print 'your response: ';
$self->{INPUT} = <STDIN>;

return $self->{INPUT};
}

return 1;





Code
package Controller; 

use strict;
use warnings;
use 5.010;

sub new {
my $class = shift;
my $self = {};

$self->{VIEW} = shift;
$self->{MODEL} = shift;


bless $self;
return $self;
}

sub interact_with_user {
my $self = shift;
my $output = shift;

$self->{VIEW}->display_output($output);
$self->{VIEW}->retrieve_input;

my $response_count = $self->{MODEL}->calculate_response_count(1);

$output = "total responses = $response_count";
$self->{VIEW}->display_output($output);

return undef;
}

return 1;


Code
     
package Model;

use strict;
use warnings;
use 5.010;

sub new {
my $self = {};

$self->{RESPONSE_COUNT} = 0;

bless $self;
return $self;
}

sub calculate_response_count {
my $self = shift;
my $increment = shift;

$self->{RESPONSE_COUNT} += $increment;

return $self->{RESPONSE_COUNT};
}

return 1;



Code
use strict; 
use warnings;
use 5.010;

use Model;
use View;
use Controller;


my $view = View->new();
my $model = Model->new();
my $controller = Controller->new($view, $model);

$controller->interact_with_user('hello');



(This post was edited by 7stud on Mar 18, 2010, 5:03 AM)

 
 


Search for (options) Powered by Gossamer Forum v.1.2.0

Web Applications & Managed Hosting Powered by Gossamer Threads
Visit our Mailing List Archives