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

This node falls below the community's minimum standard of quality and will not be displayed.

Replies are listed 'Best First'.
Re: matching digits
by DamnDirtyApe (Curate) on Jul 29, 2002 at 21:51 UTC

    This smacks of homework... Sara recently asked this exact question here.


    _______________
    D a m n D i r t y A p e
    Home Node | Email
Re: matching digits
by sauoq (Abbot) on Jul 29, 2002 at 21:58 UTC

    And this code looks exactly like neilwatson's answer here.

    It looks like it should work fine, by the way. How do you know it doesn't?

    -sauoq
    "My two cents aren't worth a dime.";
    
(newrisedesigns) Re: matching digits
by newrisedesigns (Curate) on Jul 29, 2002 at 21:56 UTC

    I'm sure someone like japhy could roll this (and the kitchen sink) into one regexp, but here's my stab at it.
    This is tested, and worked for me.

    while(<FH>){ if(m/^(\d*)\s/){ $lineOfCode = $1; } if(m/(\w*\.\w*)$/){ $filename = $1; } }

    Hope that helps

    John J Reiser
    newrisedesigns.com

Re: matching digits
by BorgCopyeditor (Friar) on Jul 29, 2002 at 21:56 UTC

    Probably it's because the data you're trying to match is full of slashes, which you're also using as delimiters for your match. Either try different delimiters (e.g., "!"), or look into the quote-endquote metacharacters \Q and \E.

    Update: As Emily Litella used to say, "Never mind." My answer might have been appropriate if you were trying to do a substitution such as s/$_/stuff/g; but that it wasn't your question. Sorry.

    BCE
    --Your punctuation skills are insufficient!

Re: matching digits
by Sifmole (Chaplain) on Jul 30, 2002 at 13:16 UTC
    #!/usr/bin/perl -w use strict; while (<DATA>) { /^(\d+).+\/(.+)$/; print "$1 :: $2 \n"; } __DATA__ 3198 X:/bs/al/src/eilass.pl
    Of course this is assuming that each line matches. You would need to write conditional code to check that this is true.