mecrazycoder has asked for the wisdom of the Perl Monks concerning the following question:

Hi Monks,

Good Morning to all. I have listed few questions below,please answer those question

  1. About perl client.Is it possible to write perl client for java web service.If yes, is there any module whick make it easy to communicate with java web services(WSDL).
  2. About Perl Thread.To use thread concept in perl which module is to prefer for easy use.
  3. About Regex. Say i am matching phone numbers in a file.The regex i wrote was
    $filecontent="12345-123456 is number. 98945-221349" if($filecontent=~m/[0-9]{5}-[0-9]{6}/) print "Match found";

It is working fine.But if want to extract all phone numbers that are matched in single line, What i have to do?

Thanks in advance

20090811 Janitored by Corion: Added formatting, code tags, as per Writeup Formatting Tips

Replies are listed 'Best First'.
Re: Few Doubts
by JadeNB (Chaplain) on Aug 07, 2009 at 06:16 UTC
    1. I don't know, but you might look at Java.
    2. No idea, sorry.
    3. To get all the matches at once, use
      my @matches = ( $line =~ m/$pattern/g )
      (i.e., use the /g flag and assign the result to an array). If your problem is how to turn $filecontent into $line, then you want split. Howeverdon't write your own regex; that's why we have Regexp::Common. (See Beast of the Number: Parsing the Feral Phone for why it's so scary to try to parse phone numbers.)

    P.S. What kind of phone number is 5 digits followed by 6 digits?

Re: Few Doubts
by hominid (Priest) on Aug 07, 2009 at 12:57 UTC
Re: Few Doubts
by vonersnae (Novice) on Aug 07, 2009 at 08:28 UTC
    Hello, Good day!!!

    1. Sorry i have no idea :(

    2. Hmmmm...well.., there are a lot of decent modules found in CPAN. I think it should be better if you're going to read perlthrtut and perlothrtut first ^_^

    3. As what have JadeNB said, you can use /g flag to get all strings that have matched w/ the pattern.

    Example:
    #!/usr/local/bin/perl -w use strict; my $str = "12345-112316 string string 11111-222311\n\n 71231-121111"; # assuming '-' is the delimiter my @pnumbers = $str=~/(\d+-\d+)/g; # print print "$_\n" foreach(@pnumbers);

    You might want to read perlretut also for better understading of regular expressions (regex)...

    Cheers!!!
Re: Few Doubts
by Anonymous Monk on Aug 07, 2009 at 06:17 UTC
    What i have to do?

    Format your posts, put code in code tags.