Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Perl : Perl equivalent to the ksh | and ;

Status
Not open for further replies.

brittany1

Technical User
Aug 17, 2007
12
0
0
US
My question is, is there a good resource that explains nesting statements.

As an example.

To change
primary
Factory CTS 1.9.0(46) P1
*Slot 1 CTS 1.10.2(42) P1


To
primary *Slot 1 CTS 1.10.2(42) P1

Perl:
while(<$in>){
    print $out $_ if /^primary$/ .. /\*Slot /;
}



The code above only gives me whats shown in blue. I want to perform a few more functions in order to arrive at the result shown in red.

Again, Im looking to learn how to nest commands. Of course in this case probably s/// and tr.

Thanks in advance.
 
$_ is carrying a newline character at the very least. Perhaps removing it will get you closer?
Code:
while(<$in>){
    chomp($_);
    print $out $_ if /^primary$/ .. /\*Slot /;
}
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top