Re: regex extraction problem



Chad Perrin wrote:
On Sun, May 28, 2006 at 03:08:07PM -0700, John W. Krahn wrote:
tom arnall wrote:
On Sunday 28 May 2006 12:20 am, John W. Krahn wrote:
tom arnall wrote:
the following code:

$_='abcd';
@f = /(x)(y)|(a)(b)/;

makes the first two cells of '@f' to be undefined, then puts 'a' and 'b'
in the third and fourth cells. how do i get the system to put 'a' and 'b'
in the first two cells and to produce no undefined cells?

@f = grep defined, /(x)(y)|(a)(b)/;

yes. solves my problem. how did you find out about this?

By programming in Perl for many years. :-)

Did it also teach you why that's necessary?

It is not necessary, but it seemed to be what the OP wanted.


John
--
use Perl;
program
fulfillment
.



Relevant Pages

  • OT - the empty set and strict and warnings
    ... I tried to post this to the perl misc but nothing happened. ... If one uses warnings and strict then an error message can be generated ... cells and then don't print the * or I don't use strict and warnings. ...
    (comp.lang.perl.tk)
  • Re: CSV Help
    ... Perl knows nothing about CSV. ... Perl is very good at creating data in any given format requirement. ... > If I can maximize the cells through the script to be as big as the largest entry ...
    (perl.beginners)
  • Re: regex extraction problem
    ... makes the first two cells of '@f' to be undefined, then puts 'a' and 'b' ... in the third and fourth cells. ... By programming in Perl for many years. ...
    (perl.beginners)
  • Re: regex extraction problem
    ... tom arnall wrote: ... the third and fourth cells. ... use Perl; ...
    (perl.beginners)
  • Re: (OT) The desktop supercomputer has arrived!
    ... encountered who believe that parallel processing or throwing more ... Good old-fashioned procedural programming. ... Consider a heuristic program that finds the way through a maze. ... Cells make a random choice at each junction and record how far they got, ...
    (comp.lang.cobol)