Hi Rob,

Just curious about your code.  When you write

while (<DATA>){

how does Perl know what data you are talking about.  Is it implied or is
Perl using $_ or @_, or something like this.  Please explain your code a
little for me, I'm still a newbie.

Thanks
Will Martell
Dallas Texas
----- Original Message -----
From: "Rob Dixon" <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Sent: Wednesday, December 31, 2003 9:57 AM
Subject: Re: Help with extracting text


> Zary Necheva wrote:
> >
> > How can I extract the text before the first occurrence of dot (.) or
> > single space  from the first field.
> >
> > This is my file
> >
> > LB1571 5TH .W43 1993|text1|text1|
> > FICT. V.12|text2|text2|
> > FICT.|text3|text3|
> > HQ806 .B35 1995|text4|text4|
> > G530.T6B4941988Q|text5|text5|
> > MPCD11 .B42 P27|text6|text6|
> > .....
> > C |textn|textn
> >
> > This is the output  that  I need
> >
> > LB1571|tex1|text1|
> > FICT|text2|text2|
> > FICT|text3|text3|
> > HQ806|text4|text4|
> > G530|text5|text5
> > MPCD11|text6|text6
> > .....
> > C |textn|textn
>
> Hi Zary.
>
> It's not clear whether you need the trailing pipe character,
> as your first four example output lines include it and the
> remainder leave it out. But the program below should help.
>
> Cheers,
>
> Rob
>
>
>   use strict;
>   use warnings;
>
>   while (<DATA>) {
>     print "$1|$2\n" if /([^\s.]+) .*? \| (\S+) \s* $/x;
>   }
>
>   __DATA__
>   LB1571 5TH .W43 1993|text1|text1|
>   FICT. V.12|text2|text2|
>   FICT.|text3|text3|
>   HQ806 .B35 1995|text4|text4|
>   G530.T6B4941988Q|text5|text5|
>   MPCD11 .B42 P27|text6|text6|
>
>
> **OUTPUT
>
>   LB1571|text1|text1|
>   FICT|text2|text2|
>   FICT|text3|text3|
>   HQ806|text4|text4|
>   G530|text5|text5|
>   MPCD11|text6|text6|
>
>
>
> --
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
> <http://learn.perl.org/> <http://learn.perl.org/first-response>
>


-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
<http://learn.perl.org/> <http://learn.perl.org/first-response>


Reply via email to