elhacker.net cabecera Bienvenido(a), Visitante. Por favor Ingresar o Registrarse
¿Perdiste tu email de activación?.

 

 


Tema destacado: Sigue las noticias más importantes de seguridad informática en el Twitter! de elhacker.NET


+  Foro de elhacker.net
|-+  Programación
| |-+  Scripting
| | |-+  [Ruby] Funcion openwords()
0 Usuarios y 1 Visitante están viendo este tema.
Páginas: [1] Ir Abajo Respuesta Imprimir
Autor Tema: [Ruby] Funcion openwords()  (Leído 1,355 veces)
BigBear


Desconectado Desconectado

Mensajes: 545



Ver Perfil
[Ruby] Funcion openwords()
« en: 10 Febrero 2012, 21:03 pm »

Una simple funcion en ruby para cargar un archivo de texto , la funcion retorna un array con las palabras encontradas en el archivo de texto.

Código
  1. #!usr/bin/ruby
  2. #Funcion openwords()
  3. #Coded By Doddy H
  4.  
  5. def openwords(file)
  6.  if File.file?(file)
  7.    print "[+] Opening file\n\n"
  8.    ar = File.open(file)
  9.    lineas = ar.readlines
  10.    ar.close
  11.    print "[+] Number of words : ",lineas.length,"\n\n"
  12.    return lineas
  13.  else
  14.    print "[-] Error opening file\n"
  15.  end
  16. end
  17.  
  18. words = openwords("test.txt")
  19. words.each do |word|
  20.  word = word.chomp
  21.  print "[+] Word : ",word
  22. end
  23.  
  24. #The End ?
  25.  


En línea

Páginas: [1] Ir Arriba Respuesta Imprimir 

Ir a:  

Mensajes similares
Asunto Iniciado por Respuestas Vistas Último mensaje
[Ruby] Funcion tomar()
Scripting
BigBear 0 1,368 Último mensaje 10 Febrero 2012, 19:01 pm
por BigBear
[Ruby] Funcion toma()
Scripting
BigBear 0 1,392 Último mensaje 10 Febrero 2012, 19:02 pm
por BigBear
[Ruby] Funcion speak()
Scripting
BigBear 0 1,377 Último mensaje 10 Febrero 2012, 19:02 pm
por BigBear
[Ruby] Funcion savefile()
Scripting
BigBear 0 1,353 Último mensaje 10 Febrero 2012, 21:02 pm
por BigBear
[Ruby] Funcion cambiarfondo()
Scripting
BigBear 0 1,286 Último mensaje 10 Febrero 2012, 21:03 pm
por BigBear
WAP2 - Aviso Legal - Powered by SMF 1.1.21 | SMF © 2006-2008, Simple Machines