User Profile

Collapse

Profile Sidebar

Collapse
Natti
Natti
Last Activity: Dec 11 '08, 05:57 PM
Joined: Feb 16 '07
Location:
  •  
  • Time
  • Show
  • Source
Clear All
new posts

  • Natti
    replied to Parsing an Error Log
    in Perl
    Heres a pseudocode


    open inputFile for reading
    open outputFile for writing
    while (!EOF) {
    look for regular expressions that you need in the inputFile
    if pattern matches write line to the outputFile
    }
    close inputFile
    close outputFile
    See more | Go to post

    Leave a comment:


  • Natti
    replied to Sorting Excel Data
    in Perl
    Hi Shanmugam,
    Use the ParseExcel module to parse through the excel sheet and get information in text.
    Sort in the information in perl as usual and write it back to the excel using WriteExcel.
    Downloading these modules gives you lots of examples on how to use them.
    You can also use an application known as xls2txt if you do not want to write back to excel.
    See more | Go to post

    Leave a comment:


  • Natti
    replied to Dynamic Multi-line Pattern Matching
    in Perl
    It works now.
    Here's how I have used the errpat variable.
    Code:
    while (  $_ =~ m/$errpat/sgm ) {
                   print "$1  $2 $3\n";
    }
    where errorpat get set to the different regexps
    ^(Error)(.*?)(\ (ERR-[0-9]+\))
    and so on..
    See more | Go to post

    Leave a comment:


  • Natti
    replied to Dynamic Multi-line Pattern Matching
    in Perl
    Here is a piece of code I picked up from
    http://perldoc.perl.or g/perlfaq6.html#I 'm-having-trouble-matching-over-more-than-one-line.
    --What's-wrong%3f-regex%2c-multiline-regexp%2c-multiline-regular-expression%2c-multiline
    and modified it to suit my requirements.


    Code:
    #!/usr/bin/perl -w
       undef $/;  		
        while ( <> ) {
    	while (  /(Error)(.*?)(\(ERR-[0-9]+\))/sgm ) { 
    	    print
    ...
    See more | Go to post

    Leave a comment:


  • Natti
    replied to Dynamic Multi-line Pattern Matching
    in Perl
    Here is the code.
    The usage is
    <prog_name>.p l -file <input_file> -pattern_file <input_pattern_ file>

    Code:
    #!/usr/bin/perl -w
    
    $debug = 0;
    $foundPattern = 0;
    while ($arg = shift @ARGV) {
            if ($arg eq "-file") {$file = shift @ARGV;}
            elsif ($arg eq "-pattern_file") {$pattern_file = shift @ARGV;}
            elsif ($arg eq
    ...
    See more | Go to post

    Leave a comment:


  • Natti
    started a topic Dynamic Multi-line Pattern Matching
    in Perl

    Dynamic Multi-line Pattern Matching

    Hello,
    I have a perl program which parses an input file for specific error patterns and generates an output file with all these lines.

    One of the error patterns that I am looking at spans across multiple lines. I can detect it can as error pattern using information from the first line but cannot print out the remaining lines.
    Is there a way to regexp multiple lines and store all lines in a string or array.
    ...
    See more | Go to post

  • docsnyder,
    I am open a pipe to the tail and then using the fileevent. The redirection to /dev/null does not work and I get the following error message.

    sh: /dev/null: ambiguous redirect...
    See more | Go to post

    Leave a comment:


  • Hello Miller,
    Thanks for the info on this post. I tried that already. However, I go into the subroutine and start the tail process for a list of files at the beginning of execution. That prevents me from using the -e option.
    I managed to overcome this problem by making sure that the file exists before the subroutine is called. i.e. I will cat a null value into the file if it does not exist.

    Natti...
    See more | Go to post

    Leave a comment:


  • Natti
    started a topic How to Autoflush STDOUT
    in Perl

    How to Autoflush STDOUT

    On execution of
    #!/usr/bin/perl
    $val = 4;
    for ($i=0;$i<=$val; $i++) {
    print "$i\n";
    sleep(1);
    }

    the output is
    0
    1
    2
    3
    4

    However if I remove the newline character from the print statement, the output on my STDOUT is seen only after the entire for loop has been completed. I would assume the output to happen as...
    See more | Go to post

  • Natti
    replied to TK Entry Widget - Events?
    in Perl
    Hi,
    You can probably use the delete method on hlist and refresh it on any keystroke on the entry box. However, I would not recommend this as it would do a redraw of your hlist each time.
    You will have to form your hlist array each time the keystroke is entered.
    See more | Go to post

    Leave a comment:


  • Natti
    started a topic STDOUT - Overwriting previous line
    in Perl

    STDOUT - Overwriting previous line

    Hello,
    I am trying to update the STDOUT dynamically.
    For eg. I am trying to display a counter whose value should get updated int he same place,

    #!/usr/bin/perl

    $val = 10;
    for ($i=0;$i<=$val; $i+) {
    print "$val\n";
    }
    would print
    0
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10

    What I am looking...
    See more | Go to post

  • Hello Miller,
    I just put in $file as an example. In my code I assign it a value. Anyway if the file does not exist, the tail warning comes up. As an example
    Assume my file ./test.txt does not exist


    #!/usr/bin/perl
    $file = "./test.txt"
    open(FILE, "tail -F -n 10 $file") or die;

    gives out the tail warning saying no file or directory.
    Once I cat some value into...
    See more | Go to post

    Leave a comment:


  • That doesnt work either. I still get the message on my shell.

    The message does not come from the Error $! but gets dumped out when perl tries to execute tail to open the file.
    See more | Go to post

    Leave a comment:


  • As a small example,

    I open my file using

    #!/usr/bin/perl -w
    open(FILE, "tail -F -n 10 $file |") or die "Error $!\n";

    'tail cannot open <filename> no such file or directory'

    is written out to my shell.

    How can I hide this.
    See more | Go to post

    Leave a comment:


  • Hiding tail "no such file or directory" message in Perl/Tk

    Hello,
    I start fileevents as soon as my tk code is invoked. My widget gets updated based on the fileevents. Most of the files do not exist in the beginning and so I get the following messages on the prompt where I invoked the perl/tk program.

    tail 'filename' for reading:no such file or directory.

    The widget update works fine. But is there anyway that I can prevent these messages from showing up. Also when information...
    See more | Go to post
No activity results to display
Show More
Working...