Sponsored Content
Top Forums Shell Programming and Scripting Perl : Perl equivalent to the ksh | and ; Post 302875325 by popeye on Tuesday 19th of November 2013 08:48:30 AM
Old 11-19-2013
Many thanks to Mr. Bean.

With his help/code I came up with this that provides the result that I was looking for.

Code:
#!/usr/bin/perl
#
use strict; use warnings; use Data::Dumper;
open my $in,'<',"codecs";
open my $out,'>',"File2.txt";
while(<$in>){
 if(/^primary$/ .. /\*Slot\s/) {
   if(/\*Slot\s/) { print "$_"; next; }
   s/[\r\n]/ /g;
   print unless /Factory/ ;
 } elsif  (/^left$/ .. /\*Slot\s/) {
    if(/\*Slot\s/) { print "$_"; next; }
    s/[\r\n]/ /g;
    print unless /Factory/ ;
 } elsif (/^right$/ .. /\*Slot\s/) {
    if(/\*Slot\s/) { print "$_"; next; }
    s/[\r\n]/ /g;
    print unless /Factory/ ;
 }
}

Which coincidentally doesnt read as well for me anyway as

Code:
clear
echo "Parse show version"
echo "------------------"
p=`sed -n '/^primary$/,/\*Slot /p' codecs | sed '/Factory/d' | tr '\012' ' '| awk '{print $1" "$5}'`
l=`sed -n '/^left$/,/\*Slot /p' codecs | sed '/Factory/d' | tr '\012' ' '| awk '{print $1" "$5}'`
r=`sed -n '/^right$/,/\*Slot /p' codecs | sed '/Factory/d' | tr '\012' ' '| awk '{print $1" "$5}'`
echo "$p : $l : $r" 
echo " "

But Ill force myself to learn perl if it kills me... and it probably will Smilie

thanks again to all ...

---------- Post updated at 08:48 AM ---------- Previous update was at 08:46 AM ----------

Sorry .. one other thing. A resource Im using, Impatient Perl, refers to Capturing and Clustering. I think that answers the real question and where I need to focus some attention.
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Perl equivalent of ksh if / echo statement

Is there an equivalent perl statement for the following ksh statement ? example if then ... else ... fi (2 Replies)
Discussion started by: gefa
2 Replies

2. Shell Programming and Scripting

export equivalent command in PERL

Hi I need an equivalent command in PERL for the following. export LC_ALL=C; I hope this is the command. Please confirm this and correct me if i am wrong $ENV{LC_ALL}="C"; Thanks and Regards Ammu (1 Reply)
Discussion started by: ammu
1 Replies

3. Shell Programming and Scripting

perl equivalent to grep -c

Guess the subject lines says it all. What is the perl equivalent to grep -c -c, --count Suppress normal output; instead print a count of match- ing lines for each input file. With the -v, --invert- match option (see below), count non-matching lines. ... (6 Replies)
Discussion started by: popeye
6 Replies

4. Shell Programming and Scripting

strtok equivalent in perl

Hi All, Is their any equivalent for strtok (in c) to use in perl script. Thanks in advance. JS (1 Reply)
Discussion started by: jisha
1 Replies

5. Shell Programming and Scripting

Bash equivalent of perl's pack function ?

Is there an equivalent of perl's pack function in bash ? Or in other words, how can I achieve the same thing in bash ? Much appreciated. (1 Reply)
Discussion started by: NewDeb
1 Replies

6. Shell Programming and Scripting

Regular expression matching in BASH (equivalent of =~ in Perl)

In Perl I can write a condition that evaluates a match expression like this: if ($foo =~ /^bar/) { do blah blah blah } How do I write this in shell? What I need to know is what operator do I use? The '=~' doesn't seem to fit. I've tried different operators, I browsed the man page for... (3 Replies)
Discussion started by: indiana_tas
3 Replies

7. Shell Programming and Scripting

need perl equivalent

Dear All, Good day, can any of you help me in the following problem: I need to find the perl equivalent for the following commandline grep characters |awk '{print \$2}'Expecting your reply and thanks in advance. Warm regards Fredrick. (4 Replies)
Discussion started by: Fredrick
4 Replies

8. Shell Programming and Scripting

grep -v equivalent in perl

I have to do grep -v in a perl script. I want to exclude blank lines and lines having visitor. #grep -v visitor abc.txt |grep '.' file:abc.txt 1340 not booked 16D:D9 tourist 8 1341 not booked 16C:D4 tourist 25 1342 not booked 16D:C4 visitor 7 1343 not booked 01C:D9 visitor 6 1344... (4 Replies)
Discussion started by: dynamax
4 Replies

9. Shell Programming and Scripting

What is the equivalent of NR (awk) in perl?

Hello, I searched online; it seems that perl use $NR as NR in awk; however it does not work for me. For example, how to re-write the following awk using perl: awk '{ print NR}' inputfile---------- Post updated at 01:55 PM ---------- Previous update was at 12:49 PM ---------- I found... (2 Replies)
Discussion started by: littlewenwen
2 Replies

10. Shell Programming and Scripting

Perl equivalent substitution

hi Geeks, my input file contains data like => 53 - Deewana Kar Raha Hai.mp3 54 - Hale Dil.mp3 55 - Ishq Sufiyana.mp3 56 - Abhi Kuch Dino Se.mp3 57 - Pee Loon Hoto Ki Sargam.mp3 I had used sed command to remove the prefix from the file name like sed 's/^\ it gives me the perfect... (4 Replies)
Discussion started by: lohith.dutta
4 Replies
cosProperty(3erl)					     Erlang Module Definition						 cosProperty(3erl)

NAME
cosProperty - The main module of the cosProperty application DESCRIPTION
To get access to the record definitions for the structures use: -include_lib("cosProperty/include/*.hrl"). This module contains the functions for starting and stopping the application. EXPORTS
install() -> Return Types Return = ok | {'EXIT', Reason} This operation installs the cosProperty application in the IFR. install_db() -> Return Types Return = ok | {'EXIT', Reason} This operation installs data in mnesia necessary for running the cosProperty application. uninstall() -> Return Types Return = ok | {'EXIT', Reason} This operation removes all data in the IFR related to the cosProperty application. uninstall_db() -> Return Types Return = ok | {'EXIT', Reason} This operation removes all data from mnesia related to the cosProperty application. start() -> Return Types Return = ok | {error, Reason} This operation starts the cosProperty application. start_SetDefFactory() -> Return Types Return = Factory | {'EXCEPTION', E} Factory = CosPropertyService::PropertySetDefFactory reference. This operation starts a PropertySetDef Factory. start_SetFactory() -> Return Types Return = Factory | {'EXCEPTION', E} Factory = CosPropertyService::PropertySetDefFactory reference. This operation starts a PropertySet Factory. stop_SetDefFactory(Factory) -> Return Types Factory = CosPropertyService::PropertySetDefFactory reference. Return = ok | {'EXCEPTION', E} This operation stops the supplied PropertySetDef Factory. stop_SetFactory(Factory) -> Return Types Factory = CosPropertyService::PropertySetFactory reference. Return = ok | {'EXCEPTION', E} This operation stops the supplied PropertySet Factory. stop() -> Return Types Return = ok | {error, Reason} This operation stops the cosProperty application. Ericsson AB cosProperty 1.1.13 cosProperty(3erl)
All times are GMT -4. The time now is 03:31 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy