Hi LAdProg2005,
What you try is pretty different from that what I posted. I modified your source a little bit - so you should see how the program works:
Code:
[url=http://perldoc.perl.org/functions/use.html][black][b]use[/b][/black][/url] [green]strict[/green][red];[/red]
[black][b]use[/b][/black] [green]warnings[/green][red];[/red]
[gray][i]#my $lines = join('', <DATA>);[/i][/gray]
[url=http://perldoc.perl.org/functions/my.html][black][b]my[/b][/black][/url] [blue]$line[/blue][red];[/red]
[black][b]my[/b][/black] [blue]$lnum[/blue] = [fuchsia]1[/fuchsia][red];[/red]
[olive][b]while[/b][/olive][red]([/red] [blue]$line[/blue] = <DATA> [red])[/red][red]{[/red]
[url=http://perldoc.perl.org/functions/chomp.html][black][b]chomp[/b][/black][/url][red]([/red][blue]$line[/blue][red])[/red][red];[/red]
[url=http://perldoc.perl.org/functions/print.html][black][b]print[/b][/black][/url] [red]"[/red][purple]The data in [blue]$lnum[/blue].line:[purple][b]\n[/b][/purple]'[blue]$line[/blue]'[purple][b]\n[/b][/purple][/purple][red]"[/red][red];[/red]
[olive][b]if[/b][/olive][red]([/red][blue]$line[/blue]=~[red]/[/red][purple]INFO:(.*)[/purple][red]/[/red][red]s[/red][red])[/red] [red]{[/red]
[black][b]my[/b][/black] [blue]$rem[/blue] = [blue]$1[/blue][red];[/red]
[black][b]print[/b][/black] [red]"[/red][purple]!!! found [purple][b]\$[/b][/purple]rem='[blue]$rem[/blue]' !!![purple][b]\n[/b][/purple][/purple][red]"[/red][red];[/red]
[red]}[/red]
[blue]$lnum[/blue]++[red];[/red]
[red]}[/red]
[gray][i]# your data:[/i][/gray]
[teal]__DATA__[/teal]
[teal]Date: 08/01/09 By: LAdProg[/teal]
[teal]INFO:$[/teal]
[teal] THIS IS TEST$[/teal]
[teal] BY \LAD:PROG$[/teal]
[teal] *A-OK FOR 20'05$[/teal]
[tt]------------------------------------------------------------
Pragmas (perl 5.10.0) used :
[ul]
[li]
strict - Perl pragma to restrict unsafe constructs[/li]
[li]
warnings - Perl pragma to control optional warnings[/li]
[/ul]
[/tt]
Output:
Code:
The data in 1.line:
'Date: 08/01/09 By: LAdProg'
The data in 2.line:
''
The data in 3.line:
'INFO:$'
[COLOR=red]!!! found $rem='$' !!![/color]
The data in 4.line:
' THIS IS TEST$'
The data in 5.line:
' BY \LAD:PROG$'
The data in 6.line:
' *A-OK FOR 20'05$'
The data in 7.line:
''
You see - your program reads the data line by line. So when you match the regex, then you have in the variable $line only the 3.line. Therefore in your case it doesn't matter if you use multiline regex (with option s) or not, you match everytime only the character '$', because the other lines are not in your variable $line.
My approach is very different:
I read at once all lines in the variable $lines at this place
Code:
[url=http://perldoc.perl.org/functions/my.html][black][b]my[/b][/black][/url] [blue]$lines[/blue] = [url=http://perldoc.perl.org/functions/join.html][black][b]join[/b][/black][/url][red]([/red][red]'[/red][purple][/purple][red]'[/red], <DATA>[red])[/red][red];[/red]
and therefore I can use succesful the multi-line regex.
Did you understand?
Here is the corrected source, which match your data
Code:
[url=http://perldoc.perl.org/functions/use.html][black][b]use[/b][/black][/url] [green]strict[/green][red];[/red]
[black][b]use[/b][/black] [green]warnings[/green][red];[/red]
[url=http://perldoc.perl.org/functions/my.html][black][b]my[/b][/black][/url] [blue]$lines[/blue] = [url=http://perldoc.perl.org/functions/join.html][black][b]join[/b][/black][/url][red]([/red][red]'[/red][purple][/purple][red]'[/red], <DATA>[red])[/red][red];[/red]
[url=http://perldoc.perl.org/functions/print.html][black][b]print[/b][/black][/url] [red]"[/red][purple]The data is:[purple][b]\n[/b][/purple][purple][b]\n[/b][/purple]'[blue]$lines[/blue]'[purple][b]\n[/b][/purple][purple][b]\n[/b][/purple][/purple][red]"[/red][red];[/red]
[olive][b]if[/b][/olive] [red]([/red][blue]$lines[/blue] =~ [red]/[/red][purple]INFO:(.*)[/purple][red]/[/red][red]s[/red][red])[/red] [red]{[/red]
[black][b]my[/b][/black] [blue]$info[/blue] =[blue]$1[/blue][red];[/red]
[blue]$info[/blue] =~ [red]s/[/red][purple][purple][b]\n[/b][/purple][/purple][red]/[/red][purple][/purple][red]/[/red][red]g[/red][red];[/red]
[black][b]print[/b][/black] [red]"[/red][purple]Info = '[blue]$info[/blue]'[purple][b]\n[/b][/purple][/purple][red]"[/red][red];[/red]
[red]}[/red]
[gray][i]# your data:[/i][/gray]
[teal]__DATA__[/teal]
[teal]Date: 08/01/09 By: LAdProg[/teal]
[teal] INFO:$[/teal]
[teal] THIS IS TEST$[/teal]
[teal] BY \LAD:PROG$[/teal]
[teal] *A-OK FOR 20'05$[/teal]
[tt]------------------------------------------------------------
Pragmas (perl 5.10.0) used :
[ul]
[li]
strict - Perl pragma to restrict unsafe constructs[/li]
[li]
warnings - Perl pragma to control optional warnings[/li]
[/ul]
[/tt]
Output:
Code:
The data is:
'Date: 08/01/09 By: LAdProg
INFO:$
THIS IS TEST$
BY \LAD:PROG$
*A-OK FOR 20'05$
'
Info = '$ THIS IS TEST$ BY \LAD:PROG$ *A-OK FOR 20'05$'