• Viernes 29 de Marzo de 2024, 07:09

Autor Tema:  Re: Lectura de ficheros binarios  (Leído 1972 veces)

tenesor

  • Miembro activo
  • **
  • Mensajes: 90
    • Ver Perfil
Re: Lectura de ficheros binarios
« en: Martes 12 de Febrero de 2002, 18:41 »
0
Hola a todos. Esta vez yo tengo el problemilla.

Necesito leer un fichero en binario y para ello debo especificar la longitud. la expresion es asi:

   sysread FILE, $buffer, $longitud

Teniendo en cuenta que lo que quiero es leer todo el fichero, como puedo hacer para calcular la longitud de dicho fichero?

Saludos,
   Tenesor
Que el toro estoque al matador, que el preso enciere al guardián, que solo sean de cerveza los tanques, que el pez pesque al pescador y que el tigre dome al domador, que la television se prohiba y el hachis se legalice, que africa sea tierra mágica y no trágica... cambiando el mundo [NS]

francisco23

  • Nuevo Miembro
  • *
  • Mensajes: 3
    • Ver Perfil
Lectura de ficheros binarios
« Respuesta #1 en: Miércoles 25 de Septiembre de 2002, 22:21 »
0
prueba con esto para averiguar el tamaño del archivo

stat FILEHANDLE

stat EXPR

stat

Returns a 13-element list giving the status info for a file, either the file opened via FILEHANDLE, or named by EXPR. If EXPR is omitted, it stats $_. Returns a null list if the stat fails. Typically used as follows:
    ($dev,$ino,$mode,$nlink,$uid,$gid,$rdev,$size,
       $atime,$mtime,$ctime,$blksize,$blocks)
           = stat($filename);
Not all fields are supported on all filesystem types. Here are the meaning of the fields:

  0 dev      device number of filesystem
  1 ino      inode number
  2 mode     file mode  (type and permissions)
  3 nlink    number of (hard) links to the file
  4 uid      numeric user ID of file's owner
  5 gid      numeric group ID of file's owner
  6 rdev     the device identifier (special files only)
  7 size     total size of file, in bytes
  8 atime    last access time in seconds since the epoch
  9 mtime    last modify time in seconds since the epoch
 10 ctime    inode change time (NOT creation time!) in seconds since the epoch
 11 blksize  preferred block size for file system I/O
 12 blocks   actual number of blocks allocated

fue sacado de la ayuda de activeperl
mira "perlfunc - Perl builtin functions"
Espero que te ayude.