The loop below is used in a script that updates the version line in perl scripts that are version controlled in git. The script is in .git/hooks/pre-commit.
I am running windows, and this script is executed by c:\Perl\bin\perl.exe. However, it is called from within git's shell. Here is my uname -a from within the git shell:
$ uname -a MINGW64_NT-6.1 w72-station 2.4.0(0.292/5/3) 2015-12-12 15:39 x86_64 Ms +ys
The problem is the print statements within this code are putting '. in the front of some of the strings and leaving off the first few characters...
LINE: while (my $line = <$input_fh>) { chomp $line; #print '.'; if ($line =~ m{(.+)\$Id:.+v.*(\d+\.\d+\.\d+)-(\d+).*\$}xms +) { my $string_to_print = "Found version line: '$line'.\n" +; $string_to_print =~ s{[^[:ascii:]]}{}g; print $string_to_print; my $preamble = $1; my $current_version = $2; my $new_build_number = $3; $new_build_number++; my $date = serial_stamp({without_seconds => 1}); my ($sec,$mins,$hours,@rest) = localtime(time); my $time = sprintf "%02d:%02d", $hours, $mins; my $new_line = "$preamble\$Id: $file, v $current_versi +on-${new_build_number} $date $time dbotham Exp \$;"; print "Orig Version: '$line'.\n"; STDOUT->autoflush(1); print "New Version: '$new_line'.\n"; STDOUT->autoflush(1); print $output_fh "$new_line\r\n"; next LINE; } print $output_fh "$line\n"; }
In the paragraph below I use ${} to quote strings, as the single quote character is actually part of the messed up output and I need to quote things somehow...
Notice that ${Found version line:} becomes ${'.und version line:}, which is really strange. Any and all google searchers I can think of wall point me to chomp, chop, substr, etc...
Also notice that ${New Version:} does not exhibit the problem. This is one of the strangest perl problems I have ever encountered...
$ git commit -m "Updated line endings git-push-all-remotes.pl." '.und version line: 'Readonly my $ID => q$Id: git-push-all +-remotes.pl, v 0.2.11-002495 20160114 13:35 dbotham Exp $; '.ig Version: 'Readonly my $ID => q$Id: git-push-all-remot +es.pl, v 0.2.11-002495 20160114 13:35 dbotham Exp $; New Version: 'Readonly my $ID => q$Id: git-push-all-remot +es.pl, v 0.2.11-002496 20160114 13:57 dbotham Exp $;'. Done. Adding updated file, 'git-push-all-remotes.pl', back for commit. Updated build numbers in 1 files. [master f444ca1] Updated line endings git-push-all-remotes.pl. 1 file changed, 1 insertion(+), 5 deletions(-)
Thank you in advance!
Any help will really appreciated.
If you need more of the script to help, please let me know...
Thanks again... david...
In reply to print Is Substituting Characters At Beginning Of String by shilo
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |