Beefy Boxes and Bandwidth Generously Provided by pair Networks
Clear questions and runnable code
get the best and fastest answer

Re: calling an exe and its input and target files

by NetWallah (Canon)
on Nov 09, 2012 at 04:50 UTC ( #1003061=note: print w/replies, xml ) Need Help??

in reply to calling an exe and its input and target files

Inside "double quotes", the "\" character (which is the 'escape' character) needs to be escaped, using "\\".

So, your foreach should read:

foreach(@files) { system("c:\\midicsv\\midicsv.exe", "c:\\midicsv\\newmidi\\$_", "c:\ +\midicsv\\newcsv\\$_") }
This shows the mixing of a variable with a path, answering your first question.

For renaming files, you need to separate the pieces of the name, and replace the last piece.
This is typically done using regular expressions, but you can also use "split".

Here is a simplified example of replacing a trailing "csv" with "mid":

my $file = "C:\\temp\\somefile.csv"; my $midfile = $file; # copy it $midfile =~ s/\.csv$/.mid/i;

             "By three methods we may learn wisdom: First, by reflection, which is noblest; Second, by imitation, which is easiest; and third by experience, which is the bitterest."           -Confucius

Replies are listed 'Best First'.
Re^2: calling an exe and its input and target files
by amateur_programmer54 (Initiate) on Nov 12, 2012 at 07:34 UTC


    Its taken a week, and I've got it to

    -capture the file names

    -Ignore the directory makers "." and ".."

    -Run the .exe file and convert the files named in the array

    -rename all the files in the director from .mid to .csv

    Then it took about 2 minutes to write and debug the reverse process.

    I haven't written code since 1979, when I was writing in FORTRAN, using punch-cards and, running the prgrams on an IBM System 370 mainframe. Its been great fun.<\P>

    now on to the more daunting task of editing the CSV files so they will work properly when converted back to MIDI format and are used with a finicky biofeedback program that teaches people to sing of all things<\P>

    Thanks again to all the monks who gave input.<\P>

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://1003061]
[marto]: good morning all

How do I use this? | Other CB clients
Other Users?
Others wandering the Monastery: (8)
As of 2018-06-20 08:35 GMT
Find Nodes?
    Voting Booth?
    Should cpanminus be part of the standard Perl release?

    Results (116 votes). Check out past polls.