softworkz 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: fuzzy logic?
by mr.nick (Chaplain) on May 24, 2001 at 18:14 UTC
    This is untested, but should work just fine.
    sub process_file { my $file=shift; open(IN,"<$file") || die "Couldn't open '$file': $!\n"; my @in=(<IN>)[0..9]; close IN; if (join('',@in)=~/\r\n/m) { ## found! ## do something exciting here } }

    Update It would probably be more intellient to

    push @in,scalar <IN> for 1..10;
    as my original code seems to snarf the entire file and THEN return the first 10 lines.
Re: (Zigster) fuzzy logic?
by zigster (Hermit) on May 24, 2001 at 17:13 UTC
    Do you really only want to look only at the first 10 lines? Do a Super Search for nodes re "dos unix convert" there are several describing how to do the conversion and how to identify the files to be converted.

    Note. Please consider carefuly how you name your nodes. This is a very common question and I am sure other monks would, in the future value being able to find information from this thread. However with the current name the information is likely to be lost. When naming consider what you would search for if you were looking for the answer to your own question, then other people can learn from your experience.
    --

    Zigster

Re: fuzzy logic?
by Masem (Monsignor) on May 24, 2001 at 17:00 UTC
    This can be done with straightforward logic through, nothing fuzzy about it.

    The trickiest part is determining if the first 10 lines of the file met your expectations to run the program, but this can be done via regex.


    Dr. Michael K. Neylon - mneylon-pm@masemware.com || "You've left the lens cap of your mind on again, Pinky" - The Brain