[22011] in Perl-Users-Digest
Perl-Users Digest, Issue: 4233 Volume: 10
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Sun Dec 8 18:05:53 2002
Date: Sun, 8 Dec 2002 15:05:08 -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, 8 Dec 2002 Volume: 10 Number: 4233
Today's topics:
Re: Future of Perl as an application server language? <pkent77tea@yahoo.com.tea>
Help with "Chomp" Command <cwg@attbi.com>
Re: Help with "Chomp" Command (Ben Morrow)
Re: Help with "Chomp" Command <brad.galiette@snet.net>
Re: Help with "Chomp" Command <tassilo.parseval@post.rwth-aachen.de>
Re: Help with "Chomp" Command <dave@dave.org.uk>
Re: Help with "Chomp" Command <cwg@attbi.com>
HoH problems (Ben Morrow)
Re: How to substitute ' by \' <stremitz@consultant.com>
Re: How to substitute ' by \' <jurgenex@hotmail.com>
Re: How to substitute ' by \' (Tad McClellan)
Re: Multi-dimensional hash question <stremitz@consultant.com>
Re: Multi-dimensional hash question (Ben Morrow)
Re: Newbie help please !! <jurgenex@hotmail.com>
nother <bart.lateur@pandora.be>
Re: search reorder replace <nospamjynyl@yahoo.co.nz>
Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: Sun, 08 Dec 2002 21:51:01 GMT
From: pkent <pkent77tea@yahoo.com.tea>
Subject: Re: Future of Perl as an application server language?
Message-Id: <pkent77tea-B6BC4B.21504908122002@news-text.blueyonder.co.uk>
In article <3226c4d3.0212070655.5dd3bf39@posting.google.com>,
simonf@simonf.com (Simon) wrote:
> toddrw69@excite.com (trwww) wrote in message
> news:<d81ecffa.0212051316.59406e54@posting.google.com>...
> > Perl and shrink wrap dont mix ;0)
> But they should, at least to a reasonable degree, if Perl is to ever
> make the next step into the mainstream!
I'll again come into this thread and say (in my experience, etc etc)
perl can be well-suited to what i think you mean by shrink-wrapped
products. Problem is that it's easy to make a program that _won't_ ship
because:
you assume the location of the perl interpreter
you assume the location of some external binary
you assume something about the arguments accepted by such a program
you assume that the directory separator is '/' and that paths won't
contain spaces
etc etc
but that's a problem with programmers taking the easy way: like using
split '/' rather than File::Spec->splitpath()
At my shop we're getting into a release candidate phase for an ambitious
content production system front end which has document revision
management, document repository management, document (which is XML)
syntax coloured editor, previewing and lots of other features built in.
That's written entirely in perl and uses wxPerl which gives the
application the appearance and behaviour of a totally standard Win32
program. [ It runs on the Windows PC desktop machines ]
Now, I don't know what kind of hoops the authors had to jump through but
you type 'install_foo.pl' and it gets installed on your machine, even
with a nice shortcut on the desktop. It barely gets more shrink wrapped
than that.
OK, the final step would be to use one of those 'InstallShield' wizards,
so that the system would show up in 'Add/Remove Programs' control panel
like most other Windows software does, but apart from that it's just as
simple as any "Insert the CD and type E:\setup.exe". The program does
assume that you already have ActivePerl installed, but an installer
batch script can easily check such things.
Quite different from that GUI application are the swathes of CGI
programs, command line programs and modules we create - almost all of
which are happy to run when plonked onto any one of many assorted
Solaris, Windows or MacOS machines running various versions of perl etc.
Still, they do contain occasional assumptions like:
use constant CACHE_DIR => '/var/tmp/foocache/';
and that kind of thing, but they're simple to fix and no doubt we will
get round to it real soon :-)
P
--
pkent 77 at yahoo dot, er... what's the last bit, oh yes, com
Remove the tea to reply
------------------------------
Date: Sun, 08 Dec 2002 20:12:08 GMT
From: "Levidikus Alatyam" <cwg@attbi.com>
Subject: Help with "Chomp" Command
Message-Id: <sINI9.285960$1O2.20665@sccrnsc04>
I have been trying to understand the "chomp" and "chop" commands. Does
anyone have a good working example? I know what they do but I cant seem to
get them work. I was able to make a work around that works great for me,
but I would like to have at least a working understanding of these two
commands. I have a few books, but they are way to basic. If some could
suggest a good site or book that has a good working example that would be
great.
Lev.
------------------------------
Date: Sun, 8 Dec 2002 20:44:32 +0000 (UTC)
From: mauzo@mimosa.csv.warwick.ac.uk (Ben Morrow)
Subject: Re: Help with "Chomp" Command
Message-Id: <at0avg$2m5$1@wisteria.csv.warwick.ac.uk>
"Levidikus Alatyam" <cwg@attbi.com> wrote:
>I have been trying to understand the "chomp" and "chop" commands. Does
>anyone have a good working example? I know what they do but I cant seem to
>get them work. I was able to make a work around that works great for me,
>but I would like to have at least a working understanding of these two
>commands. I have a few books, but they are way to basic. If some could
>suggest a good site or book that has a good working example that would be
>great.
chop removes the last character of an lvalue.
~% perl -le'$a = "aaa"; chop $a; print $a'
aa
chomp checks if the end of a string is the same as $/, and if it is it removes
it.
~% perl -l mauzo@mauzo
$/ = "c";
$a = "aaa";
$b = "abc";
chomp $a;
chomp $b;
print $a;
print $b;
^D
aaa
ab
In general, to remove newlines from a string read with <> use chomp, as it
removes whatever is currently considered end-of-line.
Note also that both these functions, like s///, take a _variable_ as an
argument and modify it _in_place_. This is important.
Ben
------------------------------
Date: Sun, 08 Dec 2002 20:45:39 GMT
From: "Brad W. Galiette" <brad.galiette@snet.net>
Subject: Re: Help with "Chomp" Command
Message-Id: <TbOI9.3099$BQ6.791951411@newssvr10.news.prodigy.com>
Consider the following examples:
---------------------------------------------------------------
my $foo = "My text\n";
my $foo2 = "My text";
chop($foo); #$foo now equals "My text"; note that the newline character
#has been removed
chop($foo2); #$foo2 now equals "My tex"; because the character "t" was the
#last character appearing in the string, it was removed
---------------------------------------------------------------
my $foo = "My text\n";
my $foo2 = "My text";
chomp($foo); #same as chop($foo)
chomp($foo2); #$foo2 now equals "My text"; chomp only removes trailing
new-line
#characters and other whitespace (\s)
---------------------------------------------------------------
If you wish to capture the character that was chop/chomped, do something
such as:
my $foo = "My text\n";
my $chop_char = chop($foo); #sets $chop_char equal to a new-line character
or
my $foo2 = "My text";
print chomp($foo2); #prints nothing, as no character was removed from $foo2
A good source of reference for the chop() and chomp() functions are
available at http://www.perldoc.com/perl5.6.1/pod/func/chop.html and
http://www.perldoc.com/perl5.6.1/pod/func/chomp.html respectively;
www.perldoc.com is also useful for review of all, non-modular aspects of
Perl. (Note that module downloads and reference information is available at
CPAN [search.cpan.org])
Brad
"Levidikus Alatyam" <cwg@attbi.com> wrote in message
news:sINI9.285960$1O2.20665@sccrnsc04...
> I have been trying to understand the "chomp" and "chop" commands. Does
> anyone have a good working example? I know what they do but I cant seem
to
> get them work. I was able to make a work around that works great for me,
> but I would like to have at least a working understanding of these two
> commands. I have a few books, but they are way to basic. If some could
> suggest a good site or book that has a good working example that would be
> great.
>
> Lev.
>
>
------------------------------
Date: 8 Dec 2002 21:12:40 GMT
From: "Tassilo v. Parseval" <tassilo.parseval@post.rwth-aachen.de>
Subject: Re: Help with "Chomp" Command
Message-Id: <at0ck8$ie8$1@nets3.rz.RWTH-Aachen.DE>
[ Please do not top-post ]
Also sprach Brad W. Galiette:
> If you wish to capture the character that was chop/chomped, do something
> such as:
>
> my $foo = "My text\n";
> my $chop_char = chop($foo); #sets $chop_char equal to a new-line character
>
> or
>
> my $foo2 = "My text";
> print chomp($foo2); #prints nothing, as no character was removed from $foo2
This only applies to chop(). chomp() on the other hand returns the
number of characters chopped off. It's not much use to see what this
character was since it must be equal to $/ (except for a few exceptions
like $/ = "" and others that are documented).
Tassilo
--
$_=q!",}])(tsuJ[{@"tnirp}3..0}_$;//::niam/s~=)]3[))_$-3(rellac(=_$({
pam{rekcahbus;})(rekcah{lrePbus;})(lreP{rehtonabus;})(rehtona{tsuJbus!;
$_=reverse;s/sub/(reverse"bus").chr(32)/xge;tr~\n~~d;eval;
------------------------------
Date: Sun, 08 Dec 2002 21:20:35 +0000
From: "Dave Cross" <dave@dave.org.uk>
Subject: Re: Help with "Chomp" Command
Message-Id: <pan.2002.12.08.21.20.19.486961@dave.org.uk>
On Sun, 08 Dec 2002 20:45:39 +0000, Brad W. Galiette wrote:
> chomp($foo2); #$foo2 now equals "My text"; chomp only removes trailing new-line
> #characters and other whitespace (\s)
Not exactly. Did you try reading the documentation.
chomp This safer version of "chop" removes any trailing string that
corresponds to the current value of $/
That really doesn't mean the same thing as "trailing new-line characters
and other whitespace". Reading the docs on $/ gives us:
$/ The input record separator, newline by default. This influences
Perl's idea of what a "line" is.
Hope that makes it clearer.
Dave...
--
It was long ago and it was far away
And it was so much better that it is today
------------------------------
Date: Sun, 08 Dec 2002 21:29:52 GMT
From: "Levidikus Alatyam" <cwg@attbi.com>
Subject: Re: Help with "Chomp" Command
Message-Id: <kROI9.279388$NH2.19473@sccrnsc01>
Thankyou very much that is exactly what I needed.
Lev.
------------------------------
Date: Sun, 8 Dec 2002 16:13:06 +0000 (UTC)
From: mauzo@ux-019-11.csv.warwick.ac.uk (Ben Morrow)
Subject: HoH problems
Message-Id: <asvr2i$qng$1@wisteria.csv.warwick.ac.uk>
mod3@hotmail.com (LazyPerfectionist) wrote:
>
>Im trying to do a look up table...eg
>
>data set in file
> #SUBJECT NAME MARK
> FRENCH JANE 83
> ...etc
>
>I want the %data to contain
> SUBJECT = FRENCH
> NAME = JANE
> MARK = 83
> etc...
>
>So when I read it from a file I use the header as a look up table
> SUBJECT = ^(FRENCH|ENGLISH|MATHS)
> NAME = \b[A-Z]+\b
> etc..
>
>the data key1 contains the line no
> %data{$lineno}
$data{$lineno}
>
>the data key2 contains the headings
> $data{$lineno}{SUBJECT} = $values[0]
>
>So I thought later I could do something like this
> for $lineno (keys %data)
> for(0..#header)
$#header, or better for(@header).
But I don't think this is what you mean anyway...
> if( $data{$lineno}{$_} !~ /values header{$_}/)
This won't work :)
> print (not valid)
>
> or better
>
> for $lineno (keys %data)
> if($data{$lineno}{keys %{$i}} !~ /values %{$i}/)
Nor will this. :)
> print (experimental idea)
>
>in the first case I would have to take the %data along with the header
>but in the second case the %data has all I need...
>
>What Im trying to achieve is a way to reduce the use of loops by
>letting the hash do everything...
Ah, I see now. I think what you want is closer to this: [all untested]
>data set in file (just for reference)
> #SUBJECT NAME MARK
> FRENCH JANE 83
> ...etc
>
my @data; # a hash keyed by numbers only should usually be an array
my @subjects = qw/FRENCH ENGLISH MATHS/;
my $subjects;
{
local $" = "|";
$subjects = qr/@subjects/;
}
# you could just have my $subjects = qr/FRENCH | ENGLISH | MATHS/x;, but I
# think this is nicer (you can get the list of subjects from elsewhere...)
while(<INPUT>) {
next if /^#/; # skip comments
/^ ($subjects) \s+ (.*?) \s+ (\d+) $/x or print "line $. is invalid", next;
# we check for invalid lines here
# you may need to adjust this re to suit the exact format of the data
# /x is your friend
push @data, { subject => $1, # I have an aversion to CAPS :)
name => $2,
mark => $3
};
}
This has the slight problem that you lose line number information: the array
only contains valid lines. This can be solved by using
my $line;
while {<INPUT>) {
$line = undef;
next if /^#/;
/^ ($subjects) \s+ (.*?) \s+ (\d+) $/x or print "line $. is invalid", next;
$line = { subject => $1,
name => $2,
mark => $3
};
}
continue {
push @data, $line;
}
which will create undef entries for comments and lines which were invalid.
I think before you go much further you need to read perldoc perllol quite
carefully :)
>p.s. thanks for your patience ben...
No problem :)
Ben
------------------------------
Date: Sun, 08 Dec 2002 12:08:44 -0500
From: Alexander Stremitzer <stremitz@consultant.com>
Subject: Re: How to substitute ' by \'
Message-Id: <3DF37C9C.6070600@consultant.com>
Try this:
$text =~ s/'/\\'/g;
Francesco Moi wrote:
>Hello.
>
>I'm trying to substitute the character ' by \' into a string:
>
>if ($text =~ /\'/) {
> $text =~ s/\./\\\./g;
>}
>
>But it does not work for me.
>
>Any suggestion? Thank you very much.
>
>
--
All man's miseries derive from not being able to sit quietly in a room alone. (Pascal)
------------------------------
Date: Sun, 08 Dec 2002 17:10:01 GMT
From: "Jürgen Exner" <jurgenex@hotmail.com>
Subject: Re: How to substitute ' by \'
Message-Id: <J1LI9.3057$_W1.1419@nwrddc03.gnilink.net>
Francesco Moi wrote:
> Hello.
>
> I'm trying to substitute the character ' by \' into a string:
>
> if ($text =~ /\'/) {
> $text =~ s/\./\\\./g;
Let's see. You got a dot, which normally would match any character in a RE.
However you escaped it with a backslash. That means it will match a literal
dot now.
Why are you trying to match a literal dot when you want to substitute a
single quote character?
Just write what you want to do:
$text =~ s/'/\\'/g;
Notes:
- the single quote has not special meaning in a RE, therefore the is not
need to escape it.
- the backslash in the replacement string otoh is magic, therefore you need
to escape it.
- if you have several quotes to replace in a single string then you should
add the g modifier.
------------------------------
Date: Sun, 8 Dec 2002 11:25:23 -0600
From: tadmc@augustmail.com (Tad McClellan)
Subject: Re: How to substitute ' by \'
Message-Id: <slrnav7043.9jk.tadmc@magna.augustmail.com>
Julian Mehnle <julian@mehnle.net> wrote:
> Francesco Moi <francescomoi@europe.com> wrote:
>> I'm trying to substitute the character ' by \' into a string:
> $text =~ s/\'/\\\'/g;
^ ^
^ ^
> $text =~ s/([\'\"])/\\$1/g;
^ ^
^ ^
Backslashes make your code hard to read and understand, so you
should only backslash when you _must_ backslash.
None of the underlined backslashes above are needed.
--
Tad McClellan SGML consulting
tadmc@augustmail.com Perl programming
Fort Worth, Texas
------------------------------
Date: Sun, 08 Dec 2002 14:18:21 -0500
From: Alexander Stremitzer <stremitz@consultant.com>
Subject: Re: Multi-dimensional hash question
Message-Id: <3DF39AFD.3040000@consultant.com>
Your comments have been extremely helpful. I was reading perlref and
perldoc. However, all the information is a little much to comprehend at
once. I was experimenting with what I have learned . Especially the
information that values of hashes can only contain scalar values from
another poster has helped my understanding. I am extremely pleased with
the quality and timeliness of answers I have received in this newsgroup.
Something I definitely did not expect when I posted my first question here.
Now back to the topic.
My main goal is to utilize the search performance that a hash (or should
I say associative array) provides. The problem is that I have a key
which is not unique. I want to retrieve multiple values for one hash
key. I know this is not exactly what the hash was built for but it beats
sequentially looping through the array.
So far I got my data structure initialized properly (verified with
Dumper). Now my problem is in getting the values back out. I would like
a loop to iterate over all entries with the key 'patid2'.
$pat_id_list_ref seems to point to just that.I don't know the value of
$accno in advance.
Data file (list_data):
patid1 acc1 mod1
patid2 acc2 mod2
patid2 acc3 mod3
patid3 acc4 mod4
patid3 acc5 mod5
Program I wrote (my 2 unsuccessful attempts commented out at the end):
#!/usr/bin/perl -w
use strict;
use Data::Dumper;
my %myhash = ();
my @LoL;
open (DATA,"<list_data");
while (<DATA>) {
my $tmp = $_;
push @LoL, $_;
my ($patid, $accno, $mod) = split();
print ("patid: $patid accno: $accno mod: $mod\n");
$myhash{$patid}{$accno} = [ $tmp ];
}
print Dumper(\%myhash);
my $pat_id_list_ref = $myhash{'patid2'};
print Dumper($pat_id_list_ref);
print ("number: #$pat_id_list_ref\n");
#while ((my $key, my $value) = each($pat_id_list_ref)) {
# print ("key: $key value: $value\n");
#}
#for my $aref ( $pat_id_list_ref ) {
# print "\t [ @$aref ],\n";
#}
exit 0;
Program output:
patid: patid1 accno: acc1 mod: mod1
patid: patid2 accno: acc2 mod: mod2
patid: patid2 accno: acc3 mod: mod3
patid: patid3 accno: acc4 mod: mod4
patid: patid3 accno: acc5 mod: mod5
$VAR1 = {
'patid1' => {
'acc1' => [
'patid1 acc1 mod1
'
]
},
'patid2' => {
'acc2' => [
'patid2 acc2 mod2
'
],
'acc3' => [
'patid2 acc3 mod3
'
]
},
'patid3' => {
'acc4' => [
'patid3 acc4 mod4
'
],
'acc5' => [
'patid3 acc5 mod5
'
]
}
};
$VAR1 = {
'acc2' => [
'patid2 acc2 mod2
'
],
'acc3' => [
'patid2 acc3 mod3
'
]
};
number: #HASH(0x1445d0)
Mina Naguib wrote:
> -----BEGIN xxx SIGNED MESSAGE-----
> Hash: SHA1
>
>
>
> Alexander Stremitzer wrote:
> | I am trying to build a multi-diemnsional hash for an application. To
> | figure out how it works I wrote a small program to test it.However, I
> | can't get it to do what I want.
> | The hash should have a level1 key which each can have several level2
> | keys which holds data in form of a list.
> | My first print loop delivers the expected result when assigning the
> list
> | value directly. When going through the hash it does not work. What am I
> | doing wrong ?
>
> Hello Alexander
>
> Please see my in-line comments below. However to fully understand it,
> you must read the perl references tutorial, available at "perldoc
> perlref" or http://www.perldoc.com/perl5.8.0/pod/perlref.html
>
> | #!/usr/local/bin/perl -w
> |
> | use strict;
> |
> | my %myhash = ();
> |
> | my @array1 = ('mod1','organ1');
>
> It's usually clearer to say:
>
> my @array1 = qw(mod1 organ1);
>
>
> | my @array2 = ('mod2','organ2');
> | my @array3 = ('mod3','organ3');
> |
> | $myhash{'patid1'}{'acc1'} = @array1;
>
> The value of a hash key can only hold a scalar content, nothing fancier
> than that (other hashes or arrays for example).
>
> The way to get around that if you have a fancy data collection, is to
> store a reference to it. Since references are smple scalar strings, you
> can store them as hash keys (or values) without a problem.
>
> In the above case, @array1 is treated in scalar content, which is not
> what you want.
>
> The correct way to do this is:
>
> $myhash{'patid1'}{'acc1'} = \@array1;
>
> This will store the reference to @array1.
>
>
> | $myhash{'patid2'}{'acc2'} = @array2;
> | $myhash{'patid2'}{'acc3'} = @array3;
>
> Same applies to these also.
>
> |
> | my @list = @array3;
> |
> | for my $i ( 0 .. $#list ) {
> | print "without hash: $list[$i]\n";
> | }
>
> *Usually* in perl to iterate over an array, you don't use an index
> holder like you do for other languages:
>
> foreach (@list) {
> print "Without hash: $_\n";
> }
>
> |
> | my @list = $myhash{'patid2'}{'acc3'};
>
> Remember that we stored a reference there ? At this point, you need to
> de-reference it to obtain the actual array:
>
> my @list = @{ $myhash{'patid2'}{'acc3'} };
>
> |
> | for my $i ( 0 .. $#list ) {
> | print "with hash: $list[$i]\n";
> | }
>
> See above for short form of iterating over an array.
>
> Also, here is an easier way to create that complex hash/arrays in the
> beginning with just 1 statement:
>
> %myhash = (
> patid1 => {
> acc1 => [
> 'mod1', 'organ1',
> ],
> },
> patid2 => {
> acc2 => [
> 'mod2', 'organ2',
> ],
> },
> patid3 => {
> acc3 => [
> 'mod3', 'organ3',
> ],
> },
> );
>
> And finally, here's an easy way to inspect any simple/complex
> scalar/array/hash.. The Data::Dumper module:
>
> use Data::Dumper;
>
> print Dumper(\%myhash);
> print Dumper(\@list);
>
> etc..
>
> See "perldoc Data::Dumper" or
> http://www.perldoc.com/perl5.6/lib/Data/Dumper.html for more information.
>
> Best of luck.
>
> -----BEGIN xxx SIGNATURE-----
> Version: GnuPG v1.0.6 (GNU/Linux)
> Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org
>
> iD8DBQE98hVReS99pGMif6wRAss3AKDCSMMrWuImyNTksXtwoP68bWcyowCgqlvm
> 2DYnlvXJCZdXjkl/JhdfYrM=
> =0fZI
> -----END PGP SIGNATURE-----
>
--
All man's miseries derive from not being able to sit quietly in a room alone. (Pascal)
------------------------------
Date: Sun, 8 Dec 2002 20:39:29 +0000 (UTC)
From: mauzo@mimosa.csv.warwick.ac.uk (Ben Morrow)
Subject: Re: Multi-dimensional hash question
Message-Id: <at0am1$2jg$1@wisteria.csv.warwick.ac.uk>
[please do not top-post]
[please snip properly]
Alexander Stremitzer <stremitz@consultant.com> wrote:
>Now back to the topic.
>My main goal is to utilize the search performance that a hash (or should
>I say associative array) provides. The problem is that I have a key
>which is not unique. I want to retrieve multiple values for one hash
>key. I know this is not exactly what the hash was built for but it beats
>sequentially looping through the array.
>
>So far I got my data structure initialized properly (verified with
>Dumper). Now my problem is in getting the values back out. I would like
>a loop to iterate over all entries with the key 'patid2'.
>$pat_id_list_ref seems to point to just that.I don't know the value of
>$accno in advance.
>
>Data file (list_data):
>patid1 acc1 mod1
>patid2 acc2 mod2
>patid2 acc3 mod3
>patid3 acc4 mod4
>patid3 acc5 mod5
>
>Program I wrote (my 2 unsuccessful attempts commented out at the end):
>#!/usr/bin/perl -w
>
>use strict;
>use Data::Dumper;
>
>my %myhash = ();
>my @LoL;
>
>open (DATA,"<list_data");
>while (<DATA>) {
> my $tmp = $_;
> push @LoL, $_;
> my ($patid, $accno, $mod) = split();
> print ("patid: $patid accno: $accno mod: $mod\n");
> $myhash{$patid}{$accno} = [ $tmp ];
No. What you want here is:
my ($patid, $accno, $mod) = split;
push @{ $myhash{$patid}{$accno} }, $mod;
This will create a hash-of-hashes-of-lists, which is I think what you want
here. I don't quite know what you were intending to do with @LoL?
The [ $tmp ] is daft: it will always return a ref to an array with only one
element. Using push instead will add the element to the end (the @{...} is
to deref the array ref in $myhash{$patid}{$accno}, which will magically
spring into being if it wasn't there previously. Perl's good like that :).
>}
>
>print Dumper(\%myhash);
>
>my $pat_id_list_ref = $myhash{'patid2'};
This is in fact a hashref, not a array ref.
Also, you don't need the quotes.
You will then need a double loop
for my $acc (keys %$pat_id_list_ref) {
for my $mod (@$pat_id_list_ref{$_}) {
<do summat>
}
}
to iterate over all mods for a gived patid.
>print Dumper($pat_id_list_ref);
>
>print ("number: #$pat_id_list_ref\n");
This won't work: $pilr is a hashref. You need a double loop like the above and
count them; or do something cleverer with map.
>
>exit 0;
Not needed.
Ben
------------------------------
Date: Sun, 08 Dec 2002 17:12:43 GMT
From: "Jürgen Exner" <jurgenex@hotmail.com>
Subject: Re: Newbie help please !!
Message-Id: <f4LI9.3058$_W1.962@nwrddc03.gnilink.net>
HelpMe wrote:
> Please Help , i built a website and installed a members password
> management perl script, but it needs cgi.pm installed my host doesn't
> seem to have it installed and i havn't got permissions to the perl
> directery. and i need help to install it , remember i havn't any idea
> what i am doing when you try 2 explain it to me ,thanks in advance
Any problems with the answer to PerlFAQ
How do I keep my own module/library directory?
jue
------------------------------
Date: Sun, 08 Dec 2002 17:28:26 GMT
From: Bart Lateur <bart.lateur@pandora.be>
Subject: nother
Message-Id: <mrv6vuooc480geap1djnnp4lnbvhfduffa@4ax.com>
PerlFAQ Server wrote:
> Use the four argument form of sysread to continually add to a buffer.
> After you add to the buffer, you check if you have a complete line
> (using your regular expression).
>
> local $_ = "";
> while( sysread FH, $_, 8192, length ) {
> while( s/^((?s).*?)your_pattern/ ) {
> my $record = $1;
> # do stuff here.
> }
> }
The FAQ shouldn't suggest something that can give wrong results , at
least not without warning about it.
For example, take this regex, which means "accept any conventional line
end": /\015\012|[\r\n]/", on a platform that doesn't do any magic CRLF
-> "\n" conversion. Suppose some file has followed the DOS line end
convention, CRLF. Suppose the data contains the text:
"One line" . "\015\012" . "Another line"
And by some coincidence, the buufer read splits these lines at an
unfortunate place: between the CR and the LF. Then the regxes strikes,
taking the LF at the start of the string to be an empty line, resulting
in:
One line
Another line
And magically, a new, empty line appears in the parsed text.
--
Bart.
------------------------------
Date: Mon, 09 Dec 2002 07:23:41 +1300
From: Peter <nospamjynyl@yahoo.co.nz>
Subject: Re: search reorder replace
Message-Id: <at02nk$vbb24$1@ID-132751.news.dfncis.de>
Anno Siegel wrote:
<snip>
> Your description of the task is less than clear, but you will want to
> look into Perl's substitution operator s///. Maybe s/(.)\0\0\0\0/\n$1/
> is what you want, but that's just a guess.
Sorry about the unclear description.
Your answer works just great! As far as I can tell, it does exactly what
I'm after (and man it's fast).
thanks heaps
Peter
------------------------------
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.
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 4233
***************************************