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

I got this anwser :
($four_digit_num) = /[[:alpha:]]+(\d{4,4})/; # this pulls out the 4 d +igits just after any leading characters.
Thanks for pointing in the right directions still need more to read
_____________________________________________________________
Dear monks !
I am working on a list of file that contain a 4 digit number, this number is the same number of our customer, I need to extract that 4 digit number but how ???
for example:
j9999120.125 where 9999 is the number of customer thank you

Replies are listed 'Best First'.
Re: How to extract the 4 number in the filename?
by FunkyMonk (Bishop) on Apr 11, 2008 at 19:59 UTC
    You should be able to work this out for yourself. Read perlretut and have a look at Regexp Quote Like Operators in perlop.

    Post back to this thread if you still can work it out, showing us what you've tried.

    Update:

    When I first read your node, I thought you already had a list of filenames, now I'm not so sure. So, if you need to read a directory to get the filenames, you can use glob (or opendir and readdir).

Re: How to extract the 4 number in the filename?
by Narveson (Chaplain) on Apr 11, 2008 at 20:01 UTC

    UPDATED: Having been censured for answering an easy question, I'll try going all Perlmonks.

    my $FOUR_DIGIT_CAPTURE = qr/ ( # left as an exercise ) /x; while (<DATA>) { if (my ($four_digit_num) = /$FOUR_DIGIT_CAPTURE/) { print # left as an exercise } else { # left as an exercise } } __DATA__ j9999120.125 Be sure to include lots of interesting test cases.
      thanks ! I need to read the THIS
      and I guess THIS
      I post the anwser I promise
      thanks again for helping me
      :o)
      What happens when the record contains a digit in the first column, rather than a lower-case "J"?

      Let padawan_linuxero read the Regex document...