This archive contains answers to questions sent to Unidata support through mid-2025. Note that the archive is no longer being updated. We provide the archive for reference; many of the answers presented here remain technically correct, even if somewhat outdated. For the most up-to-date information on the use of NSF Unidata software and data services, please consult the Software Documentation first.
On Mon, 22 Nov 1999, Steve Diggs wrote: > Robb, > > This is a 'quick-hack' subroutine to take those arrays of short integers > that used to be string arrays in netCDF into a Perl array of strings. No > error checking (which could be added). > > Let me know if you find this tool useful. Steve, It's a good idea to use pack, but I think the return should of been of type string not array. The reason is perl uses string vs array. It wouldn't be hard to change. Good idea though. Robb... > > -sd > -- > -------------------------------------------------------------------- > Steve Diggs Voice: (858)534-1108 > Scripps Institution of Oceanography FAX : (858)534-7383 > WOCE Hydrographic Program Office/STS EMAIL: address@hidden > 9500 Gilman Drive WWW : whpo.ucsd.edu > La Jolla, CA 92093-0214 > -------------------------------------------------------------------- > > # > #--> This subroutine will take in a null padded array of numerical > #--> CHARS into an array of strings. Takes the array as input, output > #--> in an array of strings. > # > #--> S. Diggs: 1999.11.22 > # > sub num_to_string_array { > > my $string_sect = pack('C*', @_); > my @new_dum = split /\000+/,$string_sect; > my @return_array = @new_dum; > } > 1; > =============================================================================== Robb Kambic Unidata Program Center Software Engineer III Univ. Corp for Atmospheric Research address@hidden WWW: http://www.unidata.ucar.edu/ ===============================================================================