Anonymous Monk has asked for the wisdom of the Perl Monks concerning the following question:

I have script which gets all the fmb files from a directory changes some of the properties for some fmb files and saves the updated file in to a another directoy. the second script goes through the updated file and compiles these forms. the script 1 is
@files =<C:\\orant\\FORMS60\\forms\\Fapidk\\source\\msvc\\changecolor\ +\Debug\\forms\\*.fmb>; foreach $file (@files) { print $file "\n"; system "changecolor.exe form=$file"; }
the script two is
@files1 =<C:\\orant\\FORMS60\\forms\\forms_up\\*.fmb>; foreach $file (@files1) { print $file . "\n"; system "IFCMP60 USERID=rmetts/rmetts\@dlegtst1 module=$file module_ac +cess=file module_type=form" # print "c:\\orant\\bin\\IFCMP60 USERID=rmetts/rmetts\@dlegtst1 modul +e=$file module_access=file module_type=form" }
i want to combine these two as one script can any one help me on suggesting me with any ideas. thanks

Replies are listed 'Best First'.
Re: combine two scripts in to one
by Zaxo (Archbishop) on May 14, 2007 at 15:32 UTC

    Is either of these working? Your system calls aren't transparent to me, so I can't tell. In the first script, it looks like you're trying to print to a filename instead of a handle, but that may just be a typo omitting a dot op.

    To combine them, it looks like you can just merge the files by appending the second to the first. use strict; and use warnings; to help spot minor errors brought about by the merge.

    I'll mention some style points. I prefer glob to angle brackets over the glob expression because that makes the intent stand out with less visual confusion. Even in windows, perl understands unix directory seperators. You don't need to put the glob list into a variable, for can work on it directly;

    for my $file (glob 'C:/orant/FORMS60/forms/forms_up/*.fmb') { # do stuff }
    It would be useful to check $@ for system call errors after each. That would probably tell you more about your problem than I can.

    After Compline,
    Zaxo

      only the first part is being executed and not the second one.
Re: combine two scripts into one
by subha (Initiate) on May 14, 2007 at 15:15 UTC

    the first script is

    @files =<C:\\orant\\FORMS60\\forms\\Fapidk\\source\\msvc\\changecolor\ +\Debug\\forms\\*.fmb>; foreach $file (@files) { print $file "\n"; system "changecolor.exe form=$file"; }

    the above script gets all the fmb and changes the properties of some of the items in some of the fmb files and saves the updated file to a different directory the secod script goes through the updated file and compiles the form .


    the second script is
    @files1 =<C:\\orant\\FORMS60\\forms_up\\*.fmb>; done and thanks for all of ur help. foreach $file (@files1) { print $file . "\n"; system "IFCMP60 USERID=rmetts/rmetts\@dlegtst1 module=$file module_ac +cess=file module_type=form" # print "c:\\orant\\bin\\IFCMP60 USERID=rmetts/rmetts\@dlegtst1 modul +e=$file module_access=file module_type=form" }
    can any one help me on combining these two scripts into one. thanks for your help.
    I did copy both of these scripts into one file but it seems to be running the first script and not the second one.
      Hi subha,

      I notice you are quite new to PerlMonks, welcome to the Monastery. That said please read the PerlMonks FAQ and How do I post a question effectively?. Using code tags makes it easier for people to read the code you have posted. Regards your Perl question, this seems to be based on one of the answers to your previous question, which you have used to make two working scripts. Have you tried combining them into one file, the contents of the second script following the second?

      Also, if these are the complete working scripts I see no use strict; or use warnings;, or even a shebang line.

      Hope this helps

      Martin
        I did format my message and I tried the option of combing two scripts into one file but only the first part is being executed. thanks for your response.

      The first, and most obvious, check is to see if @files1 is populated. If it's empty, the foreach loop will be skipped, and it will appear that the program isn't running this part of the code. If @files1 should be populated, but isn't, check to make sure that the script has permissions to read the directory; it may not if, for example, this is a CGI script.

      emc

      Insisting on perfect safety is for people who don't have the balls to live in the real world.

      —Mary Shafer, NASA Dryden Flight Research Center