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

This node falls below the community's threshold of quality. You may see it by logging in.

Replies are listed 'Best First'.
Re: regex and sysread
by ELISHEVA (Prior) on Aug 05, 2009 at 11:17 UTC

    Please be more specific in your question. What have you tried? What does the input look like? What does the output look like when you run it through your code? Without more information about all we can give you is links to the documentation for perlretut and sysread. If that is all you need, great! However, I expect you wouldn't be here asking a question if reading the docs were enough, would you? :-)

    Best, beth

Re: regex and sysread
by FloydATC (Deacon) on Aug 05, 2009 at 11:26 UTC
    If I were to venture a guess, you're trying to read lines from a text file, and you want to apply regular expressions to those lines.

    sysread() is for reading binary data and you don't want buffering etc. to get in the way.

    If you just want to read lines of text, use a simpler form such as

    open($fh, $fname) || die $!; while (my $line = <$fh>) { # Do something with each $line... } close $fh;
    -- Time flies when you don't know what you're doing
Re: regex and sysread
by moritz (Cardinal) on Aug 05, 2009 at 11:59 UTC
    Just match against the string that contains the file contents, as you would do with any other string.

    When you want to do things in perl, try the simplest thing that could possibly work - it often does.

Re: regex and sysread
by Marshall (Canon) on Aug 05, 2009 at 11:33 UTC
    sysread is normally used for reading binary stuff, NOT line by line normal text stuff.
    Perl is THE "black-belt" language for processing text.
    while (my $line = <>) { # do someting with $line which was \n # terminated. (or in Windows \r\n terminated) # Perl figures that difference out for you. }