Beefy Boxes and Bandwidth Generously Provided by pair Networks
P is for Practical
 
PerlMonks  

Re: Changing data with syswrite ?

by JavaFan (Canon)
on Apr 27, 2012 at 23:04 UTC ( [id://967735]=note: print w/replies, xml ) Need Help??


in reply to Changing data with syswrite ?

There are a number of problems:
  1. At the moment you use tell, you get the position the file pointer is: at the end of the current line. The regexp match does not influence that.
  2. seek takes three arguments, a file pointer (FH), a position to seek to, and an argument which determines how that position should be interpreted: from the beginning of the file, from the end, or from the current position. Your arguments don't make sense.
  3. A sysread advances the filepointer as well. If you want to replace the 10 characters you read, you got to seek 10 positions back before doing your syswrite.
  4. Your $BUF is empty -- shouldn't that contain at least 10 characters?
  5. As the documentation of sysread says: sysread uses unbuffered I/O, don't mix it with buffered. Do not use sysread when you also use <>.
  6. You are trying to open (as a file) anything in the directory, including . and ...

Perhaps the following works for you (untested):

$ perl -0777 -pi -e 's/(SCSI:INQ:80.{94}).{10}/${1}TEST123456/sg' /hom +e/bkirch/PERL_LSN/TICKETS/*

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others surveying the Monastery: (5)
As of 2024-04-24 03:42 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found