mIRC Homepage

mIRC syntax to Perl syntax

Posted By: Scratch

mIRC syntax to Perl syntax - 30/01/05 11:20 PM

This may be a little off topic, but I would appreciate anyone who codes in Perl, to convert the following mIRC alias into Perl syntax/code. I would greatly appreciate this.

alias test {
  if ($isfile(test.txt)) { goto process }

  var %fl = $lines(test.txt)

  if (%fl >= 1) { 

    var %rline = $rand(1,%fl)

    echo -a $read(test.txt,%rline)

    write $+(-dl,%rline) test.txt

    goto process  

Explanation about what the code is doing:

I have a text file called 'test.txt'. This text file has data on each line. The above code reads a random line from the text file, echoes the data, then it removes the line in the text file containing the data. Then the process restarts again untill the text file is empty.

I need a Perl script that will do exactly the same thing as above.
Posted By: argv0

Re: mIRC syntax to Perl syntax - 31/01/05 02:39 AM

# Filename: shuffle.pl
# Usage: ./shuffle FILENAME
# Description: shuffles FILENAME and prints to stdout
use strict;


sub shuffle($) {
  my(@lines, $r);
  if (!-e $_[0]) { return; }
  open(FILE, $_[0]);
  @lines = <FILE>;
  while ($#lines) {
    $r = int(rand($#lines));
    print $lines[$r];
    splice(@lines, $r, 1);
© 2022 mIRC Discussion Forums