Actually, I already fixed this problem with a chop().
To answer your question I put the flock()s there and commented them out
incase I do end up writing/appending to the files, which I do plan on
doing.
On Thu, 1 Aug 2002 17:52:13 -0400, "David T-G"
<[EMAIL PROTECTED]> said:
> Kyle --
>
> ...and then Kyle Babich said...
> %
> % I wrote the attached script not realizing that when I open() files it
> % would return the 1 when it was sucessful. How would I open a file
>
> Yep.
>
>
> % without the 1, or anything else besides the content of the file,
> being
> % returned?
>
> Just don't capture the result if you don't care; I see that you
>
> $content = open( INDEXDEF, "<index.html" ) || die( "error: open
> INDEXDEF failed\n" );
> # flock ( INDEXDEF, LOCK_EX );
> seek( INDEXDEF, 0, 0 );
> while( <INDEXDEF> )
> {
> print $_;
> }
> # flock ( INDEXDEF, LOCK_UN );
> close( INDEXDEF ) || die( "error: close INDEXDEF failed\n" );
>
> so you're reading the actual content in your while() loop; either skip
> the $content trap or look at it as $success instead of $content.
>
> From what I can tell you expect to capture "the whole file" for
> printing
> later but, in the meantime, you also print it line by line. Is doubled
> output your intent?
>
> It looks like your procedure is the same for every file except for the
> name of the file you open. Why not put your open / flock / seek /
> while() / unlock / close (BTW, why bother with locking when you only
> read?) in a function and pass it the filename, a la
>
> if ( $con eq "" || $con eq "index" ) { dofilemagic("index.html") }
> if ( $con eq "index2" ) { dofilemagic("index2.html") }
> if ( $con eq "main" ) { dofilemagic("main.html") }
> ...
>
> (though I'd prefer to use the lovely Switch module from CPAN in this
> sort
> of case)?
>
>
> %
> % Thank you,
> % --
> % Kyle
>
>
> HTH & HAND
>
> :-D
> --
> David T-G * It's easier to fight for one's
> principles
> (play) [EMAIL PROTECTED] * than to live up to them. -- fortune
> cookie
> (work) [EMAIL PROTECTED]
> http://www.justpickone.org/davidtg/ Shpx gur Pbzzhavpngvbaf Qrprapl
> Npg!
>
--
Kyle
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]