[31379] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 2631 Volume: 11

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Mon Oct 12 11:10:23 2009

Date: Mon, 12 Oct 2009 08:09:15 -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           Mon, 12 Oct 2009     Volume: 11 Number: 2631

Today's topics:
        Advice on proper command to use <mikaelpetterson@hotmail.com>
    Re: Advice on proper command to use <jurgenex@hotmail.com>
    Re: Advice on proper command to use <mikaelpetterson@hotmail.com>
    Re: Advice on proper command to use <sreservoir@gmail.com>
        FAQ 7.29 How can I use a variable as a variable name? <brian@theperlreview.com>
        FAQ 8.11 How do I decode encrypted password files? <brian@theperlreview.com>
    Re: FAQ postings' subjects (was: FAQ 5.17 Is there a le <brian.d.foy@gmail.com>
    Re: FAQ postings' subjects <tim@tim-landscheidt.de>
    Re: Get domain from uri <tszming@gmail.com>
    Re: Get domain from uri <bart.lateur@pandora.be>
        Help needed with tough regular expression matching <ramon@conexus.net>
    Re: Help needed with tough regular expression matching <ramon@conexus.net>
        problem with perl + thread + extension <aotto1968@users.sourceforge.net>
        regexp assistance <mikaelpetterson@hotmail.com>
    Re: regexp assistance <jurgenex@hotmail.com>
    Re: regexp assistance <mikaelpetterson@hotmail.com>
    Re: regexp assistance <bugbear@trim_papermule.co.uk_trim>
    Re: regexp assistance <mikaelpetterson@hotmail.com>
    Re: regexp assistance <sreservoir@gmail.com>
    Re: regexp assistance <marc.girod@gmail.com>
    Re: regexp assistance <ramon@conexus.net>
    Re: regexp assistance <spamtrap@shermpendley.com>
        Strange behavoiur when passing $1 to a sub (Heinrich Mislik)
    Re: Strange behavoiur when passing $1 to a sub <smallpond@juno.com>
    Re: time format +1 hour <slick.users@gmail.com>
    Re: time format +1 hour <josef.moellers@ts.fujitsu.com>
    Re: time format +1 hour <jurgenex@hotmail.com>
        Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)

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

Date: Mon, 12 Oct 2009 06:26:36 -0700 (PDT)
From: mike <mikaelpetterson@hotmail.com>
Subject: Advice on proper command to use
Message-Id: <fc778184-5550-4a6e-8f6f-c4410b5eb366@h13g2000yqk.googlegroups.com>

Hi,

I will be doing some file modification depending on certain conditions
like:

If the file contains xxxDefault() then check if it has comments
(preceeding it).
If not add getXXX();
if true then add getXXX() before comments.

I need some advice which command/s is/are most efficient to use.

br,

//mike


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

Date: Mon, 12 Oct 2009 06:33:26 -0700
From: Jürgen Exner <jurgenex@hotmail.com>
Subject: Re: Advice on proper command to use
Message-Id: <1pb6d51m380v7ori3kdel19i63c3njsqkj@4ax.com>

mike <mikaelpetterson@hotmail.com> wrote:
>Hi,
>
>I will be doing some file modification depending on certain conditions
>like:
>
>If the file contains xxxDefault() then check if it has comments
>(preceeding it).
>If not add getXXX();
>if true then add getXXX() before comments.
>
>I need some advice which command/s is/are most efficient to use.

???
How would efficient commands help you if they don't solve your problem?
First step write an algorithm that solves the problem. If it turns out
to be too slow, then investigate if there is a faster algorithm,
preferably in a better O(n) class. 
And only after you've exhausted that avenue and the program is still too
slow it may(!) be worthwhile to micro-optimize and choose different
functions, but even then only after thourougly benchmarking your code.

jue


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

Date: Mon, 12 Oct 2009 06:47:01 -0700 (PDT)
From: mike <mikaelpetterson@hotmail.com>
Subject: Re: Advice on proper command to use
Message-Id: <cb41f0ae-f865-4ab7-9463-73bca169f053@g23g2000yqh.googlegroups.com>

On 12 Okt, 15:33, J=FCrgen Exner <jurge...@hotmail.com> wrote:
> mike <mikaelpetter...@hotmail.com> wrote:
> >Hi,
>
> >I will be doing some file modification depending on certain conditions
> >like:
>
> >If the file contains xxxDefault() then check if it has comments
> >(preceeding it).
> >If not add getXXX();
> >if true then add getXXX() before comments.
>
> >I need some advice which command/s is/are most efficient to use.
>
> ???
> How would efficient commands help you if they don't solve your problem?
> First step write an algorithm that solves the problem. If it turns out
> to be too slow, then investigate if there is a faster algorithm,
> preferably in a better O(n) class.
> And only after you've exhausted that avenue and the program is still too
> slow it may(!) be worthwhile to micro-optimize and choose different
> functions, but even then only after thourougly benchmarking your code.
>
> jue

Well I don't know what command is most appropriate for the task.
Please advice me.

br,

//mike


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

Date: Mon, 12 Oct 2009 10:24:54 -0400
From: sreservoir <sreservoir@gmail.com>
Subject: Re: Advice on proper command to use
Message-Id: <have74$28k$1@aioe.org>

mike wrote:
> On 12 Okt, 15:33, Jürgen Exner <jurge...@hotmail.com> wrote:
>> mike <mikaelpetter...@hotmail.com> wrote:
>>> Hi,
>>> I will be doing some file modification depending on certain conditions
>>> like:
>>> If the file contains xxxDefault() then check if it has comments
>>> (preceeding it).
>>> If not add getXXX();
>>> if true then add getXXX() before comments.
>>> I need some advice which command/s is/are most efficient to use.
>> ???
>> How would efficient commands help you if they don't solve your problem?
>> First step write an algorithm that solves the problem. If it turns out
>> to be too slow, then investigate if there is a faster algorithm,
>> preferably in a better O(n) class.
>> And only after you've exhausted that avenue and the program is still too
>> slow it may(!) be worthwhile to micro-optimize and choose different
>> functions, but even then only after thourougly benchmarking your code.
>>
>> jue
> 
> Well I don't know what command is most appropriate for the task.
> Please advice me.
> 
> br,

it's tell()

-- 

   "Six by nine. Forty two."
   "That's it. That's all there is."
   "I always thought something was fundamentally wrong with the universe"


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

Date: Mon, 12 Oct 2009 04:00:02 GMT
From: PerlFAQ Server <brian@theperlreview.com>
Subject: FAQ 7.29 How can I use a variable as a variable name?
Message-Id: <6RxAm.489499$Ta5.62423@newsfe15.iad>

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.29: How can I use a variable as a variable name?

    Beginners often think they want to have a variable contain the name of a
    variable.

            $fred    = 23;
            $varname = "fred";
            ++$$varname;         # $fred now 24

    This works *sometimes*, but it is a very bad idea for two reasons.

    The first reason is that this technique *only works on global
    variables*. That means that if $fred is a lexical variable created with
    my() in the above example, the code wouldn't work at all: you'd
    accidentally access the global and skip right over the private lexical
    altogether. Global variables are bad because they can easily collide
    accidentally and in general make for non-scalable and confusing code.

    Symbolic references are forbidden under the "use strict" pragma. They
    are not true references and consequently are not reference counted or
    garbage collected.

    The other reason why using a variable to hold the name of another
    variable is a bad idea is that the question often stems from a lack of
    understanding of Perl data structures, particularly hashes. By using
    symbolic references, you are just using the package's symbol-table hash
    (like %main::) instead of a user-defined hash. The solution is to use
    your own hash or a real reference instead.

            $USER_VARS{"fred"} = 23;
            $varname = "fred";
            $USER_VARS{$varname}++;  # not $$varname++

    There we're using the %USER_VARS hash instead of symbolic references.
    Sometimes this comes up in reading strings from the user with variable
    references and wanting to expand them to the values of your perl
    program's variables. This is also a bad idea because it conflates the
    program-addressable namespace and the user-addressable one. Instead of
    reading a string and expanding it to the actual contents of your
    program's own variables:

            $str = 'this has a $fred and $barney in it';
            $str =~ s/(\$\w+)/$1/eeg;                 # need double eval

    it would be better to keep a hash around like %USER_VARS and have
    variable references actually refer to entries in that hash:

            $str =~ s/\$(\w+)/$USER_VARS{$1}/g;   # no /e here at all

    That's faster, cleaner, and safer than the previous approach. Of course,
    you don't need to use a dollar sign. You could use your own scheme to
    make it less confusing, like bracketed percent symbols, etc.

            $str = 'this has a %fred% and %barney% in it';
            $str =~ s/%(\w+)%/$USER_VARS{$1}/g;   # no /e here at all

    Another reason that folks sometimes think they want a variable to
    contain the name of a variable is because they don't know how to build
    proper data structures using hashes. For example, let's say they wanted
    two hashes in their program: %fred and %barney, and that they wanted to
    use another scalar variable to refer to those by name.

            $name = "fred";
            $$name{WIFE} = "wilma";     # set %fred

            $name = "barney";
            $$name{WIFE} = "betty"; # set %barney

    This is still a symbolic reference, and is still saddled with the
    problems enumerated above. It would be far better to write:

            $folks{"fred"}{WIFE}   = "wilma";
            $folks{"barney"}{WIFE} = "betty";

    And just use a multilevel hash to start with.

    The only times that you absolutely *must* use symbolic references are
    when you really must refer to the symbol table. This may be because it's
    something that can't take a real reference to, such as a format name.
    Doing so may also be important for method calls, since these always go
    through the symbol table for resolution.

    In those cases, you would turn off "strict 'refs'" temporarily so you
    can play around with the symbol table. For example:

            @colors = qw(red blue green yellow orange purple violet);
            for my $name (@colors) {
                    no strict 'refs';  # renege for the block
                    *$name = sub { "<FONT COLOR='$name'>@_</FONT>" };
            }

    All those functions (red(), blue(), green(), etc.) appear to be
    separate, but the real code in the closure actually was compiled only
    once.

    So, sometimes you might want to use symbolic references to directly
    manipulate the symbol table. This doesn't matter for formats, handles,
    and subroutines, because they are always global--you can't use my() on
    them. For scalars, arrays, and hashes, though--and usually for
    subroutines-- you probably only want to use hard references.



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

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.


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

Date: Mon, 12 Oct 2009 10:00:02 GMT
From: PerlFAQ Server <brian@theperlreview.com>
Subject: FAQ 8.11 How do I decode encrypted password files?
Message-Id: <C6DAm.489510$Ta5.196198@newsfe15.iad>

This is an excerpt from the latest version perlfaq8.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 .

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

8.11: How do I decode encrypted password files?

    You spend lots and lots of money on dedicated hardware, but this is
    bound to get you talked about.

    Seriously, you can't if they are Unix password files--the Unix password
    system employs one-way encryption. It's more like hashing than
    encryption. The best you can do is check whether something else hashes
    to the same string. You can't turn a hash back into the original string.
    Programs like Crack can forcibly (and intelligently) try to guess
    passwords, but don't (can't) guarantee quick success.

    If you're worried about users selecting bad passwords, you should
    proactively check when they try to change their password (by modifying
    passwd(1), for example).



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

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.


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

Date: Sun, 11 Oct 2009 19:13:14 -0500
From: brian d foy <brian.d.foy@gmail.com>
Subject: Re: FAQ postings' subjects (was: FAQ 5.17 Is there a leak/bug in glob()?)
Message-Id: <111020091913146049%brian.d.foy@gmail.com>

In article <m3tyy5u8se.fsf_-_@passepartout.tim-landscheidt.de>, Tim
Landscheidt <tim@tim-landscheidt.de> wrote:


>   Would it be possible to handle this here in the same way?

It's possible, but a lot of work. I started something like this a long
time ago, and it involves trying to figure out when a line in a file
was changed. That's much easier now that the sources are in git (and in
github). 

I'm not opposed to the idea, but it's not high on my to do list either.
If someone wants to submit a patch for this, I'll certainly look at it.


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

Date: Mon, 12 Oct 2009 12:04:05 +0000
From: Tim Landscheidt <tim@tim-landscheidt.de>
Subject: Re: FAQ postings' subjects
Message-Id: <m3ococn7ii.fsf@passepartout.tim-landscheidt.de>

brian d foy <brian.d.foy@gmail.com> wrote:

>>   Would it be possible to handle this here in the same way?

> It's possible, but a lot of work. I started something like this a long
> time ago, and it involves trying to figure out when a line in a file
> was changed. That's much easier now that the sources are in git (and in
> github).

> I'm not opposed to the idea, but it's not high on my to do list either.
> If someone wants to submit a patch for this, I'll certainly look at it.

I just had a look at the git repository and you're right: It
would be a lot of work with little to gain. I had assumed
that the individual FAQ entries already had information
about their authors and last changes available.

Tim


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

Date: Sun, 11 Oct 2009 18:53:41 -0700 (PDT)
From: tszming <tszming@gmail.com>
Subject: Re: Get domain from uri
Message-Id: <281f2f90-862d-4332-b0d2-1e8c4d3c33eb@w37g2000prg.googlegroups.com>

On Oct 11, 11:17=A0pm, Ben Morrow <b...@morrow.me.uk> wrote:
> Quoth Bart Lateur <bart.lat...@pandora.be>:
>
> No it's not. It gives you a list of valid TLDs, which is not the same.
>
> Ben


Check this out: http://search.cpan.org/perldoc?Domain::PublicSuffix


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

Date: Mon, 12 Oct 2009 09:20:18 +0200
From: Bart Lateur <bart.lateur@pandora.be>
Subject: Re: Get domain from uri
Message-Id: <84m5d5hg45tn45bn5g3eqnb1qto3v751en@4ax.com>

Ben Morrow wrote:

>> I found this:
>> 
>> 	Net::Domain::TLD
>> 	http://search.cpan.org/perldoc?Net::Domain::TLD
>> 
>> which is a module to reduce a domain name to its core domain name.
>
>No it's not. It gives you a list of valid TLDs, which is not the same.

You seem to be right... It was wishful thinking on my side.

-- 
	Bart.


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

Date: Mon, 12 Oct 2009 07:41:15 -0700 (PDT)
From: Ramon F Herrera <ramon@conexus.net>
Subject: Help needed with tough regular expression matching
Message-Id: <37c23f35-711e-41dd-891f-4c8dbed12916@e18g2000vbe.googlegroups.com>


Hello all,

My initial task was to match the well-known notation used in math and
other fields to denote integer sequences. Such notation is nice,
unambiguous  and -some times- succinct:

1,2,3,4,8-10,11-14

which is equivalent to:

1-4,8-14

(and to may other possibilities, the one immediately above being the
most succinct possible)

I have been able to come up with a regular expression which
unequivocally matches any valid "statement" of such "language". See
below.

My problem is that now I would like to write a more general form of
such sequence matching. The "base unit" is not an integer anymore. I
will post the actual question next.

-Ramon

ps: You will notice that this is not written in Perl, but in C++ and
will be used in some sort of "Perl emulator" (actually a Regex package
for C++). For obvious reason, a Perl NG is the best place to find the
appropriate  experts. I am sure some of you can devise regexes in your
sleep. :-)

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

const char hyphen         = '-';
const char left_paren     = '(';
const char right_paren    = ')';
const char bar            = '|';
const char comma          = ',';
const char star           = '*';

const string number       = "[0-9]+";
const string range        = number + hyphen + number;
const string term         = left_paren + number + bar + range +
right_paren;
const string sequence     = term + bar + left_paren + term + comma +
right_paren + star + term;



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

Date: Mon, 12 Oct 2009 07:48:54 -0700 (PDT)
From: Ramon F Herrera <ramon@conexus.net>
Subject: Re: Help needed with tough regular expression matching
Message-Id: <a4d7ef69-fd0f-4ef2-b84e-34ceb912f374@33g2000vbe.googlegroups.com>

On Oct 12, 10:41=A0am, Ramon F Herrera <ra...@conexus.net> wrote:
> Hello all,
>
> My initial task was to match the well-known notation used in math and
> other fields to denote integer sequences. Such notation is nice,
> unambiguous =A0and -some times- succinct:
>
> 1,2,3,4,8-10,11-14
>
> which is equivalent to:
>
> 1-4,8-14
>
> (and to may other possibilities, the one immediately above being the
> most succinct possible)
>
> I have been able to come up with a regular expression which
> unequivocally matches any valid "statement" of such "language". See
> below.
>
> My problem is that now I would like to write a more general form of
> such sequence matching. The "base unit" is not an integer anymore. I
> will post the actual question next.
>
> -Ramon
>
> ps: You will notice that this is not written in Perl, but in C++ and
> will be used in some sort of "Perl emulator" (actually a Regex package
> for C++). For obvious reason, a Perl NG is the best place to find the
> appropriate =A0experts. I am sure some of you can devise regexes in your
> sleep. :-)
>
> ---------------------------
>
> const char hyphen =A0 =A0 =A0 =A0 =3D '-';
> const char left_paren =A0 =A0 =3D '(';
> const char right_paren =A0 =A0=3D ')';
> const char bar =A0 =A0 =A0 =A0 =A0 =A0=3D '|';
> const char comma =A0 =A0 =A0 =A0 =A0=3D ',';
> const char star =A0 =A0 =A0 =A0 =A0 =3D '*';
>
> const string number =A0 =A0 =A0 =3D "[0-9]+";
> const string range =A0 =A0 =A0 =A0=3D number + hyphen + number;
> const string term =A0 =A0 =A0 =A0 =3D left_paren + number + bar + range +
> right_paren;
> const string sequence =A0 =A0 =3D term + bar + left_paren + term + comma =
+
> right_paren + star + term;

I guess the first question is this: is my initial (based on plain old
integers) version already posted correct? Are there any comments about
it? The actual program is working properly.

Once again, I got into trouble when I tried to develop a more general
version, not based on integers but in "base units" slightly more
complicated. I keep on thinking that my problem is the parentheses
(excess or deficit of them). I can never figure those out.

I still owe you the actual question.

-Ramon



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

Date: Mon, 12 Oct 2009 14:20:42 +0200
From: Andreas Otto <aotto1968@users.sourceforge.net>
Subject: problem with perl + thread + extension
Message-Id: <hav6uq$27m$03$3@news.t-online.com>

Hi,

  the following scenario:

   I use perl (see below) and write an extension (perlmsgque) as wrapper for
   an existing shared library (libmsgque).
   everything works fine without threads:

  now I add threads. 

    1)  I want to use a new interpreter per thread
    2)  the new thread is created in the libmsgque shared library
    3)  after create the perl is initialized with

>>>>>>>>>>>>>>>>>>>>>>>
static enum MqErrorE FactoryCreate (
  struct MqS * const tmpl,
  enum MqFactoryE create,
  MQ_PTR data,
  struct MqS ** contextP
) {
  if (create == MQ_FACTORY_NEW_THREAD) {
    PERL_SET_CONTEXT (perl_clone ((PerlInterpreter*)tmpl->threadData, 0));
  }
 ...
<<<<<<<<<<<<<<<<<<<<<<<<<

   4)   I use "perl_clone" the create the new interpreter as clone
        from the existing one
   6)   create and setup was fine
   7)   but the first callback:

>>>>>>>>>>>>>>>>>>>>>>>>>
static enum MqErrorE
ProcCall (
  struct MqS * const context,
  MQ_PTR const data
)
{
  dSP;
  SV * method = (SV*) data;
  enum MqErrorE ret = MQ_OK;

  ENTER;
  SAVETMPS;

  PUSHMARK(SP);
  XPUSHs((SV*)context->self);
  PUTBACK;

  call_sv (method, G_SCALAR|G_DISCARD|G_EVAL);

  ret = ProcError (aTHX_ context, ERRSV);

  FREETMPS;
  LEAVE;

  return ret;
}
<<<<<<<<<<<<<<<<<<<<<<<<<<<

create an error: the argument stack is empty and:

>>>>>>>>>>>>>>>>>>>>>>>>>>>
  sub ServerSetup {
    my $ctx = shift;
print "ctx<$ctx>\n";
 ...
<<<<<<<<<<<<<<<<<<<<<<<<<<<
says that "$ctx" is empty
so I come to the conclusion that "call_sv" and "stack" does not match
anymore. "context->self is not empty


Question

        What can I do ?




PERL:
> perl -V
Summary of my perl5 (revision 5 version 10 subversion 1) configuration:

  Platform:
    osname=linux, osvers=2.6.27.29-0.1-default, archname=x86_64-linux-
thread-multi
    uname='linux linux-522u 2.6.27.29-0.1-default #1 smp 2009-08-15 17:53:59 
+0200 x86_64 x86_64 x86_64 gnulinux '
    config_args='-des -Dprefix=/home/dev1usr/ext/x86_64-suse-linux/thread -
Dusethreads'
    hint=recommended, useposix=true, d_sigaction=define
    useithreads=define, usemultiplicity=define
    useperlio=define, d_sfio=undef, uselargefiles=define, usesocks=undef
    use64bitint=define, use64bitall=define, uselongdouble=undef
    usemymalloc=n, bincompat5005=undef
  Compiler:
    cc='cc', ccflags ='-D_REENTRANT -D_GNU_SOURCE -fno-strict-aliasing -pipe 
-fstack-protector -I/usr/local/include -D_LARGEFILE_SOURCE -
D_FILE_OFFSET_BITS=64',
    optimize='-O2',
    cppflags='-D_REENTRANT -D_GNU_SOURCE -fno-strict-aliasing -pipe -fstack-
protector -I/usr/local/include'
    ccversion='', gccversion='4.3.2 [gcc-4_3-branch revision 141291]', 
gccosandvers=''
    intsize=4, longsize=8, ptrsize=8, doublesize=8, byteorder=12345678
    d_longlong=define, longlongsize=8, d_longdbl=define, longdblsize=16
    ivtype='long', ivsize=8, nvtype='double', nvsize=8, Off_t='off_t', 
lseeksize=8
    alignbytes=8, prototype=define
  Linker and Libraries:
    ld='cc', ldflags =' -fstack-protector -L/usr/local/lib'
    libpth=/usr/local/lib /lib /usr/lib /lib64 /usr/lib64 /usr/local/lib64
    libs=-lnsl -ldl -lm -lcrypt -lutil -lpthread -lc
    perllibs=-lnsl -ldl -lm -lcrypt -lutil -lpthread -lc
    libc=/lib/libc-2.9.so, so=so, useshrplib=false, libperl=libperl.a
    gnulibc_version='2.9'
  Dynamic Linking:
    dlsrc=dl_dlopen.xs, dlext=so, d_dlsymun=undef, ccdlflags='-Wl,-E'
    cccdlflags='-fPIC', lddlflags='-shared -O2 -L/usr/local/lib -fstack-
protector'


Characteristics of this binary (from libperl):
  Compile-time options: MULTIPLICITY PERL_DONT_CREATE_GVSV
                        PERL_IMPLICIT_CONTEXT PERL_MALLOC_WRAP 
USE_64_BIT_ALL
                        USE_64_BIT_INT USE_ITHREADS USE_LARGE_FILES
                        USE_PERLIO USE_REENTRANT_API
  Built under linux
  Compiled at Oct  2 2009 09:10:52



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

Date: Mon, 12 Oct 2009 06:25:38 -0700 (PDT)
From: mike <mikaelpetterson@hotmail.com>
Subject: regexp assistance
Message-Id: <948bcbc0-0862-4589-940f-2c5515a0b210@t2g2000yqn.googlegroups.com>

Hi,

I am trying to get files that looks like:

xxxInds.java
yyyReset.java
zzzRespone.java

I am using the following regexp:

return unless -f $File::Find::name;
	/^.*Inds|Reset|Response\.java\z/s

I get files with another file extension than java.

Is \z not to match at the end of a string?

br,

//mike


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

Date: Mon, 12 Oct 2009 06:36:23 -0700
From: Jürgen Exner <jurgenex@hotmail.com>
Subject: Re: regexp assistance
Message-Id: <f2c6d595dl3hjmt7a8n4gsioepj1nitho5@4ax.com>

mike <mikaelpetterson@hotmail.com> wrote:
>	/^.*Inds|Reset|Response\.java\z/s

'z' isn't special in a RE, therefore the backslash is redundant.

>I get files with another file extension than java.
>
>Is \z not to match at the end of a string?

No, what gave you that idea?
See 'perldoc perlre' and probably 'perldoc perlretut'.

jue


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

Date: Mon, 12 Oct 2009 06:44:53 -0700 (PDT)
From: mike <mikaelpetterson@hotmail.com>
Subject: Re: regexp assistance
Message-Id: <4afc30b8-b429-4d43-8f2e-10c17cadce43@x37g2000yqj.googlegroups.com>

On 12 Okt, 15:36, J=FCrgen Exner <jurge...@hotmail.com> wrote:
> mike <mikaelpetter...@hotmail.com> wrote:
> >    /^.*Inds|Reset|Response\.java\z/s
>
> 'z' isn't special in a RE, therefore the backslash is redundant.
>
> >I get files with another file extension than java.
>
> >Is \z not to match at the end of a string?
>
> No, what gave you that idea?

http://www.somacon.com/p127.php

> See 'perldoc perlre' and probably 'perldoc perlretut'.
>
> jue



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

Date: Mon, 12 Oct 2009 14:57:31 +0100
From: bugbear <bugbear@trim_papermule.co.uk_trim>
Subject: Re: regexp assistance
Message-Id: <X6idnQhsiPBWqE7XnZ2dnUVZ8vKdnZ2d@brightview.co.uk>

Jürgen Exner wrote:
> mike <mikaelpetterson@hotmail.com> wrote:
>> 	/^.*Inds|Reset|Response\.java\z/s
> 
> 'z' isn't special in a RE, therefore the backslash is redundant.
> 
>> I get files with another file extension than java.
>>
>> Is \z not to match at the end of a string?
> 
> No, what gave you that idea?

It's in table 5.7 (Alphanumeric Regex Metasymbols) of the camel book!

  BugBear


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

Date: Mon, 12 Oct 2009 07:17:24 -0700 (PDT)
From: mike <mikaelpetterson@hotmail.com>
Subject: Re: regexp assistance
Message-Id: <818c5691-f112-4a06-97d8-69f8fb5f815d@s31g2000yqs.googlegroups.com>

On 12 Okt, 15:57, bugbear <bugbear@trim_papermule.co.uk_trim> wrote:
> J=FCrgen Exner wrote:
> > mike <mikaelpetter...@hotmail.com> wrote:
> >>        /^.*Inds|Reset|Response\.java\z/s
>
> > 'z' isn't special in a RE, therefore the backslash is redundant.
>
> >> I get files with another file extension than java.
>
> >> Is \z not to match at the end of a string?
>
> > No, what gave you that idea?
>
> It's in table 5.7 (Alphanumeric Regex Metasymbols) of the camel book!
>
>   BugBear

My question is still not answered...

//mike


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

Date: Mon, 12 Oct 2009 10:30:58 -0400
From: sreservoir <sreservoir@gmail.com>
Subject: Re: regexp assistance
Message-Id: <haveih$2vf$1@aioe.org>

mike wrote:
> Hi,
> 
> I am trying to get files that looks like:
> 
> xxxInds.java
> yyyReset.java
> zzzRespone.java
> 
> I am using the following regexp:
> 
> return unless -f $File::Find::name;
> 	/^.*Inds|Reset|Response\.java\z/s

this gets:
	anything with Inds in it
	anything with Reset in it
	anything that ends with Response.java

> I get files with another file extension than java.
> 
> Is \z not to match at the end of a string?

Yes, though you might get "Response.java\n", iirc.

Which probably still doesn't aswer your implicit question, but you
didn't ask.

-- 

   "Six by nine. Forty two."
   "That's it. That's all there is."
   "I always thought something was fundamentally wrong with the universe"


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

Date: Mon, 12 Oct 2009 07:45:15 -0700 (PDT)
From: Marc Girod <marc.girod@gmail.com>
Subject: Re: regexp assistance
Message-Id: <4f50a120-b3bf-4ca6-8838-9b9458d13910@v36g2000yqv.googlegroups.com>

On Oct 12, 2:25=A0pm, mike <mikaelpetter...@hotmail.com> wrote:

> =A0 =A0 =A0 =A0 /^.*Inds|Reset|Response\.java\z/s

Parentheses?

/^.*(Inds|Reset|Response)\.java\z/s

Marc


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

Date: Mon, 12 Oct 2009 07:55:08 -0700 (PDT)
From: Ramon F Herrera <ramon@conexus.net>
Subject: Re: regexp assistance
Message-Id: <241bc9f9-6a30-477f-9593-db0a707cb457@p20g2000vbl.googlegroups.com>

On Oct 12, 10:45=A0am, Marc Girod <marc.gi...@gmail.com> wrote:
> On Oct 12, 2:25=A0pm, mike <mikaelpetter...@hotmail.com> wrote:
>
> > =A0 =A0 =A0 =A0 /^.*Inds|Reset|Response\.java\z/s
>
> Parentheses?
>
> /^.*(Inds|Reset|Response)\.java\z/s
>
> Marc


Parentheses will be the bane of me. I always seem to have too few or
too many. The crux of such problem is that parentheses have two
distinct purposes in regexes:

(1) The normal grouping used in math and programming languages.

(2) The "grab this part" function.

Who invented regexes anyway, was it Larry Wall? I would have used
angle brackets for the functionality (2) above.

-Ramon



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

Date: Mon, 12 Oct 2009 10:57:22 -0400
From: Sherm Pendley <spamtrap@shermpendley.com>
Subject: Re: regexp assistance
Message-Id: <m2aazwvewd.fsf@shermpendley.com>

mike <mikaelpetterson@hotmail.com> writes:

> I am trying to get files that looks like:
>
> xxxInds.java
> yyyReset.java
> zzzRespone.java
>
> I am using the following regexp:
>
> return unless -f $File::Find::name;
> 	/^.*Inds|Reset|Response\.java\z/s
>
> I get files with another file extension than java.

As written, that will match filenames that contain "Inds" or "Reset",
or end in "Response.java". A parenthesized subexpression will restrict
the effect of the | so that it matches one of the three words you want.

Also, why the s modifier? Do you *really* expect to find multi-line
filenames?

> Is \z not to match at the end of a string?

Yes, but $ is far more commonly used for that. So, try this:

    /^.*(Inds|Reset|Response)\.java$/

sherm--


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

Date: 12 Oct 2009 12:31:21 GMT
From: Heinrich.Mislik@univie.ac.at (Heinrich Mislik)
Subject: Strange behavoiur when passing $1 to a sub
Message-Id: <4ad32199$0$11868$3b214f66@usenet.univie.ac.at>

Hello,

this program

#!/usr/bin/perl

use warnings;
use strict;

'a' =~ m/(.)/;
warn $1;
unter($1);
warn $1;

sub unter
{
    warn $_[0];
    'b' =~ m/(.)/;
    warn $_[0];
}
__END__

outputs:

a at ./demo.pl line 7.
a at ./demo.pl line 13.
b at ./demo.pl line 15.
a at ./demo.pl line 9.

This means, the value of $_[0] changes during evaluation of the regex
in the subroutine. Even considering $_[0] is an alias to $1, this should
not happen. This looks like entering the sub happens as follows:

1.) Make local copy of $1.
2.) Make $_[0] an alias to $1 (the local copy of $1)

This should be the other way round:

1.) Make $_[0] alias to $1 (the outer $1)
2.) Make local copy of $1.

perl -v

This is perl, v5.10.0 built for cygwin-thread-multi-64int
(with 6 registered patches, see perl -V for more detail)

Cheers

Heinrich

-- 
Heinrich Mislik
Zentraler Informatikdienst der Universitaet Wien
A-1010 Wien, Universitaetsstrasse 7
Tel.: (+43 1) 4277-14056, Fax: (+43 1) 4277-9140



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

Date: Mon, 12 Oct 2009 06:38:45 -0700 (PDT)
From: smallpond <smallpond@juno.com>
Subject: Re: Strange behavoiur when passing $1 to a sub
Message-Id: <3b76d68a-980c-4889-9c68-6df9fee8b56f@s31g2000yqs.googlegroups.com>

On Oct 12, 8:31=A0am, Heinrich.Mis...@univie.ac.at (Heinrich Mislik)
wrote:
> Hello,
>
> this program
>
> #!/usr/bin/perl
>
> use warnings;
> use strict;
>
> 'a' =3D~ m/(.)/;
> warn $1;
> unter($1);
> warn $1;
>
> sub unter
> {
> =A0 =A0 warn $_[0];
> =A0 =A0 'b' =3D~ m/(.)/;
> =A0 =A0 warn $_[0];}
>
> __END__
>
> outputs:
>
> a at ./demo.pl line 7.
> a at ./demo.pl line 13.
> b at ./demo.pl line 15.
> a at ./demo.pl line 9.
>
> This means, the value of $_[0] changes during evaluation of the regex
> in the subroutine. Even considering $_[0] is an alias to $1, this should
> not happen. This looks like entering the sub happens as follows:
>
> 1.) Make local copy of $1.
> 2.) Make $_[0] an alias to $1 (the local copy of $1)
>
> This should be the other way round:
>
> 1.) Make $_[0] alias to $1 (the outer $1)
> 2.) Make local copy of $1.
>
> perl -v
>
> This is perl, v5.10.0 built for cygwin-thread-multi-64int
> (with 6 registered patches, see perl -V for more detail)
>
> Cheers
>
> Heinrich
>

perldoc perlvar
$<digits> "These variables are all read-only and dynamically
scoped to the current BLOCK."

So $_[0] is an alias to the $1 in the current block whose
initial value was your read-only argument.  There is no need
for a sub, you can see it just as well here:


'a' =3D~ m/(.)/;
warn $1;

{
    warn $1;
    'b' =3D~ m/(.)/;
    warn $1;
}

warn $1;

a at demo.pl line 7.
a at demo.pl line 10.
b at demo.pl line 12.
a at demo.pl line 15.



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

Date: Sun, 11 Oct 2009 16:27:44 -0700 (PDT)
From: Slickuser <slick.users@gmail.com>
Subject: Re: time format +1 hour
Message-Id: <c574cb65-6fb4-4cc4-9efa-4e06225153d8@e4g2000prn.googlegroups.com>

>> Is this GMT, or a local time?  If a local time, which timezone, and
>   >> under what DST rules?

Local time, Pacific, and 1 for DST.


On Oct 11, 8:27=A0am, mer...@stonehenge.com (Randal L. Schwartz) wrote:
> >>>>> "Slickuser" =3D=3DSlickuser=A0<slick.us...@gmail.com> writes:
>
> Slickuser> I have this string fixed (opened from a text document) asSlick=
user> "20091009090832" (YYYY_MM_DD_HH_MM_SS).
>
> Slickuser> Now I want +1 hour to this string so it can be "20091009100832=
".
>
> Slickuser> Sorry for the confusion.
>
> You simply restated the problem without answering my question, and the an=
swer
> to you depends on you answering my question, which I will now ask again. =
=A0If
> you don't know the answer to it, then you don't know enough to solve your
> problem, and should ask the person who asked you to solve this:
>
> =A0 >> Is this GMT, or a local time? =A0If a local time, which timezone, =
and
> =A0 >> under what DST rules?
>
> Please answer that. =A0You *need* to know that to "add an hour". =A0Reall=
y, you
> do.
>
> print "Just another Perl hacker,"; # the original
>
> --
> Randal L. Schwartz - Stonehenge Consulting Services, Inc. - +1 503 777 00=
95
> <mer...@stonehenge.com> <URL:http://www.stonehenge.com/merlyn/>
> Smalltalk/Perl/Unix consulting, Technical writing, Comedy, etc. etc.
> Seehttp://methodsandmessages.vox.com/for Smalltalk and Seaside discussion



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

Date: Mon, 12 Oct 2009 09:54:22 +0200
From: Josef Moellers <josef.moellers@ts.fujitsu.com>
Subject: Re: time format +1 hour
Message-Id: <haunbe$nbh$1@nntp.fujitsu-siemens.com>

Peter J. Holzer wrote:
> On 2009-10-09 07:13, Josef Moellers <josef.moellers@ts.fujitsu.com> wrote:
>> Jürgen Exner wrote:
>>> Slickuser <slick.users@gmail.com> wrote:
>>>> I have this value:
>>>> 20091008155222
>>>> YYYY_MM_DD_HH_MM_SS
>>>>
>>>> Is there any module out there if I add 1 hour to my current timestamp,
>>>> it will also roll over to DD, MM, and year if possible.
>>>> This might happen at 23 hours (0-23), 0-6 days, 0-12 months..
>>>>
>>>>    my ($sec, $min, $hour, $mday, $mon, $year, $wday, $yday, $isdst) =
>>>> localtime(time);
>>> What's wrong with a simple 
>>>
>>> 	my ($sec, $min, $hour, $mday, $mon, $year, $wday, $yday, $isdst)
>>> = localtime(time + 3600);
>> It will work in 99.99999% of all cases until you fall over one of these 
>> years where they add/subtract a leap second ;-)
> 
> No. The unix time_t value ignores leap seconds. A day is always counted
> as 86400 seconds (it wouldn't be possible to compute the time_t value
> for future dates otherwise).

These leap seconds are a PITA ;-)
It probably depends upon what you define as being "one hour after":
- 3,600 seconds later or
- 1 hour later, but minutes and seconds identical.

The unix time_t counts seconds since the epoch. However, once you try to 
convert this into a human readable time onvolving years, months, days, 
hours, minutes, seconds, you *do* need to know leap days and seconds to 
do that.
So, if you happen to want to know the time and date of *exactly* 1 hour 
after *exactly* 11pm on the 31st of december 2008, the answer depends 
upon the fact that 2008 had a leap second appended to the last minute of 
the year!
If you just added 3,600 seconds to the time_t value of 12/31/2008 
11:00:00pm, then you'd end up at 12/31/2008 11:59:60pm.

But I must admit, this doesn't even help *me* and I'm not even sure any 
more that I am helping.

Josef, dazed and confused
-- 
These are my personal views and not those of Fujitsu Technology Solutions!
Josef Möllers (Pinguinpfleger bei FTS)
	If failure had no penalty success would not be a prize (T.  Pratchett)
Company Details: http://de.ts.fujitsu.com/imprint.html


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

Date: Mon, 12 Oct 2009 06:00:12 -0700
From: Jürgen Exner <jurgenex@hotmail.com>
Subject: Re: time format +1 hour
Message-Id: <hf96d5lu9869qqg2q25u5t75bob9simcta@4ax.com>

Josef Moellers <josef.moellers@ts.fujitsu.com> wrote:
>Peter J. Holzer wrote:
>> On 2009-10-09 07:13, Josef Moellers <josef.moellers@ts.fujitsu.com> wrote:
>>> Jürgen Exner wrote:
>>>> = localtime(time + 3600);
>>> It will work in 99.99999% of all cases until you fall over one of these 
>>> years where they add/subtract a leap second ;-)
>
>The unix time_t counts seconds since the epoch. However, once you try to 
>convert this into a human readable time onvolving years, months, days, 
>hours, minutes, seconds, you *do* need to know leap days and seconds to 
>do that.
>So, if you happen to want to know the time and date of *exactly* 1 hour 
>after *exactly* 11pm on the 31st of december 2008, the answer depends 
>upon the fact that 2008 had a leap second appended to the last minute of 
>the year!

While all this is true I would think that in almost all real-world
scenarios it really doesn't matter if you get a result that is off by
one second. There aren't many applications that need that kind of
precision.
IMO the problem pointed out by Randal is much more significant, because
it doesn't happens once in a blue moon for one second but regularly
twice every year for an hour, i.e. 24 seconds total for leap seconds
since 1972 compared to over 250000 seconds of summer time switching
hours since then.

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:

To submit articles to comp.lang.perl.announce, send your article to
clpa@perl.com.

Back issues are available via anonymous ftp from
ftp://cil-www.oce.orst.edu/pub/perl/old-digests. 

#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 2631
***************************************


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