[31172] in Perl-Users-Digest
Perl-Users Digest, Issue: 2417 Volume: 11
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Thu May 14 21:09:49 2009
Date: Thu, 14 May 2009 18:09:17 -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 Thu, 14 May 2009 Volume: 11 Number: 2417
Today's topics:
Re: [confused about the warn] <noreply@gunnar.cc>
Re: [confused about the warn] childpsych.columbia@gmail.com
Re: [confused about the warn] <smallpond@juno.com>
Re: [confused about the warn] childpsych.columbia@gmail.com
Re: [confused about the warn] <noreply@gunnar.cc>
Re: [confused about the warn] childpsych.columbia@gmail.com
Re: [confused about the warn] <1usa@llenroc.ude.invalid>
Re: [confused about the warn] <noreply@gunnar.cc>
Re: [confused about the warn] childpsych.columbia@gmail.com
Re: [confused about the warn] childpsych.columbia@gmail.com
comma operator <frank@example.invalid>
Re: comma operator <frank@example.invalid>
Re: FAQ 7.14 What is variable suicide and how can I pre <frank@example.invalid>
Re: How to replace c:\Program Files with Program Files <1usa@llenroc.ude.invalid>
Re: How to replace c:\Program Files with Program Files <veatchla@yahoo.com>
Re: writing get_script as an external routine callable <frank@example.invalid>
Re: writing get_script as an external routine callable <frank@example.invalid>
Re: writing get_script as an external routine callable <jurgenex@hotmail.com>
Re: writing get_script as an external routine callable <frank@example.invalid>
Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: Thu, 14 May 2009 22:36:40 +0200
From: Gunnar Hjalmarsson <noreply@gunnar.cc>
Subject: Re: [confused about the warn]
Message-Id: <773dmsF1do278U1@mid.individual.net>
childpsych.columbia@gmail.com wrote:
> On May 14, 3:10 pm, Gunnar Hjalmarsson <nore...@gunnar.cc> wrote:
>> childpsych.colum...@gmail.com wrote:
>>> I add warn in Staff.pm, but the warn information does NOT appear in
>>> the error_log.
>>
>> Try to uncomment the lines with the warn() statements.
>
> I read the source code.
Thank you very much!
> I found that the login.masn call the Staff->authenticate.
> the code is as follows:
> my $staff_id = Clinic::Party::Staff->authenticate( $username,
> $pass );
>
> So, I goto lib/Clinic/Party/Staff.pm, there is a sub authenticate.
> I add a warn statement in the sub authenticate.
> But it seems that the warn information does not appear in the
> error_log.
I see no warn() statements in sub authenticate. I see two warn()
statements in sub days_since_last_password_change, but they are
commented out.
--
Gunnar Hjalmarsson
Email: http://www.gunnar.cc/cgi-bin/contact.pl
------------------------------
Date: Thu, 14 May 2009 14:04:45 -0700 (PDT)
From: childpsych.columbia@gmail.com
Subject: Re: [confused about the warn]
Message-Id: <0a28c05c-2ef0-4891-bc11-a5792dc1020e@z5g2000vba.googlegroups.com>
On May 14, 4:36=A0pm, Gunnar Hjalmarsson <nore...@gunnar.cc> wrote:
> childpsych.colum...@gmail.com wrote:
> > On May 14, 3:10 pm, Gunnar Hjalmarsson <nore...@gunnar.cc> wrote:
> >> childpsych.colum...@gmail.com wrote:
> >>> =A0I add warn in Staff.pm, but the warn information does NOT appear i=
n
> >>> the error_log.
>
> >> Try to uncomment the lines with the warn() statements.
>
> > I read the source code.
>
> Thank you very much!
>
> > I found that the login.masn call the Staff->authenticate.
> > =A0the code is as follows:
> > =A0my $staff_id =3D Clinic::Party::Staff->authenticate( $username,
> > $pass );
>
> > So, I goto lib/Clinic/Party/Staff.pm, there is a sub authenticate.
> > I add a warn statement in the sub authenticate.
> > But it seems that the warn information does not appear in the
> > error_log.
>
> I see no warn() statements in sub authenticate. I see two warn()
> statements in sub days_since_last_password_change, but they are
> commented out.
>
> --
> Gunnar Hjalmarsson
> Email:http://www.gunnar.cc/cgi-bin/contact.pl
Thank you Gunnar.
Yes.
I add a warn in sub authenticate. But they are no value. they are like
warn ".......Bruce Bruce.....\n";
So, I paste the original source code.
^_^
Thank you very much again.
------------------------------
Date: Thu, 14 May 2009 14:42:10 -0700 (PDT)
From: smallpond <smallpond@juno.com>
Subject: Re: [confused about the warn]
Message-Id: <9fbf0519-b0a4-4612-ac32-1ca4e5d9077c@v17g2000vbb.googlegroups.com>
On May 14, 5:04 pm, childpsych.colum...@gmail.com wrote:
> On May 14, 4:36 pm, Gunnar Hjalmarsson <nore...@gunnar.cc> wrote:
>
>
>
> > childpsych.colum...@gmail.com wrote:
> > > On May 14, 3:10 pm, Gunnar Hjalmarsson <nore...@gunnar.cc> wrote:
> > >> childpsych.colum...@gmail.com wrote:
> > >>> I add warn in Staff.pm, but the warn information does NOT appear in
> > >>> the error_log.
>
> > >> Try to uncomment the lines with the warn() statements.
>
> > > I read the source code.
>
> > Thank you very much!
>
> > > I found that the login.masn call the Staff->authenticate.
> > > the code is as follows:
> > > my $staff_id = Clinic::Party::Staff->authenticate( $username,
> > > $pass );
>
> > > So, I goto lib/Clinic/Party/Staff.pm, there is a sub authenticate.
> > > I add a warn statement in the sub authenticate.
> > > But it seems that the warn information does not appear in the
> > > error_log.
>
> > I see no warn() statements in sub authenticate. I see two warn()
> > statements in sub days_since_last_password_change, but they are
> > commented out.
>
> > --
> > Gunnar Hjalmarsson
> > Email:http://www.gunnar.cc/cgi-bin/contact.pl
>
> Thank you Gunnar.
> Yes.
> I add a warn in sub authenticate. But they are no value. they are like
> warn ".......Bruce Bruce.....\n";
> So, I paste the original source code.
> ^_^
> Thank you very much again.
sub authenticate {
warn "It makes a difference\n";
my ( $self, $user, $pass ) = @_;
my $enc_pass = encrypt($pass);
my $staff = $self->fetch_one( { login => $user, password =>
$enc_pass } ) || '';
return unless $staff;
warn "where you put the warn statement.\n";
return if $staff->value('type')->raw_int == 663; # type:supervisor
return unless $staff->status; # active
return $staff->id;
warn "But we cannot read your mind.\n";
}
------------------------------
Date: Thu, 14 May 2009 16:07:32 -0700 (PDT)
From: childpsych.columbia@gmail.com
Subject: Re: [confused about the warn]
Message-Id: <443a0d8e-85e4-406e-8977-5bfe66d77e95@g20g2000vba.googlegroups.com>
On May 14, 5:42=A0pm, smallpond <smallp...@juno.com> wrote:
> On May 14, 5:04 pm, childpsych.colum...@gmail.com wrote:
>
>
>
> > On May 14, 4:36 pm, Gunnar Hjalmarsson <nore...@gunnar.cc> wrote:
>
> > > childpsych.colum...@gmail.com wrote:
> > > > On May 14, 3:10 pm, Gunnar Hjalmarsson <nore...@gunnar.cc> wrote:
> > > >> childpsych.colum...@gmail.com wrote:
> > > >>> =A0I add warn in Staff.pm, but the warn information does NOT appe=
ar in
> > > >>> the error_log.
>
> > > >> Try to uncomment the lines with the warn() statements.
>
> > > > I read the source code.
>
> > > Thank you very much!
>
> > > > I found that the login.masn call the Staff->authenticate.
> > > > =A0the code is as follows:
> > > > =A0my $staff_id =3D Clinic::Party::Staff->authenticate( $username,
> > > > $pass );
>
> > > > So, I goto lib/Clinic/Party/Staff.pm, there is a sub authenticate.
> > > > I add a warn statement in the sub authenticate.
> > > > But it seems that the warn information does not appear in the
> > > > error_log.
>
> > > I see no warn() statements in sub authenticate. I see two warn()
> > > statements in sub days_since_last_password_change, but they are
> > > commented out.
>
> > > --
> > > Gunnar Hjalmarsson
> > > Email:http://www.gunnar.cc/cgi-bin/contact.pl
>
> > Thank you Gunnar.
> > Yes.
> > I add a warn in sub authenticate. But they are no value. they are like
> > warn ".......Bruce Bruce.....\n";
> > So, I paste the original source code.
> > ^_^
> > Thank you very much again.
>
> sub authenticate {
>
> =A0 warn "It makes a difference\n";
>
> =A0 my ( $self, $user, $pass ) =3D @_;
> =A0 my $enc_pass =3D encrypt($pass);
> =A0 my $staff =3D $self->fetch_one( { login =3D> $user, password =3D>
> $enc_pass } ) || '';
> =A0 return unless $staff;
>
> =A0 warn "where you put the warn statement.\n";
>
> =A0 return if $staff->value('type')->raw_int =3D=3D 663; # type:superviso=
r
> =A0 return unless $staff->status; # active
> =A0 return $staff->id;
>
> =A0 warn "But we cannot read your mind.\n";
>
> }
>
>
Thank you very much!
I found the problem.
Everytime, I add the warn. I didn't restart the apache.
So the warn didn't appear.
Now, I restart the apache, the warn information appears.
WHY???
Perl is not like C. Why do I need to restart Apache? or Is there any
cache??
Best,
Bruce
Thank you again!
------------------------------
Date: Fri, 15 May 2009 01:22:34 +0200
From: Gunnar Hjalmarsson <noreply@gunnar.cc>
Subject: Re: [confused about the warn]
Message-Id: <773nduF1eu4noU1@mid.individual.net>
childpsych.columbia@gmail.com wrote:
> Everytime, I add the warn. I didn't restart the apache.
> So the warn didn't appear.
> Now, I restart the apache, the warn information appears.
> WHY???
> Perl is not like C. Why do I need to restart Apache?
One possible reason is that the program is run under mod_perl.
--
Gunnar Hjalmarsson
Email: http://www.gunnar.cc/cgi-bin/contact.pl
------------------------------
Date: Thu, 14 May 2009 16:33:35 -0700 (PDT)
From: childpsych.columbia@gmail.com
Subject: Re: [confused about the warn]
Message-Id: <fbfa2398-ee65-4042-9dce-eb9edf67899b@e20g2000vbc.googlegroups.com>
On May 14, 7:22=A0pm, Gunnar Hjalmarsson <nore...@gunnar.cc> wrote:
> childpsych.colum...@gmail.com wrote:
> > Everytime, I add the warn. I didn't restart the apache.
> > So the warn didn't appear.
> > Now, I restart the apache, the warn information appears.
> > WHY???
> > Perl is not like C. Why do I need to restart Apache?
>
> One possible reason is that the program is run under mod_perl.
>
> --
> Gunnar Hjalmarsson
> Email:http://www.gunnar.cc/cgi-bin/contact.pl
So, when I debug the source code. I need to restart apache if I make
any change? Is there a way to avoid this frequently restart apache?
------------------------------
Date: Fri, 15 May 2009 00:23:14 GMT
From: "A. Sinan Unur" <1usa@llenroc.ude.invalid>
Subject: Re: [confused about the warn]
Message-Id: <Xns9C0BCF6AFA8EEasu1cornelledu@127.0.0.1>
childpsych.columbia@gmail.com wrote in news:fbfa2398-ee65-4042-9dce-
eb9edf67899b@e20g2000vbc.googlegroups.com:
> On May 14, 7:22 pm, Gunnar Hjalmarsson <nore...@gunnar.cc> wrote:
>> childpsych.colum...@gmail.com wrote:
>> > Everytime, I add the warn. I didn't restart the apache.
>> > So the warn didn't appear.
>> > Now, I restart the apache, the warn information appears.
>> > WHY???
>> > Perl is not like C. Why do I need to restart Apache?
>>
>> One possible reason is that the program is run under mod_perl.
[ don't quote sigs ]
>
> So, when I debug the source code. I need to restart apache if I make
> any change? Is there a way to avoid this frequently restart apache?
Well, why, yes there is:
http://perl.apache.org/docs/2.0/api/Apache2/Reload.html
Please read the posting guidelines for this group. Please put some
effort into composing your posts.
Sinan
--
A. Sinan Unur <1usa@llenroc.ude.invalid>
(remove .invalid and reverse each component for email address)
comp.lang.perl.misc guidelines on the WWW:
http://www.rehabitation.com/clpmisc/
------------------------------
Date: Fri, 15 May 2009 02:24:02 +0200
From: Gunnar Hjalmarsson <noreply@gunnar.cc>
Subject: Re: [confused about the warn]
Message-Id: <773r16F1f5au4U1@mid.individual.net>
childpsych.columbia@gmail.com wrote:
> On May 14, 7:22 pm, Gunnar Hjalmarsson <nore...@gunnar.cc> wrote:
>> childpsych.colum...@gmail.com wrote:
>>> Why do I need to restart Apache?
>>
>> One possible reason is that the program is run under mod_perl.
>
> So, when I debug the source code. I need to restart apache if I make
> any change?
It was you who said it, so you don't need to ask, do you?
> Is there a way to avoid this frequently restart apache?
Assuming mod_perl (which is just my theory) this might help:
http://perl.apache.org/docs/2.0/api/Apache2/Reload.html
--
Gunnar Hjalmarsson
Email: http://www.gunnar.cc/cgi-bin/contact.pl
------------------------------
Date: Thu, 14 May 2009 18:07:08 -0700 (PDT)
From: childpsych.columbia@gmail.com
Subject: Re: [confused about the warn]
Message-Id: <69317818-321b-405f-9680-f68bea8ffff7@j12g2000vbl.googlegroups.com>
On 14 May, 20:23, "A. Sinan Unur" <1...@llenroc.ude.invalid> wrote:
> childpsych.colum...@gmail.com wrote in news:fbfa2398-ee65-4042-9dce-
> eb9edf678...@e20g2000vbc.googlegroups.com:
>
> > On May 14, 7:22=A0pm, Gunnar Hjalmarsson <nore...@gunnar.cc> wrote:
> >> childpsych.colum...@gmail.com wrote:
> >> > Everytime, I add the warn. I didn't restart the apache.
> >> > So the warn didn't appear.
> >> > Now, I restart the apache, the warn information appears.
> >> > WHY???
> >> > Perl is not like C. Why do I need to restart Apache?
>
> >> One possible reason is that the program is run under mod_perl.
>
> [ don't quote sigs ]
>
>
>
> > So, when I debug the source code. I need to restart apache if I make
> > any change? Is there a way to avoid this frequently restart apache?
>
> Well, why, yes there is:
>
> http://perl.apache.org/docs/2.0/api/Apache2/Reload.html
>
> Please read the posting guidelines for this group. Please put some
> effort into composing your posts.
>
> Sinan
>
> --
> A. Sinan Unur <1...@llenroc.ude.invalid>
> (remove .invalid and reverse each component for email address)
>
> comp.lang.perl.misc guidelines on the WWW:http://www.rehabitation.com/clp=
misc/
Thank you.
I will read it.
------------------------------
Date: Thu, 14 May 2009 18:08:26 -0700 (PDT)
From: childpsych.columbia@gmail.com
Subject: Re: [confused about the warn]
Message-Id: <64c50304-d770-4c18-b73e-615158dd741e@n8g2000vbb.googlegroups.com>
On 14 May, 20:24, Gunnar Hjalmarsson <nore...@gunnar.cc> wrote:
> childpsych.colum...@gmail.com wrote:
> > On May 14, 7:22 pm, Gunnar Hjalmarsson <nore...@gunnar.cc> wrote:
> >> childpsych.colum...@gmail.com wrote:
> >>> Why do I need to restart Apache?
>
> >> One possible reason is that the program is run under mod_perl.
>
> > So, when I debug the source code. I need to restart apache if I make
> > any change?
>
> It was you who said it, so you don't need to ask, do you?
>
> > Is there a way to avoid this frequently restart apache?
>
> Assuming mod_perl (which is just my theory) this might help:http://perl.apache.org/docs/2.0/api/Apache2/Reload.html
>
> --
> Gunnar Hjalmarsson
> Email:http://www.gunnar.cc/cgi-bin/contact.pl
Thank you very much.
From today, Perl will be my main working language. ^_^.
Thanks again.
------------------------------
Date: Thu, 14 May 2009 18:38:58 -0700
From: Franken Sense <frank@example.invalid>
Subject: comma operator
Message-Id: <112g3mppmfgb$.sxrcsd9lhptf$.dlg@40tude.net>
I'm reading up on perl today and find this in perldoc perlop:
Comma Operator
Binary "," is the comma operator. In scalar context it evaluates its
left argument, throws that value away, then evaluates its right
argument
and returns that value. This is just like C's comma operator.
// end excerpt
What is C's comma operator?
--
Frank
Whining is anger through a small opening.
~~ Al Franken
------------------------------
Date: Thu, 14 May 2009 19:02:55 -0700
From: Franken Sense <frank@example.invalid>
Subject: Re: comma operator
Message-Id: <rhq9dj26je3w.16vnrt41gesoz.dlg@40tude.net>
In Dread Ink, the Grave Hand of Franken Sense Did Inscribe:
[misposted to clp.misc]
[x-posted to clc; f-up set to clc]
> I'm reading up on perl today and find this in perldoc perlop:
>
> Comma Operator
>
> Binary "," is the comma operator. In scalar context it evaluates its
> left argument, throws that value away, then evaluates its right
> argument
> and returns that value. This is just like C's comma operator.
>
> // end excerpt
>
> What is C's comma operator?
--
Frank
My father grew up in the Great Depression - his mother's.
~~ Al Franken
------------------------------
Date: Thu, 14 May 2009 18:01:25 -0700
From: Franken Sense <frank@example.invalid>
Subject: Re: FAQ 7.14 What is variable suicide and how can I prevent it?
Message-Id: <b9wqb4ghbmfj.m55t81go4cl5$.dlg@40tude.net>
In Dread Ink, the Grave Hand of PerlFAQ Server Did Inscribe:
> This is an excerpt from the latest version perlfaq7.pod, which
> comes with the standard Perl distribution. These postings aim to
> reduce the number of repeated questions as well as allow the community
> to review and update the answers. The latest version of the complete
> perlfaq is at http://faq.perl.org .
>
> --------------------------------------------------------------------
>
> 7.14: What is variable suicide and how can I prevent it?
>
> This problem was fixed in perl 5.004_05, so preventing it means
> upgrading your version of perl. ;)
>
> Variable suicide is when you (temporarily or permanently) lose the value
> of a variable. It is caused by scoping through my() and local()
> interacting with either closures or aliased foreach() iterator variables
> and subroutine arguments. It used to be easy to inadvertently lose a
> variable's value this way, but now it's much harder. Take this code:
>
> my $f = 'foo';
> sub T {
> while ($i++ < 3) { my $f = $f; $f .= "bar"; print $f, "\n" }
> }
>
> T;
> print "Finally $f\n";
>
> If you are experiencing variable suicide, that "my $f" in the subroutine
> doesn't pick up a fresh copy of the $f whose value is <foo>. The output
> shows that inside the subroutine the value of $f leaks through when it
> shouldn't, as in this output:
>
> foobar
> foobarbar
> foobarbarbar
> Finally foo
>
> The $f that has "bar" added to it three times should be a new $f "my $f"
> should create a new lexical variable each time through the loop. The
> expected output is:
>
> foobar
> foobar
> foobar
> Finally foo
>
>
>
> --------------------------------------------------------------------
>
> The perlfaq-workers, a group of volunteers, maintain the perlfaq. They
> are not necessarily experts in every domain where Perl might show up,
> so please include as much information as possible and relevant in any
> corrections. The perlfaq-workers also don't have access to every
> operating system or platform, so please include relevant details for
> corrections to examples that do not work on particular platforms.
> Working code is greatly appreciated.
>
> If you'd like to help maintain the perlfaq, see the details in
> perlfaq.pod.
Does it bother perl to hit the same variable in a loop when scoped as my?
while ( <$hh> )
{
my @s = split /\s+/, $_;
my $verse = $s[0];
my $script = join(' ', @s[1..$#s]);
$Scripts{$verse} = $script;
}
--
Frank
If you put the two Bushs together in their over seven years of their two
presidencies, not one new job has been created. Numbers do not lie. If you
extrapolated from that, if the Bushs had run this country from its very
beginning to the current time, not one American would have ever worked.
We'd be hunter-gatherers.
~~ Al Franken, in response to the 2004 SOTU address
------------------------------
Date: Fri, 15 May 2009 00:26:11 GMT
From: "A. Sinan Unur" <1usa@llenroc.ude.invalid>
Subject: Re: How to replace c:\Program Files with Program Files (x86) in all scripts?
Message-Id: <Xns9C0BCFEABF79Dasu1cornelledu@127.0.0.1>
Gunnar Hjalmarsson <noreply@gunnar.cc> wrote in
news:7737h9F1e46lpU1@mid.individual.net:
> clearguy02@yahoo.com wrote:
>> I have a parent folder, C:\Test and it has a few sub-folders (and its
>> files) and files and I am now forced to do the following change in
>> all files starting from its parent folder, c:\Test
>>
>> To replace a string, "c:\\program files\" or "c:\PROGRA~1" with "C:\
>> \Program Files (x86)" in all files.
>
> Why would you need to do that? I thought that Windows was not case
> sensitive.
I am not sure but I don't think this about case sensitivity. I think he
hard coded the location of Program Files and now the program needs to be
run on 64 bit Windows and he wants to continue with hard-coding this
kind of information.
Well, good luck if the OPs application ever needs to be run on a
non-English version of Windows.
Sinan
--
A. Sinan Unur <1usa@llenroc.ude.invalid>
(remove .invalid and reverse each component for email address)
comp.lang.perl.misc guidelines on the WWW:
http://www.rehabitation.com/clpmisc/
------------------------------
Date: Thu, 14 May 2009 19:33:09 -0500
From: l v <veatchla@yahoo.com>
Subject: Re: How to replace c:\Program Files with Program Files (x86) in all scripts?
Message-Id: <15idnbWjgLvbJZHXnZ2dnUVZ_t2dnZ2d@supernews.com>
clearguy02@yahoo.com wrote:
> On May 13, 7:36 pm, l v <veatc...@yahoo.com> wrote:
>> cleargu...@yahoo.com wrote:
>>> Hi experts,
>>> I have a parent folder, C:\Test and it has a few sub-folders (and its
>>> files) and files and I am now forced to do the following change in all
>>> files starting from its parent folder, c:\Test
>>> To replace a string, "c:\\program files\" or "c:\PROGRA~1" with "C:\
>>> \Program Files (x86)" in all files.
>>> Here is some thing I am trying with:
>>> C:\>perl -i.bak -pe "s/Progra~1/Program Files (x86)/g" `find "C:\
>>> \Test" -type f -name "*.pl" `
>>> Error is:
>>> Can't open `find: No such file or directory.
>>> Can't do inplace edit: C:\\Test is not a regular file.
>>> Can't open -type: No such file or directory.
>>> Can't open f: No such file or directory.
>>> Can't open -name: No such file or directory.
>>> Can't open *.pl`: Invalid argument.
>>> When I run the find command (find C:\Test -type f -name "*.pl" ), it
>>> is returning the correct set of files, but it not working with the
>>> perl commandline.
>>> Where am I doing wrong?
>>> --J
>> Assuming windows. Try the following on a single line.
>>
>> for %F in (*.pl) do perl -i.bak -pe "s/Progra~1/Program Files (x86)/g" "%F"
>>
>> --
>>
>> Len
>
> It looks goods Len.. thanks a bunch. But what if I have to address a
> few sub-folders within c:\TEST folder?
run for /? for the documentation. for /R %F .... will walk the directory.
--
Len
------------------------------
Date: Thu, 14 May 2009 17:28:50 -0700
From: Franken Sense <frank@example.invalid>
Subject: Re: writing get_script as an external routine callable by C
Message-Id: <1jedfa8hweew9$.1hgcguek6e4qg.dlg@40tude.net>
In Dread Ink, the Grave Hand of Jürgen Exner Did Inscribe:
> Ben Morrow <ben@morrow.me.uk> wrote:
>> In any case, you will want to assign the
>>provided key and value to different variables, and then insert them into
>>the hash: assigning to a hash like that replaces everything in it.
I don't quite understand this last sentence.
>
> Another good catch! So do a
> $options{$verse} = $script;
> instead of that sub call.
>
> jue
Ok, so far so good. Here's what this looks like now:
#!/usr/bin/perl
# perl bb6.pl
use warnings;
use strict;
# open input files
my $filename = 'book1.txt';
open(my $fh, '<', $filename) or
die "cannot open $filename for reading: $!";
my $filename3 = 'ot5.txt';
open(my $hh, '<', $filename3) or
die "cannot open $filename3 for reading: $!";
# open output file
my $filename2 = 'outfile16.txt';
open(my $gh, '>', $filename2) or
die "cannot open $filename2 for writing: $!";
my @books;
my %Scripts;
my %comments;
@books = <$fh>;
chomp @books;
print "@books\n";
local $/="";
while ( <$hh> )
{
my @s = split /\s+/, $_;
my $verse = $s[0];
my $script = join(' ', @s[1..$#s]);
$Scripts{$verse} = $script;
}
print %Scripts;
my @keys = keys %Scripts;
print @keys;
# close input and output files
close($hh) or die("Error closing $filename3: $!");
close($gh) or die("Error closing $filename2: $!");
close($fh) or die("Error closing $filename: $!");
Abridged output:
Book of Psalms Book of Proverbs Ecclesiastes Solomon's Canticle of
Canticles Book of Wisdom Ecclesiasticus Prophecy of Isaias Prophecy
of Jeremias Lamentations of Jeremias Prophecy of Baruch Prophecy of
...
My son, sow not evils in the furrows of injustice, and thou shalt not reap
them sevenfold.Whofirst hath perfect knowledge of her. . .Christ was the
first that had perfect knowledge of heavenly wisdom.50:8.And as the rainbow
giving light in bright clouds, and as the flower of roses in the days of
the spring, and as the lilies that are on the brink of the water, and as
the sweet smelling frankincense in the time of summer.39:21.All the works
of the Lord are exceeding good.4:11.And thou shalt be as the obedient son
of the most High, and he will have mercy on thee more than a mother.29:25.A
sinner that transgresseth the commandment of the Lord, shall fall into an
...
49:7.16:11.It46:14.46:2.30:13.38:30.26:6.25:17.8:20.
4:19.9:19.51:28.38:32.35:17.9:20.23:34.25:25.40:23.25:1
.38:6.25:12.15:1.1:26.23:13.2:5.12:19.10:4.20:19.18:1.19:
8.49:12.14:10.21:26.3:26.Jesus3:31.10:11.34:19.34:18.21:1
4.11:13.7:33.1:9.24:23.31:15.46:9.12:18.3:8.23:1.24:20.4:
4.15:3.25:14.20:22.17:30.41:1.40:6.50:2.1:17.God's2:15.32:
19.26:27.15:20.26:22.38:27.45:17.24:7.6:20.26:23.13:16.47:
4.4:3.30:5.11:25.Wise24:32.16:24.38:21.3:30.45:20.40:4.33:
It appears true that a hash is not ordered like a binary tree.
Where I'm hung up now is in creating a control that separates comments from
scriptures. Scriptures begin with numbers, comments don't. So I was
poking around for a function like isdigit and couldn't find anything.
If comments are to be a hash, then they need something to key on, and all
that comes to mind is the natural numbers. Here's what the pseudosource
looks like:
$my $counter = 0;
while ( <$hh> )
{
my @s = split /\s+/, $_;
if (s[0] is a number)
my $verse = $s[0];
my $script = join(' ', @s[1..$#s]);
$Scripts{$verse} = $script;
else
$counter++;
my $comment = join(' ', @s);
%comments($counter) = $comment;
}
Fishing for tips. I like Ecclesiastes and the sad jews in general like
Janeane Garafalo, Al Franken and Jon Stewart.
--
Frank
My father grew up in the Great Depression - his mother's.
~~ Al Franken
------------------------------
Date: Thu, 14 May 2009 17:30:15 -0700
From: Franken Sense <frank@example.invalid>
Subject: Re: writing get_script as an external routine callable by C
Message-Id: <2fsocore0qp6$.1nczr77z2wnw1$.dlg@40tude.net>
In Dread Ink, the Grave Hand of Uri Guttman Did Inscribe:
>>>>>> "BM" == Ben Morrow <ben@morrow.me.uk> writes:
>
> >> my $filename = 'book1.txt';
> >> open(my $fh, '<', $filename) or
> >> die "cannot open $filename for reading: $!";
> >> my @books;
>
> BM> chomp( my @books = <$fh> );
>
> BM> If you prefer, you can expand that to three statements:
>
> BM> my @books;
> BM> @books = <$fh>;
> BM> chomp @books;
>
> BM> You can also use File::Slurp::read_file, which will handle opening the
> BM> file, chomping the lines and closing the file for you.
>
> read_file doesn't (yet) chomp lines. that option is in the todo
> list. but it does make it easier to read in a file as lines. this should
> work fine:
>
> use File::Slurp ;
> chomp( my @books = read_file( $file_name ) ) ;
>
> uri
C:\MinGW\source>perldoc File::Slurp
No documentation found for "File::Slurp".
C:\MinGW\source>
--
Frank
...................... o _______________ _,
` Good Morning! , /\_ _| | .-'_|
`................, _\__`[_______________| _| (_|
] [ \, ][ ][ (_|
------------------------------
Date: Thu, 14 May 2009 17:35:10 -0700
From: Jürgen Exner <jurgenex@hotmail.com>
Subject: Re: writing get_script as an external routine callable by C
Message-Id: <l3ep0595g0f70uoh489bd0if3i7g63uo8r@4ax.com>
Franken Sense <frank@example.invalid> wrote:
>Where I'm hung up now is in creating a control that separates comments from
>scriptures. Scriptures begin with numbers, comments don't. So I was
>poking around for a function like isdigit and couldn't find anything.
perldoc -q number:
How do I determine whether a scalar is a number/whole/integer/float?
jue
------------------------------
Date: Thu, 14 May 2009 18:53:54 -0700
From: Franken Sense <frank@example.invalid>
Subject: Re: writing get_script as an external routine callable by C
Message-Id: <10mkcjax9vbgc.1um67kayd6qkn$.dlg@40tude.net>
In Dread Ink, the Grave Hand of Jürgen Exner Did Inscribe:
> Franken Sense <frank@example.invalid> wrote:
>>Where I'm hung up now is in creating a control that separates comments from
>>scriptures. Scriptures begin with numbers, comments don't. So I was
>>poking around for a function like isdigit and couldn't find anything.
>
> perldoc -q number:
> How do I determine whether a scalar is a number/whole/integer/float?
>
> jue
How do I determine whether a scalar is a number/whole/integer/float?
Assuming that you don't care about IEEE notations like "NaN" or
"Infinity", you probably just want to use a regular expression.
if (/\D/) { print "has nondigits\n" }
if (/^\d+$/) { print "is a whole number\n" }
if (/^-?\d+$/) { print "is an integer\n" }
if (/^[+-]?\d+$/) { print "is a +/- integer\n" }
if (/^-?\d+\.?\d*$/) { print "is a real number\n" }
if (/^-?(?:\d+(?:\.\d*)?|\.\d+)$/) { print "is a decimal number\n" }
if (/^([+-]?)(?=\d|\.\d)\d*(\.\d*)?([Ee]([+-]?\d+))?$/)
{ print "a C float\n" }
So, I want to test whether the first byte is a digit. I think this is
/\d/. The sad thing is that I can't even put it together at this point.
I have @s populated in paragraph mode and then split. How does the test
condition look with these two: s[0] /\d/ ?
$my $counter = 0;
while ( <$hh> )
{
my @s = split /\s+/, $_;
if (s[0] is a number)
my $verse = $s[0];
my $script = join(' ', @s[1..$#s]);
$Scripts{$verse} = $script;
else
$counter++;
my $comment = join(' ', @s);
%comments($counter) = $comment;
}
--
Frank
My father grew up in the Great Depression - his mother's.
~~ Al Franken
------------------------------
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 V11 Issue 2417
***************************************