Random Quotes?? - Programmers Heaven

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..???





Sign In or Register to comment.