John W. Krahn wrote:
>
> Sudhindra K S wrote:
> >
> > Hi
>
> Hello,
>
> > I have a file with lines as shown below
> >
> > //abc/... - //xyz/...
> > //abc1/... - //xyz1/...
> >
> > Now i want to split the lines at "-" and get the string on the left in one
> > array and the string on the right in another array.
> >
> > ie: array1 = (//abc, //abc1) and array2 = (//xyz, //xyz1).
> >
> > How do i do this?
>
> my ( @array1, @array2 );
> my $save_flush = $|;
> $| = 0;
> while ( <FILE> ) {
>     push @{ --$| ? [EMAIL PROTECTED] : [EMAIL PROTECTED] }, $_ for split /\s*-\s*/;
>     }
> $| = $save_flush;

Eek! You're joking. Surely. Tell us! I'm still searching my brain
for a good reason to misuse the flush toggle like this, but if it
were sheer obfuscation then why push and pop the value of the thing?

Why not just

  {
    local $| = 0;

    while (<FILE>) {
      push @{ --$| ? [EMAIL PROTECTED] : [EMAIL PROTECTED] }, $_ foreach split 
/\s*-\s*/;
    }
  }

Tell me. Please. Before I die. Soon.

Rob






-- 
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