Beefy Boxes and Bandwidth Generously Provided by pair Networks
more useful options
 
PerlMonks  

Re: New Line removal from both Unix & Win32

by waswas-fng (Curate)
on Dec 30, 2002 at 18:17 UTC ( #223113=note: print w/replies, xml ) Need Help??


in reply to New Line removal from both Unix & Win32

One more question, why open my $fh, "+<$Conf[1]" or warn "$!"; not open my $fh, "+<$Conf[1]" or die "$!"; as from the snippet you have there you have no work around for failed open -- it can't handle it so it may as well die and be safe.

-Waswas

Replies are listed 'Best First'.
Re: Re: New Line removal from both Unix & Win32
by Anonymous Monk on Dec 30, 2002 at 19:15 UTC
    The code below is no longer getting an error but is failing to remove new lines from the end of files in the Unix environment
    my $fh = Symbol::gensym(); open $fh, '+<$Conf[1]' or warn "$!"; binmode $fh; my $size = 4096; seek $fh, -$size, 2; # Locate the end of the file while (1) { $cur_pos = tell $fh; read $fh, $buf, $size; last if $buf =~ m/\S/s; seek $fh, -$size*2, 1; } $buf =~ m/(\s*)$/s; $cur_pos += $-[0] || 0; truncate $fh, ++$cur_pos if $cur_pos; close $fh;
    Any ideas why

    Thanks again

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://223113]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others pondering the Monastery: (3)
As of 2023-12-10 08:22 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    What's your preferred 'use VERSION' for new CPAN modules in 2023?











    Results (39 votes). Check out past polls.

    Notices?