badrinathn
IS-IT--Management
Hi,
I am new to perl, but have very good experience on shell scripting and I am a dba (not a programmer), but have some scripts that I want to understand. Could you please help me understand this script and also point me to some resources where I can learn and write some simple perl programs.
#!/usr/local/bin/perl
use strict;
use Apache;
use Apache::Constants ':response';
use NBN;
use NBN::AdminProd;
my $HTML_Path = "/web/templates/admin";
my $get = NBN:arse_get();
my $post = NBN:arse_post();
SELECT: {
$get->{search} eq "customer_id" and do {
my $customer_info = NBN::AdminProd::customer_info( $get->{customer_id} );
my $customer_net_info = NBN::AdminProd::customer_net_info( $get->{customer_id} );
my $customer_net_permission_info = NBN::AdminProd::customer_net_permission_info( $get->{customer_id} );
my $customer_net_special_group_info = NBN::AdminProd::customer_net_special_group_info( $get->{customer_id} );
my $customer_standards_info = NBN::AdminProd::customer_standards_info( $get->{customer_id} );
my $customer_standards_special_group_info = NBN::AdminProd::customer_standards_special_group_info( $get->{customer_id} );
show_page( "$HTML_Path/customer_info.emb", $customer_info,
$customer_net_info, $customer_net_permission_info, $customer_net_special_group_info,
$customer_standards_info, $customer_standards_special_group_info, $get->{customer_id} );
last;
};
$get->{search_name} eq "last_name" and do {
my $search_result = NBN::AdminProd::search_by_name( lc $get->{last_name} );
show_page( "$HTML_Path/search_by_name.emb", $search_result );
last;
};
# Something requested we don't understand... forward w/o extraneous
if ( $ENV{QUERY_STRING} or $ENV{PATH_INFO} ) {
redirect( $ENV{SCRIPT_NAME} );
}
# Nothing special requested equates to home page
else {
show_page( "$HTML_Path/admin.emb" );
}
};
sub show_page {
my $r = Apache->request;
$r->content_type( "text/html" );
$r->send_http_header;
ASQ::embperl( @_ );
}
sub redirect {
my $url = shift;
my $r = Apache->request;
$r->status( REDIRECT );
$r->header_out( Location => $url );
$r->send_http_header;
}
I am new to perl, but have very good experience on shell scripting and I am a dba (not a programmer), but have some scripts that I want to understand. Could you please help me understand this script and also point me to some resources where I can learn and write some simple perl programs.
#!/usr/local/bin/perl
use strict;
use Apache;
use Apache::Constants ':response';
use NBN;
use NBN::AdminProd;
my $HTML_Path = "/web/templates/admin";
my $get = NBN:arse_get();
my $post = NBN:arse_post();
SELECT: {
$get->{search} eq "customer_id" and do {
my $customer_info = NBN::AdminProd::customer_info( $get->{customer_id} );
my $customer_net_info = NBN::AdminProd::customer_net_info( $get->{customer_id} );
my $customer_net_permission_info = NBN::AdminProd::customer_net_permission_info( $get->{customer_id} );
my $customer_net_special_group_info = NBN::AdminProd::customer_net_special_group_info( $get->{customer_id} );
my $customer_standards_info = NBN::AdminProd::customer_standards_info( $get->{customer_id} );
my $customer_standards_special_group_info = NBN::AdminProd::customer_standards_special_group_info( $get->{customer_id} );
show_page( "$HTML_Path/customer_info.emb", $customer_info,
$customer_net_info, $customer_net_permission_info, $customer_net_special_group_info,
$customer_standards_info, $customer_standards_special_group_info, $get->{customer_id} );
last;
};
$get->{search_name} eq "last_name" and do {
my $search_result = NBN::AdminProd::search_by_name( lc $get->{last_name} );
show_page( "$HTML_Path/search_by_name.emb", $search_result );
last;
};
# Something requested we don't understand... forward w/o extraneous
if ( $ENV{QUERY_STRING} or $ENV{PATH_INFO} ) {
redirect( $ENV{SCRIPT_NAME} );
}
# Nothing special requested equates to home page
else {
show_page( "$HTML_Path/admin.emb" );
}
};
sub show_page {
my $r = Apache->request;
$r->content_type( "text/html" );
$r->send_http_header;
ASQ::embperl( @_ );
}
sub redirect {
my $url = shift;
my $r = Apache->request;
$r->status( REDIRECT );
$r->header_out( Location => $url );
$r->send_http_header;
}