Perl one liner to wrap comment lines

Greetings fellow scripters.

I find myself editing multiple files, sometimes with the same bits of information. My bash script, a changelog, and a plist file (OS X). Once I realized this, I thought why not script part of this process (and so it begins). In any case, I've solved several of the tasks I've set forth for myself. My new update script will update version/revision numbers in all files, and add text to the top of my change log using a combination of bash, python, and now perl (I think I'm nerding out a bit). I know this is all overkill, I just wanted to see if I could do it.

So, with the command

./update.sh 1.8.8.8 "some text for a change log header" /some.plist
pVersion="$1"
pRevision=$(echo "$1" | awk -F. '{print $4}')
vHeader=$(echo $pVersion | sed -e 's/\.//g' -e 's/^/v/')
pChangeLog=$2

export PVERSION=$pVersion
export PREVISION=$pRevision
export PLISTPATH="$3"

python - <<END
import os
import plistlib

pVersion=os.environ['PVERSION']
pRevision=os.environ['PREVISION']
plistPath=os.environ['PLISTPATH']

Plist=plistlib.readPlist(plistPath)

Plist['ProductVersion'] = pVersion
Plist['Revision'] = pRevision


plistlib.writePlist(Plist, plistPath)

END

perl -spi -e "s/version=\"*.*.*.*\"/version=\"$pVersion\"/g" somescript.sh

What I'm stuck with is the next bit.

perl -spi -e "s/change\ log/change\ log\n#\t$pVersion\n#\t-$pChangeLog/g"

Well, maybe not stuck. It works fine. But, if I could somehow make this perl one-liner also wrap text at 80 columns and add a "#\t\t" at the start of each line (and make me a sandwich).... Is that just asking too much? Maybe I should cut down on the energy drinks.

---------- Post updated at 23:21 ---------- Previous update was at 23:20 ----------

These are the things I do when I'm bored.

It's doable, but then the one-liner would no longer be a one-liner, imho.

You might find following alternative viable/useful

#!/bin/bash

pVersion="$1"
pChangeLog="$2"


perl -spi -e "s/version=\"*.*.*.*\"/version=\"$pVersion\"/g" somescript.sh

if [ ${#pChangeLog} -gt 71 ] # 80 - 8 spaces from tab - 1 hypen
then    # wrapping necessary

MLINE=$(
    # first line
    line="${pChangeLog:0:71}"
    printf "#\t-%s\n" "$line"
    pChangeLog="${pChangeLog:71}"

    # all the rest
    while [ ${#pChangeLog} -gt 0 ];
    do
        line="${pChangeLog:0:64}" # 80 - 16 spaces from two tabs
        printf "#\t\t%s\n" "$line"
        pChangeLog="${pChangeLog:64}"
    done
)

    perl -spi -e "s/change\ log/change\ log\n#\t$pVersion\n$MLINE/g" somescript.sh

else    # fits in one line

    perl -spi -e "s/change\ log/change\ log\n#\t$pVersion\n#\t-$pChangeLog/g" somescript.sh

fi

Demo:

$ cat somescript.sh
#!/bin/coolcli

# version="w.x.y.z"
# change log

# <------ program code below this line  ------>
$
$ ./update.sh 0.0.0.1 "first version"
$ ./update.sh 0.0.0.2 "added function x"
$ ./update.sh 0.0.1.0 "some text"
$ ./update.sh 0.0.1.1 "some more text"
$ ./update.sh 0.1.0.0 "A changelog is a log or record of changes made to a proje
ct, such as a website or software project, usually including such records as bug
 fixes, new features, etc. Source: wikipedia"
$ 
$ cat somescript.sh
#!/bin/coolcli

# version="0.1.0.0"
# change log
#       0.1.0.0
#       -A changelog is a log or record of changes made to a project, such as a 
#               website or software project, usually including such records as b
#               ug fixes, new features, etc. Source: wikipedia
#       0.0.1.1
#       -some more text
#       0.0.1.0
#       -some text
#       0.0.0.2
#       -added function x
#       0.0.0.1
#       -first version

# <------ program code below this line  ------>
$