Path: utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!usc!elroy.jpl.nasa.gov!ncar!csn!news From: frechett@boulder.Colorado.EDU (-=Runaway Daemon=-) Newsgroups: comp.unix.questions Subject: Perl question relating to pattern substitution Message-ID: <1991Jan5.051035.7202@csn.org> Date: 5 Jan 91 05:10:35 GMT Sender: news@csn.org Reply-To: frechett@horton.Colorado.EDU.Colorado.EDU (-=Runaway Daemon=-) Organization: University of Colorado, Boulder Lines: 47 Nntp-Posting-Host: horton.colorado.edu I am having some problems with the following perl script. It is supposed to take a file with strings like A2448932B3F233490 which starts with %%HP and the string itsself starts with " and has a newline every sixty characters and a " terminats it, and convert this mess into a binary file that can be downloaded to the hp48sx calculator. This script was posted, with the statement that it works fine on the poster's system. Unfortunately, I don't know what that was. Here is the script and my comments after the @s. #!/usr/local/bin/perl # unasc # A perl program to extract a HP-48 binary from a text file containing a # ->ASC program. # # Usage: unasc file > binfile # # Written by Wayne Scott 1990 while (<>) { next if (!(/%%HP/../"$/)); # Skip everything but program chop; $file .= $_; } @ I added the following two lines and commented out the one after that @ as my perl had no idea what to make of \w. $file =~ s/"//g; $file =~ s/%%HP//g; # $file =~ s/.*"(\w*)\w\w\w\w".*/\1/; # strip newlines, ", and CRC @ This is the line that I am having problems with.. Simply, it replaces every @ two characters with the string "pack(C,hex(\1.\2)" whis is totally useless @ as it is supposed to be converting ascii to binary. $file =~ s/(.)(.)/pack(C,hex(\1.\2))/eg; # convert ascii to bin print $file; ----------------------------------------------------------------- The problem is that my perl doesn't recognize pack as being a function which is understandable as I can't find reference to pack in TFM for ed, ex, sed, awk, perl, or C. Anyone know how I might be able to work around this little bug and get this to work.. Remember, this works on some machine somewhere... Any help would be appreciated. ian -- -=Runaway Daemon=-