[28001] in Perl-Users-Digest
Perl-Users Digest, Issue: 9365 Volume: 10
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Sat Jun 24 00:05:42 2006
Date: Fri, 23 Jun 2006 21:05:03 -0700 (PDT)
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, 23 Jun 2006 Volume: 10 Number: 9365
Today's topics:
Re: Hash of Arrays <pradeep.bg@gmail.com>
Re: Hash of Arrays <hoosier45678@hotmail.com>
Re: Hash of Arrays <someone@example.com>
Moving C code from 32 to 64 bit <sigzero@gmail.com>
Script debugging <adamsmith@econ.com>
Re: Unwanted character "^@" in perl output <trwww@sbcglobal.net>
Re: use binary operator on ascii text string <benmorrow@tiscali.co.uk>
Re: use binary operator on ascii text string <someone@example.com>
Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: 23 Jun 2006 19:41:24 -0700
From: "Deepu" <pradeep.bg@gmail.com>
Subject: Re: Hash of Arrays
Message-Id: <1151116884.820689.278160@c74g2000cwc.googlegroups.com>
Hi All,
Thanks a lot for helping me on this.I tried the above code and got one
problem. I was trying to countthe STATESUSPEND if located between
STATEMAIN and RESET.
STATE1
STATE3
STATEMAIN ####
STATESUSPEND
STATE1
STATE2
STATERESUME
RESET
STATE6
STATE8
STATEMAIN ####
STATE9
STATE10
Code:
use strict;
use Data::Dumper;
my @files = qw/FILE1 FILE2/;
my %transitions;
my %hashsuspend
foreach my $filename (@files)
{
my $fh;
open $fh, $filename
or do {
warn "$filename missing";
next;
};
my $run_through = 0;
my $recording_enabled = 0;
while (<$fh>)
{
if (/^RESET\b/)
{
$recording_enabled = 0;
}
elsif (/^STATEMAIN\b/)
{
$run_through++;
$recording_enabled = 1;
$suspendCount =0;
}
elsif ($recording_enabled)
{
push @{$transitions{$filename}[$run_through]}, $_;
if ($_ =~ /^STATESUSPEND/)
{
$suspendCount++;
$hashsuspend{$filename}[$run_through] = $suspendCount;
next;
}
}
}
close $fh or die $!;
}
print Dumper \%transitions;
print Dumper \%hashsuspend;
The output i am getting with this is:
%transitions = (
FILE1 => [
undef,
[
STATESUSPEND
STATERESUME
STATE1
STATE2
],
and so on.
What is the reason for undef at the start of the array in every
file.This undef appears even with hashsuspend. Please help me on this.
Thanks
Deep
Tad McClellan wrote:
> John W. Krahn <someone@example.com> wrote:
> > Deepu wrote:
>
> >> %hash = (
> >> FILE1 => ["STATEMAIN", "STATESUSPEND", "STATE1",
> >> "STATE2", "STATERESUME", "RESET"],
> >> FILE1 => ["STATEMAIN", "STATE9", "STATE10"],
> >
> > In Perl a hash cannot have two different keys with the same name.
>
>
> Can a hash have two different keys with the same name somewhere
> besides in Perl?
>
> How do you distinguish between the two?
>
> How does the hashing differ?
>
> Should I take this off-topic question elsewhere? :-)
>
>
> --
> Tad McClellan SGML consulting
> tadmc@augustmail.com Perl programming
> Fort Worth, Texas
------------------------------
Date: Fri, 23 Jun 2006 22:41:22 -0500
From: James <hoosier45678@hotmail.com>
Subject: Re: Hash of Arrays
Message-Id: <pan.2006.06.24.03.41.12.559130@hotmail.com>
On Fri, 23 Jun 2006 19:41:24 -0700, Deepu wrote:
> The output i am getting with this is:
>
> %transitions = (
> FILE1 => [
> undef,
> [
> STATESUSPEND
> STATERESUME
> STATE1
> STATE2
> ],
> and so on.
>
> What is the reason for undef at the start of the array in every file.This
> undef appears even with hashsuspend. Please help me on this.
You missed my correction to my off-by-one error:
http://groups.google.com/group/comp.lang.perl.misc/msg/a95ee481249569d4?hl=en
------------------------------
Date: Sat, 24 Jun 2006 03:46:27 GMT
From: "John W. Krahn" <someone@example.com>
Subject: Re: Hash of Arrays
Message-Id: <nA2ng.6497$B91.2484@edtnps82>
Deepu wrote:
>
> Thanks a lot for helping me on this.I tried the above code and got one
> problem. I was trying to countthe STATESUSPEND if located between
> STATEMAIN and RESET.
>
> STATE1
> STATE3
> STATEMAIN ####
> STATESUSPEND
> STATE1
> STATE2
> STATERESUME
> RESET
> STATE6
> STATE8
> STATEMAIN ####
> STATE9
> STATE10
>
> Code:
use warnings;
use strict;
@ARGV = qw/FILE1 FILE2/;
my ( $suspendCount, %transitions );
while ( <> ) {
push @{ $transitions{ $ARGV } }, [] if /STATEMAIN/;
if ( /STATEMAIN/ .. /RESET/ || eof ) {
push @{ $transitions{ $ARGV }[ -1 ] }, $_;
$suspendCount += /STATESUSPEND/;
}
}
__END__
John
--
use Perl;
program
fulfillment
------------------------------
Date: 23 Jun 2006 18:39:10 -0700
From: "Robert Hicks" <sigzero@gmail.com>
Subject: Moving C code from 32 to 64 bit
Message-Id: <1151113150.365583.16930@c74g2000cwc.googlegroups.com>
I have a co-worker at work that created a module for Perl coded in "C"
that works fine in a 32-bit world. We moved to the Itanium processor
and now it is flakey and getting memory errors. Is there a resource for
Perl that describes moving your "C" coded module from 32 to 64-bits?
I hope that makes sense.
Robert
------------------------------
Date: Fri, 23 Jun 2006 21:06:07 -0700
From: Adam Smith <adamsmith@econ.com>
Subject: Script debugging
Message-Id: <YbadnfgBnbYlJAHZnZ2dnUVZ_sadnZ2d@speakeasy.net>
Hi,
Platform i386, freeBSD 4.9 O/S
I am running a perl cgi script and am getting an error message to my
http error log files
==> /usr/libexec/ld-elf.so.1:
/usr/local/lib/perl5/5.8.2/mach/CORE/libperl.so: Undefined symbol
"nl_langinfo"
grep'ing seems to localize the problem in the libperl.so library
grep -in nl_langinfo /usr/local/lib/perl5/5.8.2/mach/CORE/libperl.so
Binary file /usr/local/lib/perl5/5.8.2/mach/CORE/libperl.so matches
but I am at a bit of a loss as to how best to proceed, just need a
directional push start.
Anyone up to the task?
-- Adam --
------------------------------
Date: Sat, 24 Jun 2006 02:35:41 GMT
From: "Todd W" <trwww@sbcglobal.net>
Subject: Re: Unwanted character "^@" in perl output
Message-Id: <1y1ng.122612$dW3.41126@newssvr21.news.prodigy.com>
> Captain 3-Putt wrote:
>> My output has a bunch of unwanted "^@" characters after every valid
>> character. It looks like:
>>
>> ^@F^@i^@r^@s^@t^@^M^@
>
"Peter J. Holzer" <hjp-usenet2@hjp.at> wrote in message
news:ffkg7e.c06.ln@teal.hjp.at...
<a bunch of interesting encoding voodoo>
Hi Peter,
Where did you learn all this stuff?
I'm getting in to doing work with international content. Though I'm limping
along, I couldn't, for example, discuss it intellegently.
I'd like to find some hardcopy for the bookshelf. Those that provide detail
in relation to perl, apache, relational databases, and web browsers would be
the most useful to me. Any suggestions?
Todd W.
------------------------------
Date: Sat, 24 Jun 2006 04:10:07 +0100
From: Ben Morrow <benmorrow@tiscali.co.uk>
Subject: Re: use binary operator on ascii text string
Message-Id: <f1num3-ftm.ln1@osiris.mauzo.dyndns.org>
Quoth David Squire <David.Squire@no.spam.from.here.au>:
>
> Well, I might as well give the last (?) in the series, following Mumia's
> suggestion:
while (<DATA>) {
print $_ | (chr(64) x length);
}
:)
Ben
--
I must not fear. Fear is the mind-killer. I will face my fear and
I will let it pass through me. When the fear is gone there will be
nothing. Only I will remain.
benmorrow@tiscali.co.uk Frank Herbert, 'Dune'
------------------------------
Date: Sat, 24 Jun 2006 03:22:21 GMT
From: "John W. Krahn" <someone@example.com>
Subject: Re: use binary operator on ascii text string
Message-Id: <Nd2ng.79560$S61.66712@edtnps90>
Sean.Dewis@gmail.com wrote:
>
> I'm pretty crap at perl, so I'd appreciate so help from you guys.
>
> I have a string value held in $body variable.
>
> What I need to do is manipulate each individual character value in the
> string with OR - "|" and then replace that character with the
> character's new value.
>
> I'm using chr(ord($c) | 64) to get the new value, but I'm stuck on two
> things: -
>
> 1) How to go through the string byte by byte and perform the OR 64 on
> it
> 2) How to get the character equivalent back into the string in the
> right place
>
> For example the string is "abcdefg", by (I know it's not true)
> performing OR 64 on each char I want "fghijkl" out.
>
> Any idea's? Code examples would be appreciated.
$body =~ s/(.)/ $1 | "\x40" /seg;
John
--
use Perl;
program
fulfillment
------------------------------
Date: 6 Apr 2001 21:33:47 GMT (Last modified)
From: Perl-Users-Request@ruby.oce.orst.edu (Perl-Users-Digest Admin)
Subject: Digest Administrivia (Last modified: 6 Apr 01)
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.
NOTE: due to the current flood of worm email banging on ruby, the smtp
server on ruby has been shut off until further notice.
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.
#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 V10 Issue 9365
***************************************