Hello,

I came to perl by J.Friedl's regex-book without any perl-experiences.
I wrote a little script to scan packages and their dependencies from a book 
(lfs). The script works fine and I get the packages with their dependencies.

Now I tried to expand that script that way, that I wanted to write the 
package-name to a different file - and I didn't expect that beeing an item of 
troubles.

When I copy the lines that create the file to a different script, the code 
works as expected, but within my script no output gets generated and no error 
happens.

The lines to write to file are as follows:
------------- begin of file ------------------
# /usr/bin/perl
use strict;
use IO::Handle;

my $pkg_filename   = "longnames.txt";
open(FH, "> $pkg_filename") or die "could not create $pkg_filename";
FH->print("output-test\n") or die "could not write to $pkg_filename";
FH->close() or die "could not close $pkg_filename";
------------- end of file ---------------------

In my script I process a file with these lines:

----------- snip ---------------
undef $/;
my $input = <>;
my $pkg_filename   = "longnames.txt";

open(FH, "> $pkg_filename") or die "could not create $pkg_filename";
while ($input =~ m/.../) {
        print $1;
        FH->print("$1\n") or die "could not write to $pkg_filename";
}
FH->close() or die "could not close $pkg_filename";
--------- snap ----------------

Can anybody shine me a light on this item?

Any comment is appreciated and Thanks in advance.

Kind regards


Reinhard


-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
<http://learn.perl.org/> <http://learn.perl.org/first-response>


Reply via email to