in reply to Re: A regex question with 2 pieces of data
in thread A regex question with 2 pieces of data

The first 2 sets of numbers will vary. How do I pull those? I should have been more clear .Could you please help?
  • Comment on Re: Re: A regex question with 2 pieces of data

Replies are listed 'Best First'.
Re: Re: Re: A regex question with 2 pieces of data
by The Mad Hatter (Priest) on Apr 08, 2003 at 00:45 UTC
    Just use Abigail-II's regex (courtesy of Regexp::Common) to pull them out of your data. If $data contains your data you want to get the numbers from, then something like
    my ($one, $two) = ($data =~ /($RE{num}{decimal}).*?($RE{num}{decimal})/);
    will put the first two numbers, regardless of what they are, into $one and $two. (Make sure to use Regexp::Common; in your script though before using the regex above!)

      And at some point here it the /s regex switch will be required if there are newlines in the data because dot doesn't match newline normall.y

      How do I put the Regexp:Common library on my server? Do I just include it as Common.pm in the CGI directory? The server is hosted by someone else. Please advise.
        You could manually download the file and put it in the CGI directory like you said, but the preferred way would be to download the gzipped tarball, extract the contents and run
        perl Makefile.PL LIB=/your/perl/lib PREFIX=/your/perl/lib make make test make install
        Replace the path after LIB= and PREFIX= with where you want it installed (probably in some directory in your home). In the script wher e you plan to use the module, make sure to do a use lib '/your/perl/lib'; to add the path to @INC.

        Also, if you asked, the sysadmin would probably install it site-wide as it is a common and very useful module.

        Update Added the PREFIX and use lib ... bits which I forgot before.