[31173] in Perl-Users-Digest

home help back first fref pref prev next nref lref last post

Perl-Users Digest, Issue: 2418 Volume: 11

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Fri May 15 03:09:50 2009

Date: Fri, 15 May 2009 00:09:11 -0700 (PDT)
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)

Perl-Users Digest           Fri, 15 May 2009     Volume: 11 Number: 2418

Today's topics:
    Re: comma operator <tadmc@seesig.invalid>
    Re: FAQ 7.14 What is variable suicide and how can I pre <ben@morrow.me.uk>
    Re: How to replace c:\Program Files with Program Files  <ben@morrow.me.uk>
    Re: Launching 2 background processes with fork - how to <derykus@gmail.com>
    Re: Launching 2 background processes with fork - how to <xhoster@gmail.com>
        new CPAN modules on Fri May 15 2009 (Randal Schwartz)
    Re: s/(The N)e(urdsburg Affair)/$1$2/ looks dumb <nat.k@gm.ml>
    Re: writing get_script as an external routine callable  <uri@PerlOnCall.com>
    Re: writing get_script as an external routine callable  <jurgenex@hotmail.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  <uri@PerlOnCall.com>
    Re: writing get_script as an external routine callable  <tadmc@seesig.invalid>
    Re: writing get_script as an external routine callable  <tadmc@seesig.invalid>
    Re: writing get_script as an external routine callable  <jurgenex@hotmail.com>
        Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)

----------------------------------------------------------------------

Date: Thu, 14 May 2009 23:16:48 -0500
From: Tad J McClellan <tadmc@seesig.invalid>
Subject: Re: comma operator
Message-Id: <slrnh0pr5g.49b.tadmc@tadmc30.sbcglobal.net>

Franken Sense <frank@example.invalid> wrote:
>   
> 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?


It is an operator that evaluates its left argument, throws that value 
away, then evaluates its right argument and returns that value.

It is just like Perl's comma operator.


-- 
Tad McClellan
email: perl -le "print scalar reverse qq/moc.noitatibaher\100cmdat/"


------------------------------

Date: Fri, 15 May 2009 04:13:09 +0100
From: Ben Morrow <ben@morrow.me.uk>
Subject: Re: FAQ 7.14 What is variable suicide and how can I prevent it?
Message-Id: <573vd6-ro5.ln1@osiris.mauzo.dyndns.org>


Quoth frank@example.invalid:
> In Dread Ink, the Grave Hand of PerlFAQ Server Did Inscribe:
> 
> > 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. ;)
<snip>
> 
> Does it bother perl to hit the same variable in a loop when scoped as my?

As the FAQ says, this problem no longer applies to any current version
of perl.

Perhaps this FAQ could be retired?

Ben



------------------------------

Date: Fri, 15 May 2009 04:07:49 +0100
From: Ben Morrow <ben@morrow.me.uk>
Subject: Re: How to replace c:\Program Files with Program Files (x86) in all    scripts?
Message-Id: <5t2vd6-ro5.ln1@osiris.mauzo.dyndns.org>


Quoth "A. Sinan Unur" <1usa@llenroc.ude.invalid>:
> 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. 

For reference, the correct way to get the path of the Program Files
directory is to call Win32::GetFolderPath with CSIDL_PROGRAM_FILES. To
get the path of the x86 Program Files directory on 64bit windows, you
need
    
    use constant CSIDL_PROGRAM_FILESX86 => 0x002a;

since Win32 doesn't currently supply this constant.

Ben



------------------------------

Date: Thu, 14 May 2009 21:35:58 -0700 (PDT)
From: CDeRykus <derykus@gmail.com>
Subject: Re: Launching 2 background processes with fork - how to make wait()  work?
Message-Id: <46301534-75fb-45ce-83b4-25f44d3c9936@d19g2000prh.googlegroups.com>

On May 14, 7:51=A0pm, Xho Jingleheimerschmidt <xhos...@gmail.com> wrote:
> dery...@gmail.com wrote:
> > As mentioned briefly in one of the responses, you can also wait-block
> > on those 2 specific pids:
>
> > waitpid($proc1_pid, 0); # perldoc -f waitpid
> > waitpid($proc2_pid, 0);
>
> > However, you'll usually want to use the non-
> > blocking WNOHANG to reap them asynchronously.
>
> Since he has nothing useful to do until both finish, what would be the
> point of WNOHANG? =A0Seems like it would just burn CPU faster.
>

Agreed, that's the case here.  I was just
suggesting WNOHANG is usually the idiom in
other scenarios with more than one kid if
you could be doing something else.

Seems like even here though, async might be
an advantage if the parent needs all kids to
succeed in order to continue.  That is, if
there's a kid failure, async would be more
likely to catch it early so the parent could
abort. Of course, if the blocking wait's do
happen to target the failing kid early in the
coding, there'd be no advantage.


--
Charles DeRykus


------------------------------

Date: Thu, 14 May 2009 19:51:49 -0700
From: Xho Jingleheimerschmidt <xhoster@gmail.com>
Subject: Re: Launching 2 background processes with fork - how to make wait() work?
Message-Id: <4a0cd944$1$19978$ed362ca5@nr5-q3a.newsreader.com>

derykus@gmail.com wrote:

> As mentioned briefly in one of the responses, you can also wait-block
> on those 2 specific pids:
> 
> waitpid($proc1_pid, 0); # perldoc -f waitpid
> waitpid($proc2_pid, 0);
> 
> However, you'll usually want to use the non-
> blocking WNOHANG to reap them asynchronously.

Since he has nothing useful to do until both finish, what would be the 
point of WNOHANG?  Seems like it would just burn CPU faster.


Xho


------------------------------

Date: Fri, 15 May 2009 04:42:35 GMT
From: merlyn@stonehenge.com (Randal Schwartz)
Subject: new CPAN modules on Fri May 15 2009
Message-Id: <KJo52z.1EuL@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.

Acme-PM-Paris-Meetings-200905.02
http://search.cpan.org/~dolmen/Acme-PM-Paris-Meetings-200905.02/
Get the date/time of the next Paris.pm meeting! 
----
AnyEvent-4.41
http://search.cpan.org/~mlehmann/AnyEvent-4.41/
provide framework for multiple event loops 
----
Apache2-ASP-2.37_01
http://search.cpan.org/~johnd/Apache2-ASP-2.37_01/
ASP for Perl, reloaded. 
----
Apache2-ASP-2.37_02
http://search.cpan.org/~johnd/Apache2-ASP-2.37_02/
ASP for Perl, reloaded. 
----
Apache2-AuthCookieDBI-2.05
http://search.cpan.org/~matisse/Apache2-AuthCookieDBI-2.05/
An AuthCookie module backed by a DBI database. 
----
Bot-WootOff-0.01
http://search.cpan.org/~mschilli/Bot-WootOff-0.01/
Poll woot.com during a woot-off and notify via IRC 
----
CHI-0.22
http://search.cpan.org/~jswartz/CHI-0.22/
Unified cache interface 
----
Catalyst-Authentication-Credential-HTTP-1.010
http://search.cpan.org/~dhoss/Catalyst-Authentication-Credential-HTTP-1.010/
HTTP Basic and Digest authentication for Catalyst. 
----
Catalyst-Controller-Resources-0.05
http://search.cpan.org/~masaki/Catalyst-Controller-Resources-0.05/
Catalyst Collection Resources Controller 
----
Catalyst-Controller-Resources-0.06
http://search.cpan.org/~masaki/Catalyst-Controller-Resources-0.06/
Catalyst Collection Resources Controller 
----
Config-JFDI-0.05_2
http://search.cpan.org/~rkrimen/Config-JFDI-0.05_2/
Just * Do it: A Catalyst::Plugin::ConfigLoader-style layer over Config::Any 
----
Data-Pond-0.000
http://search.cpan.org/~zefram/Data-Pond-0.000/
Perl-based open notation for data 
----
Devel-Optrace-0.01
http://search.cpan.org/~gfuji/Devel-Optrace-0.01/
Traces opcodes which are running now 
----
Devel-Refcount-0.05
http://search.cpan.org/~pevans/Devel-Refcount-0.05/
obtain the REFCNT value of a referent 
----
Devel-StringInfo-0.04
http://search.cpan.org/~nuffin/Devel-StringInfo-0.04/
Gather information about strings 
----
Device-CableModem-Motorola-SB4200-0.10
http://search.cpan.org/~burak/Device-CableModem-Motorola-SB4200-0.10/
Interface to Motorola SurfBoard 4200 Cable Modem 
----
Dist-Zilla-Plugin-Repository-0.08
http://search.cpan.org/~fayland/Dist-Zilla-Plugin-Repository-0.08/
Automatically sets repository URL from svn/svk/Git checkout for Dist::Zilla 
----
Fey-0.28
http://search.cpan.org/~drolsky/Fey-0.28/
Better SQL Generation Through Perl 
----
File-ChangeNotify-0.04
http://search.cpan.org/~drolsky/File-ChangeNotify-0.04/
Watch for changes to files, cross-platform style 
----
Lux-IO-0.07
http://search.cpan.org/~kentaro/Lux-IO-0.07/
A Perl Interface to Lux IO 
----
Math-Decimal-0.001
http://search.cpan.org/~zefram/Math-Decimal-0.001/
arithmetic in decimal 
----
Math-Primality-0.01
http://search.cpan.org/~leto/Math-Primality-0.01/
Various Primality Algorithms 
----
Method-Cumulative-0.01
http://search.cpan.org/~gfuji/Method-Cumulative-0.01/
Accumulates the effect of methods in a class hierarchy 
----
Module-Install-GithubMeta-0.04
http://search.cpan.org/~bingos/Module-Install-GithubMeta-0.04/
A Module::Install extension to include GitHub meta information in META.yml 
----
Module-Install-GithubMeta-0.06
http://search.cpan.org/~bingos/Module-Install-GithubMeta-0.06/
A Module::Install extension to include GitHub meta information in META.yml 
----
Muldis-D-0.71.0
http://search.cpan.org/~duncand/Muldis-D-0.71.0/
Formal spec of Muldis D relational DBMS lang 
----
Nagios-Plugin-OverHTTP-0.04
http://search.cpan.org/~dougdude/Nagios-Plugin-OverHTTP-0.04/
Nagios plugin to check over the HTTP protocol. 
----
Nagios-Plugin-OverHTTP-0.05
http://search.cpan.org/~dougdude/Nagios-Plugin-OverHTTP-0.05/
Nagios plugin to check over the HTTP protocol. 
----
Net-Axigen-0.11
http://search.cpan.org/~itmfrolov/Net-Axigen-0.11/
Perl extension for Gecad Technologies Axigen Mail Server (www.axigen.com). This module use Axigen CLI interface. 
----
Net-GitHub-0.13
http://search.cpan.org/~fayland/Net-GitHub-0.13/
Perl Interface for github.com 
----
Net-GitHub-0.14
http://search.cpan.org/~fayland/Net-GitHub-0.14/
Perl Interface for github.com 
----
Net-Google-Code-0.05
http://search.cpan.org/~sunnavy/Net-Google-Code-0.05/
a simple client library for google code 
----
Net-Twitter-OAuth-0.01
http://search.cpan.org/~miyagawa/Net-Twitter-OAuth-0.01/
Net::Twitter subclass that uses OAuth instead of Basic Auth 
----
Net-Twitter-OAuth-0.02
http://search.cpan.org/~miyagawa/Net-Twitter-OAuth-0.02/
Net::Twitter subclass that uses OAuth instead of Basic Auth 
----
OP-0.212
http://search.cpan.org/~aayars/OP-0.212/
Compact Perl 5 class prototyping with object persistence 
----
PAR-Repository-Query-0.14
http://search.cpan.org/~smueller/PAR-Repository-Query-0.14/
Implements repository queries 
----
POE-Component-Client-HTTPDeferred-0.02
http://search.cpan.org/~typester/POE-Component-Client-HTTPDeferred-0.02/
Yet another poco http client with twist like deferred interface. 
----
Parse-MediaWikiDump-0.91
http://search.cpan.org/~triddle/Parse-MediaWikiDump-0.91/
Tools to process MediaWiki dump files 
----
Parse-Stallion-0.83
http://search.cpan.org/~arthur/Parse-Stallion-0.83/
EBNF based regexp backtracking parser and tree evaluator. 
----
Path-Extended-0.12
http://search.cpan.org/~ishigaki/Path-Extended-0.12/
yet another Path class 
----
Pod-Coverage-Moose-0.02
http://search.cpan.org/~drolsky/Pod-Coverage-Moose-0.02/
Pod::Coverage extension for Moose 
----
RDR-Collector-0.071
http://search.cpan.org/~shamrock/RDR-Collector-0.071/
Collect RDRv1 packets 
----
Rose-DBx-Object-Renderer-0.49
http://search.cpan.org/~danny/Rose-DBx-Object-Renderer-0.49/
Web UI Rendering for Rose::DB::Object 
----
Sub-Curried-0.10
http://search.cpan.org/~osfameron/Sub-Curried-0.10/
automatically curried subroutines 
----
Task-Kensho-0.09
http://search.cpan.org/~perigrin/Task-Kensho-0.09/
A Glimpse at an Enlightened Perl 
----
Test-Aggregate-0.35_03
http://search.cpan.org/~ovid/Test-Aggregate-0.35_03/
Aggregate *.t tests to make them run faster. 
----
Test-Command-0.08
http://search.cpan.org/~danboo/Test-Command-0.08/
Test routines for external commands 
----
Test-Output-0.15_01
http://search.cpan.org/~jlholt/Test-Output-0.15_01/
Utilities to test STDOUT and STDERR messages. 
----
Tree-Family-0.01
http://search.cpan.org/~bduggan/Tree-Family-0.01/
Represent and visualize a family tree. 
----
WWW-Contact-0.24
http://search.cpan.org/~fayland/WWW-Contact-0.24/
Get contacts/addressbook from Web 
----
XML-Descent-1.02
http://search.cpan.org/~andya/XML-Descent-1.02/
Recursive descent XML parsing 
----
Yahoo-Marketing-5.04
http://search.cpan.org/~shenj/Yahoo-Marketing-5.04/
an interface for Yahoo! Search Marketing's Web Services. 
----
Yahoo-Marketing-APT-2.02
http://search.cpan.org/~shenj/Yahoo-Marketing-APT-2.02/
an interface for Yahoo! Search Marketing's APT Web Services. 


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/>
Smalltalk/Perl/Unix consulting, Technical writing, Comedy, etc. etc.
See http://methodsandmessages.vox.com/ for Smalltalk and Seaside discussion


------------------------------

Date: Thu, 14 May 2009 20:34:08 -0700
From: Nathan Keel <nat.k@gm.ml>
Subject: Re: s/(The N)e(urdsburg Affair)/$1$2/ looks dumb
Message-Id: <Qo5Pl.29419$BZ3.12715@newsfe12.iad>

jidanni@jidanni.org wrote:

> Sure I can do
> s/(The N)e(urdsburg Affair)/$1$2/;
> but something tells me that there ought to be a smarter looking way to
> get the same functionality. Something like
> s/The N(e)urdsburg Affair/... but what?

Why would you capture (e) and not use it?

Just

s/The Neurdsburg Affair/The Nurdsburg Affair/

Or whatever makes the best sense, if that's how you really want to do
it.


------------------------------

Date: Thu, 14 May 2009 21:10:42 -0400
From: "Uri Guttman" <uri@PerlOnCall.com>
Subject: Re: writing get_script as an external routine callable by C
Message-Id: <87ab5fb27h.fsf@quad.sysarch.com>

>>>>> "FS" == Franken Sense <frank@example.invalid> writes:

  FS> C:\MinGW\source>perldoc File::Slurp
  FS> No documentation found for "File::Slurp".

duh! you install it from cpan!

uri

-- 
Uri Guttman  ------  uri@stemsystems.com  --------  http://www.sysarch.com --
-----  Perl Code Review , Architecture, Development, Training, Support ------
--------- Free Perl Training --- http://perlhunter.com/college.html ---------
---------  Gourmet Hot Cocoa Mix  ----  http://bestfriendscocoa.com ---------


------------------------------

Date: Thu, 14 May 2009 20:00:55 -0700
From: Jürgen Exner <jurgenex@hotmail.com>
Subject: Re: writing get_script as an external routine callable by C
Message-Id: <iblp0517u703smp9vfba46ru6e75muqfkm@4ax.com>

Franken Sense <frank@example.invalid> wrote:

Ok, here comes your last fish. 
I _STRONGLY_ suggest to attend a Perl class or a self-study course where
you can learn the fundamentals of Perl in a structured and comprehensive
way instead of digging for random bits and pieces while trying to
implement some program.

>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?
>
>  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
[...]

Yeah, I know the answer to that FAQ, there is no need to quote
paragraphs and paragraphs of it.

>So, I want to test whether the first byte is a digit.  

No, you probably don't. In all likelyhood you want to check if the first
character is a digit. Characters and bytes can be very different things.
 
>I think this is
>/\d/.  The sad thing is that I can't even put it together at this point.

That's why I strongly recommend a more structured approach to your
learning endeavour.

>I have @s populated in paragraph mode and then split.  How does the test
>condition look with these two: s[0] /\d/ ?

>if (s[0] is a number)

If you mean "begins with a digit" as you said above 
	if ($s[0] =~ m/^\d/)

If you mean "is a number" as you are saying now
	if ($s[0] =~ m/^\d+$/) #all characters are digits
or
	if (! $s[0] =~ m/\D/) #does not contain any non-digits

Deciphering:
The m-operator is the match operator. It can be omitted if slashes are
used as delimiters, therefore it doesn't show up in the FAQ. I still
prefer to write it sometimes because it makes the program logic more
obvious.

Normally the m (and the s) operator will use $_. If you want them to
operate on a different variable instead, then you need to bind that
variable to the operation, which is achieved by the =~ operator.

And the argument of m is a regular expression, in this case delimited by
slashes:
Case 1 matches if the beginning of the string is followed by a digit
Case 2 matches if the beginning of the string is followed by 1 or more
digits followed by the end of the string.
Case 3 matches if the string contains (at least) one non-digit.

For further details see "perldoc perlretut" and "perldoc perlre".

jue


------------------------------

Date: Thu, 14 May 2009 21:11:07 -0700
From: Franken Sense <frank@example.invalid>
Subject: Re: writing get_script as an external routine callable by C
Message-Id: <p34avlcdtmw4.1v44kxus9t1ms.dlg@40tude.net>

In Dread Ink, the Grave Hand of Franken Sense Did Inscribe:

> I have @s populated in paragraph mode and then split.  How does the test
> condition look with these two: s[0] /\d/ ?

I got that part now:

#!/usr/bin/perl
# perl bb7.pl  
use warnings;
use strict;

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 %Scripts;
      
local $/="";

while ( <$hh> ) 
{
    my @s = split /\s+/, $_;
    my $verse = $s[0];
    
    if ($s[0] =~ m/\d/)
    {
        print $_;
    }
    my $script = join(' ', @s[1..$#s]);
    $Scripts{$verse} = $script;  
}
        

# close input and output files

close($hh) or die("Error closing $filename3: $!");
close($gh) or die("Error closing $filename2: $!");

Abridged output:

1:1. All wisdom is from the Lord God, and hath been always with him,
and is before all time.

1:2. Who hath numbered the sand of the sea, and the drops of rain, and
the days of the world?  Who hath measured the height of heaven, and the
breadth of the earth, and the depth of the abyss?

1:3. Who hath searched out the wisdom of God that goeth before all
things?
 ...
26:28. Two sorts of callings have appeared to me hard and dangerous:  a
merchant is hardly free from negligence:  and a huckster shall not be
justified from the sins of the lips.

27:1. Through poverty many have sinned:  and he that seeketh to be
enriched, turneth away his eye.
 ...

Thanks for your help.
-- 
Frank

[Newt Gingrich] is the most unpopular politician in America. His favorable
rating is only four points higher than the Unabomber.
~~ Al Franken, 1996


------------------------------

Date: Thu, 14 May 2009 21:13:49 -0700
From: Franken Sense <frank@example.invalid>
Subject: Re: writing get_script as an external routine callable by C
Message-Id: <1fd7h7bckpmi4$.1qu7ex960ja73$.dlg@40tude.net>

In Dread Ink, the Grave Hand of Jürgen Exner Did Inscribe:

> Franken Sense <frank@example.invalid> wrote:
> 
> Ok, here comes your last fish. 
> I _STRONGLY_ suggest to attend a Perl class or a self-study course where
> you can learn the fundamentals of Perl in a structured and comprehensive
> way instead of digging for random bits and pieces while trying to
> implement some program.
> 
>>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?
>>
>>  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
> [...]
> 
> Yeah, I know the answer to that FAQ, there is no need to quote
> paragraphs and paragraphs of it.
> 
>>So, I want to test whether the first byte is a digit.  
> 
> No, you probably don't. In all likelyhood you want to check if the first
> character is a digit. Characters and bytes can be very different things.
>  
>>I think this is
>>/\d/.  The sad thing is that I can't even put it together at this point.
> 
> That's why I strongly recommend a more structured approach to your
> learning endeavour.
> 
>>I have @s populated in paragraph mode and then split.  How does the test
>>condition look with these two: s[0] /\d/ ?
> 
>>if (s[0] is a number)
> 
> If you mean "begins with a digit" as you said above 
> 	if ($s[0] =~ m/^\d/)
> 
> If you mean "is a number" as you are saying now
> 	if ($s[0] =~ m/^\d+$/) #all characters are digits
> or
> 	if (! $s[0] =~ m/\D/) #does not contain any non-digits

  if ($s[0] =~ m/\d/) seems to work.

> 
> Deciphering:
> The m-operator is the match operator. It can be omitted if slashes are
> used as delimiters, therefore it doesn't show up in the FAQ. I still
> prefer to write it sometimes because it makes the program logic more
> obvious.
> 
> Normally the m (and the s) operator will use $_. If you want them to
> operate on a different variable instead, then you need to bind that
> variable to the operation, which is achieved by the =~ operator.
> 
> And the argument of m is a regular expression, in this case delimited by
> slashes:
> Case 1 matches if the beginning of the string is followed by a digit
> Case 2 matches if the beginning of the string is followed by 1 or more
> digits followed by the end of the string.
> Case 3 matches if the string contains (at least) one non-digit.
> 
> For further details see "perldoc perlretut" and "perldoc perlre".
> 
> jue

Thx.  I'll take a look later.
-- 
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:24:42 -0400
From: "Uri Guttman" <uri@PerlOnCall.com>
Subject: Re: writing get_script as an external routine callable by C
Message-Id: <87hbzn8039.fsf@quad.sysarch.com>

>>>>> "FS" == Franken Sense <frank@example.invalid> writes:

  FS>   if ($s[0] =~ m/\d/) seems to work.

seems to work is not a proper logical statement. it works or it
doesn't. does it work for all test cases? for a non-number? for a number
with garbage in front of it? you have to think a bit before you claim
something works and you don't even understand why it may fail.

and i agree. take a perl class. read a whole perl book and do the
exercises. this dribs and drabs approach is not the way to learn a
programming language. it is like learning to drive but pushing all the
pedals, levers and buttons in any order with random pressures and seeing
what may or may not happen.

uri

-- 
Uri Guttman  ------  uri@stemsystems.com  --------  http://www.sysarch.com --
-----  Perl Code Review , Architecture, Development, Training, Support ------
--------- Free Perl Training --- http://perlhunter.com/college.html ---------
---------  Gourmet Hot Cocoa Mix  ----  http://bestfriendscocoa.com ---------


------------------------------

Date: Thu, 14 May 2009 23:14:07 -0500
From: Tad J McClellan <tadmc@seesig.invalid>
Subject: Re: writing get_script as an external routine callable by C
Message-Id: <slrnh0pr0f.49b.tadmc@tadmc30.sbcglobal.net>

Franken Sense <frank@example.invalid> wrote:

> It appears true that a hash is not ordered


What do you mean "appears"?

The documentation for the data structure you mention says
quite clearly that it is not ordered.

    perldoc perldata

    ... Hashes are unordered...


> If comments are to be a hash, then they need something to key on, and all
> that comes to mind is the natural numbers.  


The data structure that is indexed by numbers is called an "array".

A hash data structure is indexed by strings.


> Fishing for tips. 


No need to state the painfully obvious.


-- 
Tad McClellan
email: perl -le "print scalar reverse qq/moc.noitatibaher\100cmdat/"


------------------------------

Date: Thu, 14 May 2009 23:10:01 -0500
From: Tad J McClellan <tadmc@seesig.invalid>
Subject: Re: writing get_script as an external routine callable by C
Message-Id: <slrnh0pqop.49b.tadmc@tadmc30.sbcglobal.net>

Franken Sense <frank@example.invalid> wrote:
> In Dread Ink, the Grave Hand of Jürgen Exner Did Inscribe:

>> If you mean "begins with a digit" as you said above 


So, did you mean "begins with a digit" or not?


>> 	if ($s[0] =~ m/^\d/)
>> 
>> If you mean "is a number" as you are saying now
>> 	if ($s[0] =~ m/^\d+$/) #all characters are digits
>> or
>> 	if (! $s[0] =~ m/\D/) #does not contain any non-digits
>
>   if ($s[0] =~ m/\d/) seems to work.


That will match:

    $s[0] = 'this is not the 4th verse';

So, did you mean "begins with a digit" or not?


-- 
Tad McClellan
email: perl -le "print scalar reverse qq/moc.noitatibaher\100cmdat/"


------------------------------

Date: Thu, 14 May 2009 22:04:20 -0700
From: Jürgen Exner <jurgenex@hotmail.com>
Subject: Re: writing get_script as an external routine callable by C
Message-Id: <6otp059atllq63bpnh8jbd7dv2o72e1kv6@4ax.com>

Franken Sense <frank@example.invalid> wrote:
>In Dread Ink, the Grave Hand of Jürgen Exner Did Inscribe:
>> Franken Sense <frank@example.invalid> wrote:
>>>So, I want to test whether the first byte is a digit.  
>> 
>> No, you probably don't. In all likelyhood you want to check if the first
>> character is a digit. Characters and bytes can be very different things.

>> If you mean "begins with a digit" as you said above 
>> 	if ($s[0] =~ m/^\d/)
>> 
>> If you mean "is a number" as you are saying now
>> 	if ($s[0] =~ m/^\d+$/) #all characters are digits
>> or
>> 	if (! $s[0] =~ m/\D/) #does not contain any non-digits
>
>  if ($s[0] =~ m/\d/) seems to work.

Between "works" and "seems to work" is a similar difference as between
"well done" and "meant well".

jue  


------------------------------

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 2418
***************************************


home help back first fref pref prev next nref lref last post