[7049] in Perl-Users-Digest
Perl-Users Digest, Issue: 674 Volume: 8
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Fri Jun 27 21:07:20 1997
Date: Fri, 27 Jun 97 18:00:34 -0700
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)
Perl-Users Digest Fri, 27 Jun 1997 Volume: 8 Number: 674
Today's topics:
64-bit compilation of Perl <jheck@merck.com>
Re: ?: How to copy a file? (Jay Flaherty)
Re: Anyone know if there is an automated way to transla <rootbeer@teleport.com>
Can I get STDERR of `command` ?? <Pierre.Bergdolt@ansf.alcatel.fr>
Re: Can I get STDERR of `command` ?? (A. Deckers)
Re: decimal to hex conversion? <dneumann@telelink.com>
Re: finding cgi-lib.pl (Jay Flaherty)
Fun with ".cgi contained no blank line separating heade (Shelle)
Genericity a.k.a. Parametrized types in Perl <alexk@tti.com>
Re: Help launching/controlling external application (David Corbin)
Re: Help launching/controlling external application (David Corbin)
Help with getting file contents <perrella@ehsn6.cen.uiuc.edu>
Re: Help with getting file contents <jefpin@bergen.org>
Re: Help with getting file contents <perrella@ehsn6.cen.uiuc.edu>
HELP: force a <CR> in DOS a.maclennan@rgu.ac.uk
Re: HELP: force a <CR> in DOS <dean@tbone.biol.sc.edu>
how compute variable names from other variables in a lo (Sascha Ottolski)
Re: How to get keys in multidim-HASH (A. Deckers)
Inconsistent crossplatform Pack!? (John W. Komp)
Re: microsoft personal web server parsing perl scripts (Parillo)
Modules (King M. Lee)
Re: NDBM on Win32 in Perl (Neil Kohl)
Re: Newbee Perl Question.. Perl5 and NT? (Gurusamy Sarathy)
Re: Newbie question: 500 Server Error <rootbeer@teleport.com>
Newbie Question: Rounding of to a decimal???? <ashfield.matthew@miti.nb.ca>
Re: Newbie Question: Rounding of to a decimal???? <sfairey@adc.metrica.co.uk>
Newbie: Lookup to array not working <dundee@ccnet.com>
Perl Extensions -- how to write, etc... <drajg@conetic.com>
Re: perl script using ftp <dean@tbone.biol.sc.edu>
Digest Administrivia (Last modified: 8 Mar 97) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: Fri, 27 Jun 1997 09:33:02 -0400
From: "James J. Heck" <jheck@merck.com>
Subject: 64-bit compilation of Perl
Message-Id: <33B3C10E.446B@merck.com>
I am trying to compile Perl in 64-bit mode on a SGI running IRIX 6.2
Has anyone run into problems compiling Perl in 64-bit? Also if you have
an comments or suggestions on common mistakes for building it in 64-bit
please let me know.
I get a ton of "warning" messages but it finally comes to a halt with
these last few lines of output:
syntax error at lib/Exporter.pm line 15, near "use Exporter;"
BEGIN failed--compilation aborted.
cd t && chmod +x TEST */*.t
cd t && (rm -f perl; /sbin/ln -s ../miniperl perl) \
&& ./perl TEST base/*.t comp/*.t cmd/*.t io/*.t op/*.t
</dev/tty
./miniperl configpm tmp
sh mv-if-diff tmp lib/Config.pm
UX:mv: ERROR: tmp - No such file or directory
*** Error code 2 (bu21)
I am confuzed by the first error as that is from their source code.
TIA,
James
--------------------
James J. Heck
jheck@acm.org
http://www.bucknell.edu/~jheck
The contents of this message express only the sender's opinion.
This message does not necessarily reflect the policy or views of
my employer, Merck & Co., Inc. All responsibility for the statements
made in this Usenet posting resides solely and completely with the
sender.
------------------------------
Date: 27 Jun 1997 12:05:09 GMT
From: fty@hickory.engr.utk.edu (Jay Flaherty)
Subject: Re: ?: How to copy a file?
Message-Id: <5p0a9l$bi1$2@gaia.ns.utk.edu>
M. Mustun (mustun@active.ch) wrote:
: Hello
:
: how can I copy a file in perl?
:
use File::Copy;
copy("src-file", "dst-file");
Jay
--
**********************************************
Jay Flaherty fty@utk.edu
If software was free, who would pay "THE BILL"
**********************************************
------------------------------
Date: Fri, 27 Jun 1997 10:57:51 -0700
From: Tom Phoenix <rootbeer@teleport.com>
To: David Sims <dpsims@slb.com>
Subject: Re: Anyone know if there is an automated way to translate C source to Perl??
Message-Id: <Pine.GSO.3.96.970627105613.17693O-100000@kelly.teleport.com>
On Thu, 26 Jun 1997, David Sims wrote:
> Does anyone know if there is an automated way to translate C code
> to Perl?
There's no program which can convert arbitrary C to equivalent Perl. But
you can turn C code into Perl modules, with a little work assisted by
h2xs. Hope this helps!
--
Tom Phoenix http://www.teleport.com/~rootbeer/
rootbeer@teleport.com PGP Skribu al mi per Esperanto!
Randal Schwartz Case: http://www.rahul.net/jeffrey/ovs/
------------------------------
Date: Fri, 27 Jun 1997 16:32:50 +0200
From: Pierre BERGDOLT <Pierre.Bergdolt@ansf.alcatel.fr>
Subject: Can I get STDERR of `command` ??
Message-Id: <33B3CF12.41C6@ansf.alcatel.fr>
Hi there,
I have a set of perl scripts that perform various operations using
`command`. Normally `command` is executed in a subshell, I can get
return code of `command` using $?, but can I get what `command` put to
STDERR in the subshell? The aim of this is to put warning or error
message in a log file. Thanks to answer by e-mail.
Thanks to all Perl gurus.
--
-----------------------------------------------------------
Pierre Bergdolt Pierre.Bergdolt@ansf.alcatel.fr
Alcatel TELECOM
1 a 7, rue Ampere tel: + 33 (0)1.69.81.12.79
91300 Massy - FRANCE fax: + 33 (0)1.69.81.17.23
-----------------------------------------------------------
------------------------------
Date: 27 Jun 1997 14:42:58 GMT
From: deckers@man.ac.uk (A. Deckers)
Subject: Re: Can I get STDERR of `command` ??
Message-Id: <slrn5r7kbh.65r.deckers@news.rediris.es>
In <33B3CF12.41C6@ansf.alcatel.fr>,
Pierre BERGDOLT <Pierre.Bergdolt@ansf.alcatel.fr> wrote:
>Hi there,
>I have a set of perl scripts that perform various operations using
>`command`. Normally `command` is executed in a subshell, I can get
>return code of `command` using $?, but can I get what `command` put to
>STDERR in the subshell? The aim of this is to put warning or error
>message in a log file. Thanks to answer by e-mail.
>Thanks to all Perl gurus.
$grep -n STDERR ~/perl/PerlFAQ.pod
[...]
4703:=head2 How can I capture STDERR from an external command?
[...]
Whoa, that was difficult to find!
Moral of the story: read the documentation. You'll find answers to many
questions faster and more efficiently than by posting to usenet.
(followup set)
HTH,
Alain
--
Perl information: <URL:http://www.perl.com/perl/>
Perl archive: <URL:http://www.perl.com/CPAN/>
Perl FAQ: <URL:http://www.perl.com/CPAN/doc/FAQs/FAQ/>
>>>>>>>>>>>>> NB: comp.lang.perl.misc is NOT a CGI group <<<<<<<<<<<<<<
------------------------------
Date: Fri, 27 Jun 1997 10:23:58 -0700
From: Dean Neumann <dneumann@telelink.com>
Subject: Re: decimal to hex conversion?
Message-Id: <33B3F72E.167EB0E7@telelink.com>
Tina Marie Holmboe wrote:
>
> [Thu, 26 Jun 1997 01:17:19] [Scott Johnson]
>
> > Does anybody know (I'm sure somebody must) how to convert decimal
> > numbers to hex? I've tried a few things with pack, but everything I
> > try either comes up as the wrong number or zero. I've seen the
> > postings here on how to do this with printf, but I need to data to
> > remain in variables. Thanks in advance!
sub hexval { sprintf "%X", $_[0]; }
$hexnumber = hexval( $decimal_number );
--
Dean Neumann
TeleLink Communications Corp.
dneumann@telelink.com
------------------------------
Date: 27 Jun 1997 11:59:46 GMT
From: fty@hickory.engr.utk.edu (Jay Flaherty)
Subject: Re: finding cgi-lib.pl
Message-Id: <5p09vi$bi1$1@gaia.ns.utk.edu>
Victor Byerly (vbyerly@lakeside.net) wrote:
: can anyone direct me to a place that I can download the cgi-lib.pl file,
: thanks in advance...
:
http://www.bio.cam.ac.uk/cgi-lib/
I would recommend the using Lincoln Stein's CGI module CGI.pm
http://www-genome.wi.mit.edu/ftp/pub/software/WWW/cgi_docs.html
Jay
--
**********************************************
Jay Flaherty fty@utk.edu
If software was free, who would pay "THE BILL"
**********************************************
------------------------------
Date: Fri, 27 Jun 1997 12:39:32 GMT
From: shelle@interaccess.com (Shelle)
Subject: Fun with ".cgi contained no blank line separating header and data"
Message-Id: <5p0ca4$2c8_002@interaccess.interaccess.com>
OK, we're dealing with a Win95 (rev. b) system, running WebSite 1.1e, and Perl
for Win32 5.003_07:
This Server Error 500 message has plagued me for weeks with various scripts
Although I'm feeling somewhat vindicated in that I can see the content-type
info followed by 2 spaces print from the DOS command line, it really doesn't
help too much to kill the problem.
Yes, I have reviewed each of the nagging scripts I've had this problem with
from top to bottom (Which all execute like a charm from the command line), and
whereas I am new to Perl, I am not a complete idiot (Although exact percentage
of idiotness is yet to be determined and I may well be proved wrong on the
last statement.) and come up with no clue as all seems to be kosher, yet the
error message still comes through when viewing from the browser.
Suggestions, comments, ideas, knowledge appreciated.
Beginning to think the Perl Gods are aligning with Mr. Gates to make my life
Hell for shits & giggles.... :(_-_-
Michelle ----,-'-(@
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
I'm just a beginner with Perl but I read TFM....
Michelle Feigen ----,-'-(@ shelle@interaccess.com
http://homepage.interaccess.com/~shelle/
http://homepage.interaccess.com/~shelle/grafx/
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
------------------------------
Date: Fri, 27 Jun 1997 22:29:50 GMT
From: Alex Kravets <alexk@tti.com>
Subject: Genericity a.k.a. Parametrized types in Perl
Message-Id: <33B43EDE.A87E06D5@tti.com>
Does anyone know of any implementations of Genericity( a la C++ template
mechanism) in Perl (assuming such a thing is possible at all considering
typelessness of the language).
In other words, is it possible to have classes parametrized by types?
Or to restate the same problem: Is an STL port to Perl possible?
Cheers ...
------------------------------
Date: Fri, 27 Jun 1997 14:18:04 GMT
From: david@csol.com (David Corbin)
Subject: Re: Help launching/controlling external application
Message-Id: <5p074g$f1n@news2.zippo.com>
Clark Dorman <clark@s3i.com> wrotc:
>What you need to do is to kill the process and all of it's children,
>not just the process itself. The secret is to kill the entire process
>group, using - before the id of the group. Normally, the parent would
>die, but you make the parent ignore the signal. Try the following or
>some variation thereof (time_waster.sh is just a shell script that
>calls a C program that takes a long time to run):
Okay. That works. But if why can't I just do "kill <signal>,-$pid;".
Won't that kill the shell and the process it launched? That doesn't
seem to work for me.
Maybe I just don't understand "process groups".
David Corbin
------------------------------
Date: Fri, 27 Jun 1997 15:19:40 GMT
From: david@csol.com (David Corbin)
Subject: Re: Help launching/controlling external application
Message-Id: <5p0ao1$ghk@news2.zippo.com>
Clark Dorman <clark@s3i.com> wrotc:
>david@csol.com (David Corbin) writes:
>> I am trying to launch an application (tcpdump), and be able to kill it
>> after a certain time. I'm using Fork/Exec, and that launching part
>> works fine. But, if I attempt redirect the output to /dev/null, then
>> it launches a shell first, which launches the tcpdump. This wouldn't
>> be a problem, but when I attempt to KILL the process I created, the
>> shell dies, but tcpdump doesn't. (well, it seems that it will if I
>> use SIGHUP, but that seems to do REAL bad things to my system).
>>
>> I need either 1) a better way to kill these two process, or 2) someway
>> to redirect the tcpdump stdout/stderr without launching a shell.
>What you need to do is to kill the process and all of it's children,
>not just the process itself. The secret is to kill the entire process
>group, using - before the id of the group. Normally, the parent would
>die, but you make the parent ignore the signal. Try the following or
>some variation thereof (time_waster.sh is just a shell script that
>calls a C program that takes a long time to run):
>--
>Clark Dorman "Evolution is cleverer than you are."
>http://cns-web.bu.edu/pub/dorman/D.html -Francis Crick
And on further reflection...."you've got to be kidding". What if I
want to launch several process, but kill them selectively?
David Corbin
------------------------------
Date: Fri, 27 Jun 1997 10:41:34 -0500
From: perrella andrew c <perrella@ehsn6.cen.uiuc.edu>
Subject: Help with getting file contents
Message-Id: <Pine.SOL.3.95.970627103740.292B-100000@ehsn6.cen.uiuc.edu>
How do you get read the contents of a file into a scalar variable?
This has me stumped. I'd like to take a file in the same directory as my
script and end up with a scalar, for example $file_contents, that contains
the contents of the file I want.
any ideas?
thanks,
Andrew Perrella
perrella@uiuc.edu
------------------------------
Date: Fri, 27 Jun 1997 15:29:28 -0400
From: TechMaster Pinyan <jefpin@bergen.org>
Subject: Re: Help with getting file contents
Message-Id: <Pine.SGI.3.96.970627152815.17057C-100000@davinci.bergen.org>
>> How do you get read the contents of a file into a scalar variable?
How 'bout:
open (FILE, "/what/ever/file") || die "Error: $!\n";
while (<FILE>){ $filestring .= <FILE>; }
close (FILE);
----------------
| "Shooting is NOT too good for my enemies!"
| - "The Overlord List"
----------------
Jeff "TechMaster" Pinyan | http://www.bergen.org/~jefpin
HTML/CGI Designer and Consultant and JavaScripter
jefpin@bergen.org | TechMasterJeff@juno.com
Got a JavaScript/CGI/Perl question or problem? Let me know!
webXS - the new eZine for WebProgrammers! webXS@juno.com
Visit us @ http://www.bergen.org/~jefpin/webXS
------------------------------
Date: Fri, 27 Jun 1997 12:26:09 -0500
From: perrella andrew c <perrella@ehsn6.cen.uiuc.edu>
To: Simon Fairey <sfairey@adc.metrica.co.uk>
Subject: Re: Help with getting file contents
Message-Id: <Pine.SOL.3.95.970627122539.318A-100000@ehsn6.cen.uiuc.edu>
Thanks,
Works great.
Andrew Perrella
perrella@uiuc.edu
On Fri, 27 Jun 1997, Simon Fairey wrote:
> perrella andrew c wrote:
> >
> > How do you get read the contents of a file into a scalar variable?
> >
> > This has me stumped. I'd like to take a file in the same directory as my
> > script and end up with a scalar, for example $file_contents, that contains
> > the contents of the file I want.
> >
> > any ideas?
> >
> > thanks,
> >
> > Andrew Perrella
> > perrella@uiuc.edu
>
> You do this by undefining the input record seperator and slurping the
> whole file into your variable.
>
> undef $/;
> $file_contents = <FILE>;
> $/ = '\n';
>
> Take care if you are going to do any pattern matching or substitution on
> this scalar. You will want to look at the /m operator.
>
> Simon
>
>
------------------------------
Date: Fri, 27 Jun 1997 06:51:36 -0600
From: a.maclennan@rgu.ac.uk
Subject: HELP: force a <CR> in DOS
Message-Id: <867412180.7994@dejanews.com>
I'm running Perl 5.001, in a DOS window under Win95. Iwant to get the
current date into a scalar, so I thought I'd do it like this:
open(DIR, 'date |') ;
while (<DIR>){
/^Current date is (\w+) (\S+)/ && ($datebit = $2);
}
print $datebit;
close (DIR);
(Thanks for the help with my last pipe, BTW - wrong version on home
machine ;-<)
This (sort of) works, but I need to hit Return to display $datebit. Is
ther any way I can make the script do this? I've tried
print "\r\n"; which I saw in this newsgroup, in another context (probably
the wrong one :-), but that doesn't seem to make any difference.
Now, I realise, I'm probably going at it the wrong way completely, so I'd
expect some abuse, but would be grateful for suggestions - I *have*
searched myself, tried the FAQ's, but no joy.
Alan
-------------------==== Posted via Deja News ====-----------------------
http://www.dejanews.com/ Search, Read, Post to Usenet
------------------------------
Date: 27 Jun 1997 11:29:50 -0400
From: Dean Pentcheff <dean@tbone.biol.sc.edu>
Subject: Re: HELP: force a <CR> in DOS
Message-Id: <m1pvt8t66p.fsf@nauplius.psc.sc.edu>
a.maclennan@rgu.ac.uk writes:
> I'm running Perl 5.001, in a DOS window under Win95. Iwant to get the
> current date into a scalar, so I thought I'd do it like this:
>
> open(DIR, 'date |') ;
>
>
> while (<DIR>){
> /^Current date is (\w+) (\S+)/ && ($datebit = $2);
> }
> print $datebit;
>
> close (DIR);
>
> (Thanks for the help with my last pipe, BTW - wrong version on home
> machine ;-<)
>
> This (sort of) works, but I need to hit Return to display $datebit. Is
> ther any way I can make the script do this? I've tried
>
> print "\r\n"; which I saw in this newsgroup, in another context (probably
> the wrong one :-), but that doesn't seem to make any difference.
>
> Now, I realise, I'm probably going at it the wrong way completely, so I'd
> expect some abuse, but would be grateful for suggestions - I *have*
> searched myself, tried the FAQ's, but no joy.
Abuse. Abuse. There -- enough? But seriously... I suspect that the
trouble is that the DOS date function a) requires a carriage-return to
terminate, and b) may be designed so that the CR must come from the
keyboard, not from the generic STDIN.
But... an excellent way to sidestep the problem altogether is to use
Perl's built-in function to get a printable date. Other advantages to
the built-in solution are that it avoids the overhead of an external
program call, and will act identically across different operating
system platforms. Using Perl's internal facilities, you could do:
print scalar localtime;
The "localtime" function in Perl returns an array of time-related
information when called in an array context. When called in a scalar
context (here forced by use of the "scalar" keyword), it returns a
printable date string. (See the documentation in the "perlfunc"
manual entry.)
Just to clarify that array/scalar distinction (which is a key concept
to learn about in Perl)... If you were to call localtime like this:
@date = localtime;
then the @date list would be filled with a predetermined series of
date/time-related thingies (like seconds, minute, hour, day of month,
day of week, etc.) that you could use programmatically. Were you to
call it:
$date = localtime;
then $date is filled with a string something like:
Fri Jun 27 11:20:15 1997
that you can print (note that you'll need to add a trailing "\n" if
you want that on the end).
The difference is that the first call is assigning to the list
variable @date, therefore doing the call in an "array context"; the
second call assigns to the scalar $date, therefore doing the call in a
"scalar context". By default, the argument of a "print" statement is
in an array context (one generally supplies a list of things to be
printed), so you need to force the localtime call to be interpreted
within a scalar context. The "scalar" keyword in front of the
"localtime" forces a scalar context.
Hope that's helpful...
-Dean
--
N. Dean Pentcheff <pentcheff@acm.org> WWW: http://tbone.biol.sc.edu/~dean/
Biological Sciences, Univ. of South Carolina, Columbia SC 29208 (803-777-3936)
PGP ID=768/22A1A015 Keyprint=2D 53 87 53 72 4A F2 83 A0 BF CB C0 D1 0E 76 C0
Get PGP keys and information with the command: "finger dean@tbone.biol.sc.edu"
------------------------------
Date: 27 Jun 1997 15:00:18 GMT
From: sascha@ella.ww.tu-berlin.de (Sascha Ottolski)
Subject: how compute variable names from other variables in a loop ?
Message-Id: <5p0ki2$g3b$1@news.cs.tu-berlin.de>
Hi,
I have written a little ugly script to stat a list of files to find out what
if they are some kind of secure.
Since I need to stat several files in several scripts I want to do this in a
loop to avoid typing lots of stuff again and again, and to use many variables
to make it easily reusable; well, I found a glue how to to this in an old
posting to this group, and it works well, but it is somewhat ugly and
unreadable (and emacs' perl-mode doesn't like all these "{" and "}" :-)).
I'm wondering if there is a more elegant way to do this, maybe with hash-lists
or more arrays or whatever...
Thanks for any help,
Greetings Sascha
---part of the script I'm talking about---------------------------------
@externals = ($ipup_00,$ipup_01,$route,$myself);
# first we need to know if external programs are secure
for $external (@externals) {
(${'dev' . $external},${'ino' . $external},${'mode' . $external},
${'nlink' . $external},${'uid' . $external},${'gid' . $external},
${'rdev' . $external},${'size' . $external},${'atime' . $external},
${'mtime' . $external},${'ctime' . $external},${'blksize' . $external},
${'blocks' . $external})
= lstat($external);
if ((${'mode' . $external} & 0022) != 0) {
push @error,"$external is unsecure: writeable!\n\n";
}
if (!( -x $external)) {
push @error,"$external is not executable\n\n";
}
}
# if we are not SUID root, nothing will work...
if (!( -u $myself)) {
push @error,"SUID-bit is not set.\n\n";
}
if (${'uid' . $myself} != 0) {
push @error,"$myself must be owned by uid 0\n\n";
}
----the end so far-----------------------------
------------------------------
Date: 27 Jun 1997 14:20:06 GMT
From: deckers@man.ac.uk (A. Deckers)
Subject: Re: How to get keys in multidim-HASH
Message-Id: <slrn5r7j0i.65r.deckers@news.rediris.es>
In <5p0f8v$978@epervier.CC.UMontreal.CA>,
CHAN TANG Eric-Aubert <chantane@JSP.UMontreal.CA> wrote:
>
>Let say I have:
>
>#--------------------------
> my %hash;
>
> $hash{"a"}{"A"} = "aA";
> $hash{"b"}{"B"} = "bB";
> $hash{"c"}{"C"} = "cC";
> $hash{"d"}{"D"} = "dD";
>
> my @keysList = keys %hash;
>#--------------------------
>
>I can have the ("a", "b", "c", "d"), but I can't find how
>to get ("A", "B", "C", "D").
>
>And something like:
>
>#-------------------------------------------
> while (($key1, $key2, $value) = each %hash)
> {
> print $key1.",".$key2." = ".$value."\n";
> }
>#-------------------------------------------
#!/usr/bin/perl -w
my %hash = (
'a' => {'A' => 'aA'},
'b' => {'B' => 'bB'},
'c' => {'C' => 'cC'},
'd' => {'D' => 'dD'},
);
my(
$key1,
$key2,
$val,
);
foreach $key1 (keys %hash) {
# Let's assume this thing is only 2 levels deep.
while (($key2, $val) = each %{$hash{$key1}}) {
print "$key1..$key2 = $val\n";
}
}
__END__
The things you have to realise is that the "value" of your first level
array is actually a reference to another hash, which you have to
dereference.
See man perldsc and man perlref. If you don't have them handy on your
system, find them on any CPAN mirror under the CPAN/doc subdirectory.
HTH,
Alain
--
Perl information: <URL:http://www.perl.com/perl/>
Perl archive: <URL:http://www.perl.com/CPAN/>
Perl FAQ: <URL:http://www.perl.com/CPAN/doc/FAQs/FAQ/>
>>>>>>>>>>>>> NB: comp.lang.perl.misc is NOT a CGI group <<<<<<<<<<<<<<
------------------------------
Date: 27 Jun 1997 15:14:13 GMT
From: jk0101@medtronic.com (John W. Komp)
Subject: Inconsistent crossplatform Pack!?
Message-Id: <5p0lc5$afj$1@gazette.corp.medtronic.com>
I'm trying to reformat an ASCII file of hex numbers to a raw binary
file. My truncated code is:
while (<>)
{
# Strip off the first two bytes and throw the rest away
/(..)(..)(.*)/;
# Convert it to a packed string of hex values and send to the file
$outval = pack("H*" x 2,$2,$1);
print OUTFILE $outval;
}
and the input file:
000000
001800
030F00
0A0000
1F0A00
001F00
0A0000
1F0A00
...
On a Unix box using version 4.0.1.8 patch level 36 I get what I'm
expecting:
0000 1800 0f03 000a 0a1f 1f00 000a 0a1f
1f00 000a 0a1f 1f00 b419 0aaf 1f00 000a
0a1f 1f00 b519 0aef 1f00 000a 0a1f 1f00
On a DOS box using version 4.0.1.6, patch level 19 I get:
0000 1800 0f03 000d 0a0d 0a1f 1f00 000d
0a0d 0a1f 1f00 000d 0a0d 0a1f 1f00 b419
0d0a af1f 0000 0d0a 0d0a 1f1f 00b5 190d
It appears the DOS version insists that source line 0a00 should be
000d 0a0d and not the expected 000a. What am I doing wrong with my
usage of pack?
-John
--
****************************************************
This morning I shot six holes in my freezer
I think I've got cabin fever
Somebody sound the alarm
- J. Buffett
****************************************************
------------------------------
Date: 27 Jun 1997 14:56:32 GMT
From: lparillo@newshost.li.net (Parillo)
Subject: Re: microsoft personal web server parsing perl scripts
Message-Id: <5p0kb0$er7@linet06.li.net>
Trust me, it works.
On evenings or weekends, try the say hello button at
http://marco.gtc.pw.com
I am running PWS, and Activewares Win32 Perl
J.R. Dean (jrd@spam.blows_see.sig) wrote:
: In article <5omt2j$ad2@linet06.li.net>, lparillo@newshost.li.net (Parillo) wrote:
: >Try http://www.endcontsw.com/people/evangelo/Perl_for_Win32_FAQ.html
: >and also read the Microsoft Knowledge Base article covering this issue,
: >"Configuring and Testing a PERL [sic] Script with IIS,"
: >(http://www.microsoft.com/kb/articles/q150/6/29.htm).
: >
: That's not the same as the MS Personal Web server, though,
: is it? I believe he's talking about the little web server
: that's now bundled with the latest OEM version of Windows95.
: I played with it briefly on a contract (normally, I prefer
: to use WebSite for Win95/NT). I don't think the configuration
: for IIS will necessarily help in this case.
: -- Dean
: -------------
: jrd@enclave.org -- URL = <http://www.enclave.org/jrd/>
: "The Enclave" -- Boulder Creek, California -- +1 408 336-0610
: =+! Public Access Usenet BBS for Writers & Other Fiends !+=
------------------------------
Date: 27 Jun 1997 09:08:25 GMT
From: klee@sally.nas.nasa.gov (King M. Lee)
Subject: Modules
Message-Id: <5ovvu9$i6r$1@cnn.nas.nasa.gov>
Hello,
I have a program consisting of several modules (.pm files)
and I would like to distribute this program. The problem
is that I would like to distribute a single file
so that users do not have to clutter up their bin directory.
I can of course use perl to read all files into single
file, strip off the lines related to packages, but that's
ugly and error prone. Or should I from now on use require
which allows me to do this more easily.
Please email me as my news reader is not very reliable.
King Lee
--
|King Lee * Phone 805-664-3148 |
|California State University,Bakersfield * email: klee@nas.nasa.gov |
|9001 Stockdale Highway * |
|Bakersfield, CA 93309 * |
------------------------------
Date: 27 Jun 1997 14:19:23 GMT
From: neilkohl@netaxs.com (Neil Kohl)
Subject: Re: NDBM on Win32 in Perl
Message-Id: <slrn5r7ivb.ioh.neilkohl@unix1.netaxs.com>
On 24 Jun 1997 11:24:36 -0400, Todd Hivnor <hivnor@shore.net> wrote:
>I'm trying to access an NDBM file under Windows NT from Perl (5.004_01).
>(So I can play with Netscape Server's User database)
>But NDBM doesn't seem to be supported under Win32.
>The NDBM install-time test was skipped,
> and TIEHASH isn't found in the NDBM_File module.
>Am I missing something ?
>There really is no NDBM support under Win32?
Nope. SDBM_File is supported.
Try something like:
use SDBM_File;
#flags for SDBM
sub O_CREAT { 0x0100 }
sub O_BINARY { 0x8000 }
sub O_RDWR { 0x0002 }
my %db;
tie (%db, "SDBM_File", "$dbm_file_name", O_RDWR | O_CREAT | O_BINARY,
0666) or die "tie die!";
# fiddle with data here...
untie %db;
SDBM files aren't as compact as other formats, but they work...
--
neil kohl
=====================================================================
neilkohl@netaxs.com | "A long quiet like a purge and then
philadelphia, pa | a contemplation and decision of future roads,
usa | that is what to look forward to."
| - T.E. Lawrence, 15.vi.18
=====================================================================
------------------------------
Date: 27 Jun 1997 17:15:42 GMT
From: gsar@engin.umich.edu (Gurusamy Sarathy)
Subject: Re: Newbee Perl Question.. Perl5 and NT?
Message-Id: <5p0sfu$o9m@srvr1.engin.umich.edu>
[ mailed and posted ]
In article <01bc8300$07a56610$45efdd80@slick>,
Brian Gruttadauria <Brian_Gruttadauria@dg.com> wrote:
>
>perl.exe -pi.bak -e 's/foo/bar/g' filename.ini
>
>It does nothing to the file???
Better make that:
perl.exe -pi.bak -e "s/foo/bar/g" filename.ini
^ ^
double quotes
for it to work with the cmd.exe shell.
- Sarathy.
gsar@umich.edu
------------------------------
Date: Fri, 27 Jun 1997 10:59:50 -0700
From: Tom Phoenix <rootbeer@teleport.com>
To: Andre Pinheiro <l41325@alfa.ist.utl.pt>
Subject: Re: Newbie question: 500 Server Error
Message-Id: <Pine.GSO.3.96.970627105919.17693P-100000@kelly.teleport.com>
On Tue, 24 Jun 1997, Andre Pinheiro wrote:
> Subject: Newbie question: 500 Server Error
When you're having trouble with a CGI program in Perl, you should first
look at the please-don't-be-offended-by-the-name Idiot's Guide to
solving such problems. It's available on the perl.com web pages. Hope
this helps!
http://www.perl.com/perl/
http://www.perl.com/perl/faq/
http://www.perl.com/perl/faq/idiots-guide.html
--
Tom Phoenix http://www.teleport.com/~rootbeer/
rootbeer@teleport.com PGP Skribu al mi per Esperanto!
Randal Schwartz Case: http://www.rahul.net/jeffrey/ovs/
------------------------------
Date: 27 Jun 1997 13:53:17 GMT
From: "mashfiel" <ashfield.matthew@miti.nb.ca>
Subject: Newbie Question: Rounding of to a decimal????
Message-Id: <01bc8237$cf738d80$3e080a0a@mashfiel.miti.nb.ca>
Hi,
I am rather new to the Perl environment and have been reading much of the
documentation that is out there. However, it still has yet to answer a very
simple problem that i am having. Basically I two variables with integers in
them. I want to represent one as a percentage as the other. Now to print
that percentage say to the nearest .01 decimal place, how do I do this? I
assume it could be done through some sort of string matching etc.. but
figured there must be a simple function that does this. Bascially my code
looks like
$a = 123456;
$b =12345677;
$apercentage = $a / $b * 100;
print $apercentage;
and of course this gives me a number with many decimal places. Anyway, I've
read the man page etc... but haven't found anything on it.. Either I'm
blind or there actually exists no such round function, and if that is the
case I'd love to hear the quick way to do this. Anyway, any help or advice
would be greatly appreciated, preferably by email.
Thanks for your time,
Matt
ashfield.matthew@miti.nb.ca
------------------------------
Date: Fri, 27 Jun 1997 15:40:23 +0100
From: Simon Fairey <sfairey@adc.metrica.co.uk>
To: mashfiel <ashfield.matthew@miti.nb.ca>
Subject: Re: Newbie Question: Rounding of to a decimal????
Message-Id: <33B3D0D7.FF6@adc.metrica.co.uk>
mashfiel wrote:
>
> Hi,
> I am rather new to the Perl environment and have been reading much of the
> documentation that is out there. However, it still has yet to answer a very
> simple problem that i am having. Basically I two variables with integers in
> them. I want to represent one as a percentage as the other. Now to print
> that percentage say to the nearest .01 decimal place, how do I do this? I
> assume it could be done through some sort of string matching etc.. but
> figured there must be a simple function that does this. Bascially my code
> looks like
> $a = 123456;
> $b =12345677;
> $apercentage = $a / $b * 100;
> print $apercentage;
Change the print to use printf or sprintf if you want to store it.
i.e.
printf( "%.2f", $apercentage );
Simon
------------------------------
Date: Fri, 27 Jun 1997 07:00:14 -0700
From: Sean Scannell <dundee@ccnet.com>
Subject: Newbie: Lookup to array not working
Message-Id: <33B3C76E.66AF@ccnet.com>
I guess I'm missing something basic, and can't pick it from the examples
in the camel or llama book. I'm trying to return default info about a
user to a form, but I get all the records in the file instead of just
the just the one I want. Any tips really appreciated. This is my test
script:
###### Get Manager default info #########
print "Enter your User ID: ";
$this_user = <STDIN>;
chop($this_user);
open(MGR_DATA,"mgr_data");
while (<MGR_DATA>) {
($user_id,$mgr_records)= split(",");
$mgr_record{$user_id} = $mgr_records;
($nameprefix,$firstname,$lastname,$title,$areacode,$prefix,$phone,$ext,$email,$company,$dept,$dept_no,$address1,$city,$state,$zip,$div_mgr)
= split /:/,$mgr_records;
if ($this_user = $user_id) {;
print "USER_ID $user_id \n";
print "MGR_RECORDS $mgr_records \n";
print "nameprefix $nameprefix \n";
print "first name $firstname \n";
print "last name $lastname \n";
} else { }
}
close (MGR_DATA);
------------------------------
Date: Fri, 27 Jun 1997 11:42:19 -0700
From: Bonita Dattner-Garza <drajg@conetic.com>
Subject: Perl Extensions -- how to write, etc...
Message-Id: <33B4098A.F64@conetic.com>
I am looking for information of how to write PERL Extensions -- for
reading and writing from a NON-SUPPORTED database engine. I have "C++"
wrappes already written and functional. Does any one know where I can
get documentation on DBI-Perl "structure", "rules", etc.. Which object
library I need to link to etc...
Any help would be greatly appreicated!
-Andy Garza
andy@conetic.com
------------------------------
Date: 27 Jun 1997 11:16:13 -0400
From: Dean Pentcheff <dean@tbone.biol.sc.edu>
Subject: Re: perl script using ftp
Message-Id: <m1radot6te.fsf@nauplius.psc.sc.edu>
"Eric Tung" <etung@bellatlantic.net> writes:
> I need to transfer data on a regular basis from mutilple OSs (NT/UNIX etc)
> to one server. After considering several options, I though using the good
> old ftp is probably simplest and most portable. I am thinking of using
> sockets and ftp spec (RFC ?) for this task.
>
> If you have any insight and experience with this, please advise. Let me
> know of any sample codes on the net that may be helpful.
Run, don't walk to the CPAN archive of Perl modules. You can find it
starting at <URL:http://www.perl.com/perl/> -- visit Software, and
find the "Full modules list".
In that list, you will find, among _many_ other useful modules, the
Net::FTP module. It's a direct and very functional interface to the
FTP protocol for use within Perl.
> Thank you.
You're very welcome: it's a pleasure to save someone the time and pain
of rewriting an already-written piece of code.
-Dean
--
N. Dean Pentcheff <pentcheff@acm.org> WWW: http://tbone.biol.sc.edu/~dean/
Biological Sciences, Univ. of South Carolina, Columbia SC 29208 (803-777-3936)
PGP ID=768/22A1A015 Keyprint=2D 53 87 53 72 4A F2 83 A0 BF CB C0 D1 0E 76 C0
Get PGP keys and information with the command: "finger dean@tbone.biol.sc.edu"
------------------------------
Date: 8 Mar 97 21:33:47 GMT (Last modified)
From: Perl-Request@ruby.oce.orst.edu (Perl-Users-Digest Admin)
Subject: Digest Administrivia (Last modified: 8 Mar 97)
Message-Id: <null>
Administrivia:
The Perl-Users Digest is a retransmission of the USENET newsgroup
comp.lang.perl.misc. For subscription or unsubscription requests, send
the single line:
subscribe perl-users
or:
unsubscribe perl-users
to almanac@ruby.oce.orst.edu.
To submit articles to comp.lang.perl.misc (and this Digest), send your
article to perl-users@ruby.oce.orst.edu.
To submit articles to comp.lang.perl.announce, send your article to
clpa@perl.com.
To request back copies (available for a week or so), send your request
to almanac@ruby.oce.orst.edu with the command "send perl-users x.y",
where x is the volume number and y is the issue number.
The Meta-FAQ, an article containing information about the FAQ, is
available by requesting "send perl-users meta-faq". The real FAQ, as it
appeared last in the newsgroup, can be retrieved with the request "send
perl-users FAQ". Due to their sizes, neither the Meta-FAQ nor the FAQ
are included in the digest.
The "mini-FAQ", which is an updated version of the Meta-FAQ, is
available by requesting "send perl-users mini-faq". It appears twice
weekly in the group, but is not distributed in the digest.
For other requests pertaining to the digest, send mail to
perl-users-request@ruby.oce.orst.edu. Do not waste your time or mine
sending perl questions to the -request address, I don't have time to
answer them even if I did know the answer.
------------------------------
End of Perl-Users Digest V8 Issue 674
*************************************