Roman Hanousek wrote:
Hi

Hello,

I have a txt file that contains the following info:

Text start here --------------------------------

$/Dev/something/something.com/blah1:
default.asp user Exc 26/07/04 1:42p [TEST-DEV]F:\content\blah\wwwroot\blah1


$/Dev/something/something.com/something:
test.asp user Exc 26/07/04 3:09p [TEST-DEV] F:\content\blah\wwwroot\something


$/Dev/something/something.com/blah:
Blah.inc user Exc 23/07/04 11:13a [BAGEL-DEV] F:\content\blah\wwwroot\blah


$/Dev/something/something.com/blah/blah/20GB:
Something-were.htm user Exc 23/07/04 11:24a [TEST-DEV]F:\content\blah\wwwroot\blah\blah\20GB


Text end here --------------------------------


The result I am trying to get is the this:

$/Dev/something/something.com/blah1/default.asp
$/Dev/something/something.com/something/test.asp
$/Dev/something/something.com/blah/Blah.inc
$/Dev/something/something.com/blah/blah/20GB/Something-were.htm



I been trying to various combinations of the below. If i could work out how
to match the file name on the line below.

Perl code start  --
use strict;

my $file = shift;
my $line;


open(IN, "<$file") || die "$!";
while($line =<IN>)
{
$line =~ /(\$\S+):.(\S+)/is;
print "match1: $1; match2: $2 \n";
}
Perl code end --

This works for me with the data provided:

#!/usr/bin/perl
use warnings;
use strict;

my $file = shift or die "usage: $0 filename\n";
open IN, '<', $file or die "Cannot open $file: $!";
$/ = '';  # set $/ to paragraph mode
while ( <IN> ) {
    s!:\n!/!;
    print /^(\S+)/, "\n";
    }

__END__



John
--
use Perl;
program
fulfillment

--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
<http://learn.perl.org/> <http://learn.perl.org/first-response>




Reply via email to