Hello there, Is there the posibility of changing the bellow snippet into a subroutine so every time I invoke into all *.rc files (changing the versions). Here how it is:
.............. chomp(my $rc_dir_file1 = "C:\\$dev_proj"); chomp(my $rc_file1 = "C:\\$dev_proj\\file1.rc"); chomp(my $rc_file2 = "C:\\$dev_proj\\file2.rc"); chomp(my $olddot_ver = $v_rc_file1); my $pendingnewdot = (chop($v_rc_file1)+1) if ($vss_usr_auto =~ /^up$/i +); my $pendingnewdot = (chop($v_rc_file1)-1) if ($vss_usr_auto =~ /^down$ +/i); chomp(my $dot_ver = ($v_rc_file1 . $pendingnewdot)); print "\nUpdating: file1.dll, File: "; system('ss.exe Checkout "$rc_file1" -cAutomated_Version_UPDATE_System +-F- -I-Y -R'); system('ss.exe Checkout "$rc_file2" -cAutomated_Version_UPDATE_System +-F- -I-Y -R'); #FILE VERSION my $screw = $olddot_ver; $olddot_ver =~ s/\./\,/g; my $oldcomma_ver = $olddot_ver; chomp(my $newdot_ver = $dot_ver); $newdot_ver =~ s/\./\,/g; chomp(my $newcomma_ver = $newdot_ver); my $find = (' FILEVERSION ' . "$olddot_ver"); my $replace = (' FILEVERSION ' . "$newcomma_ver"); my $find1 = ('VALUE "FileVersion", ' . "\"" . "$screw" . "\""); my $replace1 = ('VALUE "FileVersion", ' . "\"" . "$dot_ver" . "\"" +); #FILE VERSION Subtitution find(sub{return unless(/\.$doctype_rc$/i);local @ARGV = $_; local $^I += '.bac';while(<>){if(s/$find/$replace/ig) {print;} else {print;}}}," +$rc_dir_file"); find(sub{return unless(/\.$doctype_rc$/i);local @ARGV = $_; local $^I += '.bac';while(<>){if(s/$find1/$replace1/ig) {print;}else{print;}}}," +$rc_dir_file"); print "$file.$type:"; system('ss.exe Checkin "$rc_file1" -cAutomated_Version_UPDATE_System - +I-Y -R'); system('ss.exe Checkin "$rc_file2" -cAutomated_Version_UPDATE_System - +I-Y -R'); sub d { my $file = $File::Find::name; $file =~ s,/,\\,g; return unless -f $file; return unless $file =~ /$file_pattern/; open F, $file || print "couldn't open $file\n" && return; while (<F>) { if (my ($found) = m/($search_pattern)/o) { print "ERRORs found in: $file\n\n"; last; } } close F; } .........
Thank you for all your help.

In reply to Find Replace into a subroutine by sf500

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.