Question:

Do you know Perl !!!

by  |  earlier

0 LIKES UnLike

I have file in D:\plb25484.tex and i must do change "\cal" to "\mathcal",

I do "s/\\cal/\\mathcal/g;"

How to join file and this "change", do hou know script..?!

Thanks..!

 Tags:

   Report

2 ANSWERS


  1. Sorry, stealthstranger-- your answer is missing a very crucial step: you have to save the changes you made!

    if(open (MYFILE, "D:\plb25484.tex")) {

    my $newfile = '';

    foreach my $line (<MYFILE>) {

    $line =~ s/\\cal/\\mathcal/g;

    $newfile .= $line;

    close(MYFILE);

    if(open (MYFILE, "> D:\plb25484.tex")) {

    print MYFILE $newfile;

    close(MYFILE);

    } else {

    print "Error writing to file!\r\n";

    }

    } else {

    print "Couldn't open file!\r\n";

    }

    DaveE


  2. open (MYFILE, "D:\plb25484.text");

    foreach $line  (<MYFILE>) {

      $line = ~s/\\cal/\\mathcal/g;

      ....

      ....

    }

    close(MYFILE);

    ....
You're reading: Do you know Perl !!!

Question Stats

Latest activity: earlier.
This question has 2 answers.

BECOME A GUIDE

Share your knowledge and help people by answering questions.