[28063] in Perl-Users-Digest
Perl-Users Digest, Issue: 9427 Volume: 10
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Wed Jul 5 18:05:49 2006
Date: Wed, 5 Jul 2006 15:05:05 -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 Wed, 5 Jul 2006 Volume: 10 Number: 9427
Today's topics:
Re: 'Undifined commands' on FTP Server, when using FTP <chris-usenet@roaima.co.uk>
cgi script in perl with password protection <cljlk@hotmail.com>
Re: cgi script in perl with password protection <no@email.com>
Re: cgi script in perl with password protection xhoster@gmail.com
Re: Crimson Editor query <bg1act@yahoo.com.au>
Re: date format axel@white-eagle.invalid.uk
Re: File Handles, Perl Naming, Agglutination in Natural <vtatila@mail.student.oulu.fi>
Re: How to use mechanize on https pages? <brian.d.foy@gmail.com>
Re: languages with full unicode support <DaleWKing@gmail.com>
Re: Learning Typeglobs, Symbol Tables and the More Obsc <vtatila@mail.student.oulu.fi>
Re: Learning Typeglobs, Symbol Tables and the More Obsc anno4000@radom.zrz.tu-berlin.de
Re: Learning Typeglobs, Symbol Tables and the More Obsc <ced@blv-sam-01.ca.boeing.com>
Re: Learning Typeglobs: Assignment Confusion Cleared <vtatila@mail.student.oulu.fi>
Perl Hacks: Rough Cuts Version: buy bk+net, or just boo (David Combs)
Re: Problem with split <r.ted.byers@rogers.com>
Reg: "pattern match read eof" error <dinakar.reddy@gmail.com>
Re: Searching a string in a list of delimited fields <mritty@gmail.com>
Re: Searching a string in a list of delimited fields <jgibson@mail.arc.nasa.gov>
Terse vs didactic. Was Re: date format <scobloke2@infotop.co.uk>
Re: unicode anno4000@radom.zrz.tu-berlin.de
Re: unicode <syscjm@gwu.edu>
Re: unicode <syscjm@gwu.edu>
Re: Using reference for performance gain? <uri@stemsystems.com>
Re: Win32: File Manipulation <mritty@gmail.com>
Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: Tue, 4 Jul 2006 14:02:59 +0100
From: Chris Davies <chris-usenet@roaima.co.uk>
Subject: Re: 'Undifined commands' on FTP Server, when using FTP 'put' and 'quit' in Client
Message-Id: <3h5qn3-o9p.ln1@news.roaima.co.uk>
Asaf Sinai <asafsi@radware.com> wrote:
> I use WFTPD as an FTP Server on WIN XP.
> I wrote the following perl program:
[...deleted...]
> As you can see, when the 'put' command was performed, the FTP Server
> did not recognize command ALLO (is it allocate space?).
Read RFC 959 for details of the ALLOCATE command. The server is supposed
to ignore this command if it's not required, which it correctly appears
to do.
> Also after transfer finished successfully, a data signal was received
> ???
I have no idea. Maybe Texas Imperial Software can tell you what triggers
that error message in its software.
> Also after 'quit' command, unknown command was received ???
There isn't anything sent after the QUIT command, so all I can surmise
is that maybe the ftp server isn't processing CR/LF pairs correctly.
Perhaps Texas Imperial Software can give you a better idea.
> When I performed the FTP session from the command line:
> ftp 1.100.100.10
This is a different client, using a different subset of ftp commands, so
it's not necessarily a fair comparison.
If you have access to a network sniffer such as "ethereal" you can dump
the TCP stream and inspect it visually for further clues.
Chris
------------------------------
Date: 5 Jul 2006 12:24:25 -0700
From: "blackdog" <cljlk@hotmail.com>
Subject: cgi script in perl with password protection
Message-Id: <1152127465.679790.277820@a14g2000cwb.googlegroups.com>
I have web site that require enter password, the web site is written in
cgi perl script.
When user enter password, the password display on the web which I don't
like.
How do I handle it, let the password display as "******" instead of
real password.
Thanks
------------------------------
Date: Wed, 05 Jul 2006 20:28:57 +0100
From: Brian Wakem <no@email.com>
Subject: Re: cgi script in perl with password protection
Message-Id: <4h2i7pF1os1m3U1@individual.net>
blackdog wrote:
> I have web site that require enter password, the web site is written in
> cgi perl script.
> When user enter password, the password display on the web which I don't
> like.
> How do I handle it, let the password display as "******" instead of
> real password.
>
> Thanks
This is an HTML question.
The answer is change 'input type="text"' to 'input type="password"'.
--
Brian Wakem
Email: http://homepage.ntlworld.com/b.wakem/myemail.png
------------------------------
Date: 05 Jul 2006 19:35:26 GMT
From: xhoster@gmail.com
Subject: Re: cgi script in perl with password protection
Message-Id: <20060705153626.306$60@newsreader.com>
"blackdog" <cljlk@hotmail.com> wrote:
> I have web site that require enter password, the web site is written in
> cgi perl script.
> When user enter password, the password display on the web which I don't
> like.
> How do I handle it, let the password display as "******" instead of
> real password.
If you are using CGI.pm, then do it the way the perldocs for CGI.pm say to.
If you are rolling the html yourself, then this isn't a Perl question, but
a html question.
Xho
--
-------------------- http://NewsReader.Com/ --------------------
Usenet Newsgroup Service $9.95/Month 30GB
------------------------------
Date: 5 Jul 2006 06:45:48 -0700
From: "goho" <bg1act@yahoo.com.au>
Subject: Re: Crimson Editor query
Message-Id: <1152107148.308326.262180@v61g2000cwv.googlegroups.com>
V S Rawat wrote:
> Anyone using Crimson Editor for working in Perl?
>
> I have set it up and defined perl interpreter in its tools. It is duly
> compiling and executing the program (from within crimson editor). I
> have given "capture output" and it is showing the progress in the lower
> pane.
>
> However, as soon as it encounters some ReadKey/ReadLine command,
> instead of waiting for me to input something, it exits with
>
> > Terminated with exit code 2.
>
> For this reason I have to open a separate dos window to execute the
> program.
>
> Any method of making Crimson Editor accept input from me?
>
> Thanks.
> --
> Rawat
This is way off Perl topic as others have pointed out, so apologies to
those folk, however -
No, CE is a Windows app so it obviously needs some sort of dialogue to
input stuff while run under CE. (AFAIK it has no capabilty of
automatically opening a prompt dialogue - I'm a little bit puzzled how
you intended to get your input into the app other than under a "shell"
like DOS).
Tk is reasonably good for writing quick windows-like dialogues, it
works well under CE and with any luck it will be portable to other OS -
I've never had any probs porting across to *NIX.
That aside, I use CE almost exclusively now whenever my employer(s) say
I have to develop on a Windows box (the ActiveState builds are actually
pretty good!)
------------------------------
Date: Wed, 05 Jul 2006 20:22:23 GMT
From: axel@white-eagle.invalid.uk
Subject: Re: date format
Message-Id: <3cVqg.3483$5K2.3112@fed1read03>
Bart Van der Donck <bart@nijlen.com> wrote:
> spross wrote:
>> sorry, i'm a beginner :)
>> i have a file and the first line looks like:
>> %%%%%%%% HEADER Fri Jun 16 17:21:03 MEST 2006 %%%%%%%%%%%%
>> my question: how chan i get the date in this header in a format like:
>> YYYYMMDD
> #!perl
> use strict;
> use warnings;
> my $file =
> '%%%%%%%% HEADER Fri Jun 16 17:21:03 MEST 2006 %%%%%%%%%%%%
> 1111111111111111111111
> 2222222222222222222222
> 3333333333333333333333
> ';
> my @m = ('Jan', 'Feb', 'Mar', 'Apr', 'May',
> 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec');
> my @ar = split / /, (split /\n/, $file)[0];
> $ar[3] =~ s/$m[$_]/@{[sprintf('%02g',$_+1)]}/ for (0..$#m);
> die "Can't find month '$ar[3]'\n" unless $ar[3]=~/^(0|1)[0-9]$/;
> print $ar[7], $ar[3], sprintf('%02g',$ar[4]);
It seems a bit overcomplicated :)
#!/usr/bin/perl
use strict;
use warnings;
my $s ='%%%%%%%% HEADER Fri Jun 16 17:21:03 MEST 2006 %%%%%%%%%%%%';
my %mon = (Jan => 1, Feb => 2, Mar => 3, Apr => 4, May => 5,
Jun => 6, Jul => 7, Aug => 8, Sep => 9, Oct => 10,
Nov => 11, Dec => 12);
my ($month, $date, $year) = (split ' ', $s)[3, 4, 7];
printf ("%.4d%.2d%.2d\n", $year, $mon{$month}, $date);
__END__
Axel
------------------------------
Date: Wed, 5 Jul 2006 23:43:15 +0300
From: "Veli-Pekka Tätilä" <vtatila@mail.student.oulu.fi>
Subject: Re: File Handles, Perl Naming, Agglutination in Natural Languages (Partly OT:)
Message-Id: <e8h896$ms5$1@news.oulu.fi>
ano 4000 rayden crc 2 per linda
> [typeglobs]
>> open my $handle, $mode, $file
>> the thing stored in the handle is a whole type glob. Print and other
>> functions then magically use the file handle portion of that glob.
>> are directory handles yet another kind of "scalar type"?
> No, dir handles appear as a special case of file handle, both are
> accessed through (say) *main::HANDLE{ IO} as the case may be.
Umm interesting. Is this dirs are files in disguise part of Perl's Unix
heritage? I found it surprising as a user but some Unix man pages includedd
passages like "if a file is a directory" which let me conclude, ok I suppose
that's the case internally.
[Perl naming]
having read Larry Wall's essay on Perl's natural language principles at:
http://www.wall.org/~larry/natural.html
I wonder if Perl 6 will borrow even more from natural languages.
All of my Perl variables and comments are in English so far, though, so I
don't get to use all the fancy suffixes mentioned later on, <grin>. However,
I've tried using a kind of speech-synth friendly Hungarian notation to
denote the perl datatype in some way. I use singular words for scalars if
they aren't references to collections, plurals for arrays and the number 2
(read as the preposition to) to emphasize the kinds of mappings most hashes
are. Sometimes this can get very awkward and I scrap it after all. Hmm,
awkword would that be towards AWK as opposed to say Perlward <smile>?
Finally regarding compounds, I know programmers speaking English as a second
language who like to separate even the words in compounds, preferring to
write $postCard so the naming practices are absolutely clear to everyone.
[natural language OT]
>> contains much less compound words than Finnish does. But then again, the
>> perldocs ues just that and programmres tend to like $hashref better than
>> $hash_ref.
> Heh, the gluing-together of words is one trait shared by our otherwise
> widely unrelated languages , Finnish and German. It happens in English
Quite right, things like video card are compounds here but not in English.
> In my entirely unqualified opinion, there is a
> tendency in English (rather recent, as languages go), to make more
> productive use of agglutination.
> Off topic? What's that?
I think I've seen the term somewhere. Let me guess glueing together pieces
to words to give them new and well-defined meanings. Finnish uses a number
of such suffixes. One of them is sto denoting a collection of things.
"Kirja" (book) "kirjasto" (library), "laiva" (ship) "laivasto"
(both fleat and the Navy), "kone" (machine) "koneisto" (machinery). Needless
to say not all words can be treated like this, even if it would make sense.
--
With kind regards Veli-Pekka Tätilä (vtatila@mail.student.oulu.fi)
Accessibility, game music, synthesizers and programming:
http://www.student.oulu.fi/~vtatila/
------------------------------
Date: Wed, 05 Jul 2006 11:40:47 -0500
From: brian d foy <brian.d.foy@gmail.com>
Subject: Re: How to use mechanize on https pages?
Message-Id: <050720061140472261%brian.d.foy@gmail.com>
In article <4h1a3pF1p2sp5U1@individual.net>, Brian Wakem <no@email.com>
wrote:
> info@perot.com wrote:
>
> > How to use mechanize on https pages?
> >
> > Thanks
>
>
> use Crypt::SSLeay;
Actually, that's not right. You simple need to install that module to
enable that support. You don't use it directly since LWP will
automatically use it if available.
--
Posted via a free Usenet account from http://www.teranews.com
------------------------------
Date: Wed, 05 Jul 2006 14:00:07 -0400
From: Dale King <DaleWKing@gmail.com>
Subject: Re: languages with full unicode support
Message-Id: <6_adneQRdcb3YzbZnZ2dnUVZ_vGdnZ2d@insightbb.com>
Tim Roberts wrote:
> "Xah Lee" <xah@xahlee.org> wrote:
>
>> Languages with Full Unicode Support
>>
>> As far as i know, Java and JavaScript are languages with full, complete
>> unicode support. That is, they allow names to be defined using unicode.
>> (the JavaScript engine used by FireFox support this)
>>
>> As far as i know, here's few other lang's status:
>>
>> C ? No.
>
> This is implementation-defined in C. A compiler is allowed to accept
> variable names with alphabetic Unicode characters outside of ASCII.
I don't think it is implementation defined. I believe it is actually
required by the spec. The trouble is that so few compilers actually
comply with the spec. A few years ago I asked for someone to actually
point to a fully compliant compiler and no one could.
--
Dale King
------------------------------
Date: Wed, 5 Jul 2006 16:18:38 +0300
From: "Veli-Pekka Tätilä" <vtatila@mail.student.oulu.fi>
Subject: Re: Learning Typeglobs, Symbol Tables and the More Obscure Features?
Message-Id: <e8ge7h$lnj$1@news.oulu.fi>
anno4000@radom.zrz.tu-berlin.de wrote:.
> Veli-Pekka Tätilä <vtatila@mail.student.oulu.fi> wrote:
>> I'd like to learn more about the various ways to access and use type
>> globs and how to deal with symbol table entries.
> Don't sweat it. There is one thing a Perl programmer needs to know
> about globs, and that is what
>
> *glob = $ref;
>
> does, where $ref is an arbitrary (non-symbolic) reference. You know
> that, don't you? All everyday aliasing and symbol-table munging can
> be done through that.
OK, thanks for the tip. In light of this, it is hardly Surprising that type
globs seem to get only passing mentions in the docs, then. While I do
realize that Perl can never be mastered entirely, which for me is a reason
to like the language, I sort of thought I should know about the more exotic
bits.
I just recently realized that when you say:
open my $handle, $mode, $file
the thing stored in the handle is a whole type glob. Print and other
functions then magically use the file handle portion of that glob. So my
question is, what else can be stored in type globs? Subroutines, scalars,
arrays and hashes, of course, plus formats, I think. But are directory
handles yet another kind of "scalar type"? I haven't found the answer in the
docs sofar.
On a side note, maybe it is just me but I find the syntax:
*glob = $ref;
slightly confusing. Plainly put, when I assign to something I tend to think
that the value goes on the left (i.e. the right side is evaluated and
whatever it returns is copied). However, in a type glob assignment the right
side becomes an alias of the left. ANd you don't generaly use the left side
after that, because the right side will do just as well being an alias.
>> howabout docs on the rest of the more obscure features that
>> make Perl perl such as formats and symbolic references under use strict
>> 'vars'.
> In my opinion, formats are strictly optional. Some people who happen
> to know how to work with formats still use them, but the majority of
> Perl programmers don't
Which reminds me, are there any recommended Perl libraries for replacing
formats with something more modern and lexical-friendly. One pretty nice
I've come across is Text::Template. The thing that makes it so simple is
that there's virtually no separate sub-language, you can embed PErl code to
be evaluated directly.
<snipped a nice, familiar explanation of symbolic references>
>> PS: Is it a type glob or a typeglob or are both forms OK?
> From one second-language speaker of English to another: both are okay.
Good. I thought type glob would be preferrable having read that English
contains much less compound words than Finnish does. But then again, the
perldocs ues just that and programmres tend to like $hashref better than
$hash_ref.
--
With kind regards Veli-Pekka Tätilä (vtatila@mail.student.oulu.fi)
Accessibility, game music, synthesizers and programming:
http://www.student.oulu.fi/~vtatila/
------------------------------
Date: 5 Jul 2006 17:07:54 GMT
From: anno4000@radom.zrz.tu-berlin.de
Subject: Re: Learning Typeglobs, Symbol Tables and the More Obscure Features?
Message-Id: <4h29vaF1pav9iU1@news.dfncis.de>
Veli-Pekka Tätilä <vtatila@mail.student.oulu.fi> wrote in comp.lang.perl.misc:
> anno4000@radom.zrz.tu-berlin.de wrote:.
> > Veli-Pekka Tätilä <vtatila@mail.student.oulu.fi> wrote:
[typeglobs]
> I just recently realized that when you say:
>
> open my $handle, $mode, $file
>
> the thing stored in the handle is a whole type glob. Print and other
> functions then magically use the file handle portion of that glob. So my
> question is, what else can be stored in type globs? Subroutines, scalars,
> arrays and hashes, of course, plus formats, I think. But are directory
> handles yet another kind of "scalar type"? I haven't found the answer in the
> docs sofar.
No, dir handles appear as a special case of file handle, both are
accessed through (say) *main::HANDLE{ IO} as the case may be.
> On a side note, maybe it is just me but I find the syntax:
>
> *glob = $ref;
>
> slightly confusing. Plainly put, when I assign to something I tend to think
In a follow-up you said:
> Feel free to ignore my syntax complaint earlier in this thread.
so that's what I'm doing.
> >> PS: Is it a type glob or a typeglob or are both forms OK?
> > From one second-language speaker of English to another: both are okay.
> Good. I thought type glob would be preferrable having read that English
> contains much less compound words than Finnish does. But then again, the
> perldocs ues just that and programmres tend to like $hashref better than
> $hash_ref.
Heh, the gluing-together of words is one trait shared by our otherwise
widely unrelated languages, Finnish and German. It happens in English
too, but mostly in fixed combinations (household, waterproof), but not
freely productive. In my entirely unqualified opinion, there is a
tendency in English (rather recent, as languages go), to make more
productive use of agglutination.
Off topic? What's that?
Anno
------------------------------
Date: Wed, 5 Jul 2006 21:08:27 GMT
From: Charles DeRykus <ced@blv-sam-01.ca.boeing.com>
Subject: Re: Learning Typeglobs, Symbol Tables and the More Obscure Features?
Message-Id: <J1y822.C0x@news.boeing.com>
Veli-Pekka Tätilä wrote:
> Hi,
> I'd like to learn more about the various ways to access and use type globs
> and how to deal with symbol table entries. Having started out with Perl 5.8,
> I try to generaly stick to modern solutions such as references, exporter and
> lexical file handles. Yet both type globs and symbol tables seem to pop up
> in interesting places and appear somewhat related because symbol tables hold
> globs and even some of the glob syntax looks like dereferencing to me. As
> for usage, aliasing variable names like English does, creating truely
> "weird" classses based on type globs, implementing callbacks using the
> caller's package variables such as those in List::Util and installing new
> subroutines (Memoize) or applying reflection come to mind.
>
> Most books only briefly mention type globs and symbol tables, and even
> Programming Perl has the information scattered in various places. Advanced
> Perl Programming appears to have a whole chapter on the topic, number 3 that
> is, but even so not all of the syntax such as *foo{thing} is covered, as far
> as I can tell.
>
>...
>
> So are there any good books, tutorials or references that would fully cover
> symbol tables and type globs, in particular, their usage in Perl 5? I'd
> prefer on-line sources. Now that I'm here I'll also slip in another
> question, howabout docs on the rest of the more obscure features that make
> Perl perl such as formats and symbolic references under use strict 'vars'.
> While not often needed, I'd like to read up more on those, too, and have a
> feeling that I might have to maintain someone else's ancient Perl code some
> day. Learning Perl doesn't cover formats any more, and most books deal with
> symbolic references vaguely if at all.
>
I think the 1st ed. of "Advanced Perl Programming" does a better job
than others. For instance, the section "Glob Values and Symbol Tables"
delves into the internals and explains how both are related. There're
tidbits such as:
Symbol tables are HV's that map variable names to GV's. But aren't
Hv's supposed to store Sv's only? Well, you may have noticed that
all value types have identical-looking wrapper structures that
maintain the reference count, flags, and the pointer to an interior
structure. Because they are identical, you can cast an AV*, HV*, CV*
to an SV* and thus fool the HV into storing anything you want.
I don't recall seeing this level of detail in a single source.
> PS: Is it a type glob or a typeglob or are both forms OK?
>
Advanced Perl Programming uses typeglob. Since it's struct internally,
this agglutinizing somehow seems "righter" and more Perlish than the
loosely coupled "type glob".
Hth,
--
Charles DeRykus
------------------------------
Date: Wed, 5 Jul 2006 17:00:12 +0300
From: "Veli-Pekka Tätilä" <vtatila@mail.student.oulu.fi>
Subject: Re: Learning Typeglobs: Assignment Confusion Cleared
Message-Id: <e8gglf$mal$1@news.oulu.fi>
Veli-Pekka Tätilä wrote:
<snip>
> On a side note, maybe it is just me but I find the syntax:
>
> *glob = $ref;
>
> slightly confusing. <snip in a type glob assignment
> the right side becomes an alias of the left.
Darn, silly me. The assignment goes just the other way around, depending on
how you look at it, so <funny-character>glob would be an alias of
<funny-character>$ref only, after the assignment. Aliasness is symmettric
and the way it is stated in perldata confused me:
quote:
local *Here::blue = \$There::green;
temporarily makes $Here::blue an alias for $There::green, but doesn't make
@Here::blue an alias for @There::green, or %Here::blue an alias for
%There::green
End quote.
My bad as usual, oh well.
Feel free to ignore my syntax complaint earlier in this thread.
--
With kind regards Veli-Pekka Tätilä (vtatila@mail.student.oulu.fi)
Accessibility, game music, synthesizers and programming:
http://www.student.oulu.fi/~vtatila/
------------------------------
Date: 5 Jul 2006 12:21:28 -0400
From: dkcombs@panix.com (David Combs)
Subject: Perl Hacks: Rough Cuts Version: buy bk+net, or just book (at half the price)?
Message-Id: <e8gou8$3t9$1@panix3.panix.com>
----------------------- The buying options:
AMAZON:
By [28]Damian Conway, [29]chromatic, [30]Curtis "Ovid" Poe
Rough Cuts Release: February 2006
Print Book Release: May 2006
Series: [31]Hacks
ISBN: 0-596-52714-4
Retail Price: $29.99 US
Rough Cuts Pricing:
Print Book and Online Access Bundle: $32.99 US
Online Access Only: $14.99 US
Print Book Only: [DEL: $29.99 :DEL] $19.99 US
* Average Customer Review: [stars-5-0.gif] based on 4 reviews.
-------------------
BOOKPOOL:
[16]Shane Warden, [17]Damian Conway, [18]Curtis "Ovid" Poe
O'Reilly Media, Paperback, Published May 2006, 304 pages, ISBN
0596526741
List Price: $29.99
Our Price: $18.95
You Save: $11.04 (37% Off)
-------------------
I haven't yet ever used an O'Reilly "Rough Cuts"
book + web-access-4-updates, so have no idea
what benefit "rough cuts" brings me.
Any opinions on what to do?
(Yes, *if* there's lots of action, updates, etc,
on the book's web-site (or whatever they use),
I'd indeed find it very valuable.)
Thanks!
David
------------------------------
Date: 5 Jul 2006 06:55:32 -0700
From: "Ted" <r.ted.byers@rogers.com>
Subject: Re: Problem with split
Message-Id: <1152107732.703929.311680@v61g2000cwv.googlegroups.com>
Thanks one and all. I not only learned what I missed in my regular
expression, and a lot of other stuff about regular expressions, but
also some additional Perl idioms.
Thanks.
Ted
------------------------------
Date: 5 Jul 2006 14:22:05 -0700
From: "Dinakar" <dinakar.reddy@gmail.com>
Subject: Reg: "pattern match read eof" error
Message-Id: <1152134525.184926.200470@l70g2000cwa.googlegroups.com>
Hi,
I am using the Telnet module for Cisco Routers Testing Automation.
Recently i am facing an issue with it on one machine. Script is
quitting the execution printing "pattern match read eof at line 3030".
Code at line 3030 is "$session->cmd("exit")".
Here i am exiting from Cisco Router to the Solaris machine.
The same code is working fine in other solaris machines. It is
giving the warning "pattern match read eof at line 3030" to the command
"$session->cmd("exit")". But it is not quitting the execution.
Please give me your suggestions regarding this error.
Regards
Dinakar
------------------------------
Date: 5 Jul 2006 07:04:05 -0700
From: "Paul Lalli" <mritty@gmail.com>
Subject: Re: Searching a string in a list of delimited fields
Message-Id: <1152108245.904225.231940@j8g2000cwa.googlegroups.com>
Ronald Fischer wrote:
> List::MoreUtils,
> according to the CPAN site, seems to be made for Perl 5.8.4 and beyond
What part of "the CPAN site" suggests that? I see at the bottom of
List::MoreUtils documentation the notice that the module can be
distributed with the same terms as either 5.8.4 or any post-5.0 version
of Perl. I further see in the source code of the module:
package List::MoreUtils;
use 5.00503;
Sure as heck looks like it isn't "made for" Perl 5.8.4 to me...
Paul Lalli
------------------------------
Date: Wed, 05 Jul 2006 10:37:13 -0700
From: Jim Gibson <jgibson@mail.arc.nasa.gov>
Subject: Re: Searching a string in a list of delimited fields
Message-Id: <050720061037139130%jgibson@mail.arc.nasa.gov>
In article <1152010744.65@user.newsoffice.de>, Ronald Fischer
<ronaldf@eml.cc> wrote:
> I do already have a solution for my problem, but it looks
> clumsy to me, so I would like to know if someone could
> point out a more elegant way to do it (no need to post
> "tested" code - just given general hints would be OK as
> well).
>
> PROBLEM: A string contains fields delimited by vertical bars
> (optionally surrounded by spaces). The first and last
> characters are guaranteed to be neither | nor a space. Example:
>
> my $s = "foo | bar baz | whoosh";
>
> is assumed to denote 3 fields, "foo", "bar baz", and "whoosh".
>
> Now giving a key,
>
> my $key = "bar baz";
>
> return the number of the field (counting starts at 0) which equals
> the key (here, it should return 1), or -1 if the field is not
> present.
[sample code snipped]
> Any suggestions?
Here is a method using index, substr, and tr:
#!/usr/local/bin/perl
#
use strict;
use warnings;
my $s = "foo | bar baz | whoosh";
my $key = shift || "bar baz";
my $ind = -1;
if( (my $pos = index($s,$key)) >= 0 ) {
$ind = ( substr($s,0,$pos) =~ tr(|)(|) );
}
print "$ind\n";
Posted Via Usenet.com Premium Usenet Newsgroup Services
----------------------------------------------------------
** SPEED ** RETENTION ** COMPLETION ** ANONYMITY **
----------------------------------------------------------
http://www.usenet.com
------------------------------
Date: Wed, 05 Jul 2006 16:53:34 +0100
From: Ian Wilson <scobloke2@infotop.co.uk>
Subject: Terse vs didactic. Was Re: date format
Message-Id: <mOidnauidJoefTbZRVnyrg@bt.com>
Bart Van der Donck wrote:
>
> But of course I do like occasional "sport lines" like
>
> $ar[3] =~ s/$m[$_]/@{[sprintf('%02g',$_+1)]}/ for (0..$#m);
>
> in stead of splitting it up in 5 lines or so, like I would rather do in
> production code. Just do myself a favour in the future :-)
>
Yes, so far as I can tell, the above is identical to
my $i = 0;
$ar[3] =~ s/$_/sprintf "%02g",++$i/e for (@m);
using s///e instead of s//@{[]}/
and using the array more like a list.
With didactic variable names ...
my $monthnumber = 0;
foreach my $monthname (@monthnames){
$line =~s/$monthname/sprintf "%02g", ++$monthnumber/e;
};
Which, personally, I do prefer :-)
------------------------------
Date: 5 Jul 2006 13:29:02 GMT
From: anno4000@radom.zrz.tu-berlin.de
Subject: Re: unicode
Message-Id: <4h1t4uF1pl0hlU1@news.dfncis.de>
<nicolas_laurent545@hotmail.com> wrote in comp.lang.perl.misc:
>
> Tobias Witek a écrit :
>
> > nicolas_laurent545@hotmail.com wrote:
> > > This command perl -pi -e 's/(\p{IsAplha}+)(é)(\s)/($1$2)/g' text.txt
> > > returns
> > > Can't find Unicode property definition "Aplha" at -e line 1, <> line 1.
> > >
> > > What should I do to correct the problem ?
> >
> > I guess you could probably try to spell "Alpha" correctly.
> >
> > I am not an expert in Perl, but that might fix your problem :-D
>
> I am sorry but still have the problem with unicode.
>
> perl -pi -e 's/(\p{IsAlpha}+)(é)(\s)/($1$2)/g' text.txt
> This tell perl to take this as input
> input:détrôné ôperaé ôpéraé tônâné tûtéé
> expected output:(détrôné) (ôperaé) (ôpéraé) (tônâné) (tûtéé)
I wouldn't expect any blanks in the output because the substitution
pattern doesn't use $3. So I'd expect
(détrôné)(ôperaé)(ôpéraé)(tônâné)(tûtéé)
and that's what I get.
> actual output: détrô(né)ô(peraé)ôpé(raé)tônâ(né)tûtéé
What version of Perl?
Anno
------------------------------
Date: Wed, 05 Jul 2006 17:23:21 -0400
From: Chris Mattern <syscjm@gwu.edu>
Subject: Re: unicode
Message-Id: <12aobjb2nmffdcf@corp.supernews.com>
anno4000@radom.zrz.tu-berlin.de wrote:
> <nicolas_laurent545@hotmail.com> wrote in comp.lang.perl.misc:
>
>>Tobias Witek a écrit :
>>
>>
>>>nicolas_laurent545@hotmail.com wrote:
>>>
>>>>This command perl -pi -e 's/(\p{IsAplha}+)(é)(\s)/($1$2)/g' text.txt
>>>>returns
>>>>Can't find Unicode property definition "Aplha" at -e line 1, <> line 1.
>>>>
>>>>What should I do to correct the problem ?
>>>
>>>I guess you could probably try to spell "Alpha" correctly.
>>>
>>>I am not an expert in Perl, but that might fix your problem :-D
>>
>>I am sorry but still have the problem with unicode.
>>
>> perl -pi -e 's/(\p{IsAlpha}+)(é)(\s)/($1$2)/g' text.txt
>>This tell perl to take this as input
>>input:détrôné ôperaé ôpéraé tônâné tûtéé
>>expected output:(détrôné) (ôperaé) (ôpéraé) (tônâné) (tûtéé)
>
>
> I wouldn't expect any blanks in the output because the substitution
> pattern doesn't use $3. So I'd expect
>
> (détrôné)(ôperaé)(ôpéraé)(tônâné)(tûtéé)
>
> and that's what I get.
>
>
>>actual output: détrô(né)ô(peraé)ôpé(raé)tônâ(né)tûtéé
>
>
> What version of Perl?
>
> Anno
On Solaris 10 with a UTF-8 environment, I tried it with 5.8.4 and got
his results (with a line feed at the end), and with 5.6.1 and got yours
(with no line feed at the end). There was a line feed at the end of the
original input data.
Chris Mattern
------------------------------
Date: Wed, 05 Jul 2006 17:26:24 -0400
From: Chris Mattern <syscjm@gwu.edu>
Subject: Re: unicode
Message-Id: <12aobp1n3c3mk49@corp.supernews.com>
anno4000@radom.zrz.tu-berlin.de wrote:
> <nicolas_laurent545@hotmail.com> wrote in comp.lang.perl.misc:
>
>>Tobias Witek a écrit :
>>
>>
>>>nicolas_laurent545@hotmail.com wrote:
>>>
>>>>This command perl -pi -e 's/(\p{IsAplha}+)(é)(\s)/($1$2)/g' text.txt
>>>>returns
>>>>Can't find Unicode property definition "Aplha" at -e line 1, <> line 1.
>>>>
>>>>What should I do to correct the problem ?
>>>
>>>I guess you could probably try to spell "Alpha" correctly.
>>>
>>>I am not an expert in Perl, but that might fix your problem :-D
>>
>>I am sorry but still have the problem with unicode.
>>
>> perl -pi -e 's/(\p{IsAlpha}+)(é)(\s)/($1$2)/g' text.txt
>>This tell perl to take this as input
>>input:détrôné ôperaé ôpéraé tônâné tûtéé
>>expected output:(détrôné) (ôperaé) (ôpéraé) (tônâné) (tûtéé)
>
>
> I wouldn't expect any blanks in the output because the substitution
> pattern doesn't use $3. So I'd expect
>
> (détrôné)(ôperaé)(ôpéraé)(tônâné)(tûtéé)
>
> and that's what I get.
>
>
>>actual output: détrô(né)ô(peraé)ôpé(raé)tônâ(né)tûtéé
>
>
> What version of Perl?
>
> Anno
I have 5.8.4 and I get his results.
------------------------------
Date: Wed, 05 Jul 2006 14:26:37 -0400
From: Uri Guttman <uri@stemsystems.com>
Subject: Re: Using reference for performance gain?
Message-Id: <x7zmfn52n6.fsf@mail.sysarch.com>
>>>>> "h" == howa <howachen@gmail.com> writes:
h> anno4000@radom.zrz.tu-berlin.de
>> Your benchmarks don't tell much about the actual performance of
>> returning a list vs. returning a reference. For one, you are building
>> the hash on each call to the routine. That is going to swamp out
>> other performance differences.
h> i have considered this, but this just reflect the real world suitation.
what real world? if you are building constant hashes in each call, then
your real world is very slow. and as anno said, it will swamp out any
return overhead.
you need to show real world code if you want to get real world
optimizations.
uri
--
Uri Guttman ------ uri@stemsystems.com -------- http://www.stemsystems.com
--Perl Consulting, Stem Development, Systems Architecture, Design and Coding-
Search or Offer Perl Jobs ---------------------------- http://jobs.perl.org
------------------------------
Date: 5 Jul 2006 08:16:21 -0700
From: "Paul Lalli" <mritty@gmail.com>
Subject: Re: Win32: File Manipulation
Message-Id: <1152112581.286257.191040@b68g2000cwa.googlegroups.com>
AJ wrote:
> I am trying to build a script to move files between a couple of FTP
> servers and I need to rename the files before I transfer them to the
> second server. I am able to get them to a network directory without any
> problems but I am having trouble manipulating the files once there.
This is an absolutely horrid problem description. What "trouble" are
you having? What exactly is going wrong? What results are you seeing
that you do not desire, or vice versa?
> Below is the code snipit I am having trouble with. Anyone have some
> insight?
Insight into *what*? You haven't told us what the problem is. You
haven't even told us what the output of the below code is. How are we
supposed to know what is wrong with the code when you haven't told us
what's wrong with the results?
> while ($nextname = <\\\\serverName\\shareName\\PTL\\PTL*.txt>) {
> #strip off .txt extension store for uses after file has been ftped
> (for second rename)
> print $nextname "\n";
> $basename = $nextname;
> print $basename " ->";
I don't believe for a second that that "works", as $basename is a
string, not a filehandle. Is this the "trouble" you were talking
about? Did you get a compiler error here?
> $basename =~ s#.*/##;
In the glob, you're using double-backslashes, but here you're searching
for everything up to the last front-slash. Did the files from the glob
really get returned with the front slashes instead? Or is this the
"trouble" you were talking about?
> print $basename " ->";
Same thing here. Not valid syntax, unless $basename is a filehandle,
which it's not. You either need a comma or a period operator between
the two strings.
> $dnlname = $basename.".dnl";
> print $dnlname "\n";
And a third instance.
> if ($PickFTP->Put($nextname.dnl)){
Are you not enabling warnings either? This should give you a warning
about an unquoted string "dnl". Always always enable warnings in your
source code! Of course, since you have three compiler errors above
this line, perhaps you don't even get to this line? Regardless,
you're trying to "Put" the string $nextname concatenated with the
string "dnl", rather than the string ".dnl". Is that what you wanted?
Or is this the "trouble" you were talking about?
And wasn't the whole point of the above to get you to $dnlname? Here
you're using the full path, with the original .txt suffix, and sticking
an extra "dnl" (not ".dnl", mind you) onto it. Do you realize that
after doing all that work to get this variable, you then never use it?
Or is that part of the "trouble" you were talking about?
> if ($PickFTP->Rename($nextname.dnl,$nextname)) {
Same problem here.
> print LOGfile "$thisDay, $thisMonth $mday, $Year, $hour:$min:$sec -
> Transfer of $nextname.txt to PTL server sucessful.\n";
Now you're printing out $nextname with an additional .txt on the end?
Why? You never removed the suffix from $nextname.
> }
> }
> }
>
> Thanks for your responses.
You need to do a *lot* of work composing a better posting if you want
better help. At a bare minimum, your post should contain:
A short-but-complete script that *we can run* that demonstrates your
error
Your sample input.
Your desired output.
Your actual output.
Of course, if you actually figured out what those four things are, you
would most likely solve your own problem and not need to make a posting
to begin with. Have you read the Posting Guidelines that are posted to
this group twice a week?
Paul Lalli
------------------------------
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 9427
***************************************