extract data from notepad - perl

can u give me a script for the following?

1.txt
___________________________________________
XXXXXXXXXXXXXXXXXXXXXXXXX
XXXXXXXXXXXXBBBBBBBBBBB
WWWWWOOOOONNNNNNNNNNNN
WwwIIIIIOOOOOOO |quote= "pravin"| SSSSSSSSSSSS
SSSSSSSSSSSSSSSSSSSSSS
SSSSSSSSSSSS
SSSSSSSSSSSSSSSSSSSS
SSSSSSSSSSS |/quote| UUUWWWDDDDDDD
XXXWWXXXXXXBBBBXXXBBBBBBB
WWWWWOOSSSSSSSSS
SSSSSSSSS
___________________________________________

Required OUTPUT:

SSSSSSSSSSSS
SSSSSSSSSSSSSSSSSSSSSS
SSSSSSSSSSSS
SSSSSSSSSSSSSSSSSSSS
SSSSSSSSSSS
pravink22Asked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Gerwin Jansen, EE MVETopic Advisor Commented:
Do your require that perl is used? I'd use a simple grep to get your output:

grep -o [S]* 1.txt

Open in new window


Output:

SSSSSSSSSSSS
SSSSSSSSSSSSSSSSSSSSSS
SSSSSSSSSSSS
SSSSSSSSSSSSSSSSSSSS
SSSSSSSSSSS
SSSSSSSSS
SSSSSSSSS

Open in new window

pravink22Author Commented:
Hi,

My requirement is to grep data present in between

|quote= "pravin"| to  |/quote|

Thanks
ozoCommented:
perl  -0777 -pe '($_)=/\|quote= "pravin"\|(.*?)\|\/quote\|/s'  1.txt
Introduction to Web Design

Develop a strong foundation and understanding of web design by learning HTML, CSS, and additional tools to help you develop your own website.

pravink22Author Commented:
can you write the full program?
tel2Commented:
Hi pravink22,

Here's one way of rewriting ozo's on-liner as a full script:

    #!/usr/bin/perl
    undef $/;
    $_ = <>;
    ($_) = /\|quote= "pravin"\|\s*(.*?)\s*\|\/quote\|/s;
    print "$_\n";

However, there are some practical differences between this and ozo's, i.e.:
1. The above removes any spaces from the beginning and end of the output.  If you don't want to do that, remove the 2 instances of "\s*".
2. This above puts a newline character at the end of the output.  If you don't want this, change the last line to:
    print $_;
or just:
    print;
since $_ is the default print argument.

If you're going to have other code in the same script after the above code, then it would be safer to do something like this:

    #!/usr/bin/perl
    {
        local $/ = undef;
        $_ = <>;
        ($_) = /\|quote= "pravin"\|\s*(.*?)\s*\|\/quote\|/s;
        print "$_\n";
    }
    # Other code here...

otherwise your input separator ($/) will still be undefined afterwards, which may cause problems in any subsequent code.

If you do accept this answer, remember to give ozo some points, since this is based on his one-liner.

tel2

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
tel2Commented:
Thanks for the points, pravink.

Probably some of the points should have gone to others (especially ozo, who needs them so badly), so bear that in mind for the future.  As I had indicated, my scripts were based on ozo's one-liner.  I assume you know how to split points among multiple experts?

tel2
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Perl

From novice to tech pro — start learning today.