in reply to search file for text then only use some of the text in the line

IF your source file is in fact XML, you're much better off using XML::Twig or another XML::Parser derivate.

Otherwise:

local $/; open my $fh,"<filename"; my $file = <$fh>; close $fh; my ($content) = $file =~ /<Directory Filename="([^"]*)"/;
should get you started. problem areas in this code include: single vs double quotes, xml entities, large files, multiple matches etc. Don't use this as is.
  • Comment on Re: search file for text then only use some of the text in the line
  • Download Code

Replies are listed 'Best First'.
Re^2: search file for text then only use some of the text in the line
by Anonymous Monk on Jul 29, 2004 at 20:57 UTC
    Thank you VERY MUCH!
    I've been trying to get this working for days now and actually got it working but I had used about 20 lines of code to do what you did in 5.
    Your solution is perfect. THANK YOU!