Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Perl Help 1

Status
Not open for further replies.

badrinathn

IS-IT--Management
Nov 15, 2005
16
US
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::parse_get();
my $post = NBN::parse_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;
}


 
Well for one this script runs under mod_perl. It's seems to take form input or return an error. There are several modules that are require'd (NBN & NBN::AdminProd). From the look of it NBN is the base class while NBN:adminProd provides the customer search functions for this script.

If you are looking into using perl a good book to start with would be..

Elements of Programming with Perl, Andrew L. Johnson and Perl Best Practices, Damian Conway.

M. Brooks
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top