The UNIX and Linux Forums  

Go Back   The UNIX and Linux Forums > Top Forums > Shell Programming and Scripting
.
google unix.com



Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts and shell scripting languages here.

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
Newbi - Understanding the Code and proper download mpinto UNIX for Dummies Questions & Answers 2 12-24-2008 10:48 AM
am a newbie to unix. plz help in understanding this code. gokulj UNIX for Dummies Questions & Answers 1 12-23-2008 05:29 AM
Little Trouble Understanding some code... NycUnxer UNIX for Dummies Questions & Answers 2 10-31-2007 09:20 AM
how i prepare a c++ code(c code) for implementing my own protocol format amitpansuria High Level Programming 1 09-07-2007 12:09 AM

Closed Thread
English Japanese Spanish French German Portuguese Italian Dutch Swedish Russian Norwegian Hungarian Hebrew Danish Bulgarian Greek Powered by Powered by Google
 
LinkBack Thread Tools Search this Thread Rating: Thread Rating: 1 votes, 2.00 average. Display Modes
  #1 (permalink)  
Old 03-19-2009
Raheel Hassan Raheel Hassan is offline
Registered User
  
 

Join Date: Mar 2009
Posts: 1
Need help in understanding thisperl code.

Can any body explains the under given lines of code i have difficulties in understanding it,


my $errorlog = "/var/log/controler.log";

&initLanguage($language);
&launchCbox();
sub launchCbox {

$scr = Term::ScreenColor->new;
$scr->clrscr();
my ($mode) = @_;
my $error = 0;
my $cbox_x = $dog_x + 3;

my $args;
my %box_args = %{$args[3]};
$args .= "-d " if $box_args{"debug"};
$args .= "-l " if $box_args{"log"};
$args .= "-L ".$box_args{"language"} if $box_args{"language"};

if($mode ne "restart") { $scr->at($y_pos,3)->puts($x.". ".$txth->getText("5016")); }
else { $y_pos = $dog_y_pos+3; $scr->at($dog_y_pos+3,3)->puts($cbox_x.". ".$txth->getText("5016"." "x($status_bar_pos-(length($txth->getText("5016"))+7)))); }

if(!$xwindow) { `perl ./cbox.pl 2>>/var/log/cbox.log $args > /dev/tty9`; }
else { `perl ./cbox.pl 2>>/var/log/cbox.log $args > /dev/pts/2`; }
$error ? &printNOK : &printOK;

}

Kindest Regards,
Raheel.
  #2 (permalink)  
Old 03-19-2009
pludi's Avatar
pludi pludi is offline Forum Staff  
Moderator
  
 

Join Date: Dec 2008
Location: .at
Posts: 1,900
Hint of the Day: "Use [code][/code ] tags (sans the space), or the '#' symbol in the advanced editor to make your source or listing better readable for others."

That said, I can only guess what this code might be doing, as it relies heavily on global variables.
Code:
my $errorlog = "/var/log/controler.log";

&initLanguage($language); # I18N / L10N?
&launchCbox();

sub launchCbox {

    $scr = Term::ScreenColor->new; # Enable us to use pretty colors and
                                   # positioning on the terminal
    $scr->clrscr(); # Clear the screen
    my ($mode) = @_;
    my $error  = 0;
    my $cbox_x = $dog_x + 3; # Global. Source unknown. Meaning
                             # unknown.

    my $args;
    my %box_args = %{ $args[3] }; # Same as above
    $args .= "-d "                         if $box_args{"debug"};
    $args .= "-l "                         if $box_args{"log"};
    $args .= "-L " . $box_args{"language"} if $box_args{"language"};

    if ( $mode ne "restart" ) {
        
        # Print at line $y_pos, column 3 of the terminal the translation with
        # the key 5016 (whatever that is)
        $scr->at( $y_pos, 3 )->puts( $x . ". " . $txth->getText("5016") );
    }
    else {
        $y_pos = $dog_y_pos + 3; # Globals again
        $scr->at( $dog_y_pos + 3, 3 )->puts(
            $cbox_x . ". "
              . $txth->getText(
                "5016"
                  . " " x (
                    $status_bar_pos - ( length( $txth->getText("5016") ) + 7 )
                  )
              )
        ); # Write at position $dog_y_pos+3, 3 the content of $cbox_x,
           # the translation for key 5016, and a space (' ') times
           # the position of the status bar minus (about) the length of
           # text #5016
    }

    if ( !$xwindow ) { # If a xterm (or similar) is there, write to one
                       # hardcoded TTY, to another hardcoded TTY otherwise.
                       #Either way call cbox.pl
        `perl ./cbox.pl 2>>/var/log/cbox.log $args > /dev/tty9`;
    }
    else { `perl ./cbox.pl 2>>/var/log/cbox.log $args > /dev/pts/2`; }
    $error ? &printNOK : &printOK;

}
If I had to guess I'd say this code was written by someone who likes to use code generation utilities and is concerned more with appearence than function.
Closed Thread

Bookmarks

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On




All times are GMT -4. The time now is 12:07 PM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited. Language Translations Powered by .
vBCredits v1.4 Copyright ©2007 - 2008, PixelFX Studios
The UNIX and Linux Forums Content Copyright ©1993-2009. All Rights Reserved.Ad Management by RedTyger

Content Relevant URLs by vBSEO 3.2.0