Technically, this isn't a server side question but it is a Perl question and this seems to be the only Perl forum here!
I want to specify part of a Perl script such that it will only get executed if I pass a specific command line parameter. For example, if I specify --build-all on my command line, the whole script will get processed - but if I don't pass that parameter, part of the script will get skipped. Here's the kind of thing:-
I want the blue section to get skipped unless I specify --build-all as a parameter when running the script. I'm sure this is probably child's play for an experienced Perl programmer but I'm very unfamiliar with Perl. How can I do it?Code:#! e:/program files/perl/bin/perl.exe $major = 1; $minor = 3; $micro = 7; sub process_file { my $outfilename = shift; my $infilename = $outfilename . ".in"; open (INPUT, "< $infilename") || exit 1; open (OUTPUT, "> $outfilename") || exit 1; while (<INPUT>) { s/\@GLIB_MAJOR_VERSION\@/$major/g; s/\@GLIB_MINOR_VERSION\@/$minor/g; s/\@GLIB_MICRO_VERSION\@/$micro/g; print OUTPUT; } } process_file ("my-project-config.win32"); if (build-all-specified) process_file ("my-project.rc"); process_file ("my-project.some_other_file");


Reply With Quote
Bookmarks