Beefy Boxes and Bandwidth Generously Provided by pair Networks
go ahead... be a heretic
 
PerlMonks  

Re^5: Substitution don't work with a special inputfile

by poj (Abbot)
on Aug 24, 2015 at 18:09 UTC ( [id://1139720]=note: print w/replies, xml ) Need Help??


in reply to Re^4: Substitution don't work with a special inputfile
in thread Substitution don't work with a special inputfile

Your addition should have worked but anyway try this

#!perl # Aufruf: perl removeEK1.pl TestEK.txt > Out.txt use strict; use warnings; my $regex = '{\[%tqu[^\]]*]}'; my $line = do { local $/; <>; }; $line =~ s/\n/ /g; $line =~ s/$regex//gi; $line =~ s/ (\d+\. |\[)/\n$1/g; print $line;
poj

Replies are listed 'Best First'.
Re^6: Substitution don't work with a special inputfile
by OldChamp (Acolyte) on Aug 25, 2015 at 08:40 UTC

    Thank you poj for helping me again, now it works like a charm. I have tried to solve the remaining problem by myself like this:

    #!/usr/bin/perl # Remove extra text from a PGN or Text-file. use strict; use warnings; my $regex = '{\[%tqu[^\]]*]}'; my $line = do { local $/; <>; }; $line =~ s/\n/ /g; $line =~ s/$regex//gi; # these statements I have inserted $line =~ s/\]/\]\n/g; $line =~ s/\[E/\n\[E/g; # end $line =~ s/ (\d+\. )/\n$1/g; print $line;

    and it "nearly" worked, but I got an empty first line in the outputfile.

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://1139720]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others meditating upon the Monastery: (5)
As of 2024-04-24 12:50 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found