Howdy, Stranger!

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

Categories

Welcome to the new platform of Programmer's Heaven! We apologize for the inconvenience caused, if you visited us from a broken link of the previous version. The main reason to move to a new platform is to provide more effective and collaborative experience to you all. Please feel free to experience the new platform and use its exciting features. Contact us for any issue that you need to get clarified. We are more than happy to help you.

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.