Perl question relating to pattern substitution

Randal L. Schwartz merlyn at iwarp.intel.com
Sun Jan 6 05:29:26 AEST 1991


In article <1991Jan5.051035.7202 at csn.org>, frechett at boulder (-=Runaway Daemon=-) writes:
| @ 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

| 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.

You have an old Perl (the "pack" function wasn't in earlier Perls).
Say perl -v.  If you don't get at least version 3.0, get yerself a
brand-spankin'-new Perl.  Version 3.0 patchlevel 41 is the latest, and
can be fetched from most GNU places as well as devvax.jpl.nasa.com.

Just another Perl hacker,
-- 
/=Randal L. Schwartz, Stonehenge Consulting Services (503)777-0095 ==========\
| on contract to Intel's iWarp project, Beaverton, Oregon, USA, Sol III      |
| merlyn at iwarp.intel.com ...!any-MX-mailer-like-uunet!iwarp.intel.com!merlyn |
\=Cute Quote: "Intel: putting the 'backward' in 'backward compatible'..."====/



More information about the Comp.unix.questions mailing list