Convert perl to shell


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Convert perl to shell
# 1  
Old 12-06-2013
Convert perl to shell

Hi
I am a novice in scripting .Please help me converting perl script into shell
Code:
my ($ref) = shift;
 my $id;
 my $cnt=0;
 my $first =0;
my $filename ;
my $filename1  ;   
     FOREACH:foreach my $r (qw(RET LSH PDM )) {
      $ref->{$cnt}->{num_errors} =0;
  $ref->{$cnt}->{num_warnings} =0;
 
        if($first==0){
   $filename = "$PASS_DIR/$r.rpt"; 
          $filename1 = "$PASS_DIR/${r}_su.rpt";
    $ref->{$cnt}->{is_raw} =1; 
 }else{
   $filename = "$PASS_DIR/$r.rpt";
   $filename1 = "$PASS_DIR/${r}_su.rpt"; 
    $ref->{$cnt}->{is_raw} =0;
 
 }
    $ref->{$cnt}->{type}= $r;
  if(!-e $filename1){
   $ref->{$cnt}->{sumf}= '';
  }else{
   $ref->{$cnt}->{sumf}= $filename1;  
   }
   
    if(-e $filename){  
   my $start = 0;
               while ( my $line = <IN> ) {
  if ( $line =~ m/\s*(${r}.*)\:/ ) {
                    $id    = $1;
                    $start = 1;
                }
  if (( $start == 1 ) and ( $line =~m/\s*Sev\s*\:\s*(\w+)\s+\w+\s*\:\s*(\d+)\s*$/ )){
#                  $ref->{$1}->{ ${id} } = $2;
                 if ($1 eq 'Er'){
    $ref->{$cnt}->{num_errors} += $2 ;
   }elsif($1 eq 'War'){
    $ref->{$cnt}->{num_warnings} += $2 ;
   }
                   $start = 0;
                }
     }
     close IN;
     
}


Last edited by Franklin52; 12-07-2013 at 07:35 AM.. Reason: Please use code tags
# 2  
Old 12-07-2013
Please use codetags.

if you show input and expected output, it would be better to write shell script, since some knows shell only, some knows perl, as well as shell,awk,etc. if you do not tell us what you are trying to achieve, person who knows perl as well as shell also may not be able to answer you.

Hope you will understand.
# 3  
Old 12-07-2013
We don't usually deal in covert operations. Please check your spelling when submitting questions Smilie
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Perl to shell convert

HI All, I am new in shell scripting ,can any one please help me to convert this scripts from Perl to Shell. Thank in advance. $customer=$ARGV; $rows=`hadoop fs -ls /ncip/$customer/|wc -l`; if($rows==3){ print "$customer directory exists , cleaning up ! \n"; `hadoop fs -rm... (1 Reply)
Discussion started by: Atul301
1 Replies

2. Shell Programming and Scripting

perl to shell convert

#!/usr/bin/perl #************************************************************** # # PERL SCRIPT # This script restarts the Application # # ##************************************************************** $ENV{'IFS'} = ' '; #open(STDERR,">&STDOUT"); #select... (2 Replies)
Discussion started by: srikoundinya
2 Replies

3. Shell Programming and Scripting

Convert shell script to Perl

Hello,,I have a very small script that contains these lines; and it works perfectly; however I need to use Perl now as I will need to feel variables from a MySQL table into this; to it would be nice to start by converting this first... find / -perm 777 \( -type f -o -type d \) -exec ls -lid {}... (1 Reply)
Discussion started by: gvolpini
1 Replies

4. Shell Programming and Scripting

Convert perl program to shell

Hi is there a way that i can convert this simple perl program into shell script #!usr/bin/perl -w use strict; use warnings; open INPUTFILE, "uniqprobecoordinates.out" || die "canot open the file $!"; open OUTPUTFILE, ">", "1_4reads.out"; while(<INPUTFILE>) { chomp; ... (3 Replies)
Discussion started by: bhargavpbk88
3 Replies

5. Shell Programming and Scripting

HELP on Perl array / sorting - trying to convert Korn Shell Script to Perl

Hi all, Not sure if this should be in the programming forum, but I believe it will get more response under the Shell Programming and Scripting FORUM. Am trying to write a customized df script in Perl and need some help with regards to using arrays and file handlers. At the moment am... (3 Replies)
Discussion started by: newbie_01
3 Replies

6. Shell Programming and Scripting

Convert perl-statement to /bin/sh shell

Hi, I'm doing a small shellscript which is going to take each line in a "queue file" and do stuff to them. I can do the script easily, but I'd like this one to be a bit prettier. Consider the following perl statement: ... foreach my $line (@filedata) { my ($a, $b, $c) = split(/\t/,... (4 Replies)
Discussion started by: brightstorm
4 Replies

7. Shell Programming and Scripting

convert perl code to shell script

This is about how to Monitoring folder for new files using shell script im doing a project using smsserver tools 3. i have used a perl script to handle incoming messages. the content of each message must be directed to a java program. this program generates the answer to reply to the user... (2 Replies)
Discussion started by: x34
2 Replies

8. Shell Programming and Scripting

Shell/Perl script to convert to Capitalize case

I need a shell script which will convert the given string within a <title> tag to Capitalize case. E.g "<title>hi man: check this out</title>" to "<title>Hi Man: Check This Out</title>" (11 Replies)
Discussion started by: parshant_bvcoe
11 Replies

9. Shell Programming and Scripting

Help! Need to convert bash shell to perl

Hello All. I am very new to Linux and I am currently interning. I have been working on a project for 2 weeks now and I have had no success. I have to convert bash shell into perl to decrypt and store files. Here is the code in Linux and Bash. Any help would be greatly appreciated. $... (0 Replies)
Discussion started by: freak
0 Replies

10. Shell Programming and Scripting

convert the below perl sript to shell script

perl script: my $logdir = '/smp/dyn/logfiles/fsm/mp/mp'; $logdir = $logdir ."/mp${toDate}*"; i tried to make it..as below .. but not working .. date +%m%d%y logdir = /smp/dyn/logfiles/fsm/mp/mp logdir=$logdir/mp"$date" but it was not working..... can someone please help me out in... (1 Reply)
Discussion started by: mail2sant
1 Replies
Login or Register to Ask a Question