The UNIX and Linux Forums  
Hello and Welcome from United States to the UNIX and Linux Forums! Thank You for Visiting and Joining Our Global Community.

Go Back   The UNIX and Linux Forums > Top Forums > Shell Programming and Scripting
.
google unix.com



Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts and shell scripting languages here.

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
Matches and mismatches in perl srisha Shell Programming and Scripting 0 01-22-2008 11:40 PM
issue with if loop in perl amitrajvarma Shell Programming and Scripting 4 01-09-2008 12:02 AM
loop throw perl regexp selection umen Shell Programming and Scripting 6 08-28-2006 11:35 AM
for loop using the value '01' in PERL dangral Shell Programming and Scripting 9 10-01-2003 04:34 PM
help with perl while loop methos Shell Programming and Scripting 2 04-08-2002 04:30 PM

Closed Thread
English Japanese Spanish French German Portuguese Italian Dutch Swedish Russian Norwegian Hungarian Hebrew Danish Bulgarian Greek Powered by Powered by Google
 
LinkBack Thread Tools Search this Thread Rate Thread Display Modes
  #1 (permalink)  
Old 07-25-2006
umen umen is offline
Registered User
  
 

Join Date: Aug 2005
Posts: 239
how to get the pos() of 2 str matches in one loop in perl

Hello all
i have this simple loop that gets me every time the match of "<#" in my string
something like that :

my $str ="gggg<#nnnnn#>kkkk<#ssss#>llllll";
while($str =~m/<#/g){
print pos($str);
}

but now i like to get another pos in the same loop iteration , i will like to get the match of "#>"
can it be done in perl ?
  #2 (permalink)  
Old 07-26-2006
cbkihong cbkihong is offline Forum Advisor  
Advisor
  
 

Join Date: Sep 2002
Location: Hong Kong, China
Posts: 1,624
What about

Code:
my $str ="gggg<#nnnnn#>kkkk<#ssss#>llllll";
 while($str =~m/(<#|#>)/g){
 print pos($str);
 }
Closed Thread

Bookmarks

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On




All times are GMT -4. The time now is 05:33 AM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited. Language Translations Powered by .
vBCredits v1.4 Copyright ©2007 - 2008, PixelFX Studios
The UNIX and Linux Forums Content Copyright ©1993-2009. All Rights Reserved.Ad Management by RedTyger

Content Relevant URLs by vBSEO 3.2.0