Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories

Random Quotes??

Anyone know how to make a perl program that randomly gets text from a different file..???


Comments

  • # Directory of files

    $dir = "/home/me/public"


    # Open, read, and close dir

    opendir(DIR, $dir); # Opens the directory stored in $dir and creates stream DIR

    @files = readdir(DIR); # Reads the filenames from stream DIR

    closedir(DIR); # Closes stream DIR


    # Choose random file

    srand(time ^ $$); # Generates a random number from the time

    $file = rand(@files); # Chooses that number from the array of files


    ********************

    After this you would open the file as normal and

    read from it.


    -Matt(AA)


    : Anyone know how to make a perl program that randomly gets text from a different file..???





  • Shawn CarterShawn Carter Member Posts: 0

    | http://forcoder.org | free video tutorials and ebooks about { C++ PL/SQL Visual Basic C C# JavaScript Java Go Ruby R Assembly PHP Swift Python Delphi Scratch Visual Basic .NET Perl MATLAB Objective-C Apex Fortran Hack SAS Lua Dart LabVIEW Ada FoxPro Julia Transact-SQL Scala Clojure D Rust Alice Crystal Bash Scheme ABAP Awk Lisp F# Kotlin Logo Erlang COBOL Prolog VBScript ML } ___________

Sign In or Register to comment.