[28742] in Perl-Users-Digest
Perl-Users Digest, Issue: 10106 Volume: 10
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Sun Dec 31 03:06:00 2006
Date: Sun, 31 Dec 2006 00:05:06 -0800 (PST)
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)
Perl-Users Digest Sun, 31 Dec 2006 Volume: 10 Number: 10106
Today's topics:
[Announce] ClieOp2psv <pieter@de-rijk.com>
Re: Assigning pattern matches to an array <DJStunks@gmail.com>
Re: Assigning pattern matches to an array <graham@letsgouk.com>
Re: Assigning pattern matches to an array <rvtol+news@isolution.nl>
Re: Assigning pattern matches to an array <mritty@gmail.com>
Re: Assigning pattern matches to an array <noreply@gunnar.cc>
Re: Assigning pattern matches to an array <DJStunks@gmail.com>
dynamically loading perl modules <_nospam_stigerikson@yahoo.se>
MIDI::Score: Duration < 0, Adding Events, Native NRPNs? <vtatila@mail.student.oulu.fi>
new CPAN modules on Sun Dec 31 2006 (Randal Schwartz)
Re: perl -V in 5.8.8 doesn't add architecture dependent <kevin@vaildc.net>
Problem by pushing a String and a Hash on an array! pod69@gmx.net
Re: Problem by pushing a String and a Hash on an array! <noreply@gunnar.cc>
Re: Problem by pushing a String and a Hash on an array! <mritty@gmail.com>
Re: Problem by pushing a String and a Hash on an array! <tadmc@augustmail.com>
Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: Sat, 30 Dec 2006 23:23:22 +0100
From: Pieter de Rijk <pieter@de-rijk.com>
Subject: [Announce] ClieOp2psv
Message-Id: <4596e6da$0$31089$e4fe514c@dreader28.news.xs4all.nl>
Hi All,
Clieop2psv is a tiny perl-script which converts ClieOp03-files into a
pipe-seperated-values (|) file. ClieOp files are used in the Netherlands
by telebankingsystems to load banktransactions out of an administration
application (i.e. SAP).
Website: http://www.adslweb.net/links/clieop2psv
Some nice details... it converts 279.236 lines with 69.016 transactions
within 1 minute (on a IBM Lenovo T60, with Safequard and Windows XP).
Information regarding ClieOp can be found at:
http://www.adslweb.net/links/clieopdoc
Have fun with it, if you need it!
--
Greetz,
Pieter de Rijk
+---------------------------------------------------------+
|GB/GCM/GG d++ s: a- C L UBL++++ P+++ L++ E-- W+++ N+ o+ |
|w-- M+ PS PE+ PGP++ t 5-- X++ R tv b D G e++ h! r+++ y+++|
+---------------------------------------------------------+
|GPG Public key can be found at: |
| http://www.de-rijk.com/pgp |
+---------------------------------------------------------+
|Draadloos Alblasserdam: |
| http://www.alblasserdam.org |
+---------------------------------------------------------+
------------------------------
Date: 30 Dec 2006 11:22:45 -0800
From: "DJ Stunks" <DJStunks@gmail.com>
Subject: Re: Assigning pattern matches to an array
Message-Id: <1167506565.933525.68510@a3g2000cwd.googlegroups.com>
Graham Stow wrote:
> push(@matches, $line=~/\b\w+@\w+\b/g); did it for me
> The pattern doesn't match an email address, but I can work on that...
well, for one thing, the \w metacharacter doesn't match a literal .
don't roll your own email address regexp.
perldoc Email::Address
-jp
------------------------------
Date: Sat, 30 Dec 2006 21:27:53 -0000
From: "Graham Stow" <graham@letsgouk.com>
Subject: Re: Assigning pattern matches to an array
Message-Id: <4596df70.0@entanet>
"DJ Stunks" <DJStunks@gmail.com> wrote in message
news:1167506565.933525.68510@a3g2000cwd.googlegroups.com...
> Graham Stow wrote:
>> push(@matches, $line=~/\b\w+@\w+\b/g); did it for me
>> The pattern doesn't match an email address, but I can work on that...
>
> well, for one thing, the \w metacharacter doesn't match a literal .
>
> don't roll your own email address regexp.
>
> perldoc Email::Address
>
> -jp
>
Emaill::Address doesn't grab me
Done a quick test between
use Email::Address
push(@matches, Email::Address->parse($line));
and
push(@matches, $line=~/\b[.-\w]*@[-\w]*\.+[-\w]*\.*[-\w]*\b/g);
The latter pulled up a number of correct email address, while the former
pulled these up plus other stuff that weren't true email addresses
Graham
------------------------------
Date: Sat, 30 Dec 2006 23:11:58 +0100
From: "Dr.Ruud" <rvtol+news@isolution.nl>
Subject: Re: Assigning pattern matches to an array
Message-Id: <en6rrp.144.1@news.isolution.nl>
Graham Stow schreef:
> /\b\w+@\w+\b/g;
The \b's are superfluous there.
--
Affijn, Ruud
"Gewoon is een tijger."
------------------------------
Date: 30 Dec 2006 14:25:00 -0800
From: "Paul Lalli" <mritty@gmail.com>
Subject: Re: Assigning pattern matches to an array
Message-Id: <1167517500.086158.66520@h40g2000cwb.googlegroups.com>
Graham Stow wrote:
> Emaill::Address doesn't grab me
> Done a quick test between
> use Email::Address
> push(@matches, Email::Address->parse($line));
> and
> push(@matches, $line=~/\b[.-\w]*@[-\w]*\.+[-\w]*\.*[-\w]*\b/g);
> The latter pulled up a number of correct email address, while the former
> pulled these up plus other stuff that weren't true email addresses
Says you. I trust Email::Address's belief of what a "true" email
address is a hell of a lot better than yours. Just because they don't
look like what you might consider "normal" addresses doesn't mean they
aren't valid. Email::Address follows the RFC. Your handrolled
solution does not.
Paul Lalli
------------------------------
Date: Sun, 31 Dec 2006 00:05:53 +0100
From: Gunnar Hjalmarsson <noreply@gunnar.cc>
Subject: Re: Assigning pattern matches to an array
Message-Id: <4vo9ngF1d0kv9U1@mid.individual.net>
Paul Lalli wrote:
> Graham Stow wrote:
>>Done a quick test between
>> use Email::Address
>> push(@matches, Email::Address->parse($line));
>>and
>> push(@matches, $line=~/\b[.-\w]*@[-\w]*\.+[-\w]*\.*[-\w]*\b/g);
>>The latter pulled up a number of correct email address, while the former
>>pulled these up plus other stuff that weren't true email addresses
Could you post some example data showing that?
> Says you. I trust Email::Address's belief of what a "true" email
> address is a hell of a lot better than yours. Just because they don't
> look like what you might consider "normal" addresses doesn't mean they
> aren't valid. Email::Address follows the RFC. Your handrolled
> solution does not.
I suspect that a library that accepts _all_ RFC 822 compliant addresses
isn't an adequate tool for parsing out substrings from any document that
are likely email addresses.
--
Gunnar Hjalmarsson
Email: http://www.gunnar.cc/cgi-bin/contact.pl
------------------------------
Date: 30 Dec 2006 15:29:00 -0800
From: "DJ Stunks" <DJStunks@gmail.com>
Subject: Re: Assigning pattern matches to an array
Message-Id: <1167521340.903496.86600@v33g2000cwv.googlegroups.com>
Graham Stow wrote:
> "DJ Stunks" <DJStunks@gmail.com> wrote in message
> news:1167506565.933525.68510@a3g2000cwd.googlegroups.com...
> > Graham Stow wrote:
> >> push(@matches, $line=~/\b\w+@\w+\b/g); did it for me
> >> The pattern doesn't match an email address, but I can work on that...
> >
> > well, for one thing, the \w metacharacter doesn't match a literal .
> >
> > don't roll your own email address regexp.
> >
> > perldoc Email::Address
>
> Emaill::Address doesn't grab me
> Done a quick test between
> use Email::Address
> push(@matches, Email::Address->parse($line));
> and
> push(@matches, $line=~/\b[.-\w]*@[-\w]*\.+[-\w]*\.*[-\w]*\b/g);
> The latter pulled up a number of correct email address, while the former
> pulled these up plus other stuff that weren't true email addresses
try (untested):
push @matches, map { $_->address } Email::Address->parse($line);
-jp
------------------------------
Date: Sat, 30 Dec 2006 20:55:42 +0100
From: stig <_nospam_stigerikson@yahoo.se>
Subject: dynamically loading perl modules
Message-Id: <en6gcs$1ar$1@oden.abc.se>
Hi.
We are starting to build a small web portal in perl.
Already at this stage we see the need to be able to plug-in certain functionality.
strategy 1
We have thought about a solution where we can put modules in a special directory.
When the portal looks in that directory and find new modules it reads some information in via an API
that each of the modules contains (eg: getName(), getVersion() ) and presents the modules on the web portal.
strategy 2
We have also though about a solution where we enable and disable modules based on information
stored separately (in a database). This would be less dynamic but perhaps better for other reasons?
The questions i have are:
1. Is the first strategy good at all, or should we aim for the second?
2. How can we dynamically load a module?
3. Are there ways to ask a module which functions/methods it provides?
4. Should i stop developing this in perl, and look for something else?
thanks
stig
------------------------------
Date: Sat, 30 Dec 2006 22:41:31 +0200
From: "Veli-Pekka Tätilä" <vtatila@mail.student.oulu.fi>
Subject: MIDI::Score: Duration < 0, Adding Events, Native NRPNs?
Message-Id: <en6itu$4tj$1@news.oulu.fi>
Hi,
In some MIDI files I receive negative note durations from MIDI::Score. I'm
pretty certain it is some bug in my own code. Here's a minimal version:
test.plx:
#!perl
# This is perl, v5.8.8 built for MSWin32-x86-multi-thread.
use strict; use warnings;
use MIDI; # V0.81.
(my($inFile, $outFile) = @ARGV) == 2 or die "2 files please.\n";
my $opus = MIDI::Opus->new( { from_file => $inFile } );
my $ticks = $opus->ticks();
my $tracks = $opus->tracks_r();
my $newTracks; # For output.
for(@$tracks)
{ # Copy each one.
# Convert only events.
if($_->type() ne 'MTrk')
{ # Not events, but data in stead.
push @$newTracks, $_->copy();
next;
} # if
my $events = $_->events_r();
my $score = MIDI::Score::events_r_to_score_r($events);
# MIDI::Score says the format is:
# ['note', starttime, duration, channel, note, velocity]
my @bad = grep { $_->[0] eq 'note' and $_->[2] < 0 } @$score;
if(@bad)
{ # No such thing as negative duration? At least in seqs.
warn "Bad: [ @$_ ]\n" for @bad;
# This reveals both note and note_on events.
# print $_->dump;
# die "Stopped.\n";
} # if
# Turn score back to events and tracks.
my $newEvents = MIDI::Score::score_r_to_events_r($score);
push @$newTracks, MIDI::Track->new( {events_r => $newEvents} );
} # for
# Now we can write out the file safely.
my $newOpus = MIDI::Opus->new;
$newOpus->tracks_r($newTracks);
$newOpus->ticks($ticks); # Many seqs support > 96 PPQ.
$newOpus->write_to_file($outFile);
print "Done.\n";
The check for negative note lengths appears to catch some note events in
quite a number of MIDI files. Here's one nice piano boogie called sockhop
which does this:
http://netdancer.com/midis/Sockhop.mid
Say we run:
test.plx sockhop.mid test.mid
The output would be:
Bad: [ note 15344 -15344 2 64 88 ]
Bad: [ note 15351 -15351 2 67 82 ]
Bad: [ note 71520 -71520 9 39 102 ]
Bad: [ note 71760 -71760 9 39 85 ]
Bad: [ note 73429 -73429 9 39 108 ]
Bad: [ note 73674 -73674 9 39 108 ]
Bad: [ note 74400 -74400 9 39 102 ]
Bad: [ note 115680 -115680 9 38 102 ]
Bad: [ note 115920 -115920 9 38 85 ]
Bad: [ note 116640 -116640 9 38 102 ]
Bad: [ note 167907 -167907 9 38 99 ]
Bad: [ note 15344 -15344 12 64 103 ]
Bad: [ note 15351 -15351 12 67 96 ]
Bad: [ note 71520 -71520 15 39 120 ]
Bad: [ note 71760 -71760 15 39 100 ]
Bad: [ note 73429 -73429 15 39 127 ]
Bad: [ note 73674 -73674 15 39 127 ]
Bad: [ note 74400 -74400 15 39 120 ]
Bad: [ note 115680 -115680 15 38 120 ]
Bad: [ note 115920 -115920 15 38 100 ]
Bad: [ note 116640 -116640 15 38 120 ]
Bad: [ note 167907 -167907 15 38 117 ]
Done.
Oddly enough the Note duration and its start ttime are exactly the same
absolute tick counts, according to this dump, though they have a different
sign. Obviously this shouldn't happen and at any rate no MIDI sequencer I've
ever used shows the lengths in the event list as being negative. Despite
this a proper copy of the MIDI is written hinting at some problem in my
usage of the SCore and Event structures.
By the way, another MIDI file with this negative length problem is the one
coming with Windows i.e. %windir%\media\town.mid
But to make things more interesting many MIDI files are converted quite all
right. Take Axel F for example at the same MIDI site
http://netdancer.com/midis/Axelf.mid
Uncommenting the dump line and dumping the head of the output would produce
(for sockhop.mid):
Bad: [ note 15344 -15344 2 64 88 ]
Bad: [ note 15351 -15351 2 67 82 ]
MIDI::Track->new({
'type' => 'MTrk',
'events' => [ # 2879 events.
['raw_meta_event', 0, 33, "\x00"],
['track_name', 0, 'Piano Right Hand'],
['patch_change', 0, 2, 0],
['control_change', 0, 2, 7, 108],
['control_change', 0, 2, 10, 64],
['control_change', 0, 2, 91, 65],
['control_change', 0, 2, 93, 0],
['pitch_wheel_change', 0, 2, 0],
['control_change', 0, 2, 64, 0],
['note', 1173, 122, 2, 74, 108],
['note', 1210, 82, 2, 75, 108],
['note', 1288, 150, 2, 76, 108],
['note_on', 1292, 2, 75, 0],
['note_on', 1295, 2, 74, 0],
['note_on', 1438, 2, 76, 0],
['note', 1475, 146, 2, 79, 108],
['note_on', 1621, 2, 79, 0],
['note', 1700, 136, 2, 81, 108],
...
Is the output supposed to contain both the note_on events in the event
structure an the abstracted note events with duration?
I wonder what might cause the negative length to show up. I'm suspecting
some obvious error in my own code very first but if that's not the case,
some other possibilities do come to mind.
1. Many sequencers support HiFi resolutions far exceeding 96 pulses per
quarter note (PPQ). Sonar can do 960, for example, even if many hardware is
96 or 120. I've noticed that MIDI::Simple assumes 96 PPQ and thus Windows's
default 192 PPQ MIDs play all too slowly after conversion. Unless you add
the PPQ yourself as I did in the above example with MIDI::Score.
2. Imagine a hypothetical scenario. That is hold down a note while you start
recording and then release it. IF the sequencer is silly, and doesn't
monitor active sensing, see:
http://www.borg.com/~jglatt/tech/midispec/sense.htm
then it might just record a note off event without a corresponding note on
at all. A smarter sequencer might wait for you to release notes before
beginning to record or insert the missing note on automatically. If
MIDI::Score has been written under the assumption of strict note on/off
pairs with note on always first, such mishaps, though arguably bugs in the
MIDI performance, might affect matters.
3. Many synthesizers, Rolands in particular, have adopted a special
convention for note off events. In stead of actually transmitting as many
bytes as they'd have for a normal note off, they can use note on messages
with velocity 0 and running status to compress data. See:
http://www.borg.com/~jglatt/tech/midispec/run.htm
and
http://www.borg.com/~jglatt/tech/midispec/noteon.htm
In addition to saving bytes, very few keyboards actually send out varying
release velocity values anyway, so the note on method doesn't lose
information. For MIDI::Score is a note on with velo 0 equivalent to a note
off? I've tried reading the source and while I can understand bits and
pieces, I don't seem to get the gist of the processing.
By the way, I've also got a related question on adding new MIDI data on
event structures that have been converted to scores. Do I need to add
note_on events as well? Here I'm refering to the above score structure that
had both note and note_off events. I thought I could simply, when modifying
MIDI data, push 'note' events understood by MIDI::Score (including time and
duration) at the very end of the score structure and then sort the whole
thing by time using sort_score_r. After that, I would finally convert the
whole thing back to events and tracks. I'd imagine the same thing works for
controellers, sysex or whatever. Sometimes, in another script of mine,
adding notes as described above works fine and at other times not. The issue
is problably something different, but thought I'd ask about the canonical
way of adding data to a MIDI::Score. I'm interested in controllers, sysex
and channel after touch as all of my synths send those. Another abstraction,
which would be nice to get into MIDI::Score, would be virtual RPN and NRPN
events as in Sonar. Normally they are composed of several controllers.
Chehck out:
http://www.borg.com/~jglatt/tech/midispec/dslider.htm
http://www.borg.com/~jglatt/tech/midispec/nrpn.htm
http://www.borg.com/~jglatt/tech/midispec/rpn.htm
PS: My favorite MIDI site of all time, which also includes both MIDI and
MIDI file specs, is this Jeff Glatt's MIDI programming page:
http://www.borg.com/~jglatt/tech/miditech.htm
Much better and easier to understand than just the MIDI BNF quoted in the
manual pages.
Most of the links I've put here are from the above site.
--
With kind regards Veli-Pekka Tätilä (vtatila@mail.student.oulu.fi)
Accessibility, game music, synthesizers and programming:
http://www.student.oulu.fi/~vtatila/
------------------------------
Date: Sun, 31 Dec 2006 05:42:12 GMT
From: merlyn@stonehenge.com (Randal Schwartz)
Subject: new CPAN modules on Sun Dec 31 2006
Message-Id: <JB4IIC.24Ln@zorch.sf-bay.org>
The following modules have recently been added to or updated in the
Comprehensive Perl Archive Network (CPAN). You can install them using the
instructions in the 'perlmodinstall' page included with your Perl
distribution.
Apache-SWIT-0.18
http://search.cpan.org/~bosu/Apache-SWIT-0.18/
mod_perl based application server with integrated testing.
----
Cairo-1.022
http://search.cpan.org/~tsch/Cairo-1.022/
Perl interface to the cairo library
----
Compass-Bearing-0.01
http://search.cpan.org/~mrdvt/Compass-Bearing-0.01/
Convert angle to text bearing (aka Heading)
----
Gnome2-1.041
http://search.cpan.org/~tsch/Gnome2-1.041/
Perl interface to the 2.x series of the GNOME libraries
----
Gnome2-Rsvg-0.10
http://search.cpan.org/~tsch/Gnome2-Rsvg-0.10/
Perl interface to the RSVG library
----
HTML-Tested-0.21
http://search.cpan.org/~bosu/HTML-Tested-0.21/
Provides HTML widgets with the built-in means of testing.
----
HTML-Tested-ClassDBI-0.08
http://search.cpan.org/~bosu/HTML-Tested-ClassDBI-0.08/
Enhances HTML::Tested to work with Class::DBI
----
LaTeX-Pod-0.05
http://search.cpan.org/~schubiger/LaTeX-Pod-0.05/
Transform LaTeX source files to POD (Plain old documentation)
----
LaTeX-TOM-0.5
http://search.cpan.org/~schubiger/LaTeX-TOM-0.5/
A module for parsing, analyzing, and manipulating LaTeX documents.
----
Math-Symbolic-Custom-Pattern-1.21
http://search.cpan.org/~smueller/Math-Symbolic-Custom-Pattern-1.21/
Pattern matching on Math::Symbolic trees
----
Net-TiVo-0.05
http://search.cpan.org/~boumenot/Net-TiVo-0.05/
Perl interface to TiVo.
----
POE-Component-Win32-ChangeNotify-1.04
http://search.cpan.org/~bingos/POE-Component-Win32-ChangeNotify-1.04/
A POE wrapper around Win32::ChangeNotify.
----
POE-Component-Win32-EventLog-1.08
http://search.cpan.org/~bingos/POE-Component-Win32-EventLog-1.08/
A POE component that provides non-blocking access to Win32::EventLog.
----
RPC-Xmlrpc_c-1.01
http://search.cpan.org/~giraffed/RPC-Xmlrpc_c-1.01/
----
Set-IntSpan-Fast-v0.0.3
http://search.cpan.org/~andya/Set-IntSpan-Fast-v0.0.3/
Fast handling of sets containing integer spans.
----
Sort-Rank-v0.0.1
http://search.cpan.org/~andya/Sort-Rank-v0.0.1/
Sort arrays by some score and organise into ranks.
----
Sys-Statistics-Linux-0.05
http://search.cpan.org/~bloonix/Sys-Statistics-Linux-0.05/
Collect linux system statistics.
If you're an author of one of these modules, please submit a detailed
announcement to comp.lang.perl.announce, and we'll pass it along.
This message was generated by a Perl program described in my Linux
Magazine column, which can be found on-line (along with more than
200 other freely available past column articles) at
http://www.stonehenge.com/merlyn/LinuxMag/col82.html
print "Just another Perl hacker," # the original
--
Randal L. Schwartz - Stonehenge Consulting Services, Inc. - +1 503 777 0095
<merlyn@stonehenge.com> <URL:http://www.stonehenge.com/merlyn/>
Perl/Unix/security consulting, Technical writing, Comedy, etc. etc.
See PerlTraining.Stonehenge.com for onsite and open-enrollment Perl training!
------------------------------
Date: Sat, 30 Dec 2006 22:31:07 GMT
From: Kevin Michael Vail <kevin@vaildc.net>
Subject: Re: perl -V in 5.8.8 doesn't add architecture dependent directories?
Message-Id: <kevin-E5C6AE.17310730122006@news.verizon.net>
In article <1167493642.421345.59350@73g2000cwn.googlegroups.com>,
"Robert Nicholson" <robert.nicholson@gmail.com> wrote:
> I've got two systems and one with 5.8.0 and another with 5.8.8
>
> in 5.8.0 perl -V includes architecture dependent directories added to
> site_perl where as 5.8.8 doesn't
>
> did this behaviour change in after 5.8.0?
>
> so on 5.8.8 I have to explicitly add the arch directories in PERL5LIB
> where as in 5.8.0 I don't.
The only time I ever saw anything like this behavior was when I
installed ActiveState 5.8.8 on a Windows system that already had
ActiveState 5.6.1 installed, and had a PERL5LIB environment variable
already set. I eventually discovered that if I made sure that variable
was NOT set when installing Perl, everything worked fine and I got the
site libs in perl -V.
It's hard to tell if this has anything to do with your problem, but it
might give you a direction to look in.
--
Kevin Michael Vail | "This is so cool I have to go to the bathroom!"
kevin@vaildc.net | -- Calvin
------------------------------
Date: 30 Dec 2006 13:46:47 -0800
From: pod69@gmx.net
Subject: Problem by pushing a String and a Hash on an array!
Message-Id: <1167515207.799321.207910@73g2000cwn.googlegroups.com>
Hello,
I try to push on an array(global) a string and a hash ->
push(@array,{name => $n_name, hash => \%myhash});
now i try to read out everything but i have a problems with the array?
I try this to read everything out:
sub println {
for(my $i = 0; $i < scalar(@array) ; $i++ ){
print $array[$i]{name};
my %hash = $array[$i]{hash};
foreach $key ( keys %hash){
print $key." = ".$hash{$key}."\n"
}
}
}
the name gets printed out but not the hash?
thx
------------------------------
Date: Sat, 30 Dec 2006 23:19:03 +0100
From: Gunnar Hjalmarsson <noreply@gunnar.cc>
Subject: Re: Problem by pushing a String and a Hash on an array!
Message-Id: <4vo6vgF1cuvvgU1@mid.individual.net>
pod69@gmx.net wrote:
> I try to push on an array(global) a string and a hash ->
> push(@array,{name => $n_name, hash => \%myhash});
Do you realize that @array only contains one element, i.e. a hash reference?
> now i try to read out everything but i have a problems with the array?
> I try this to read everything out:
>
> sub println {
> for(my $i = 0; $i < scalar(@array) ; $i++ ){
> print $array[$i]{name};
> my %hash = $array[$i]{hash};
> foreach $key ( keys %hash){
> print $key." = ".$hash{$key}."\n"
> }
> }
> }
>
> the name gets printed out but not the hash?
If that's all you have to tell us, you run the code without strictures
and warnings enabled. Please follow the posting guidelines
http://www.augustmail.com/~tadmc/clpmisc/clpmisc_guidelines.html
by adding
use strict;
use warnings;
to the top of your script, and let Perl tell you what's wrong with your
code.
--
Gunnar Hjalmarsson
Email: http://www.gunnar.cc/cgi-bin/contact.pl
------------------------------
Date: 30 Dec 2006 14:21:01 -0800
From: "Paul Lalli" <mritty@gmail.com>
Subject: Re: Problem by pushing a String and a Hash on an array!
Message-Id: <1167517261.231047.126460@k21g2000cwa.googlegroups.com>
pod69@gmx.net wrote:
> I try to push on an array(global) a string and a hash ->
> push(@array,{name => $n_name, hash => \%myhash});
\%myhash is not a hash. It is a reference to a hash. The distinction
is important.
> now i try to read out everything but i have a problems with the array?
> I try this to read everything out:
>
> sub println {
> for(my $i = 0; $i < scalar(@array) ; $i++ ){
> print $array[$i]{name};
> my %hash = $array[$i]{hash};
$array[$i]{hash} is a reference to a hash. You are attempting to
create a new hash with this one single scalar value. If you had
enabled warnings, Perl would have told you you were doing something
wrong here. Please ask Perl for help before asking thousands of people
around the world.
You need to dereference the reference. Change this line to:
my %hash = %{$array[$i]{hash}};
or
my $hash_ref = $array[$i]{hash};
> foreach $key ( keys %hash){
> print $key." = ".$hash{$key}."\n"
If you go with the second option above, change these two lines to:
foreach my $key (keys %{$hash_ref}) {
print $key . " = " . $hash_ref->{$key} . "\n";
> }
> }
> }
>
> the name gets printed out but not the hash?
Please enable warnings, and please read up on references and
multi-dimensional structures.
perldoc perlreftut
perldoc perllol
perldoc perldsc
Paul Lalli
------------------------------
Date: Sat, 30 Dec 2006 17:39:04 -0600
From: Tad McClellan <tadmc@augustmail.com>
Subject: Re: Problem by pushing a String and a Hash on an array!
Message-Id: <slrnepdu4o.qft.tadmc@tadmc30.august.net>
pod69@gmx.net <pod69@gmx.net> wrote:
> push(@array,{name => $n_name, hash => \%myhash});
> my %hash = $array[$i]{hash};
You should always enable warnings when developing Perl code.
And by now you have used up all of your coupons.
So long!
--
Tad McClellan SGML consulting
tadmc@augustmail.com Perl programming
Fort Worth, Texas
------------------------------
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 10106
****************************************