Hi everyone,
I'm new to perl scripting...But I managed to write a script and it is executing well.
The requirement is error management should be implemented for this script. That is
some error handling code should be included in the script so that if there is any error at any point in the script that you are expecting, it should terminate from that point.
I think we have to use trial,catch and finally blocks for this..but I'm not sure.
If anyone you guys have any idea on how to write it in the script below, please help me out.....Thanks in advance.
I'm new to perl scripting...But I managed to write a script and it is executing well.
The requirement is error management should be implemented for this script. That is
some error handling code should be included in the script so that if there is any error at any point in the script that you are expecting, it should terminate from that point.
I think we have to use trial,catch and finally blocks for this..but I'm not sure.
If anyone you guys have any idea on how to write it in the script below, please help me out.....Thanks in advance.
Code:
use LWP::UserAgent;
$ua = LWP::UserAgent->new;
my $file = "createFile.xml";
my $file_location = "C:\\Users\\rthout\\$file";
open FILE, "<" , $file_location or die $!;
while (<FILE>) {
$myrequest = $myrequest . $_;
}
my $req = HTTP::Request->new(POST => 'https://IP:Port/service/mgmt/current/');
$req->content_type('text/xml');
$req->content($myrequest);
$req->authorization_basic('kyedaval', 'datapower007');
my $res = $ua->request($req);
if ($res->is_success) {
print $res->as_string;
print $res->decoded_content;
}
else {
print "Failed: ", $res->status_line, "\n";
}
Comment