User Profile

Collapse

Profile Sidebar

Collapse
nithinpes
nithinpes
Last Activity: Dec 2 '21, 04:39 PM
Joined: Dec 19 '07
Location:
  •  
  • Time
  • Show
  • Source
Clear All
new posts

  • If I understood your question right, I am guessing the keywords in your keywords.txt will be something like:
    keywords.txt
    Code:
    keyword\d
    \d\d\d
    p\w{7}\d
    if that's the case, the line 5 of you code should be
    Code:
    my $keyword_or = join '|', map {chomp;qr/$_/} <$keywords>;

    Using \Q will escape all special characters that follow, which may not be what you want if you...
    See more | Go to post

    Leave a comment:


  • nithinpes
    replied to How to compare two XML files in perl?
    in Perl
    To compare two XML documents and find the differences, you may make use of XML::SemanticDi ff.

    The documentation given in CPAN would be sufficient to start with the script. Try it out and if you face any problem, post it here.
    See more | Go to post

    Leave a comment:


  • If the path contains spaces, then the entire path needs to be escaped within quotes (quoted command should be passed to system).

    Code:
    system("start \"C:\\Documents and Settings\\mybatchfile.bat\"");
    See more | Go to post

    Leave a comment:


  • I am not sure what you want "to compare" here. But if you want to create the scalar fresh with each iteration, use 'my' (for local scope). You can later push each value into an array.

    Code:
    my $total = $number3**2+$number2**2+$number1**2;
    print "$total\n";
    
    push @totals,$total;
    See more | Go to post

    Leave a comment:


  • You may make use of Java::Swing module.
    See more | Go to post

    Leave a comment:


  • nithinpes
    replied to system command in perl
    in Perl
    If you want to return the control without closing the notepad, use:
    Code:
    $res=exec("notepad.exe");
    See more | Go to post

    Leave a comment:


  • Try the following repositories:
    http://www.bribes.org/perl/ppm/
    OR
    http://trouchelle.com/ppm10/

    Alternately, you can try to download from CPAN and install manually....
    See more | Go to post

    Leave a comment:


  • nithinpes
    replied to Palindrome Question
    in Perl
    If you had used use strict; and use warnings;, you would have caught the problem. The problem is with the use of global variable inside the subroutine. The code below works (make use of local variables):

    Code:
    for (my $j = "100"; $j <= "110"; $j += 1){ 
     for(my $i = "100"; $i <= $j; $i += 1){ 
      if(isPalindrome($i*$j)){ 
       print STDOUT ($i*$j)." Is a product of two three-digit
    ...
    See more | Go to post

    Leave a comment:


  • nithinpes
    replied to code is not working
    in Perl
    There are multiple errors in your script.
    1. the way you have defined hash
    Code:
    %dbase = { 
            apple => "fruit", 
            brinjal => "vegetable" , 
            coffee => "beverage", 
            };
    Using curly braces will create an anonymous hash(a hash reference). You should use parentheses in this case.

    2. The return statement should...
    See more | Go to post

    Leave a comment:


  • nithinpes
    replied to what is wrong with my script.
    in Perl
    If you use :
    Code:
    $myfile =~ /<b>(.*)<\/b>/xg
    $1 would have "The Testing Page is here</b></a>
    <b> extrat text".
    This is because of the greedy nature of * quantifier. To limit this behaviour in order to match minimum number of characters before finding a </b>, use:
    Code:
    $myfile =~ /<b>(.*?)<\/b>/xg
    See more | Go to post

    Leave a comment:


  • nithinpes
    replied to program for input apple output "apple"
    in Perl
    when you read from the file, $file contains a newline. Remove the newline before appending the #.

    Code:
    foreach $file(@line)
    {
    chomp $r;                         #remove newline
    $r="#$file#\n";                    #add newline
    print(OUT "$r");
    }
    See more | Go to post

    Leave a comment:


  • nithinpes
    replied to problem with spaces in directory name
    in Perl
    In the below line from your code:
    Code:
    my $h_dir = '$homedir/$f/Analyst-$1/Projects/$1/Project Information';
    use double quotes instead of single quotes. There will be no substitution of variables inside single quotes. Single quotes are used for literal strings.
    See more | Go to post

    Leave a comment:


  • nithinpes
    replied to perl hash doubt
    in Perl
    The approach would be to remove duplicate lines first.
    Then split each unique line on spaces into an array and then create a hash of arrays. The first column in the file will be made hash key and the remaining values will be pushed into an array which is value for the key. Whenever you come across a key that already exists, append rest of the elements into the existing value of key.
    I am giving only the approach since you haven't...
    See more | Go to post

    Leave a comment:


  • nithinpes
    replied to Matrix pairings to print 0 or 1
    in Perl
    Your script works absolutely fine if you put the order of animals in @order. Also, close the while loop after reading the data.
    Code:
    use strict; 
    use warnings; 
      
    my %A;
    my @order=qw(horse mule tiger lion);
      
    while (<DATA>) { 
      warn("Line $.: cannot understand: $_") , next unless /(\w+);(\w+)/; 
      my ($row, $col) = ($1,$2); 
     $A {$row}{$col}++;
    ...
    See more | Go to post

    Leave a comment:


  • The write_comment method accepts the comment string as a single argument. When you pass an array, each element of the array will be considered as an argument and this violates syntax of the method.
    You can read entire chunk of the file as a single string and pass it as comment.
    Code:
    use Spreadsheet::WriteExcel; 
    $workbook = Spreadsheet::WriteExcel->new('perl.xls'); 
    $worksheet = $workbook->add_worksheet();
    ...
    See more | Go to post

    Leave a comment:


  • nithinpes
    replied to PDF display from perl script
    in Perl
    To read from the PDF file, you can make use of PDF::Core module.
    See more | Go to post

    Leave a comment:


  • nithinpes
    replied to telnet to router
    in Perl
    For the first program, the 'print' method only passes the command to telnet. It will not display the result on your console. If you want the result on console, use 'cmd' method to capture result. Alternately, you can use 'Output_log' and 'Input_log' options to save input & output of telnet session to a log file.

    Code:
    my $telnet = new Net::Telnet ( Timeout=>10,Errmode=>'die',Input_log => 'input.txt, Output_log=>
    ...
    See more | Go to post

    Leave a comment:


  • nithinpes
    replied to telnet to router
    in Perl
    That should be simple.
    Code:
    print "\nEnter Router IP:";
    $hostname=<STDIN>;
    print "\nEnter password:";
    $password=<STDIN>;
    See more | Go to post

    Leave a comment:


  • nithinpes
    replied to String manipulation for a date
    in Perl
    Jeff's command should have been:

    Code:
    perl -pi.bak -e 's/(\d{4})(\d{2})(\d{2})T(\d{2})(\d{2})(\d{2})/$1-$2-$3-$4.$5.$6.000000/' /tmp/junk.txt
    \d{,4} will set an upper limit of 4 occurences for digits(max. 4 digits) and not exact 4 occurences as in \d{4} (which is appropriate for the given sample data).
    See more | Go to post

    Leave a comment:


  • The problem is in this line:
    Code:
    $params{$query_ref[1][1]}={};
    With each iteration of the while loop, value for the key 'age' will be re-assigned to an anonymous hash, overwriting the value (key-value pair) assigned in:
    Code:
    $params{$key}{$1} = 1;
    The structure for "age" key is different from others in your script. If that is how you want it to be, define that line...
    See more | Go to post

    Leave a comment:

No activity results to display
Show More
Working...