Home > Archive > PERL Beginners > November 2006 > search and replace basics
You are viewing an archived Text-only version of the thread.
To view this thread in it's original format and/or if you want to reply to
this thread please [click here]
| Author |
search and replace basics
|
|
| IJALAB 2006-11-21, 6:57 pm |
| Hi,
My file is like
(20:34:08.747) Rx 48 bytes
<F0><00><10><00><05><18><00><73><1B><0D><00>
(20:34:08.810) Rx 48 bytes
<00><00><00><0B><FF><7F><15><00><00><00><00><00><00><18><FF><7F><15><00>
>From a file(Text1.txt), I have to remove the text before 48 bytes and
retain the remaining string.I am trying to do the following
open(FILE1, ">Text1.txt") || die "Can't open output file.";
while(<FILE1> )
{
s/*.*bytes //g;
print FILE1 ;
}
I am unable to achieve what I want. In the manual, it is given as $'
will print everything after the match string. but that also doesn't
work.
Also, I need to remove the
| |
| plu5even 2006-11-21, 6:57 pm |
| #!/your/perl/install/dir -w
use strict;
open(FILE1, "foo") || die "Can't open output file.";
while(<FILE1> )
{
#performs pattern matching on $_ which is the current line of FILE1
#returns all text on line after the matching sequence as variable
$'
$_ =~ /(\(.+\))/;
print "$'\n"; #prints the non-matching text
}
Not that this won't touch the lines that do not have "(someNumberHere)"
on them.
HTH,
Peter
On Nov 21, 2:47 pm, "IJALAB" <balaji.d...@gmail.com> wrote:
> Hi,
>
> My file is like
>
> (20:34:08.747) Rx 48 bytes
> <F0><00><10><00><05><18><00><73><1B><0D><00>
> (20:34:08.810) Rx 48 bytes
> <00><00><00><0B><FF><7F><15><00><00><00><00><00><00><18><FF><7F><15><00>
>
> open(FILE1, ">Text1.txt") || die "Can't open output file.";
>
> while(<FILE1> )
> {
> s/*.*bytes //g;
> print FILE1 ;
>
> }
>
> I am unable to achieve what I want. In the manual, it is given as $'
> will print everything after the match string. but that also doesn't
> work.
>
> Also, I need to remove the
|
|
|
|
|