Sponsored Content
Top Forums Shell Programming and Scripting Need help in understanding thisperl code. Post 302299101 by pludi on Thursday 19th of March 2009 08:01:31 AM
Old 03-19-2009
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.
 

10 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

Little Trouble Understanding some code...

Couple of questions as I try to decipher someones code who left... What would something coded like this do? IFS=: grep FIELD1 /Path/Path2/Param.fle | read LBL1 LBL2 USRID EADR SUBJ SERVERNAME CFGTBL DIR ERR=0 Param.fle contents.. FIELD1:FEI::FIELD2:dATAFIELD BATCH:MAIN SERVER......etc.. (2 Replies)
Discussion started by: NycUnxer
2 Replies

2. UNIX for Dummies Questions & Answers

Understanding Code in IF LOOP

Hello All, I would like to know and understand the difference between the below 3 IF loops and also if possible what are the different other parameters i could use other than those mentioed in the below lF LOOP conditions, appreciate your help. Thanks, Sam. (1 Reply)
Discussion started by: Ariean
1 Replies

3. UNIX for Dummies Questions & Answers

Problems understanding example code

I am really new to UNIX and programming in general and so apologies if this thread is a bit simple. I have searched and found a piece of sample code for a training program I am currently undertaking, but seeing as I am relatively new, I dont completely understand how it works. Here is the... (6 Replies)
Discussion started by: Makaer
6 Replies

4. UNIX Desktop Questions & Answers

Understanding the code

hello all, May i know what is this "DEBUG_ME $DEBUG_CMD main" doing in the below code. I am confused with alias also "alias DEBUG_ME='#'". Thanks for your help. set -x alias DEBUG_ME='#' if ; then . /product/apps/informatica/v7/pc/ExtProc/debug.ksh "$1" fi # Declaring the... (1 Reply)
Discussion started by: Ariean
1 Replies

5. Shell Programming and Scripting

Help understanding Perl code.

Well, I found myself trying to fix some Perl code (Ive never done any Perl in my life) and I pinpointed the place where the bug could be. But to be sure I have to know what does a few line of code mean: $files_lim =~ (/^\d*$/) $files_lim =~ (/^\d*h$/)$files_age =~ s/h//The code where this was... (0 Replies)
Discussion started by: RedSpyder
0 Replies

6. Shell Programming and Scripting

Help understanding some Perl code.

Well, I found myself trying to fix some Perl code (Ive never done any Perl in my life) and I pinpointed the place where the bug could be. But to be sure I have to know what does a few line of code mean: $files_lim =~ (/^\d*$/) $files_lim =~ (/^\d*h$/) $files_age =~ s/h// The code where... (2 Replies)
Discussion started by: RedSpyder
2 Replies

7. Programming

Understanding perl code

What is the difference between the two statements below? A: $a->{"$fruit"}->{"$color"}->{size} = $size B: $size = $a->{"$fruit"}->{"$color"}->{size} Please assist. Thanks! (0 Replies)
Discussion started by: onlinelearner02
0 Replies

8. Shell Programming and Scripting

Help with perl code understanding

Hi, I need to understand below perl code, can some one advise me. perl -MDate::Parse -e'BEGIN{$main::now=time;$main::old=(time-60*30)}' -nE'if(/^(\w+\s+\d+\s+\d+:\d+:\d+)/) {$t=str2time $1; $t > $old && $t < $now && print}' (1 Reply)
Discussion started by: learnbash
1 Replies

9. Shell Programming and Scripting

[Solved] Help understanding this code!!

Hi guys, I am still learning awk and much apprecated to shed some light on the following: the questions asked is below! { total = i = 0 do { ++i total += $i } while ( total <= 100 ) print i, ":", total } File used: cat test.do 45 25 60 20 10 105 50 40 33 5 9 67 108 3 5 4 (2 Replies)
Discussion started by: Apollo
2 Replies

10. Programming

Understanding Assembly Code

As the title suggests, I want to better understand the following assembly code: section .text global main ; must be declared for linker (gcc) main: ; tell linker entry point mov edx, len ; message length mov ecx, msg ; message to write... (2 Replies)
Discussion started by: Azrael
2 Replies
CMAP(5)                                                         File Formats Manual                                                        CMAP(5)

NAME
cmap - format of .cmap files (color maps) DESCRIPTION
Color-map files define the mapping between eight-bit color numbers and red, green and blue intensities used for those numbers. They are read by Magic as part of system startup, and also by the :load and :save commands in color-map windows. Color-map file names usually have the form x.y.z.cmapn, where x is a class of technology files, y is a class of displays, z is a class of monitors, and n is a version number (currently 1). The version number will change in the future if the formap of color-map files ever changes. Normally, x and y correspond to the corresponding parts of a display styles file. For example, the color map file mos.7bit.std.cmap1 is used today for most nMOS and CMOS technology files using displays that support at least seven bits of color per pixel and standard-phosphor monitors. It corresponds to the display styles file mos.7bit.dstyle5. Color-map files are stored in ASCII form, with each line containing four decimal integers separated by white space. The first three inte- gers are red, green, and blue intensities, and the fourth field is a color number. For current displays the intensities must be integers between 0 and 255. The color numbers must increase from line to line, and the last line must have a color number of 255. The red, green, and blue intensities on the first line are used for all colors from 0 up to and including the color number on that line. For other lines, the intensities on that line are used for all colors starting one color above the color number on the previous line and continuing up and through the color number on the current line. For example, consider the color map below: 255 0 0 2 0 0 255 3 255 255 255 256 This color map indicates that colors 0, 1, and 2 are to be red, color 3 is to be blue, and all other colors are to be white. SEE ALSO
magic(1), dstyle(5) 4th Berkeley Distribution CMAP(5)
All times are GMT -4. The time now is 06:30 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy