[25485] in Perl-Users-Digest
Perl-Users Digest, Issue: 7729 Volume: 10
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Thu Feb 3 09:05:43 2005
Date: Thu, 3 Feb 2005 06:05:16 -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, 3 Feb 2005 Volume: 10 Number: 7729
Today's topics:
Re: a very bad question <wyzelli@yahoo.com>
Re: a very bad question chris-usenet@roaima.co.uk
Debugger aliases do not work (Volker Nicolai)
Does perlcc work OK? francescomoi@europe.com
Re: How bad is $'? (Was: "Get substring of line") bik.mido@gmail.com
Re: How to stop print newline with autoflush handle on? <wyzelli@yahoo.com>
Re: in line editing (roller)
Re: Invisible cache for LWP / Mechanize? <jakob.fix@gmail.com>
Re: Invisible cache for LWP / Mechanize? <gisle@activestate.com>
Invisible variables in Perl debugger (Volker Nicolai)
PAR/PP on Windows XP with ActiveState sigzero@gmail.com
Perl on Mac finding files by colour? daninbrum@hotmail.com
Re: Perl on Mac finding files by colour? <josef.moellers@fujitsu-siemens.com>
Re: Perl on Mac finding files by colour? <daninbrum@hotmail.com>
Re: recursive function and hashe <sppNOSPAM@libello.com>
Re: recursive function and hashe (Anno Siegel)
Regex to match say char 't' exactly once in a string a <ganesh_tiwari@hotmail.com>
Re: Regex to match say char 't' exactly once in a strin <toreau@gmail.com>
Re: Regex to match say char 't' exactly once in a strin (Anno Siegel)
Re: x-www-form-urlencoded <no@email.com>
Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: Thu, 03 Feb 2005 10:34:11 GMT
From: "Peter Wyzl" <wyzelli@yahoo.com>
Subject: Re: a very bad question
Message-Id: <D6nMd.146056$K7.70259@news-server.bigpond.net.au>
<leo.hou@gmail.com> wrote in message
news:1107394580.644080.49610@c13g2000cwb.googlegroups.com...
: Hi guys, prepare for a bad question... I want to know how to pronounce
: "~" and "#" in English
~ is spelt tilde but pronounced tild or tilled
# is called either pound or hash depending whether you speak US English
(pound) or UK/Australian English (hash)
P
--
print "Just another Perl Hacker";
------------------------------
Date: Thu, 3 Feb 2005 10:40:15 +0000
From: chris-usenet@roaima.co.uk
Subject: Re: a very bad question
Message-Id: <flb9d2-ht2.ln1@moldev.cmagroup.co.uk>
leo.hou@gmail.com wrote:
> Hi guys, prepare for a bad question... I want to know how to
> pronounce "~" and "#" in English
Larry <larry_wallet@yahoo.com> wrote:
> Tilde and Pound sir.
Ah. You must be using American English.
In English English it's "tilde" and (usually) "hash", respectively.
However, I've also heard "#" being described as "square" and even
"octothorpe". There's a FAQ somewhere on one of the UK newsgroups about
this.
The noun "pound" is never used for "#" as this word is used[*] for our
currency symbol and an (obsolete) imperial weight measurement.
Ob Perl:
print "UK currency symbol is \x{A3}\n"; # U+00A3 POUND SIGN
Chris
[*] Actually there are other uses of the noun "pound" but none is for
describing the symbol "#".
------------------------------
Date: 3 Feb 2005 05:04:20 -0800
From: vnick@freenet.de (Volker Nicolai)
Subject: Debugger aliases do not work
Message-Id: <de7655a5.0502030504.78fad4c@posting.google.com>
Hi,
I have tried to use aliases in the Perl debugger.
Running my script-to_debug in the Perl debugger
I included a debug module I wrote and set an alias for invoking it:
DB<10> use dump_vars;
DB<11> = dvo dump_all_vars (\%main::, "main::","");
or
DB<11> $alias{dvo} = 'dump_all_vars (\%main::, "main::","");'
But neither of these works, nor does one of these:
= dvo 'dump_all_vars (\%main::, "main::","");'
= dvo dump_all_vars(\%main::,"main::","");
= dvo "dump_all_vars (\%main::, \"main::\",\"\");"
For the '$alias =...' setting above I get this when trying to use it:
Bareword found where operator expected at (eval
64)[/cadappl/perl/5.6.1/lib/5.6.1/perl5db.pl:1521] line 2, near
""dump_all_vars (%main::, "main::"
(Missing operator before main::?)
String found where operator expected at (eval
64)[/cadappl/perl/5.6.1/lib/5.6.1/perl5db.pl:1521] line 2, near
"main::",""
String found where operator expected at (eval
64)[/cadappl/perl/5.6.1/lib/5.6.1/perl5db.pl:1521] line 2, near
"","");""
(Missing operator before ");"?)
syntax error at (eval
64)[/cadappl/perl/5.6.1/lib/5.6.1/perl5db.pl:1521] line 2, near
""dump_all_vars (%main::, "main::"
The same holds for the last "=dvo..." above
The other ones seem to cause the invokation of my sub without
arguments.
What happens here? Why don't my aliases work?
How to properly set aliases in the debugger?
Thanks for helping.
Volker
------------------------------
Date: 3 Feb 2005 01:05:58 -0800
From: francescomoi@europe.com
Subject: Does perlcc work OK?
Message-Id: <1107421558.748978.256020@f14g2000cwb.googlegroups.com>
Hi.
I'm working on Linux Fedora with Perl v5.8.3.
I try to create an executable binary from a simple Perl code
(hello.pl):
----------
#!/usr/bin/perl
open (logfile, ">>file.log");
print logfile ("Hello World\n");
close (logfile);
-----------
When compiling, I get some strange warnings:
----------
[root@pc]# perlcc hello.pl -o execute
pccwqCJM.c: In function `perl_init_aaaa':
pccwqCJM.c:1185: warning: this decimal constant is unsigned only in ISO
C90
-----------
But I get an executable. But when trying to execute it:
-----------
[root@pc]# ./execute
panic: invalid pad in pad_sv: 0x8c1e0b8[0x8c2d660] at hello.pl line 3.
-------------
Is 'perlgcc' a reliable program? Or is it a fun for geeks?
------------------------------
Date: 3 Feb 2005 01:30:37 -0800
From: bik.mido@gmail.com
Subject: Re: How bad is $'? (Was: "Get substring of line")
Message-Id: <1107423037.092676.106270@c13g2000cwb.googlegroups.com>
jl_post@hotmail.com wrote:
> > Well, but then I _think_ (although I'm not really _sure_)
> > that even if you're running the code through a string eval()
> > the interpreters run to execute the code _are_ still affected
> > by the side effect of using $', or, as you say, 'taintedness'.
[snip]
> I agree with you completely when you say that code running through a
> string eval() is still tainted, but I think you're missing one key
> point: The code is not tainted if the string containing the $' has
not
> been eval()ed yet. Take your example code:
[snip]
I'm not trying your modified benchmarks myself, but I'll trust your
word for it. It seems I kind of misunderstood what you meant...
Michele
------------------------------
Date: Thu, 03 Feb 2005 10:32:17 GMT
From: "Peter Wyzl" <wyzelli@yahoo.com>
Subject: Re: How to stop print newline with autoflush handle on?
Message-Id: <R4nMd.146052$K7.85480@news-server.bigpond.net.au>
"David" <dz_ny@hotmail.com> wrote in message
news:LTjMd.101342$kq2.55940@twister.nyc.rr.com...
: use strict;
: use warnings;
:
: $| = 1;
:
: for ( 1 .. 5 )
: {
: print ".";
: sleep 1;
: }
:
: the code prints:
I run Activeperl on Windows XP Pro and get ..... with that code cut and
pasted...
P
--
print "Just another Perl Hacker";
------------------------------
Date: 3 Feb 2005 04:09:32 -0800
From: kitoclick1@yahoo.co.uk (roller)
Subject: Re: in line editing
Message-Id: <4d1f122c.0502030409.6aa940d9@posting.google.com>
"John W. Krahn" <someone@example.com> wrote in message news:<RQcMd.98464$Qb.30530@edtnps89>...
> > my @file1 = <$in>;
> > my @usernames = <$users>;
> > close $in;
> > chomp @usernames;
> > for (my $i=0;$usernames[$i];$i++)
> > {$file1[$i] =~ s/username/$usernames[$i]/g}
> > open my $out, '>', './file2.txt' or die "error";
> > print $out for @file1; #problem line
> Unfortunately perl doesn't DWIM in this case. You have to explicitly add the
> list after the filehandle:
> print $out $_ for @file1;
> > and it unexpectedly prints to STDOUT:
> >
> > GLOB(0x183522c)GLOB(0x183522c)GLOB(0x183522c)
> >
> > I was also wondering why I can't write
> >
> > for (my $i=0;$usernames[$i];$i++)
> > {$file1[$i] =~ s/username/$usernames[$i]/g}
> >
> > as
> >
> > $file1[$i] =~ s/username/$usernames[$i]/g
> > for (my $i=0;$usernames[$i];$i++);
> Because the statement modifier 'for' only works with lists. You might be able
> to do it with something like this:
> $file1[$_] =~ s/username/$usernames[$_]/g for 0 .. $#usernames;
> John
Thanks all for the info so far,
To clarify I need to loop through a file say 'names' and for every
occurrence of a username in this file that it finds in file
'auto_home_users' I need to change the line in auto_home_users so that
username -soft server:/export/vol00/users:username
is changed to
username -soft another_server:/export/vol00/users:username
perl -i.bak -p -e would change every line with server to
another_server.
------------------------------
Date: 3 Feb 2005 01:41:02 -0800
From: "jfix" <jakob.fix@gmail.com>
Subject: Re: Invisible cache for LWP / Mechanize?
Message-Id: <1107423662.701294.50570@f14g2000cwb.googlegroups.com>
Hi Steven,
> First see
>
> http://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html#sec14.9
>
> Then use HTTP::Headers to construct the appropriate headers;
> use HTTP::Request to construct your request.
>
> Use LWP::UserAgent or "Mech" to dispatch your request.
thanks for your response. I was aware of the different no-cache
mechanisms, but I didn't know that they can be put in the HTTP Request
as well, I thought only the server can specify such a header.
Admittedly, not very original, but this is what I finally ended up
doing:
### create "no-cache" header
my $http_headers = HTTP::Headers->new;
$http_headers->header("Cache-Control" => "no-cache");
### let's pretend to be the real thing
$ua->agent("McAfee AutoUpdate");
$ua->default_headers( $http_headers );
Thanks again for your help.
--
cheers,
Jakob.
------------------------------
Date: 03 Feb 2005 13:00:17 +0100
From: Gisle Aas <gisle@activestate.com>
Subject: Re: Invisible cache for LWP / Mechanize?
Message-Id: <87pszhsvji.fsf@ask.g.aas.no>
"jfix" <jakob.fix@gmail.com> writes:
> Admittedly, not very original, but this is what I finally ended up
> doing:
>
> ### create "no-cache" header
> my $http_headers = HTTP::Headers->new;
> $http_headers->header("Cache-Control" => "no-cache");
>
> ### let's pretend to be the real thing
> $ua->agent("McAfee AutoUpdate");
> $ua->default_headers( $http_headers );
Hint: you can shorten this as:
$ua->agent("McAfee AutoUpdate"); # pretend to be the real thing
$ua->default_header( Cache_Control => "no-cache" );
--
Gisle Aas
------------------------------
Date: 3 Feb 2005 05:13:09 -0800
From: vnick@freenet.de (Volker Nicolai)
Subject: Invisible variables in Perl debugger
Message-Id: <de7655a5.0502030513.74c1aa3f@posting.google.com>
Hi,
under the Perl debugger I ran a script which invokes another one
at the end with
require "gen_spec.pl";
In this invoked script gen_spec.pl I can not see/trace any variable.
I can tell the debugger with
b load gen_spec.pl
to stop when loading this script, that works.
I can also tell it with
b 160
to break at line 160, works too.
But if I set a condition for the breakpoint, like
b 160 ($reg_key =~ /LAYER1_START/)
it fails.
To verify that I tried to print the value of $reg_key
p $reg_key
but nothing comes out though it should and I can see in a print
statement in my code-to-be-debugged that $reg_key does have a value.
Does anyone know where the problem is??
Thanks for helping
Volker
------------------------------
Date: 3 Feb 2005 05:30:33 -0800
From: sigzero@gmail.com
Subject: PAR/PP on Windows XP with ActiveState
Message-Id: <1107437433.506992.91050@l41g2000cwc.googlegroups.com>
I am trying to build an EXE without the Perl DLL included. I run my
make.bat which contains:
pp --icon app.ico -d -o popups.exe popups.pl
And it errors out with this:
Goto undefined subroutine &DynaLoader::bootstrap_inherit at
C:/aperl58/lib/XSLoa
der.pm line 95.
Compilation failed in require at C:/aperl58/lib/IO/Handle.pm line 260.
BEGIN failed--compilation aborted at C:/aperl58/lib/IO/Handle.pm line
260.
Compilation failed in require at C:/aperl58/lib/IO/Seekable.pm line
101.
BEGIN failed--compilation aborted at C:/aperl58/lib/IO/Seekable.pm line
101.
Compilation failed in require at C:/aperl58/lib/IO/File.pm line 117.
BEGIN failed--compilation aborted at C:/aperl58/lib/IO/File.pm line
117.
Compilation failed in require at -e line 305.
BEGIN failed--compilation aborted at -e line 835.
Cannot open popups.exe for reading: No such file or directory at
C:/Perl/site/li
b/Parse/Binary.pm line 611.
I then read the -d switch and it says:
-d, --dependent
Reduce the executable size by not including a copy of perl interpreter.
Executables built this way will need a separate perl5x.dll or
libperl.so to function correctly. This option is only available if perl
is built as a shared library.
The last sentence is what got me. Is the ActiveState distro built as a
shared library? Or is a lean EXE out of my reach because AS was not
built that way?
Robert
------------------------------
Date: 3 Feb 2005 04:51:05 -0800
From: daninbrum@hotmail.com
Subject: Perl on Mac finding files by colour?
Message-Id: <1107435065.223254.148340@c13g2000cwb.googlegroups.com>
Hi Group,
Thanks ever so much for your starting points on my backup app. I
cobbled together some code (still needs all sorts of cleaning up), and
it works!
Someone notices my app working and decided that they'd love to use
it. This wouldn't be a problem, but they want it with one key
difference... it needs to search by colour.
At the moment, it uses file::find to dig out files with a .doc
extension created since it last ran. However, my colleague wants it to
find files marked with a certain colour (Apple OS-X lets you colour
mark files). Is that possible?
Thanks,
Dan
------------------------------
Date: Thu, 03 Feb 2005 14:02:05 +0100
From: Josef Moellers <josef.moellers@fujitsu-siemens.com>
Subject: Re: Perl on Mac finding files by colour?
Message-Id: <ctt785$r5p$1@nntp.fujitsu-siemens.com>
daninbrum@hotmail.com wrote:
> Hi Group,
>=20
> Thanks ever so much for your starting points on my backup app. I
> cobbled together some code (still needs all sorts of cleaning up), and
> it works!
>=20
> Someone notices my app working and decided that they'd love to use
> it. This wouldn't be a problem, but they want it with one key
> difference... it needs to search by colour.
>=20
> At the moment, it uses file::find to dig out files with a .doc
> extension created since it last ran. However, my colleague wants it to
> find files marked with a certain colour (Apple OS-X lets you colour
> mark files). Is that possible?
I don't know much about OS-X, but I'd say if you have access to the=20
colour mapping, then there'd be no problem: read the mapping and aply it =
to each file found and compare the colour thus generated with the colour =
the user specified.
--=20
Josef M=F6llers (Pinguinpfleger bei FSC)
If failure had no penalty success would not be a prize
-- T. Pratchett
------------------------------
Date: 3 Feb 2005 05:52:33 -0800
From: "Dan" <daninbrum@hotmail.com>
Subject: Re: Perl on Mac finding files by colour?
Message-Id: <1107438753.035787.271720@f14g2000cwb.googlegroups.com>
> I don't know much about OS-X, but I'd say if you have access to the
> colour mapping, then there'd be no problem: read the mapping and aply
it
> to each file found and compare the colour thus generated with the
colour
>the user specified.
I know, but I can't for the life of me work out where this mapping info
is stored.
Thanks,
Dan
------------------------------
Date: Thu, 03 Feb 2005 09:40:18 +0100
From: =?ISO-8859-15?Q?S=E9bastien?= Cottalorda <sppNOSPAM@libello.com>
Subject: Re: recursive function and hashe
Message-Id: <4201e372$0$544$626a14ce@news.free.fr>
Brian McCauley wrote:
>
>
> Sébastien Cottalorda wrote:
>
>> I all,
>>
>> Here is my problem,
>>
>> I'd like to store in a hash table those numbers like that:
>> (123, 124, 13, 145, 2, 25)
>>
>> %number = (
[snip]
>> "2" => {
>> "value" => "OK",
>> "5" => {
>> "value" => "OK"
>> }
>> }
>> );
>
> That's a very odd structure - what are you planning to use it for?
I'm planning to make a program that allow me to determine from which country
is a Credit Card.
I've downloaded the BIN table that is basically like this:
MinCC-MaxCC Network(VISA,MASTER,NATIONAL,etc...) Country
The problem is that each interval do not contains the same number of Credit
Card.
ie:
1234000000000000-1234999999999999 VISA USA
1235678900000000-1235678999999999 VISA CHN
2567894561000000-2567894561999999 MASTER TUR
etc...
I then plan to store in memory each interval:
- 1234
- 12356789
- 2567894561
as seen before.
When I try to determine from which country a Credit Card is, I use a
recursive algorithme.
For example: from which country is the credit card number 1234567890123456 ?
1 -> 2 -> 3 -> 4 -> (value=>'OK') ----> Country Found (If, instead of "OK",
I put the country, I can know it).
Another example: from wich country is the credit card number
1239123456789456 ?
1 -> 2 -> 3 -> 9 -> (do not exists) ----> "Country not found"
I hope the BIN Table is not too big.
>> I think I need to use recursive function,
>
> Whilst a recursive function may seeme the most natural approach acually
> an iterative one works perfectly well in this case.
>
> for (123, 124, 13, 145, 2, 25) {
> my $r = \\%number;
> $r = \$$r->{$_} for split //;
> $$r->{value} = 'OK';
> }
>
> > but I did know how, I'm not familiar with passing references.
>
> The only way to become familiar is to read documentation and try.
I agree with that, but I need to quick process the BIN table file, I didn't
have time to read the documentation on this precise problem.
I'd rather ask a very precise question hoping someone helps me.
Note, I didn't ask for my entire problem, I only ask for the number to hash
transformation.
Cheers.
Sébastien
--
[ retirer NOSPAM pour répondre directement
remove NOSPAM to reply directly ]
------------------------------
Date: 3 Feb 2005 12:32:57 GMT
From: anno4000@lublin.zrz.tu-berlin.de (Anno Siegel)
Subject: Re: recursive function and hashe
Message-Id: <ctt5lp$m9b$1@mamenchi.zrz.TU-Berlin.DE>
Sébastien Cottalorda <sppNOSPAM@libello.com> wrote in comp.lang.perl.misc:
> Brian McCauley wrote:
>
> >
> >
> > Sébastien Cottalorda wrote:
> >
> >> I all,
> >>
> >> Here is my problem,
> >>
> >> I'd like to store in a hash table those numbers like that:
> >> (123, 124, 13, 145, 2, 25)
> >>
> >> %number = (
> [snip]
> >> "2" => {
> >> "value" => "OK",
> >> "5" => {
> >> "value" => "OK"
> >> }
> >> }
> >> );
> >
> > That's a very odd structure - what are you planning to use it for?
>
> I'm planning to make a program that allow me to determine from which country
> is a Credit Card.
> I've downloaded the BIN table that is basically like this:
> MinCC-MaxCC Network(VISA,MASTER,NATIONAL,etc...) Country
> The problem is that each interval do not contains the same number of Credit
> Card.
> ie:
> 1234000000000000-1234999999999999 VISA USA
> 1235678900000000-1235678999999999 VISA CHN
> 2567894561000000-2567894561999999 MASTER TUR
> etc...
[...]
Look on CPAN for ready-made solutions. Tie::RangeHash looks good, there
may be others.
Anno
------------------------------
Date: 3 Feb 2005 00:53:25 -0800
From: "Gancy" <ganesh_tiwari@hotmail.com>
Subject: Regex to match say char 't' exactly once in a string and no more than once
Message-Id: <1107420805.276429.118320@l41g2000cwc.googlegroups.com>
Some times Regex's which are supposed to be simple eats head. I have
come across one such, though looks very simple, i am frustrted to right
the expressions for it.
I want to match a specifice charecter in a string, say 't', exactly
once anywhere in the string, but should not match 't' more than once.
sounds simple is it not.
------------------------------
Date: Thu, 03 Feb 2005 09:59:02 +0100
From: Tore Aursand <toreau@gmail.com>
Subject: Re: Regex to match say char 't' exactly once in a string and no more than once
Message-Id: <jJlMd.7199$IW4.154775@news2.e.nsc.no>
Gancy wrote:
> I want to match a specifice charecter in a string, say 't', exactly
> once anywhere in the string, but should not match 't' more than once.
> sounds simple is it not.
What have you tried so far? Have you checked the Perl documentation,
especially the FAQ? Hint:
perldoc -q count
--
Tore Aursand <tore@aursand.no>
"If you can't annoy somebody with what you write, I think there's
little point in writing." (Kingsley Amis)
------------------------------
Date: 3 Feb 2005 14:00:32 GMT
From: anno4000@lublin.zrz.tu-berlin.de (Anno Siegel)
Subject: Re: Regex to match say char 't' exactly once in a string and no more than once
Message-Id: <cttaq0$pss$1@mamenchi.zrz.TU-Berlin.DE>
Tore Aursand <toreau@gmail.com> wrote in comp.lang.perl.misc:
> Gancy wrote:
> > I want to match a specifice charecter in a string, say 't', exactly
> > once anywhere in the string, but should not match 't' more than once.
> > sounds simple is it not.
>
> What have you tried so far? Have you checked the Perl documentation,
> especially the FAQ? Hint:
>
> perldoc -q count
That discusses counting of substrings, but not matching if there is
only one occurrence.
Now, in general it *is* the better solution to count and see if the
result is 1, especially if going for multi-character strings or even
general subpatterns.
For the problem of matching single occurrences of a *single character*,
there is a simple regex solution:
my $char = 't';
my $re = /
^ # beginning of string
[^$char]* # any number of characters different from $char
$char # a single $char
[^$char]* # any number of characters different from $char
$ # end of string
/x;
Anno
------------------------------
Date: Thu, 03 Feb 2005 09:25:57 +0000
From: Brian Wakem <no@email.com>
Subject: Re: x-www-form-urlencoded
Message-Id: <36e915F512asjU1@individual.net>
Tad McClellan wrote:
> Brian Wakem <no@email.com> wrote:
>
>> From: Brian Wakem <no@email.com>
>
>
> Still using that "make me invisible" address I see...
>
>
I keep meaning to change it. If anyone needs to get hold of me then 2
minutes on Google will tell them more than they need to know.
--
Brian Wakem
------------------------------
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 7729
***************************************