Welcome to the most active Linux Forum on the web.
Go Back > Forums > Non-*NIX Forums > Programming
User Name
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.


  Search this Thread
Old 04-14-2006, 02:03 PM   #1
Registered: Aug 2002
Location: St Louis, MO
Distribution: Xubuntu, RHEL, Solaris 10
Posts: 929

Rep: Reputation: 30
Iterate through regular expression results in Perl

Is it possible to iterate through a regular expression's results?

For example, if I have

 foreach (@lines) {
   print STDOUT "checking line: $_\n";
     if(/.*(http:\/\/.*\.mp3).*/) {
       print STDOUT "***********Found REMOTE file: $1\n";
       $shortfilename = substr($1, rindex($1, "/")+1, length($1));
       $prospectiveFiles{$shortfilename} = $1;
My initial assumption was that there would be just one URL per line. However, this has proved not to be the case in some of my test files...there's more than one, and I don't know how many there could be. Using just straight $1 is right out because of that...that line will have to change to a loop, which I hope will iterate through all of the results.

Is there a way to find out how many results were returned, and then to iterate through them?

Old 04-14-2006, 02:47 PM   #2
Registered: Aug 2002
Location: St Louis, MO
Distribution: Xubuntu, RHEL, Solaris 10
Posts: 929

Original Poster
Rep: Reputation: 30
Sigh, nevermind - figured it out, I was just googling for the wrong thing.

Commenting so this gets off the 0 Reply Threads list...


Thread Tools Search this Thread
Search this Thread:

Advanced Search

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 Off
HTML code is Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
perl regular expression problem true_atlantis Programming 4 05-27-2009 07:35 AM
Perl regular expression issue zikhermm Programming 7 09-23-2005 04:48 PM
Perl Regular Expression dilemma GATTACA Programming 1 03-27-2004 08:48 PM
Perl Regular Expression rch Programming 14 07-12-2003 12:00 AM
using a perl regular expression in php markus1982 Programming 5 11-18-2002 03:31 PM > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 09:25 PM.

Main Menu
Write for LQ is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration