Kai Gollan wrote:
>
> My intention is to open a file, search for the pattern "DT" und replace
> the pattern with "SomethingElse"!
> The message after using my skript is "4294967294" but this is not what I
> want! What I want ist to display the whole file with my replacements.
> Maybe it is a more difficult as expected because the file I opend has
> got no Line-Feed in it.
>
I changed your script a bit:
> #!/usr/bin/perl -w
> use strict;
>
> my $pattern = 'DT';
> my $replacement = 'Something' ;
>
> open ( FILE, 'transa33' ) || die " can�t open file: $!";
> while ( <FILE> ) {
# the g-modifier guarants you, that all patterns are
substituted.
> s/$pattern/$replacement/g;
> print;
> }
> close FILE;
>
That should do what you want.
Problem was, that you created a new variable $datei.
Than you told perl via
$datei =~ s/.../.../; to substitute anything in the empty variable
$datei.
So nothing could happen :-)
Now, <FILE> reads the next line into the invisible variable $_.
The s/.../.../ is in reality $_ =~ s/.../.../
and print; is really print $_;
Have a lots of fun,
Andrea
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]