Howdy, Stranger!

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

Categories

Creating files

sheranjemsheranjem Member Posts: 1
I was just wondering what is the most efficient way to create an empty file in a perl script? I'll be checking the size of two files and if they are equal I want to create an empty file. Can anyone help?

Comments

  • KevinADCKevinADC Member Posts: 63
    : I was just wondering what is the most efficient way to create an empty file in a perl script? I'll be checking the size of two files and if they are equal I want to create an empty file. Can anyone help?
    :


    open(FH,'>new.txt') or die "Can't create new.txt: $!";
    close(FH);
  • XfactorXfactor Member Posts: 343
    : : I was just wondering what is the most efficient way to create an empty file in a perl script? I'll be checking the size of two files and if they are equal I want to create an empty file. Can anyone help?
    : :
    :
    :
    : open(FH,'>new.txt') or die "Can't create new.txt: $!";
    : close(FH);
    :

    I would think this would be a little more efficient:

    qx(touch $filename);
  • JonathanJonathan Member Posts: 2,914
    : : open(FH,'>new.txt') or die "Can't create new.txt: $!";
    : : close(FH);
    : :
    :
    : I would think this would be a little more efficient:
    :
    : qx(touch $filename);
    :
    Highly unlikely; that requires the touch program to be spawned, and process creation is surely not as cheap an operation as opening and closing a file (which touch itself will do). Unless you mean less typing, in which case you're of course right. :-)

    Jonathan

    ###
    for(74,117,115,116){$::a.=chr};(($_.='qwertyui')&&
    (tr/yuiqwert/her anot/))for($::b);for($::c){$_.=$^X;
    /(p.{2}l)/;$_=$1}$::b=~/(..)$/;print("$::a$::b $::c hack$1.");

  • KevinADCKevinADC Member Posts: 63
    : I would think this would be a little more efficient:
    :
    : qx(touch $filename);

    [code]
    if (perl forum) {
    print "perl solutions";
    }
    else {
    print "other solutions";
    }
    [/code]
Sign In or Register to comment.