[25534] in Perl-Users-Digest
Perl-Users Digest, Issue: 7778 Volume: 10
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Mon Feb 14 11:05:47 2005
Date: Mon, 14 Feb 2005 08:05:26 -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 Mon, 14 Feb 2005 Volume: 10 Number: 7778
Today's topics:
Anyone using Storable.pm on x86_64? Seems to be broken (Marinos Yannikos)
Re: Feeding false an App <1usa@llenroc.ude.invalid>
Re: Feeding false an App <hackeras@gmail.com>
Re: Feeding false an App <spamtrap@dot-app.org>
Re: Feeding false an App <hackeras@gmail.com>
Re: Feeding false an App <spamtrap@dot-app.org>
Re: Feeding false an App <hackeras@gmail.com>
glob question (justme)
Re: glob question <josef.moellers@fujitsu-siemens.com>
Re: How to make a regex substitution repeat until there <noreply@gunnar.cc>
Re: Invisible variables in Perl debugger (Volker Nicolai)
mkpath <alexj@floor.ch>
Re: mkpath <phaylon@dunkelheit.at>
Re: mkpath <spamtrap@dot-app.org>
Re: Mod_perl: can I share a database connection by putt <nobull@mail.com>
Re: Process word occurances in Bible? <1usa@llenroc.ude.invalid>
Re: Process word occurances in Bible? ioneabu@yahoo.com
Re: Process word occurances in Bible? <dave_frank@hotmail.com>
question about variable procedure call <alexj@floor.ch>
Re: question about variable procedure call <kurzhalsflasche@yahoo.co.uk>
Re: question about variable procedure call <do-not-use@invalid.net>
Re: question about variable procedure call <nobull@mail.com>
Re: Record Hash Data Structure (Newbie) rajasekaran.natarajan@gmail.com
Re: Record Hash Data Structure (Newbie) ioneabu@yahoo.com
Re: Record Hash Data Structure (Newbie) <nobull@mail.com>
strange <alexj@floor.ch>
Re: strange <phaylon@dunkelheit.at>
Re: strange <kurzhalsflasche@yahoo.co.uk>
Re: strange <spamtrap@dot-app.org>
Re: strange <bernard.el-haginDODGE_THIS@lido-tech.net>
Re: strange chris-usenet@roaima.co.uk
Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: 14 Feb 2005 05:28:15 -0800
From: mjy@geizhals.at (Marinos Yannikos)
Subject: Anyone using Storable.pm on x86_64? Seems to be broken
Message-Id: <342cab6e.0502140528.6bdf105f@posting.google.com>
According to the manpage, Storable should be able to read data
generated on a 32 bit platform under e.g. Debian x86_64. It doesn't -
data written by Perl 5.8.4/Storable 2.12 under 32 bit Debian x86
causes this under Debian x86_64 (also Perl 5.8.4/Storable 2.12):
Byte order is not compatible at ../../lib/Storable.pm (autosplit into
../../lib/auto/Storable/_retrieve.al) line 328, at ./testdesc.pl line
4
Are there any known solutions for this?
------------------------------
Date: Mon, 14 Feb 2005 12:49:53 GMT
From: "A. Sinan Unur" <1usa@llenroc.ude.invalid>
Subject: Re: Feeding false an App
Message-Id: <Xns95FD4FA984FE7asu1cornelledu@127.0.0.1>
Richard Anderson <hackeras@gmail.com> wrote in
news:Xns95FD2856F8D65hackerasgmailcom@194.177.210.210:
> Gregory Toomey <nospam@bigpond.com> wrote in news:379sn3F5bn0dqU1
> @individual.net:
>
> Sorry didnt paste the whole code:
Richard, whoever you are, please learn to use proper attributions when you
post Gregory Toomey did not write the line above.
For what it is worth, my sense is that you are a nine year old troll in
training.
Sinan.
------------------------------
Date: Mon, 14 Feb 2005 14:58:01 +0000 (UTC)
From: Richard Anderson <hackeras@gmail.com>
Subject: Re: Feeding false an App
Message-Id: <Xns95FDACD5774E7hackerasgmailcom@194.177.210.210>
"A. Sinan Unur" <1usa@llenroc.ude.invalid> wrote in
news:Xns95FD4FA984FE7asu1cornelledu@127.0.0.1:
> Richard Anderson <hackeras@gmail.com> wrote in
> news:Xns95FD2856F8D65hackerasgmailcom@194.177.210.210:
>
>> Gregory Toomey <nospam@bigpond.com> wrote in news:379sn3F5bn0dqU1
>> @individual.net:
> Richard, whoever you are, please learn to use proper attributions when
> you post Gregory Toomey did not write the line above.
>
> For what it is worth, my sense is that you are a nine year old troll
> in training.
>
> Sinan.
You ve got a wrong sense then, sorry for the line though it missed me on
delettion.
What about my question?
------------------------------
Date: Mon, 14 Feb 2005 10:20:09 -0500
From: Sherm Pendley <spamtrap@dot-app.org>
Subject: Re: Feeding false an App
Message-Id: <y7udnZgdl7w0XI3fRVn-2g@adelphia.com>
Richard Anderson wrote:
> You ve got a wrong sense then, sorry for the line though it missed me on
> delettion.
Intentional troll or not, the fact is that every message you've posted so
far has been complete gibberish. If that's not intentional, then it's
apparent that you haven't got the first clue what you're talking about.
> What about my question?
Was there a Perl question buried in there somewhere? The only Perl I've so
far simply printed a Content-type header and some output. There was nothing
wrong with the Perl code that I could see.
sherm--
--
Cocoa programming in Perl: http://camelbones.sourceforge.net
Hire me! My resume: http://www.dot-app.org
------------------------------
Date: Mon, 14 Feb 2005 15:36:24 +0000 (UTC)
From: Richard Anderson <hackeras@gmail.com>
Subject: Re: Feeding false an App
Message-Id: <Xns95FDB36285DBAhackerasgmailcom@194.177.210.210>
Sherm Pendley <spamtrap@dot-app.org> wrote in
news:y7udnZgdl7w0XI3fRVn-2g@adelphia.com:
Well i made a prog my self but not a complte one. i dont know how to make
my program listen to and respinf to cpu id requests
------------------------------
Date: Mon, 14 Feb 2005 10:51:02 -0500
From: Sherm Pendley <spamtrap@dot-app.org>
Subject: Re: Feeding false an App
Message-Id: <4_WdnYapvP56VY3fRVn-iQ@adelphia.com>
Richard Anderson wrote:
> Well i made a prog my self but not a complte one. i dont know how to make
> my program listen to and respinf to cpu id requests
More gibberish. You're not getting any answers because your question makes
no sense. What is a "cpu id request"? What's it coming from? What protocol
is being used?
sherm--
--
Cocoa programming in Perl: http://camelbones.sourceforge.net
Hire me! My resume: http://www.dot-app.org
------------------------------
Date: Mon, 14 Feb 2005 16:01:30 +0000 (UTC)
From: Richard Anderson <hackeras@gmail.com>
Subject: Re: Feeding false an App
Message-Id: <Xns95FDB7A3DD184hackerasgmailcom@194.177.210.210>
Sherm Pendley <spamtrap@dot-app.org> wrote in
news:4_WdnYapvP56VY3fRVn-iQ@adelphia.com:
> Richard Anderson wrote:
>
>> Well i made a prog my self but not a complte one. i dont know how to
>> make my program listen to and respinf to cpu id requests
>
> More gibberish. You're not getting any answers because your question
> makes no sense. What is a "cpu id request"? What's it coming from?
> What protocol is being used?
Well a cpu id request is a request made from an application running on a
machine asking for the hardware's(cpu specifically) serial number.
Thats what my frind is using through his app to identify my pc uniquley.
What i want to do is to captute this cpu id request made from his
application and hen false feed it!
Make any sense now! I hope eys :-)
------------------------------
Date: 14 Feb 2005 04:27:03 -0800
From: eight02645999@yahoo.com (justme)
Subject: glob question
Message-Id: <c0837966.0502140427.5fe79d1b@posting.google.com>
hi
while using the glob function to check for wildcards eg,
while ( glob *.txt )
{
#do something with txt files...
}
how can i specify globbing those not *.txt?
is it something like this
while ( ! glob *.txt )
{
}
when i use this method , there is no output, even though there are
other files in the directory ...
thanks
------------------------------
Date: Mon, 14 Feb 2005 13:37:02 +0100
From: Josef Moellers <josef.moellers@fujitsu-siemens.com>
Subject: Re: glob question
Message-Id: <cuq5uo$9fd$1@nntp.fujitsu-siemens.com>
justme wrote:
> hi
>=20
> while using the glob function to check for wildcards eg,
>=20
> while ( glob *.txt )
> {
> #do something with txt files...
> }
> how can i specify globbing those not *.txt?
>=20
> is it something like this=20
> while ( ! glob *.txt )
> {
>=20
> }
while ( glob "*" )
{
next if /\.txt$/;
# Do something with non-txt
}
But tpmtowtdi,
Josef
--=20
Josef M=F6llers (Pinguinpfleger bei FSC)
If failure had no penalty success would not be a prize
-- T. Pratchett
------------------------------
Date: Mon, 14 Feb 2005 15:06:24 +0100
From: Gunnar Hjalmarsson <noreply@gunnar.cc>
Subject: Re: How to make a regex substitution repeat until there are no more matches?
Message-Id: <37bqegF57vn3nU1@individual.net>
David Deutsch wrote:
> I am trying to write a regular expression that will do a substitution
> repeatedly until there are not more matches. Specifically, let's say I want
> to convert every <option> tag in a select with name "YYY" into a link. If I
> use:
>
> s|(<select name="YYY">)<select.*?>(.*?)</select>|$1<a href =
> "$2">$2</a>|gs
>
> it will only change the first select
Wasn't it <option> tags you wanted to change?
local $_ = <<HTML;
<select name="YYY">
<option value="1">1</option>
<option value="2">2</option>
</select>
HTML
s[(<select[^>]+name="YYY".+?</select>)][
my $select = $1;
$select =~ s|<option.*?>(.*?)</option>|<a href="$1">$1</a>|gis;
$select
]eis;
print;
Outputs:
<select name="YYY">
<a href="1">1</a>
<a href="2">2</a>
</select>
--
Gunnar Hjalmarsson
Email: http://www.gunnar.cc/cgi-bin/contact.pl
------------------------------
Date: 14 Feb 2005 04:15:06 -0800
From: vnick@freenet.de (Volker Nicolai)
Subject: Re: Invisible variables in Perl debugger
Message-Id: <de7655a5.0502140415.55a4603f@posting.google.com>
Ilya Zakharevich <nospam-abuse@ilyaz.org> wrote in message news:<ctu2bt$1pq0
> On a surface, it looks that this may be a true bug. However, what you
> write is very ambiguous (and I suspect that English is not your first
> language, so it may take a lot of time to clear through...). If you
> can create a short example, please post it.
>
> Thanks,
> Ilya
I am not too sure what sort of example you want but here is one (hope
that does it):
(I have tested $casn too, that works but not $i...
--------------------------------------------------
DB<49> l 1027-1045
1027==>b if (exists $case[$casn+1]) { # A
next case exists?
1028: for($i=0; $i < scalar(@{$case[$casn]}); $i++) { # For
all sequences of this case (incl. general one)...
1029: print "Restore: i: $i \n"; # DEBUG!
1030: foreach $reg_key (keys (%{$case[$casn][$i]})) { # For
all register keys of this case + sequence...
1031: next if (defined
$case[$casn][$i]{$reg_key}{_RESTORE_} &&
$case[$casn][$i]{$reg_key}{_RESTORE_} eq "n");
1032 # Skip case
reg if restore to orig spec shall be done.
1033: foreach $field_key (keys
(%{$case[$casn][$i]{$reg_key}})) {
1034 # For all
slice keys of each register ...
1035: if (defined $case[$casn+1][$i] && ! defined
$case[$casn+1][$i]{$reg_key} &&
1036 ! defined
$case[$casn+1][$i]{$reg_key}{$field_key}){
1037 # Reg/slice
key not (re-)defined in next case? (->prevent overwriting)
1038: $case[$casn+1][$i]{$reg_key}{$field_key} =
$case[$casn][$i]{$reg_key}{$field_key};
1039 } # Take last's
cases rule or specical key and copy it to next one.
1040 }
1041 }
1042 }
1043 }
1044
1045: print CMDFILE "\nprint_msg (\"FINISHED PROGRAMMING
REGISTERS\"); \n\n";
DB<50> s
main::(gen_specs.pl:1028): for($i=0; $i <
scalar(@{$case[$casn]}); $i++) { # For all sequences of this case
(incl. general one)...
DB<50> s
main::(gen_specs.pl:1028): for($i=0; $i <
scalar(@{$case[$casn]}); $i++) { # For all sequences of this case
(incl. general one)...
DB<50>
main::(gen_specs.pl:1029): print "Restore: i: $i \n";
# DEBUG!
DB<50>
Restore: i: 0
main::(gen_specs.pl:1030): foreach $reg_key (keys
(%{$case[$casn][$i]})) { # For all register keys of this case +
sequence...
DB<50> p $i
Use of uninitialized value in print at (eval
21)[/cadappl/perl/5.6.1/lib/5.6.1/perl5db.pl:1521] line 2.
DB<51> print $i
Use of uninitialized value in print at (eval
22)[/cadappl/perl/5.6.1/lib/5.6.1/perl5db.pl:1521] line 2.
DB<52> p $casn
0
------------------------------------------------------
The related lines of code are inside gen_spec.pl:
if (exists $case[$casn+1]) {
for($i=0; $i < scalar(@{$case[$casn]}); $i++) {
print "Restore: i: $i \n"; # DEBUG!
foreach $reg_key (keys (%{$case[$casn][$i]})) {
next if (defined $case[$casn][$i]{$reg_key}{_RESTORE_} &&
$case[$casn][$i]{$reg_key}{_RESTORE_} eq "n");
foreach $field_key (keys (%{$case[$casn][$i]{$reg_key}})) {
if (defined $case[$casn+1][$i] &&
! defined $case[$casn+1][$i]{$reg_key} &&
! defined $case[$casn+1][$i]{$reg_key}{$field_key}){
$case[$casn+1][$i]{$reg_key}{$field_key} =
$case[$casn][$i]{$reg_key}{$field_key};
}
}
}
}
(Sorry for long lines above)
gen_spec.pl is invoked by another script with:
require "gen_specs.pl" ;
Hope that does it.
Thanks for helping, sorry for the delay of my response.
Volker
------------------------------
Date: Mon, 14 Feb 2005 15:05:47 +0100
From: Alexandre Jaquet <alexj@floor.ch>
Subject: mkpath
Message-Id: <cuqb7q$s6l$1@news.hispeed.ch>
Hi again,
does mkpath(['/foo/bar/baz', 'blurfl/quux'], 1, 0711); create
/foo/bar/baz directories based on blurf1/quux or it's only create thow
directories
thx
------------------------------
Date: Mon, 14 Feb 2005 15:09:48 +0100
From: phaylon <phaylon@dunkelheit.at>
Subject: Re: mkpath
Message-Id: <pan.2005.02.14.14.09.47.484766@dunkelheit.at>
Alexandre Jaquet wrote:
> does mkpath(['/foo/bar/baz', 'blurfl/quux'], 1, 0711); create
> /foo/bar/baz directories based on blurf1/quux or it's only create thow
> directories
I'm sorry if I don't understand your question right, but are you asking in
what relation '/foo/bar/baz' and 'blurfl/quux' are standing? If so, the
documentation may help:
L<perldoc File::Path>
| ... "mkpath" takes three arguments:
|
| o the name of the path to create, or a reference to a
| list of paths to create,
| ...
If this does not help, sorry, please reformulate your question if nobody
else understands it[1].
hth,phay
[1] Maybe it's me, not native english.
--
http://www.dunkelheit.at/
»Better to reign in hell than to serve in heaven«
-- John Milton, »Paradise Lost«
------------------------------
Date: Mon, 14 Feb 2005 09:45:56 -0500
From: Sherm Pendley <spamtrap@dot-app.org>
Subject: Re: mkpath
Message-Id: <8tOdnTRVgsM4JI3fRVn-gw@adelphia.com>
Alexandre Jaquet wrote:
> does mkpath(['/foo/bar/baz', 'blurfl/quux'], 1, 0711); create
> /foo/bar/baz directories based on blurf1/quux or it's only create thow
> directories
I'm not sure what you mean by "based on" here, but the docs are pretty clear
- if you pass an array reference as the first argument to mkpath(), it's
taken as a list of paths to create.
sherm--
--
Cocoa programming in Perl: http://camelbones.sourceforge.net
Hire me! My resume: http://www.dot-app.org
------------------------------
Date: Mon, 14 Feb 2005 14:08:44 +0000
From: Brian McCauley <nobull@mail.com>
Subject: Re: Mod_perl: can I share a database connection by putting it in the startup-script?
Message-Id: <cuqb34$hlv$1@sun3.bham.ac.uk>
Oliver Green wrote:
> I'm using Apache::Registry to speed up my cgi scripts. So far I've not
> modified the scripts themselves apart from moving most of the common
> "use <Module>" to the startup-script so Apache caches them.
>
> As all scripts connect to a database (using DBI), I might as well move
> the connect statement to the startup-script. This works, and apparently
> the connection is now shared by all the children that Apache forks.
>
> However, I have a hard time telling if it will work correctly under
> load.
It will not.
> I suspect that by re-using the same connection over and over I
> might get some concurrency issues, or inconsistency errors.
You will.
> How would I setup a test on my (modest) development system simulating
> high usage?
Don't bother.
> And I would love to hear from someone that actually knows if this
> connection sharing is at all advisable.
It is not.
In mod_perl2 with the next generation of Apache::DBI connection sharing
(or rather pooling) will be apparently supported eventually by some DBDs
- but it will be manged transparently by Apache::DBI.
------------------------------
Date: Mon, 14 Feb 2005 12:46:43 GMT
From: "A. Sinan Unur" <1usa@llenroc.ude.invalid>
Subject: Re: Process word occurances in Bible?
Message-Id: <Xns95FD4F2042332asu1cornelledu@127.0.0.1>
ioneabu@yahoo.com wrote in news:1108349677.656571.97340
@f14g2000cwb.googlegroups.com:
>
> Anno Siegel wrote:
...
>> "$total++" and the count in %words should be independent statements,
>> not connected by "and". If the first word in the file is a unique
>> word, you'll miss it. "$total++" will return 0 when it should be
>> counted.
>
> I don't understand this part. Can you give an example. I know you
> must be right, but I keep reading it over and over and missing it.
Then you should read about the difference between pre- and post-
increment. I believe you have learned where the documentation is
installed on your computer by now.
From perldoc perlop:
Auto-increment and Auto-decrement
"++" and "--" work as in C. That is, if placed before a variable,
they increment or decrement the variable by one before returning the
value, and if placed after, increment or decrement after returning
the value.
$i = 0; $j = 0;
print $i++; # prints 0
print ++$j; # prints 1
Please.
Sinan.
------------------------------
Date: 14 Feb 2005 05:37:34 -0800
From: ioneabu@yahoo.com
Subject: Re: Process word occurances in Bible?
Message-Id: <1108388254.937188.153300@f14g2000cwb.googlegroups.com>
David Frank wrote:
> "David Frank" <dave_frank@hotmail.com> wrote in message
> news:420f700d$0$38924$ec3e2dad@news.usenetmonster.com...
> >
> >
> >
> > Impressive,
> > however what if further processing is then desired, are the
individual
> > unique words, counts
> > available for searching etc.. in their respective arrays?
> > They will be in other language's solutions.
> > Can you get a runtime with 4.xx precision?
> >
>
> My challenge stated that 2 arrays would be loaded with words and
their
> counts.
> e.g. the #occurances of "god" in the bible appears to be 4446
times.
>
> Cant Perl produce these 2 arrays for further processing (write
unique words
> and occurances to a file?
Sure, that would be easy. It makes more sense to use a hash
(associative array) with the words as keys and the count per word as
values rather than two arrays. Java and C++ have similar containers.
I think they call it a map.
------------------------------
Date: Mon, 14 Feb 2005 08:47:38 -0500
From: "David Frank" <dave_frank@hotmail.com>
Subject: Re: Process word occurances in Bible?
Message-Id: <4210abf6$0$38899$ec3e2dad@news.usenetmonster.com>
<ioneabu@yahoo.com> wrote in message
news:1108388254.937188.153300@f14g2000cwb.googlegroups.com...
>
> David Frank wrote:
>
>> Cant Perl produce these 2 arrays for further processing (write
> unique words
>> and occurances to a file?
>
> Sure, that would be easy. It makes more sense to use a hash
> (associative array) with the words as keys and the count per word as
> values rather than two arrays. Java and C++ have similar containers.
> I think they call it a map.
>
Sooo, can you show us a version that produces outputs shown in my Fortran
below?
http://home.cfl.rr.com/davegemini/wp_bible.f90
------------------------------
Date: Mon, 14 Feb 2005 14:02:22 +0100
From: Alexandre Jaquet <alexj@floor.ch>
Subject: question about variable procedure call
Message-Id: <cuq7gt$kri$1@news.hispeed.ch>
Hi I currently try to optimize an application and I got the following
question.
How in perl can I call call variable procedure call.
I want to delete code like that :
if ($var = something) { doThat()
if ($var = other) ( doOther
if
to $routine = $var_name
call routine
any idea thanx
------------------------------
Date: Mon, 14 Feb 2005 14:16:56 +0100
From: Dominik Seelow <kurzhalsflasche@yahoo.co.uk>
Subject: Re: question about variable procedure call
Message-Id: <37bmm8F5b32gqU1@individual.net>
Alexandre Jaquet wrote:
> Hi I currently try to optimize an application and I got the following
> question.
>
> How in perl can I call call variable procedure call.
>
> I want to delete code like that :
>
> if ($var = something) { doThat()
>
> if ($var = other) ( doOther
>
> if
>
> to $routine = $var_name
> call routine
>
> any idea thanx
Hello Alexandre,
I suggest to use a hash storing sub references:
use strict;
my $var_name='subA';
my %subs = (
subA =>sub { print 'A'},
subB =>sub { print 'B'}
);
foreach my $var_name (qw (subA subB subC)){
&{$subs{$var_name}} if ref $subs{$var_name} eq 'CODE';
}
This will allow you to check whether a sub exists before you call it.
But I'm not sure that this really optimises your code. I prefer if/elsif
constructions.
Cheers,
Dominik
------------------------------
Date: 14 Feb 2005 14:22:41 +0100
From: Arndt Jonasson <do-not-use@invalid.net>
Subject: Re: question about variable procedure call
Message-Id: <yzdsm3z1djy.fsf@invalid.net>
Alexandre Jaquet <alexj@floor.ch> writes:
> Hi I currently try to optimize an application and I got the following
> question.
>
> How in perl can I call call variable procedure call.
>
> I want to delete code like that :
>
> if ($var = something) { doThat()
>
> if ($var = other) ( doOther
>
> if
>
> to $routine = $var_name
> call routine
Your own example isn't even correct Perl, so I'm guessing what it is
you want.
Do you know that this change will make the program faster?
Maybe this is something like what you want:
sub apa {
my $r = shift;
$r * 2;
}
sub banan {
my $r = shift;
$r + 2;
}
$f = \&apa;
$x = &$f (5);
You could map the values of $var to the correct function reference via
a hash table.
------------------------------
Date: Mon, 14 Feb 2005 13:49:57 +0000
From: Brian McCauley <nobull@mail.com>
Subject: Re: question about variable procedure call
Message-Id: <cuq9vt$h43$1@sun3.bham.ac.uk>
Dominik Seelow wrote:
> Alexandre Jaquet wrote:
>
>> Hi I currently try to optimize an application and I got the following
>> question.
>>
>> How in perl can I call call variable procedure call.
>>
>> I want to delete code like that :
>>
>> if ($var = something) { doThat()
>>
>> if ($var = other) ( doOther
>>
>> if
>>
>> to $routine = $var_name
>> call routine
> my %subs = (
> subA =>sub { print 'A'},
> subB =>sub { print 'B'}
> );
Surley to match the OP this should be:
my %subs = (
something => \&doThat,
other => \&doOther,
);
> &{$subs{$var_name}} if ref $subs{$var_name} eq 'CODE';
The OP example did noy share the current @_ with the called subroutine
so it would be more ideomatic as:
$subs{$var_name}->() if $subs{$var_name};
Note: I've simplified the condition. There is no legitmate way a value
other than a CODEref could have got into %subs. If, somehow, one has it
is better that the program fall over rather than silently ignore
something that can only indicate a bug in the program.
(ISTR the -> is optional in recent Perl but I think this is one case I'd
keep it).
------------------------------
Date: 14 Feb 2005 03:15:14 -0800
From: rajasekaran.natarajan@gmail.com
Subject: Re: Record Hash Data Structure (Newbie)
Message-Id: <1108379714.636673.178660@o13g2000cwo.googlegroups.com>
I have got the mistake!
------------------------------
Date: 14 Feb 2005 04:33:26 -0800
From: ioneabu@yahoo.com
Subject: Re: Record Hash Data Structure (Newbie)
Message-Id: <1108384406.307104.177740@c13g2000cwb.googlegroups.com>
rajasekaran.natarajan@gmail.com wrote:
> Hi all,
>
> I am trying to write a program which extracts the data feom a text
file
> and stores it in a data structure. But there is some mistake and I
> couldnt able to get over with.
>
> I am a newbie (my 25th program or so) in Perl and I have checked the
> oreilly books and perldoc but I have some limitations to understand
to
> be frank. (i mean unable to get the thing correct after reading)
>
> below I had given my script and if anybody can thorw some light I
will
> be greatfull. Thanks in advance.
>
> #!/usr/sbin/perl -w
> #extracts grid data from test.dat and stores in dataStructure
> $file1 = "test.dat";
> open(CLIST,"$file1") || die ("Cant open input file \"$file1\", Unable
> to Find, Check the file name and path");
> while($line= <CLIST>){
> if ($line =~ m/^GRID/) {
> ($gridNo,$cp,$xcor,$ycor,$coor,$cd)= unpack("x8 A8 A8 A8 A8
> A8",$line);
> $record = {
> GRIDNO => $gridNo,
> cp => $cp,
> xcor => $xcor,
> ycor => $ycoor,
> zcor => $zcoor,
> cd => $cd,
> };
> $grid{ $record->{GRIDNO} } = $record;
> }
> while( $gridNo = each %grid) {
> printf "%s is grid no\n",$grid->{$gridNo};
> }
> }
> close(CLIST);
I have no idea what your program is supposed to do and I think you have
some typos, but here is a version of your program that compiles with
perl -c program.pl. Clean it up and provide some test data. Learning
Perl is a great book to start with. I keep re-reading the first few
chapters and l learn something new every time.
#!/usr/bin/perl
use strict;
use warnings;
#extracts grid data from test.dat and stores in dataStructure
my $file1 = "test.dat";
open(CLIST,$file1) || die ("Cant open input file \"$file1\", Unable
to Find, Check the file name and path");
my $line;
my ($gridNo,$cp,$xcor,$ycor,$zcor,$cd);
my %grid;
while($line= <CLIST>){
if ($line =~ m/^GRID/) {
($gridNo,$cp,$xcor,$ycor,$zcor,$cd)= unpack("x8 A8 A8 A8 A8
A8",$line);
my $record = {
GRIDNO => $gridNo,
cp => $cp,
xcor => $xcor,
ycor => $ycor,
zcor => $zcor,
cd => $cd,
};
$grid{ $record->{GRIDNO} } = $record;
}
while( $gridNo = each %grid) {
printf "%s is grid no\n",$grid{$gridNo};
}
}
close(CLIST);
good luck!
wana
------------------------------
Date: Mon, 14 Feb 2005 13:56:04 +0000
From: Brian McCauley <nobull@mail.com>
Subject: Re: Record Hash Data Structure (Newbie)
Message-Id: <cuqabd$hcn$1@sun3.bham.ac.uk>
ioneabu@yahoo.com wrote:
> my ($gridNo,$cp,$xcor,$ycor,$zcor,$cd);
> while($line= <CLIST>){
> if ($line =~ m/^GRID/) {
> ($gridNo,$cp,$xcor,$ycor,$zcor,$cd)= unpack("x8 A8 A8 A8 A8
> A8",$line);
You are suffering from a nasty case of premature declaration there. You
probably should get that seen to before it causes you too much
embarrassment.
Anyhow since you immediately puy this into a hash, a hash slice
assignment would be more natural.
@{my $record}{qw( GRIDNO cp xcor ycor zcor cd)} =
= unpack("x8 A8 A8 A8 A8 A8",$line);
------------------------------
Date: Mon, 14 Feb 2005 15:28:05 +0100
From: Alexandre Jaquet <alexj@floor.ch>
Subject: strange
Message-Id: <cuqchk$uhl$1@news.hispeed.ch>
I can't understand this error :
Can't call method "echo" without a package or object reference
here the code :
#!/usr/bin/perl -w
use strict;
use File::Path;
my $project_name;
my $path;
print "donnez le nom de votre projet\n";
$project_name = <STDIN>;
createDirectory ($project_name);
sub createDirectory {
$project_name = shift || '';
my $path1 = '/data/web/floor.ch/cms/interface/'.$project_name;
echo $path1;
------------------------------
Date: Mon, 14 Feb 2005 15:25:51 +0100
From: phaylon <phaylon@dunkelheit.at>
Subject: Re: strange
Message-Id: <pan.2005.02.14.14.25.50.523353@dunkelheit.at>
Alexandre Jaquet wrote:
> I can't understand this error :
>
> Can't call method "echo" without a package or object reference
This is Perl, not PHP. Use 'print', use 'printf', but use the docs! There
are posting guidelines posted here twice (I think so) a week, which will
have many useful information to help you and the people which are trying
to help you.
You should have the perl documentation on your computer. If not, or if you
can't find it, try searching the web for 'perldoc'.
hth,phay
--
http://www.dunkelheit.at/
sapere aude.
------------------------------
Date: Mon, 14 Feb 2005 15:33:25 +0100
From: Dominik Seelow <kurzhalsflasche@yahoo.co.uk>
Subject: Re: strange
Message-Id: <37br5lF5def6jU1@individual.net>
Alexandre Jaquet wrote:
> I can't understand this error :
>
> Can't call method "echo" without a package or object reference
>
> here the code :
SNIP
> echo $path1;
There is no Perl function 'echo'. You may want to use 'print' instead.
Dominik
------------------------------
Date: Mon, 14 Feb 2005 09:43:13 -0500
From: Sherm Pendley <spamtrap@dot-app.org>
Subject: Re: strange
Message-Id: <8tOdnTVVgsOeJI3fRVn-gw@adelphia.com>
Alexandre Jaquet wrote:
> I can't understand this error :
>
> Can't call method "echo" without a package or object reference
Have a look at "perldoc perlobj", in the section titled "Indirect Object
Syntax". Essentially, when you wrote this:
> echo $path1;
It gets interpreted like this:
$path1->echo();
By the way, are you certain you wanted to call echo(), not print()? This is
Perl we're talking here, not a shell script...
sherm--
--
Cocoa programming in Perl: http://camelbones.sourceforge.net
Hire me! My resume: http://www.dot-app.org
------------------------------
Date: Mon, 14 Feb 2005 15:42:38 +0100
From: "Bernard El-Hagin" <bernard.el-haginDODGE_THIS@lido-tech.net>
Subject: Re: strange
Message-Id: <Xns95FD9FD0AD7ADelhber1lidotechnet@62.89.127.66>
Alexandre Jaquet <alexj@floor.ch> wrote:
Subject: strange
Please put the subject of your post in the Subject of your post.
> I can't understand this error :
>
> Can't call method "echo" without a package or object reference
[...]
> sub createDirectory {
> $project_name = shift || '';
> my $path1 = '/data/web/floor.ch/cms/interface/'.$project_name;
> echo $path1;
What did you expect echo (which is not a Perl built-in nor is it
defined in File::Path) to do? Did you perhaps want to use print()
instead?
--
Cheers,
Bernard
------------------------------
Date: Mon, 14 Feb 2005 15:29:21 +0000
From: chris-usenet@roaima.co.uk
Subject: Re: strange
Message-Id: <hns6e2-o86.ln1@moldev.cmagroup.co.uk>
Alexandre Jaquet <alexj@floor.ch> wrote:
> print "donnez le nom de votre projet\n";
> $project_name = <STDIN>;
> createDirectory ($project_name);
Do you intend a "chomp $project_name" in there somewhere?
Chris
------------------------------
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 7778
***************************************