Anonymous Monk 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: working with contents of diff. files
by tommyw (Hermit) on Oct 30, 2001 at 19:20 UTC

    Well, to start with, the shell command ls Dev*.txt > Dev.txt will put Dev.txt into Dev.txt, which is probably not intended.

    Why bother using backticks if you're just going to print the answer anyway? You might as well use system, and save some interprocess communication (or use perl to construct the file list).

    Why do you want to concatenate all the Dev*.txt files into res.txt anyway? t'ain't going to help you much (but the quick way to do it is cat Dev*.txt > res.txt). If you really want to find all files for words ending with three digits, then grep is more likely to be your friend.

    Why do you want to do this anyway? Given the laborious number of steps you want to go through, I'd suspect this is homework, rather than a real world problem.

    --
    Tommy
    Too stupid to live.
    Too stubborn to die.

Re: working with contents of diff. files
by claree0 (Hermit) on Oct 30, 2001 at 19:06 UTC

    Well, show us what you've done so far and we'll see what we can do.....

Re: working with contents of diff. files
by doc (Scribe) on Oct 30, 2001 at 19:26 UTC

    Yes we can help. It is nice to see you helping yourself though. This is untested but should do what you want:

    #!/usr/bin/perl -w use strict; undef $/; my $all; while (<Dev*.txt>) { open F, $_ or die "Can't open $_: $!\n"; my $content = <F>; close F; $all .= "Name: $_\n$content"; if ($content =~ /\b(\w+\d\d\d)\b/) { my $found = $1; (my $first_two) = $content =~ m/(^[^\n]*\n[^\n]*\n)/; print "Found $found\n$first_two\n"; } } open F, ">res.txt" or die "Can't write res.txt $!\n"; print F $all; close F;

    doc

    print(s<>ecode?scalar reverse :p)

      Thanks man !! it works ...

        Excellent. Now get a f@#$%^n login and join the crew.

        Yo later dude, see you round like a rissole.

        d-d-doc