Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl-Sensitive Sunglasses
 
PerlMonks  

Re: File seek

by Anonymous Monk
on Feb 25, 2013 at 10:15 UTC ( #1020487=note: print w/replies, xml ) Need Help??


in reply to File seek

You're not error checking

$ perl -le " open my($fh), 1 or die$!; seek $fh, 1,0 or die$!; " $ perl -le " open my($fh), 1 or die$!; seek $fh, -1,0 or die$!; " Invalid argument at -e line 1.

You have the file size, if you want to seek to -500, do some math :)

Replies are listed 'Best First'.
Re^2: File seek
by Anonymous Monk on Feb 25, 2013 at 10:37 UTC

    I am seeking to -500 as i know that the keyworn(<run>)wil be in last 500 characters

      I am seeking to -500 as i know that the keyworn(<run>)wil be in last 500 characters

      no you aren't, seek doesn't take negative offsets, like the error message I showed says

        From the documentation

        The values for WHENCE are 0 to set the new position in bytes to POSITION; 1 to set it to the current position plus POSITION; and 2 to set it to EOF plus POSITION, typically negative.

        I suspect your error message is because you are trying to seek to a negative offset from the beginning of the file.

        Cheers,

        JohnGG

        seek (file, distance, from)

        As you can see, seek requires three arguments:

        file: which is the file variable representing the file in which to skip

        distance: which is an integer representing the number of bytes (characters) to skip

        from:which is either 0, 1, or 2

        0 - The number of bytes to skip from beginning of the file.

        1 - The number of bytes to skip from current location of the file.

        2 - The number of bytes to skip from end of the file.

        seek(CONFIRMEDOUTPUTFILE, -500, 2);

        The above line skip backward 500 bytes from the end of the file.

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://1020487]
help
Chatterbox?
[hippo]: Really? Not using the one from the CentOS repository? Perhaps that's the problem.
[vedagiri89]: i need when this issue will come usually
[hippo]: How about mod_perl? Was that installed from the CentOS packge or from source?
[vedagiri89]: from the source
[hippo]: But APR.pm is under vendor_perl in your error message so you are mixing up modules installed from the packager and by hand. That's rarely a good plan.
[vedagiri89]: the prm is..works fine if i run file directly..not working if i run through apache http file
[hippo]: Environments differ.
[vedagiri89]: so, how to fix that differ

How do I use this? | Other CB clients
Other Users?
Others exploiting the Monastery: (11)
As of 2018-06-19 11:38 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    Should cpanminus be part of the standard Perl release?



    Results (113 votes). Check out past polls.

    Notices?