learingperl01
MIS
Hello everyone, hoping someone can point me in the right direction.
I have the following code which finds files that end in .txt then tries to match on a regx. The scripts works fine, the only problem is how to I tell the script to stop the regex or print the line until a space is found. Here an example which should clear things up a bit more.
Thanks for the help in advanced
I have the following code which finds files that end in .txt then tries to match on a regx. The scripts works fine, the only problem is how to I tell the script to stop the regex or print the line until a space is found. Here an example which should clear things up a bit more.
Thanks for the help in advanced
Code:
CODE USED
sub edits() {
if ( -f && \.txt$ ) { #Find files ending in .txt
open(LOG, "< $File::Find::name") or return(0);
while ( my $LINE = <LOG> ) {
if ( $LINE =~ m/http\:\/\/|[URL unfurl="true"]www\:\/\//i[/URL] ) {
print $LINE;
}
}
}
}
SAMPLE FILE
I AM SEARCHING TRYING PRINT URL'S FOUND WITHING THE TXT DOCUMENT WHICH START WITH HTTP OR WWW
This is a test this is a test test test [URL unfurl="true"]http://www.website.[/URL]
com/getme.html this is test this is a test
This is a test this is a test test test [URL unfurl="true"]http://www.website2.com/[/URL]
getme.html this is test this is a test
This is a test this is a test test test [URL unfurl="true"]http://www.website3.com/getme[/URL]
.html this is test this is a test
This is a test this is a test test test [URL unfurl="true"]http://www.website4.com/getme.h[/URL]
tml this is test this is a test
-------------------
| OUTPUT SEEN |
-------------------
This is a test this is a test test test [URL unfurl="true"]http://www.website.[/URL]
This is a test this is a test test test [URL unfurl="true"]http://www.website2.com/[/URL]
This is a test this is a test test test [URL unfurl="true"]http://www.website3.com/getme[/URL]
This is a test this is a test test test [URL unfurl="true"]http://www.website4.com/getme.h[/URL]
-------------------
| WANTED OUTPUT |
-------------------
[URL unfurl="true"]http://www.website.com/getme.html[/URL]
[URL unfurl="true"]http://www.website2.com/getme.html[/URL]
[URL unfurl="true"]http://www.website3.com/getme.html[/URL]
[URL unfurl="true"]http://www.website4.com/getme.html[/URL]