[25649] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 7891 Volume: 10

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Thu Mar 17 14:05:51 2005

Date: Thu, 17 Mar 2005 11:05:11 -0800 (PST)
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)

Perl-Users Digest           Thu, 17 Mar 2005     Volume: 10 Number: 7891

Today's topics:
        ¸Û¸u Free Lance ¤¬Ápºôµ¸¤u§@­û¤@¦W..................... sales@no-back-this.com
    Re: FAQ 9.16 How do I decode a CGI form? <noreply@gunnar.cc>
    Re: HTML table position text injector? <anonymous@_.com>
    Re: Is there a perl array for... <buellboy@gmail.com>
        Is this considered ugly? <kristo605@gmail.com>
    Re: Is this considered ugly? <mritty@gmail.com>
        Log files in a Date / Time Stamped Directory <manzoorul.hassan@gmail.com>
    Re: Log files in a Date / Time Stamped Directory <nobull@mail.com>
    Re: Log files in a Date / Time Stamped Directory <nobull@mail.com>
    Re: Log files in a Date / Time Stamped Directory <tadmc@augustmail.com>
    Re: Maximum string length in perl <someone@example.com>
        Pattern Matching <alder.bw@forces.gc.ca>
    Re: Pattern Matching <phaylon@dunkelheit.at>
    Re: Pattern Matching <jl_post@hotmail.com>
    Re: Pattern Matching (Walter Roberson)
    Re: Pattern Matching <alder.bw@forces.gc.ca>
    Re: perl & corba <pobugfix@peterlink.ru>
    Re: pop3 and http proxy <noreply@gunnar.cc>
    Re: Probably a dumb s/// question. <tzz@lifelogs.com>
    Re: Probably a dumb s/// question. <tzz@lifelogs.com>
    Re: Regex - every character but " <spamtrap@dot-app.org>
        Switch.pm affecting < > operator <mritty@gmail.com>
    Re: Switch.pm affecting < > operator <1usa@llenroc.ude.invalid>
        time stamps in perl?? <packetboy@yahoo.com>
    Re: time stamps in perl?? <mritty@gmail.com>
    Re: time stamps in perl?? <Im.so.HuckinFappy@spamgourmet.com>
    Re: time stamps in perl?? <packetboy@yahoo.com>
    Re: time stamps in perl?? <tintin@invalid.invalid>
        Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)

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

Date: Thu, 17 Mar 2005 17:25:22 +0000 (UTC)
From: sales@no-back-this.com
Subject: ¸Û¸u Free Lance ¤¬Ápºôµ¸¤u§@­û¤@¦W..................................
Message-Id: <d1cei2$1dl$34@news.hgc.com.hk>

¤¬Ápºôµ¸ªA°È¤½¥q
¸Û¸u Free Lance ºôµ¸¤u§@­û¤@¦W
»Ý¹ï¤¬Ápºôµ¸ªA°È¦³¤@©w»{ÃÑ,¥]¬A Hosting ¤Î Web-Design.
Free Lance §Î¦¡¤u§@,¤£¥Î¤W¯Z,¦ý¥²¶·¦³³d¥ô¤ß,ªÖ¾ÇªÖ°µ.
¤u§@½d³ò¥D­n¸ò¶i«È¤á,¹q¸Ü©Î¹q¶l¸Ñµª«È¤á°ÝÃD,ºôµ¸±À¼sµ¥.

¦³·N§ë¨­¤¬Ápºôªº«ÈªA¤u§@ªÌ½Ð¦^ÂлդUªº¸Ô²Ó¸ê®Æ,¦p»Õ¤Uªº¸ê®Æ¤£§¹¾ã,®¤¤£±µ¨ü!
©m¦W : 
¹q¸Ü :
«Î¦í¦a°Ï :
¾Ç¾ú :
¦~ÄÖ :
©Ê§O :
¹ï¹q¸£¤Î¤¬Ápºôªº»{ÃÑ :
¦Û§Ú¤¶²Ð :
²{¦b¤u§@ :
¤u§@¸g¾ú :

½Ð±N¥H¤W¸ê®Æ¦^ÂШì : admin@hkhost.net
uHost Networking System..................................


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

Date: Thu, 17 Mar 2005 13:28:29 +0100
From: Gunnar Hjalmarsson <noreply@gunnar.cc>
Subject: Re: FAQ 9.16 How do I decode a CGI form?
Message-Id: <39tbhmF65j380U1@individual.net>

PerlFAQ Server wrote:
> 
> 9.16: How do I decode a CGI form?

I was under the impression that this FAQ entry has undergone significant 
changes.

http://faq.perl.org/perlfaq9.html#How_do_I_decode_a_CG

Aren't these automatic postings supposed to reflect the latest FAQ version?

-- 
Gunnar Hjalmarsson
Email: http://www.gunnar.cc/cgi-bin/contact.pl


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

Date: Thu, 17 Mar 2005 08:31:51 -0600
From: "me" <anonymous@_.com>
Subject: Re: HTML table position text injector?
Message-Id: <113j57qe25sfi05@corp.supernews.com>

"Dan Jacobson" <jidanni@jidanni.org> wrote in message
news:87is3r42k9.fsf@jidanni.org...
> Gentlemen, often HTML tables meant for regular monitors become hard to
> keep one's place reading when viewed on small handheld devices. So
> let's insert visual clues -- letters or numbers indicating what column
> we are looking at -- right into the text of the table, so the user is
> sure to know what column an item was in, no matter how jumbled the
> table ends up.
>
> Let's put a,b,c,d before each bus departure time:
> aNurdsburg      bTurdsburg     cNorflewitz     dBlahsville
> eSoftstools       fBoogerworth     gSnitsville
>  a16:20       b16:50       c17:15           d
> e18:50        f19:20        g22:00
> (Blahsville to boring to stop in these days.)
>
> One might further deal with e.g., COLSPAN="3": a-c or abc.
> Multi-dimensional tables: a3, c7b etc.
>
> HTML::TableExtract, HTML::Parser is way over my head.
> Anyway perhaps somebody has already made a table position text injector?
>
> (What I did:)
> $ wget -O - http://www.fybus.com.tw/bus8.htm| #[1.6MB Big5]
> tr -d \\n|perl -pwe 's/<t[dhr]/\n$&/ig'|
> perl -pwe '$c=ord q{a}if/<tr/i;
> s/<t[dh][^>]*>(<[^t\/][^>]*>|\&nbsp\;|\s)*/$&.chr $c++/ige'
> ... plucker-build ... pilot-xfer

Son, I hate to burst your bubble but I'm not waiting for a 1.6MB table to
download, most especially without a loading message to tell me if the page
even exists.
Signed,
me




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

Date: 17 Mar 2005 10:00:01 -0800
From: "advice please wireless 802.11 on RH8" <buellboy@gmail.com>
Subject: Re: Is there a perl array for...
Message-Id: <1111082401.657983.60260@g14g2000cwa.googlegroups.com>


Sherm Pendley wrote:
> advice please wireless 802.11 on RH8 wrote:
>
> > No, I meant an array to contain matches such as for:
> >
> >    $_ = 'cat  12  Felix  17 Anytown NY';
> >
> >    print "yes!"\n" if /^(cat|dog)\s+(\d+)\s+(\w+)\s+(\d+)/;
> > # this mystery array would now contain qw(cat 12 Felix 17)
> >
> >   ---------------------------------------
> >
> > It seems to me this would be common enough to store as a system
array
> > somewhere? By system array I mean one like @_ or @ARGV, etc.. ,
> > something created for us by Perl...
>
> Like I said before, just assign the results of the comparison to any
array
> you like:
>
>     #!/usr/bin/perl
>
>     use warnings;
>     use strict;
>
>     my @animals = ('cat 12 Felix', 'horse 20 Ed');
>
>     foreach (@animals) {
>         if (my @matches = /^(cat|dog)\s+(\d+)\s+(\w+)/) {
>             print join(',', @matches), "\n";
>         }
>         if (my ($species, $age, $name) =
/^(cat|dog)\s+(\d+)\s+(\w+)/) {
>             print "Name=$name, age=$age, species=$species\n";
>         }
>     }
Sherm Pendley wrote:

 .
 .

>
> Why are you so insistent on a built-in array, anyway? I can
understand being
> lazy, but c'mon - is typing "my @matches = " such a hardship???
>
> sherm--
>


It's not about laziness, its about style and versatility. There are
many cases where I need the LHS for something else besides an array
assignment. That's not always practical, and it can also lead to parens
around expressions that make the syntax harder to read. I have to keep
things as simple as I can we have a lot of rookies on this team.

It also seemed inconsistent that whenever Perl "can" capture arrays or
hashes, i.e. %ENV, @_, @ARGV, etc, it seems to like to do so. Here is a
case where it would be perfectly natural to capture $1 $2 $3 ... as an
array and it doesn't.

So it's not that I'm insisting this array to be there, it's just that I
thought I'd "missed" something that perhaps wasn't in Camel but still
present in the language.  I have missed things before, believe it or
not!

No need to get sardonic about it, Sherm old pal, I was just asking.
That's how you learn things. Now I know.


BB

In case you're wondering WHICH one BTW, it's an X1W.



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

Date: 17 Mar 2005 07:01:41 -0800
From: "Kristo" <kristo605@gmail.com>
Subject: Is this considered ugly?
Message-Id: <1111070399.123733.168230@f14g2000cwb.googlegroups.com>

I'm in the process of learning Perl and I'm wondering if there's a
preferred way to do the following.  I have a list of strings that
potentially will contain ampersands.  I'd like to replace all
occurrances of & with &amp; for use on a webpage.  Here's what I have
so far:

use warnings;
use strict;

my ($foo, $bar, $baz) = ("A&B", "C&D", "E&F");
foreach (($foo, $bar, $baz))
{
     s/&/&amp;/g;
}
print "Foo = $foo, Bar = $bar, Baz = $baz\n";
__END__

This outputs "Foo = A&amp;B, Bar = C&amp;D, Baz = E&amp;F" as expected.
The reason I chose to name each element of the list was so I could use
the strings later and retain an idea of what each element represented.
Now, in an attempt to be more concise, I came up with this:

use warnings;
use strict;

my @foo = ("A&B", "C&D", "E&F");
foreach (@foo)
{
     s/&/&amp;/g;
}
print "Foo = $foo[0], Bar = $foo[1], Baz = $foo[2]\n";
__END__

I've succeeded in making the code shorter but at the cost of having to
remember which list element goes with each subscript.  My question to
everyone is this: which approach is more "Perlish"?

Thanks in advance.

Kristo



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

Date: Thu, 17 Mar 2005 15:13:38 GMT
From: "Paul Lalli" <mritty@gmail.com>
Subject: Re: Is this considered ugly?
Message-Id: <C8h_d.2754$Ue6.2445@trndny04>

"Kristo" <kristo605@gmail.com> wrote in message
news:1111070399.123733.168230@f14g2000cwb.googlegroups.com...
> I'm in the process of learning Perl and I'm wondering if there's a
> preferred way to do the following.  I have a list of strings that
> potentially will contain ampersands.  I'd like to replace all
> occurrances of & with &amp; for use on a webpage.  Here's what I have
> so far:
>
> use warnings;
> use strict;
>
> my ($foo, $bar, $baz) = ("A&B", "C&D", "E&F");
> foreach (($foo, $bar, $baz))
> {
>      s/&/&amp;/g;
> }
> print "Foo = $foo, Bar = $bar, Baz = $baz\n";
> __END__
>
> This outputs "Foo = A&amp;B, Bar = C&amp;D, Baz = E&amp;F" as
expected.
> The reason I chose to name each element of the list was so I could use
> the strings later and retain an idea of what each element represented.
> Now, in an attempt to be more concise, I came up with this:
>
> use warnings;
> use strict;
>
> my @foo = ("A&B", "C&D", "E&F");
> foreach (@foo)
> {
>      s/&/&amp;/g;
> }
> print "Foo = $foo[0], Bar = $foo[1], Baz = $foo[2]\n";
> __END__
>
> I've succeeded in making the code shorter but at the cost of having to
> remember which list element goes with each subscript.  My question to
> everyone is this: which approach is more "Perlish"?

Neither. :)

Hashes are used exactly for this reason - to associate a string with the
value in that position of the structure.

my %strs = (Foo=>'A&B', Bar=>'C&D', Baz=>'E&F');
foreach (keys %strs){
  $strs{$_} =~ s/&/&amp;/g;
}
print join (', ', map "$_ = $strs{$_}", keys %strs), "\n";

Also, there already exists a function do do the substitution you're
looking for.  It is CGI::escapeHTML.  This will convert & to &amp;, < to
&lt;, etc:

#!/usr/bin/perl
use strict;
use warnings;
use CGI qw/escapeHTML/;
my %strs = (Foo=>'A&B', Bar=>'C&D', Baz=>'E&F', Omega=>'5<8');
foreach (keys %strs){
  $strs{$_} = escapeHTML($strs{$_});
}
print join (', ', map "$_ = $strs{$_}", keys %strs), "\n";
__END__

For more information on what I've used here:
hashes: perldoc perldata
map: perldoc -f map
join: perldoc -f map
escapeHTML: perldoc CGI

Hope this helps,
Paul Lalli



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

Date: 17 Mar 2005 09:06:51 -0800
From: "Manzoorul Hassan" <manzoorul.hassan@gmail.com>
Subject: Log files in a Date / Time Stamped Directory
Message-Id: <1111079211.149421.111240@l41g2000cwc.googlegroups.com>

I would like to store my logs in a Directory / Subdirectory tree that
corresponds to the date / time the script is executed. For example, if
the script is executed today and noon, then the logs would be stored
under 20050317/1200/

How do I do this?

- manzoor



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

Date: Thu, 17 Mar 2005 17:38:14 +0000
From: Brian McCauley <nobull@mail.com>
Subject: Re: Log files in a Date / Time Stamped Directory
Message-Id: <d1cevg$rkd$1@sun3.bham.ac.uk>



Manzoorul Hassan wrote:
> I would like to store my logs in a Directory / Subdirectory tree that
> corresponds to the date / time the script is executed. For example, if
> the script is executed today and noon, then the logs would be stored
> under 20050317/1200/
> 
> How do I do this?

What have you tried?  How did it fail?



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

Date: Thu, 17 Mar 2005 17:40:40 +0000
From: Brian McCauley <nobull@mail.com>
Subject: Re: Log files in a Date / Time Stamped Directory
Message-Id: <d1cf41$rke$1@sun3.bham.ac.uk>



Manzoorul Hassan wrote:

> I would like to store my logs in a Directory / Subdirectory tree that
> corresponds to the date / time the script is executed. For example, if
> the script is executed today and noon, then the logs would be stored
> under 20050317/1200/
> 
> How do I do this?

perldoc -f localtime



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

Date: Thu, 17 Mar 2005 12:25:20 -0600
From: Tad McClellan <tadmc@augustmail.com>
Subject: Re: Log files in a Date / Time Stamped Directory
Message-Id: <slrnd3jisg.3ur.tadmc@magna.augustmail.com>

Manzoorul Hassan <manzoorul.hassan@gmail.com> wrote:
> I would like to store my logs in a Directory / Subdirectory tree that
> corresponds to the date / time the script is executed. For example, if
> the script is executed today and noon, then the logs would be stored
> under 20050317/1200/
> 
> How do I do this?


   perldoc -f time
   perldoc -f localtime
   perldoc -f gmtime
   perldoc -f mkdir


-- 
    Tad McClellan                          SGML consulting
    tadmc@augustmail.com                   Perl programming
    Fort Worth, Texas


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

Date: Thu, 17 Mar 2005 11:07:09 GMT
From: "John W. Krahn" <someone@example.com>
Subject: Re: Maximum string length in perl
Message-Id: <xxd_d.60750$gJ3.51020@clgrps13>

Murugesh wrote:
> 
> John W. Krahn wrote:
> 
>> Murugesh wrote:
>>>
>>>   Thanks ! that works!
>>>   My content is not a binary file.In Windows, I tried ,
>>>   my $str = do{ undef $/; <FH> };
>>
>> You shouldn't undef() a global variable like that, it will affect your 
>> whole
>> program.  You should use local() instead:
>>
>> my $str = do{ local $/; <FH> };
>
 >   Does local method also undefines $/.

Yes.


John
-- 
use Perl;
program
fulfillment


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

Date: Thu, 17 Mar 2005 12:09:02 -0500
From: "Barry_Alder" <alder.bw@forces.gc.ca>
Subject: Pattern Matching
Message-Id: <4626a5ab1c91dcf87fb285954559b648@localhost.talkaboutprogramming.com>

I've run into a small problem in trying to match a string in another string
that contains the '?' character.

The code is as follows

$t1 = '    <NoMultiLoop Pattern='??REP2'/>';
$t2 = 'REP2';
$idx = index($t1, $t2);

Using 'index' does not return a match, and neither does 'm' or '=~'.

Any suggestions as to how I can find a match?

I'm running on Windows 2000 with PERL v5.6.1

Thanks!





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

Date: Thu, 17 Mar 2005 18:22:46 +0100
From: phaylon <phaylon@dunkelheit.at>
Subject: Re: Pattern Matching
Message-Id: <pan.2005.03.17.17.22.46.65106@dunkelheit.at>

Barry_Alder wrote:

> Any suggestions as to how I can find a match?

Read(!) the Posting Guidelines. Add use warnings and use strict to the
head of your script and don't use not-escaped singlequotes in singlequotes.

-- 
http://www.dunkelheit.at/

Ordinary morality is only for ordinary people.
                       -- Aleister Crowley



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

Date: 17 Mar 2005 09:28:49 -0800
From: "jl_post@hotmail.com" <jl_post@hotmail.com>
Subject: Re: Pattern Matching
Message-Id: <1111080529.915317.64780@z14g2000cwz.googlegroups.com>

Barry_Alder wrote:
>
> I've run into a small problem in trying to match a string in
> another string that contains the '?' character.
>
> The code is as follows
>
> $t1 = '    <NoMultiLoop Pattern='??REP2'/>';
> $t2 = 'REP2';
> $idx = index($t1, $t2);


Dear Barry,

   Look at the line that says:

      $t1 = '    <NoMultiLoop Pattern='??REP2'/>';

Try adding the line:

      print "\$t1: $t1\n";

right after it.  Does it print what you'd expect?

   One problem is that you are using unescaped single-quote characters
inside a string delimited with single-quotes.  As a result, the Perl
interpreter thinks the $t1 string ends with "Pattern=".  (As a result,
I have no idea how you got the Perl script to compile and run.)

   My suggestion is to change the line that assigns to $t1 to:

      $t1 = "    <NoMultiLoop Pattern='??REP2'/>";

and see if that fixes your problem.  (The only thing that's different
is that the quotes that specify the string are now double-quotes
instead of single-quotes.)

   I hope this helps, Barry.

   -- Jean-Luc



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

Date: 17 Mar 2005 17:29:49 GMT
From: roberson@ibd.nrc-cnrc.gc.ca (Walter Roberson)
Subject: Re: Pattern Matching
Message-Id: <d1ceqd$9ud$1@canopus.cc.umanitoba.ca>

In article <4626a5ab1c91dcf87fb285954559b648@localhost.talkaboutprogramming.com>,
Barry_Alder <alder.bw@forces.gc.ca> wrote:
:I've run into a small problem in trying to match a string in another string
:that contains the '?' character.

:The code is as follows

:$t1 = '    <NoMultiLoop Pattern='??REP2'/>';

You start the string with ' and the next ' is not escaped,
so the string ends just after the = . Then you have a ?
operator, which is going to test the left hand side string;
since it is not empty, the result would be logically true.
But then you hit another ? operator and that's not allowed
there.

I don't think your code will even compile.

Perhaps you want:

$t1 = '    <NoMultiLoop Pattern=\'??REP2\'/>';
-- 
Would you buy a used bit from this man??


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

Date: Thu, 17 Mar 2005 14:00:20 -0500
From: "Barry_Alder" <alder.bw@forces.gc.ca>
Subject: Re: Pattern Matching
Message-Id: <6d79eff22f7c1464fd922cf92db6c370@localhost.talkaboutprogramming.com>

First of all, thank you all for the quick response.

Secondly, mea culpa, mea culpa, mea culpa. In my rush to simplify the
explanation, I didn't give a clean example. 

The following is the test program I am using.
=================================
open (MOD, "bec2.xml");
@ModLines = <MOD>;
$t2 = 'BFAX';
  $TRUE = 1;
  $icnt = 0;
  while ( $TRUE )
    {
     $t4 = @Modlines[$icnt];
     $t3 = index ($t4 , $t2);
     print "index is $t3: @ModLines[$icnt]\n";
     $icnt++;
     if ($icnt > $#ModLines )
       { exit 0 ; }
    }
=====================================
This is the test file I am using:
=====================================
<?xml version="1.0"?>
<BecSettings
    <Stream Name="House" Type="OverNight" Mode="Dynamic" Blast="S"
Dependencies="Report1" Condition="Done"/>
    <NoMultiLoop Pattern='??BFAX'/>
    <NoMultiLoop Pattern='??BELM'/>
    <NoMultiLoop Pattern='??B907'/>
</BecSettings>
=====================================
And here are the results of the run
===============================
index is -1: <?xml version="1.0"?>

index is -1: <BecSettings

index is -1:     <Stream Name="House" Type="OverNight" Mode="Dynamic"
Blast="S"
Dependencies="Report1" Condition="Done"/>

index is -1:     <NoMultiLoop Pattern='??BFAX'/>

index is -1:     <NoMultiLoop Pattern='??BELM'/>

index is -1:     <NoMultiLoop Pattern='??B907'/>

index is -1: </BecSettings>
==========================================

Note that the input line that does contain the 'BFAX' string didn' get
matched.

Can anyone suggest how I can process the file to get a match. Note that
this is only a test file and the real-life file will be more complicated
and bigger.

Thanks again,

Barry



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

Date: Thu, 17 Mar 2005 21:30:48 +0000
From: Andrew Tkachenko <pobugfix@peterlink.ru>
Subject: Re: perl & corba
Message-Id: <d1cigb$e24$1@news.rol.ru>

Ted Zlatanov wrote on 16 Март 2005 16:33:

> On Tue, 15 Mar 2005, pobugfix@peterlink.ru wrote:
> 
>> No, thanks. As i said above, I'm looking for points from people who use
perl
>> bindings in their projects. IMHO except MICO and ORBit bindings the rest
>> are not supported and all and useful just for home work rather than for
>> serious proj.
> 
> Sounds like your mind is already made up, Andrew.
> 
> FWIW, I find the other RPC methods available for Perl, mainly XML-RPC
> and SOAP, much better than CORBA for all purposes.  I think most Perl
> programmers would agree, so you probably won't get too many responses
> from people that use Perl with CORBA.
> 
> Ted

Unfortunately, all of them can't deal with objects. SOAP and XML-RPC are
almost the same things. Also, SOAP implementation for perl is a SOAP::Lite
module only. And this module is not quite suitable for me.
Thanks.

-- 
Andrew


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

Date: Thu, 17 Mar 2005 14:29:33 +0100
From: Gunnar Hjalmarsson <noreply@gunnar.cc>
Subject: Re: pop3 and http proxy
Message-Id: <39tf4rF64juuhU1@individual.net>

Daniel wrote:
> I need to write a small tool to read mail from a mailbox using pop3.
> the problem i have is that i use proxy to connect to the internet, and
> the Net::Pop3 does not support proxy. outlook can get to the mailbox
> with no problem.
> can someone give me direction how do i use proxy for pop3 in perl?

Did you search for "proxy" at CPAN?

A commercial Perl script that works fine also on proxy connections is: 
http://www.endymion.com/products/mailman/

-- 
Gunnar Hjalmarsson
Email: http://www.gunnar.cc/cgi-bin/contact.pl


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

Date: Thu, 17 Mar 2005 10:26:41 -0500
From: Ted Zlatanov <tzz@lifelogs.com>
Subject: Re: Probably a dumb s/// question.
Message-Id: <4n64zqcmz2.fsf@lifelogs.com>

On Wed, 16 Mar 2005, tadmc@augustmail.com wrote:

Ted Zlatanov <tzz@lifelogs.com> wrote: 

>> It's probably better to do something like this:
>> 
>> perl -p -e's/(\w+)/ucfirst($1)/eg'
> 
> Try it on this string:
> 
>     it's a wonderful life!

Like I said, Text::Capitalize is better than any of the other
solutions, unless the OP really did mean the original requirements.
Natural language-such as it is- can,and often IS very tricky! :)

Ted


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

Date: Thu, 17 Mar 2005 10:41:05 -0500
From: Ted Zlatanov <tzz@lifelogs.com>
Subject: Re: Probably a dumb s/// question.
Message-Id: <4nzmx2b7qm.fsf@lifelogs.com>

On Wed, 16 Mar 2005, tadmc@augustmail.com wrote:

> \u _is_ ucfirst(), it respects locales too.

I see this in perldoc perlre:

"         \u          uppercase next char (think vi)
 ...
       If "use locale" is in effect, the case map used by "\l", "\L",
       "\u" and "\U" is taken from the current locale.  See
       perllocale."

This is not, however, the same as ucfirst.  It's 
uc($char1) . $rest
not 
ucfirst($char1 . $rest)

In fact, ucfirst() should do a Titlecase, as it's called in Unicode,
although I don't know if the internal Perl implementation does exactly
that.  Titlecase is not the uppercasing of the first character,
although in English it usually works that way.

Why is this important?  If you look at the Unicode standard, there is
a good example:
(from http://www.unicode.org/reports/tr21/tr21-3.html)

"Characters may also have different case mappings, depending on the context.

For example, 03A3 capital sigma lowercases to 03C3 small sigma if it
is followed by another letter, but lowercases to 03C2 small final
sigma if it is not."

and later

"Converting to Titlecase

Map each character to its titlecase or lowercase. If the preceeding
letter is cased, chose the lowercase mapping; otherwise chose the
titlecase mapping (in most cases, this will be the same as the
uppercase, but not always)."

The Unicode standard feels strongly enough about titlecasing to define
different terms for it and to explicitly warn about just uppercasing
the first character.  That's why I brought it up.  Sorry I didn't
expand on it earlier.

Sorry to get into technicalities like this, but I feel the point is
important for anyone interested in Unicode programming.  Often, things
that seem obvious in English are radically different in other
languages and writing systems.

> For this application, we don't need to ensure that it is a letter at all:
> 
>    s/(^|\s)(.)/$1\u$2/g;

Yes, noted by others too.  As I said, Text::Capitalize is probably
what the OP wants.  My point was just that [a-z] is a good sign of trouble.

Ted


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

Date: Thu, 17 Mar 2005 10:03:50 -0500
From: Sherm Pendley <spamtrap@dot-app.org>
Subject: Re: Regex - every character but "
Message-Id: <D5qdnWs1O7jFAaTfRVn-rQ@adelphia.com>

Bob Walton wrote:

> Sherm Pendley wrote:
> 
>>     [\x00..\x7f]
> 
> That should probably be:
> 
>        [\x00-\x7f]

Yep. Got stuck in a for() loop. :-\

Good catch, thanks.

sherm--

-- 
Cocoa programming in Perl: http://camelbones.sourceforge.net
Hire me! My resume: http://www.dot-app.org


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

Date: Thu, 17 Mar 2005 13:41:14 GMT
From: "Paul Lalli" <mritty@gmail.com>
Subject: Switch.pm affecting < > operator
Message-Id: <_Nf_d.14070$FB6.4085@trndny09>

Greetings.

I'm noticing some bizzare behavior when use'ing the Switch.pm module.
It seems to be affecting how the < > operator behaves when the
filehandle enclosed is stored in a lexical reference.  The behavior is
seen using perl v5.8.0 on solaris, with Switch.pm v2.09.  An example:

#!/usr/bin/perl
use Switch;
use strict;
use warnings;

open my $fh, '<', $ARGV[0] or die "Cannot open $ARGV[0]: $!";
while (my $line = <$fh>){
  print "Read: $line";
}
close $fh;

my $foo = 1;
switch ($foo){
  case 1{
    print "foo =1\n";
  }
  case 2 {
    print "foo = 2\n";
  }
}
__END__

Run this script passing any text file on the command line.  (I cannot
post a self-contained example using __DATA__, as you'll see in a
moment).  The output is not the lines of the file, but rather a GLOB
reference:

Read: GLOB(0x2496c)foo =1

Running the example through B::Deparse shows the reason for the odd
output:

use Switch;
BEGIN {${^WARNING_BITS} = "UUUUUUUUUUUU"}
use strict 'refs';
die "Cannot open $ARGV[0]: $!" unless open my $fh, '<', $ARGV[0];
use File::Glob ();
while (defined(my $line = glob(' ' . $fh))) {
    print "Read: $line";
}
close $fh;
[snip remaining code]

Why would C<<$fh>> be treated as C<glob(' ' . $fh)> rather than
C<readline($fh)>?

The example works fine when the use Switch; line and switch($foo) block
are all commented out.  It will manifest the problem if the switch block
is commented out (either through POD blocks or multiple #'s) but use
Switch; remains.  It will NOT manifest the problem if the switch block
is actually removed from the file.

If we change the example to use bareword filehandles instead of lexical
referenced filehandles, the problem does not manifest itself:

#!/usr/bin/perl
use Switch;
use strict;
use warnings;

open FH, '<', $ARGV[0] or die "Cannot open $ARGV[0]: $!";
while (my $line = <FH>){
  print "Read: $line";
}
close FH;

my $foo = 1;
switch ($foo){
  case 1{
    print "foo =1\n";
  }
  case 2 {
    print "foo = 2\n";
  }
}

__END__

This code works fine.

Note that I do have access to another solaris system running perl 5.8.2
and Switch.pm v2.10, which does not manifest this issue, so I'm content
to call it a bug fix.  The problem is that I have found no references to
this issue in the Switch.pm docs nor the perldelta's for 5.8.1 or 5.8.2.
Has anyone else ever seen this?

Thank you for your time,
Paul Lalli





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

Date: Thu, 17 Mar 2005 15:54:53 GMT
From: "A. Sinan Unur" <1usa@llenroc.ude.invalid>
Subject: Re: Switch.pm affecting < > operator
Message-Id: <Xns961C6F077A12Easu1cornelledu@127.0.0.1>

"Paul Lalli" <mritty@gmail.com> wrote in
news:_Nf_d.14070$FB6.4085@trndny09: 

> I'm noticing some bizzare behavior when use'ing the Switch.pm module.

 ...
> The problem is that I have found no references to this issue in the 
> Switch.pm docs nor the perldelta's for 5.8.1 or 5.8.2. Has anyone 
> else ever seen this?

Paul:

I have no clues to offer, but just the observation that your test script 
ran as expected on my system, Win XPSP2 and

D:\Home\asu1\UseNet\clpmisc> perl -v

This is perl, v5.8.6 built for MSWin32-x86-multi-thread

Ditto for:

asu1:~ > perl -v
This is perl, v5.8.6 built for i386-freebsd-64int

Sorry, can't be of more help.

Sinan.


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

Date: Thu, 17 Mar 2005 10:58:27 -0500
From: "p@ck3th@xr" <packetboy@yahoo.com>
Subject: time stamps in perl??
Message-Id: <pan.2005.03.17.15.58.26.921615@yahoo.com>

is there a time function (or even a 3rd party module) that can get the
time in the following format: eg 200503171055  ?
-> 2005 - 03 - 17 - 10:55am
basically i want to backup log files with that sort of format.
eg. rename "file.new", "file.200503171055";

TIA


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

Date: Thu, 17 Mar 2005 16:08:09 GMT
From: "Paul Lalli" <mritty@gmail.com>
Subject: Re: time stamps in perl??
Message-Id: <JXh_d.4356$jt6.2954@trndny07>

"p@ck3th@xr" <packetboy@yahoo.com> wrote in message
news:pan.2005.03.17.15.58.26.921615@yahoo.com...
> is there a time function (or even a 3rd party module) that can get the
> time in the following format: eg 200503171055  ?
> -> 2005 - 03 - 17 - 10:55am
> basically i want to backup log files with that sort of format.
> eg. rename "file.new", "file.200503171055";

Have you read the posting guidelines for this group?  You are expected
to check the built-in Perl documentation *before* posting.

perldoc -f time
which will lead you to
perldoc -f localtime

Paul Lalli



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

Date: Thu, 17 Mar 2005 09:06:58 -0700
From: Jeff <Im.so.HuckinFappy@spamgourmet.com>
Subject: Re: time stamps in perl??
Message-Id: <d1c9v3$2ea1@xco-news.xilinx.com>

p@ck3th@xr wrote:
> is there a time function (or even a 3rd party module) that can get the
> time in the following format: eg 200503171055  ?
> -> 2005 - 03 - 17 - 10:55am
> basically i want to backup log files with that sort of format.
> eg. rename "file.new", "file.200503171055";

See the Time::CTime module from CPAN:

stampes@flux[6] ~ > perl -MTime::CTime -e 'print strftime("%Y%m%d%H%M", 
localtime( time )), "\n"'
200503170905

~Jeff


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

Date: Thu, 17 Mar 2005 11:26:45 -0500
From: "p@ck3th@xr" <packetboy@yahoo.com>
Subject: Re: time stamps in perl??
Message-Id: <pan.2005.03.17.16.26.43.574798@yahoo.com>

thanks jeff.

On Thu, 17 Mar 2005 09:06:58 -0700, Jeff wrote:

> p@ck3th@xr wrote:
>> is there a time function (or even a 3rd party module) that can get the
>> time in the following format: eg 200503171055  ?
>> -> 2005 - 03 - 17 - 10:55am
>> basically i want to backup log files with that sort of format.
>> eg. rename "file.new", "file.200503171055";
> 
> See the Time::CTime module from CPAN:
> 
> stampes@flux[6] ~ > perl -MTime::CTime -e 'print strftime("%Y%m%d%H%M", 
> localtime( time )), "\n"'
> 200503170905
> 
> ~Jeff



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

Date: Fri, 18 Mar 2005 07:32:04 +1300
From: "Tintin" <tintin@invalid.invalid>
Subject: Re: time stamps in perl??
Message-Id: <39u0p6F65j25uU1@individual.net>


"p@ck3th@xr" <packetboy@yahoo.com> wrote in message 
news:pan.2005.03.17.15.58.26.921615@yahoo.com...
> is there a time function (or even a 3rd party module) that can get the
> time in the following format: eg 200503171055  ?
> -> 2005 - 03 - 17 - 10:55am
> basically i want to backup log files with that sort of format.
> eg. rename "file.new", "file.200503171055";

use POSIX 'strftime';
print strftime "%Y%m%d%H%M", localtime();




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

Date: 6 Apr 2001 21:33:47 GMT (Last modified)
From: Perl-Users-Request@ruby.oce.orst.edu (Perl-Users-Digest Admin) 
Subject: Digest Administrivia (Last modified: 6 Apr 01)
Message-Id: <null>


Administrivia:

#The Perl-Users Digest is a retransmission of the USENET newsgroup
#comp.lang.perl.misc.  For subscription or unsubscription requests, send
#the single line:
#
#	subscribe perl-users
#or:
#	unsubscribe perl-users
#
#to almanac@ruby.oce.orst.edu.  

NOTE: due to the current flood of worm email banging on ruby, the smtp
server on ruby has been shut off until further notice. 

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

#To request back copies (available for a week or so), send your request
#to almanac@ruby.oce.orst.edu with the command "send perl-users x.y",
#where x is the volume number and y is the issue number.

#For other requests pertaining to the digest, send mail to
#perl-users-request@ruby.oce.orst.edu. Do not waste your time or mine
#sending perl questions to the -request address, I don't have time to
#answer them even if I did know the answer.


------------------------------
End of Perl-Users Digest V10 Issue 7891
***************************************


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