[24008] in Perl-Users-Digest
Perl-Users Digest, Issue: 6206 Volume: 10
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Wed Mar 3 00:05:56 2004
Date: Tue, 2 Mar 2004 21:05:07 -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 Tue, 2 Mar 2004 Volume: 10 Number: 6206
Today's topics:
Re: 7-bit transmission via Net::SMTP? <jwillmore@remove.adelphia.net>
Re: a comparison operator that is no more sensitive tha <jurgenex@hotmail.com>
local and my variables in a subroutine (Phil Jacobson)
Re: local and my variables in a subroutine <ddunham@redwood.taos.com>
Re: local and my variables in a subroutine <1usa@llenroc.ude>
Re: local and my variables in a subroutine <invalid-email@rochester.rr.com>
Re: Macros (Jay Tilton)
Re: matching multiple lines as one record <bmb@ginger.libs.uga.edu>
Re: Need help sending a password to ftp (David Efflandt)
Re: Need help sending a password to ftp <mgjv@tradingpost.com.au>
Re: Need to find a file on the execution PATH <krahnj@acm.org>
Re: perl implementation of rand() and srand() <mgjv@tradingpost.com.au>
Re: Perl running on Windows and Berkeley DB <invalid-email@rochester.rr.com>
Re: Perl running on Windows and Berkeley DB <kalinaubears@iinet.net.au>
PERL to VBScript help (Jeremy)
Re: PERL to VBScript help <jurgenex@hotmail.com>
Regex to replace unsafe chars? <bcoon@sequenom.com>
Re: Regex to replace unsafe chars? <j.g.karssenberg@student.utwente.nl>
Re: Regex to replace unsafe chars? <1usa@llenroc.ude>
Re: Regex to replace unsafe chars? <invalid-email@rochester.rr.com>
Re: split into array <bmb@ginger.libs.uga.edu>
Re: Suppress "mytime redefined" message from Benchmark? (Jay Tilton)
Re: undef or zero? (semantic question) <bmb@ginger.libs.uga.edu>
webservices <hillmw@charter.net>
Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: Wed, 03 Mar 2004 00:03:39 -0500
From: James Willmore <jwillmore@remove.adelphia.net>
Subject: Re: 7-bit transmission via Net::SMTP?
Message-Id: <pan.2004.03.03.05.03.36.880852@remove.adelphia.net>
On Tue, 02 Mar 2004 16:44:14 +0000, Guru03 wrote:
> Hi,
>
> I must delivery an email message from a SMTP server to an another.
>
> The transmission MUST be 7-bit coded (*NOT* 8BITMIME).
>
> It's ok to use Net::SMTP? The documentation about it don't tell me about
> the type of transmission. And the code isn't clear.
>
> It must be able to delivery MIME 1.0 format emails with special characters
> (i.e. non US keyboard) coded in 8-bit format (with some attachments in UTF8
> code converted into BASE64 that already are in 7bit format).
>
> Any idea?
You *may* be able to use MIME::Lite to do this. I'm not 100% sure about
Net::SMTP.
HTH
--
Jim
Copyright notice: all code written by the author in this post is
released under the GPL. http://www.gnu.org/licenses/gpl.txt
for more information.
a fortune quote ...
Be free and open and breezy! Enjoy! Things won't get any better
so get used to it.
------------------------------
Date: Wed, 03 Mar 2004 02:49:34 GMT
From: "Jürgen Exner" <jurgenex@hotmail.com>
Subject: Re: a comparison operator that is no more sensitive than printf
Message-Id: <2Jb1c.31499$6K.29767@nwrddc02.gnilink.net>
Dan Jacobson wrote:
> perldoc perlop says Testing for exact equality of floating-point
> equality or inequality is not a good idea.
Yeah, that is "Introduction into Computer Numerics: lesson 1"
> OK, perhaps add a new "squishy comparison operator" one could use so
> that even this wouldn't overrun the last test at least on my computer:
> $i=0; while($i<1){printf "$i\n"; $i+=.1};
> $i=0; while($i<1){printf "%.19f\n",$i; $i+=.1}; #for details
>
> The main frustration is that the < operator is much more sensitive to
> tiny floating trailing digits than any of the printf defaults. I wish
> there was a comparison operator "that was no more sensitive than
> printf".
I have no idea what you mean, but have you heard about epsilon environments
or ranges?
At least that is what people are talking about in the second half of
"Introduction into Computer Numerics: lesson 1"
jue
------------------------------
Date: 2 Mar 2004 15:42:07 -0800
From: p_jacobson@hotmail.com (Phil Jacobson)
Subject: local and my variables in a subroutine
Message-Id: <2453019.0403021542.79bf1a47@posting.google.com>
Good afternoon, I was fooling around with the following test code:
1. sub pageprint
2. {
3. foreach my $one (@pages)
4. {
5. my @subpage = @{$one};
6. foreach my $two (@subpage)
7. { print "$two\n"; }
8. }
9. }
10.
11. my @page1 = ("1", "2", "3");
12. my @page2 = ("one", "two", "three");
13. my @page3 = ("uno", "dos", "tres");
14. my @pages = (\@page1, \@page2, \@page3,);
15. &pageprint;
The above code doesn't work unless I remove the "my" declarations. It
brought up a few questions: Does the interpreter create a @pages when
it sees line 3 and then creates another separate one when it sees line
14? I understand if I put the subroutine at the bottom of the code it
will work with all the arrays my'd. The code also works having the
subroutine first if I "local" the page arrays. Are there any benefits
I'm overlooking of having Perl operate this way and in your opinion,
what are some of the best ways to deal with a situation where you want
to handle global variables inside a subroutine?
Thank you for your time,
Phil Jacobson
------------------------------
Date: Wed, 03 Mar 2004 00:36:15 GMT
From: Darren Dunham <ddunham@redwood.taos.com>
Subject: Re: local and my variables in a subroutine
Message-Id: <2M91c.5309$YK3.4768@newssvr27.news.prodigy.com>
Phil Jacobson <p_jacobson@hotmail.com> wrote:
> Good afternoon, I was fooling around with the following test code:
> 1. sub pageprint
> 2. {
> 3. foreach my $one (@pages)
> 4. {
> 5. my @subpage = @{$one};
> 6. foreach my $two (@subpage)
> 7. { print "$two\n"; }
> 8. }
> 9. }
> 10.
> 11. my @page1 = ("1", "2", "3");
> 12. my @page2 = ("one", "two", "three");
> 13. my @page3 = ("uno", "dos", "tres");
> 14. my @pages = (\@page1, \@page2, \@page3,);
> 15. &pageprint;
> The above code doesn't work unless I remove the "my" declarations.
Which ones? The only problem I had was that you used a variable
(@pages) on line 3 without declaring it elsewhere. If you had a 'use
strict', then this code would not compile.
If you didn't use strict, but had warnings enabled, it would tell you..
Name "main::pages" used only once: possible typo at perl line 3.
Which should give you a clue as to what is happening. Why don't you
have warnings enabled when you're working with new code?
Also, what do you mean by "doesn't work"? Does it fail to compile or is
the output not what you expect?
I put a 'my @pages' above the subroutine, and then changed line 14 to be
simply 'pages = ....'
Without that, then the @pages you're assigning in line 14 and the @pages
you're using in line 3 are different variables.
> It brought up a few questions: Does the interpreter create a @pages
> when it sees line 3 and then creates another separate one when it sees
> line 14?
I wouldn't use the verb 'create' here, but yes, those are two separate
variables. Since prior to line 3, no 'my @pages' is seen, then the one
there is the package variable main::pages. Later on line 14 you declare
a new lexical variable and assign to it.
> I understand if I put the subroutine at the bottom of the code it
> will work with all the arrays my'd.
That's because the '@pages' in the subroutine would be after the lexical
declaration of 'my @pages' and would share the scope.
> The code also works having the
> subroutine first if I "local" the page arrays. Are there any benefits
> I'm overlooking of having Perl operate this way and in your opinion,
> what are some of the best ways to deal with a situation where you want
> to handle global variables inside a subroutine?
I think you need to understand why your code is not working, and how
lexical variables work before you try to understand 'local'. It has
it's uses, but I would not consider it in this situation.
--
Darren Dunham ddunham@taos.com
Senior Technical Consultant TAOS http://www.taos.com/
Got some Dr Pepper? San Francisco, CA bay area
< This line left intentionally blank to confuse you. >
------------------------------
Date: 3 Mar 2004 01:13:04 GMT
From: "A. Sinan Unur" <1usa@llenroc.ude>
Subject: Re: local and my variables in a subroutine
Message-Id: <Xns94A0CDAABB1D0asu1cornelledu@132.236.56.8>
p_jacobson@hotmail.com (Phil Jacobson) wrote in
news:2453019.0403021542.79bf1a47@posting.google.com:
> Good afternoon, I was fooling around with the following test code:
Please
use strict;
use warnings;
in code you post here. Also,
use diagnostics;
may help.
>
> 1. sub pageprint
> 2. {
> 3. foreach my $one (@pages)
> 4. {
> 5. my @subpage = @{$one};
> 6. foreach my $two (@subpage)
> 7. { print "$two\n"; }
> 8. }
> 9. }
> 10.
> 11. my @page1 = ("1", "2", "3");
> 12. my @page2 = ("one", "two", "three");
> 13. my @page3 = ("uno", "dos", "tres");
> 14. my @pages = (\@page1, \@page2, \@page3,);
...
>
> The above code doesn't work unless I remove the "my" declarations. It
> brought up a few questions: Does the interpreter create a @pages when
> it sees line 3 and then creates another separate one when it sees line
> 14?
That question would have been answered for you had you enabled strictures
and warnings in your code.
> 15. &pageprint;
Make sure the behavior implied by this syntax is the behavior you want.
> what are some of the best ways to deal with a situation where you want
> to handle global variables inside a subroutine?
I don't know what is best in that case, but in my opinion, the following
code is preferable:
use strict;
use warnings;
my @page1 = ( '1', '2', '3');
my @page2 = ('one', 'two', 'three');
my @page3 = ('uno', 'dos', 'tres');
pageprint(\@page1, \@page2, \@page3);
sub pageprint {
foreach (@_) {
foreach (@{$_}) {
print "$_\n";
}
}
}
--
A. Sinan Unur
1usa@llenroc.ude (reverse each component for email address)
------------------------------
Date: Wed, 03 Mar 2004 02:02:20 GMT
From: Bob Walton <invalid-email@rochester.rr.com>
Subject: Re: local and my variables in a subroutine
Message-Id: <40453917.2040606@rochester.rr.com>
Phil Jacobson wrote:
> Good afternoon, I was fooling around with the following test code:
>
> 1. sub pageprint
> 2. {
> 3. foreach my $one (@pages)
> 4. {
> 5. my @subpage = @{$one};
> 6. foreach my $two (@subpage)
> 7. { print "$two\n"; }
> 8. }
> 9. }
> 10.
> 11. my @page1 = ("1", "2", "3");
> 12. my @page2 = ("one", "two", "three");
> 13. my @page3 = ("uno", "dos", "tres");
> 14. my @pages = (\@page1, \@page2, \@page3,);
> 15. &pageprint;
>
> The above code doesn't work unless I remove the "my" declarations. It
> brought up a few questions: Does the interpreter create a @pages when
> it sees line 3 and then creates another separate one when it sees line
> 14? I understand if I put the subroutine at the bottom of the code it
> will work with all the arrays my'd. The code also works having the
> subroutine first if I "local" the page arrays. Are there any benefits
> I'm overlooking of having Perl operate this way and in your opinion,
> what are some of the best ways to deal with a situation where you want
> to handle global variables inside a subroutine?
>
...
> Phil Jacobson
Try putting your sub after the main program code. Then it will work
fine. Note that it is necessary to declare a variable the first time
the compiler encounters it, and that, in a case like you give here, it
also matters whether the declaration is in the main program or the sub.
Also, add:
use strict;
use warnings;
to the start of your program -- let Perl help you all it can.
You could also add:
my @pages;
at the start of your program and delete the "my" in front of
"my @pages = (..."
Note, though, that it is not really good practice to use a lexical
declared with my() as if it were a package global variable -- it might
be considered misleading. In any event, the variable needs to be
declared the first time the compiler encounters it, unless it is
actually a package global (Perl's default variable type) -- and in that
case, it must be withheld from "use strict"'s effects via a "use vars"
declaration.
Also note that the usual way of getting variables to a sub is to pass
them as arguments (in the case of arrays or hashes, a reference to the
variable is passed). This will generate "pure" subs that don't generate
side-effects, which is helpful when others need to deal with your
program. Good programmers would usually consider good subs to be pure
subs. Using package globals (or even lexical variables defined in the
scope of the sub definition) to pass values to a sub is an invitation
for bugs and hard-to-debug code. This doesn't mean it is wrong --
sometimes it is just the ticket (as with closures). It probably
warrants commentary when used.
And finally, the &subname call to a sub is generally frowned upon these
days (see "perldoc -q &foo"). The & does a couple of things it is very
possible you might not realize, and, unless you specifically want those
things, can get you into trouble in a fashion that will be hard to debug
if you aren't aware.
HTH.
--
Bob Walton
Email: http://bwalton.com/cgi-bin/emailbob.pl
------------------------------
Date: Wed, 03 Mar 2004 02:19:31 GMT
From: tiltonj@erols.com (Jay Tilton)
Subject: Re: Macros
Message-Id: <40453439.356974381@news.erols.com>
"chatiman" <chatiman@free.fr> wrote:
: "Ben Morrow" <usenet@morrow.me.uk> a écrit dans le message de news:
: c22kr2$3en$4@wisteria.csv.warwick.ac.uk...
: > > Or is there a way to access the caller's function local variables ?
: >
: > Why do you want to do this? There is almost certainly a better way.
: >
: Has you saw in my previous post, I'm trying to "localize" my application
: (ie support different languages). I took a look at Locale::Maketext but it
: seems
: to complex to use and require additionnal packages.
Life is like that sometimes. If you want something done right, you'll have
to work at it.
: So I thought to write a simple module which will do what I want :
:
: The idea is to have a text file for each language (or a simple hash) like:
: id1: the text associated to id1 with $variableA
:
: And also I will have a function:
:
: sub my_gettext {
: my ($id) = @_
: return eval "return \"$localized{$id}\"";
: }
:
: where localized is a hash associated to the configuration file
: This would work when variable are not localized with "my" ...
Then don't use such lexical variables to store information needed by the
subroutine.
: But to be "cleaner" I would like it to work in anycases
That's just wrong thinking. Prying open a foreign lexical scope is useful
for debugging or in cases of dire emergency, but doing it in real
production code is an _appallingly_ bad idea. The code will certainly not
be clean.
: for that I need to access the caller's localized variables or use macros
: But the main idea is to keep it simple ...
The simple solution would be to use package variables when you need to
access them from somewhere else. That's the whole reason why package
variables exist.
For a recent discussion of I18N techniques, see the thread starting at
Message-ID: <butrb1$knh$2@hudsucker.umdac.umu.se>
------------------------------
Date: Tue, 2 Mar 2004 21:41:07 -0500
From: Brad Baxter <bmb@ginger.libs.uga.edu>
Subject: Re: matching multiple lines as one record
Message-Id: <Pine.A41.4.58.0403022133510.14326@ginger.libs.uga.edu>
On Thu, 26 Feb 2004, Stephen Moon wrote:
> I have a file containing the following data. How would you use
> regular expression to match the record from the header before the next
> header.
Your subject says, "multiple lines as one record" but your note says, "I
have a file". Maybe the file answer would simply things.
while ( <DATA> ) {
/([^:]+):\s(\w+)/ and do{ print "Header: $1,$2\n"; next };
/(\d+\.\d+)\s+(\d+\.\d+)/ and do{ print "Record: $1,$2\n"; next };
}
__DATA__
G11: AD113167 #beginnning of header
Freq Mag
----------------------------------
0.00000 0.0002430974787725
0.01987 0.0002434897808872
G22: AD113168 #start of next header
Freq Mag
----------------------------------
0.09934 0.0000005524295687
0.11921 0.0000005192898866
0.13908 0.0000003088175192
G33: AD113169
__END__
Regards,
Brad
------------------------------
Date: Wed, 3 Mar 2004 03:49:59 +0000 (UTC)
From: efflandt@xnet.com (David Efflandt)
Subject: Re: Need help sending a password to ftp
Message-Id: <slrnc4alf7.fi5.efflandt@typhoon.xnet.com>
On 2 Mar 2004 07:23:47 -0800, joe <joez3@yahoo.com> wrote:
> I need to create a perl/expect script that will telnet into a system
> then bring up ftp on that system to transfer some files over there. I
> can get the telnet session open. I then start up ftp but that looks
> like it doesn't take my password. The script fails with:
> 331 Password required for moose .
> Password:
> 530 Login incorrect.
> Login failed.
> ftp> cd /tmp
> 530 Please login with USER and PASS.
>
> This is what my script looks like:
> #!/usr /bin/expect
Since this is a Perl newsgroup, you might try using Perl module Net::FTP
(in libnet group of modules) and Net::Telnet (separate module).
--
David Efflandt - All spam ignored http://www.de-srv.com/
------------------------------
Date: 03 Mar 2004 04:34:55 GMT
From: Martien Verbruggen <mgjv@tradingpost.com.au>
Subject: Re: Need help sending a password to ftp
Message-Id: <slrnc4ao3e.8k7.mgjv@verbruggen.comdyn.com.au>
On 2 Mar 2004 07:23:47 -0800,
joe <joez3@yahoo.com> wrote:
> I need to create a perl/expect script that will telnet into a system
> then bring up ftp on that system to transfer some files over there. I
> can get the telnet session open. I then start up ftp but that looks
> like it doesn't take my password. The script fails with:
> #!/usr /bin/expect
Obviously, this is not a Perl program but an expect program, and you
shouldn't be asking the question here. Maybe comp.unix.shells would be
a good place. i don't really know.
However, there is a Perl module called Expect
(http://search.cpan.org), which can be used to do what you want. There
is also Net::Telnet.
You might be able to use Net::FTP. I am not certain how I should
interpret your description up there. You seem to be saying that you
want to telnet to the remote machine, then from there FTP files back
to the machine you came from? If the remote machine has an FTP serve,
you can use that. Maybe it supports other transfer protocols (rcp,
scp), for which modules are available.
Martien
--
|
Martien Verbruggen | Think of the average person. Approximately
Trading Post Australia | half of the people out there are dumber.
|
------------------------------
Date: Tue, 02 Mar 2004 23:22:23 GMT
From: "John W. Krahn" <krahnj@acm.org>
Subject: Re: Need to find a file on the execution PATH
Message-Id: <40451729.8B69379C@acm.org>
"davido@codethought.nospamforme.com" wrote:
>
> Does anyone know of a (cross platform - works in Win32 /or/ *nix) way
> to figure out of a executable program is on a search path? For
> example, to find if foobar.exe is in the Win32 PATH?
>
> Googling didn't turn up suitable results (but I might have not not
> used the right search criteria).
use Env '@PATH';
my $program = 'foobar.exe';
-x and print "$_\n" for map "$_/$program", @PATH;
John
--
use Perl;
program
fulfillment
------------------------------
Date: 02 Mar 2004 23:34:09 GMT
From: Martien Verbruggen <mgjv@tradingpost.com.au>
Subject: Re: perl implementation of rand() and srand()
Message-Id: <slrnc4a6fg.8k7.mgjv@verbruggen.comdyn.com.au>
On Wed, 3 Mar 2004 00:02:44 +0100,
Simon <simschla@freesurf.ch> wrote:
> On 02 Mar 2004 01:23:29 GMT, Martien Verbruggen wrote:
>> Perl's rand() just calls whatever rand() function the system it runs
>> on provides, and those are notoriously non-identical. In later
>> versions of Perl, the person compiling Perl can actually override what
>> pseudo-random generator they want to use.
>>
>> In other words, rand() in Perl is not guaranteed to produce the same
>> results at all times.
>
> this is exactly my problem. since i need to produce the same random numbers
> as the original razor client, as i believe (see below).
But what I'm saying is, that since the razor clients are implemented
in Perl, that the current set of installations out there can't rely on
rand() always returning the same sequence already.
So, the current implementations of the razor client and protocol can't
require rand() to always return the same pseudo-random sequence
number, so your Java implementation should not need to care either.
>> Are you sure you interpreted the razor code correctly? I couldn't
>> actually find a document that describes the server-client exchange.
>
> here is a snipplet from razor source code, where different positions inside
> a mail-messages are "randomly" chosen for computing an identifier (hash):
>
><snip>
> srand($$self{seed});
>
> my @content = split /$$self{separator}/, $content;
>
> my $lines = scalar @content;
>
> # Randomly choose relative locations and section sizes (in percent)
> my $sections = 6;
> my $ssize = 100/$sections;
> my @rel_lineno = map { rand($ssize) + ($_*$ssize) } 0 .. ($sections-1);
> my @lineno = map { int(($_ * $lines)/100) } @rel_lineno;
>
> my @rel_offset1 = map { rand(50) + ($_*50) } qw(0 1);
> my @rel_offset2 = map { rand(50) + ($_*50) } qw(0 1);
></snip>
>
> these positions are then used to compute a hash which is then compared
> against stored hashes on the server. i assume that if i chose other
> positions in the message, i never end up with a hash, that represents the
> message in the right way, when trying to compare with the db on the server
> side. don't you agree?
I don't know. Like I said, I couldn't find any documentation on how
the protocol works, or what sort of signature is generated.
On first reading, your argument sounds convincing, but when you think
about it, it can't be right, since every rand() in every Perl
installation could be a different one (unlikely, but there certainly
will be differences). There must be some other trick in the algorithm
that avoids the need to have a specific offset sequence.
Have you tried contacting the author of the razor modules? They might
have some documentation that describes how the whole thing works. It's
often easier to work from documentation like that than to try to
reverse engineer an algorithm from code that implements it.
Martien
--
|
Martien Verbruggen | Useful Statistic: 75% of the people make up
Trading Post Australia | 3/4 of the population.
|
------------------------------
Date: Wed, 03 Mar 2004 01:17:58 GMT
From: Bob Walton <invalid-email@rochester.rr.com>
Subject: Re: Perl running on Windows and Berkeley DB
Message-Id: <40452EBD.5090409@rochester.rr.com>
Researcher wrote:
> I did everything I could to install Berkeley DB for perl running on a
> windows system, I tryed unsuccessfully getting online help or reading
> the README file but I only found help on installing it on a UNIX
> machine. Can anybody help me?
...
> Pablo Borges
>
Hmmmm...If you have installed a recent version of ActiveState Perl on
your Windoze machine, the Berkeley Database package (DB_File) should
already be installed, and, in fact, be the default for dbmopen(). You
shouldn't have to do anything but use it.
--
Bob Walton
Email: http://bwalton.com/cgi-bin/emailbob.pl
------------------------------
Date: Wed, 03 Mar 2004 12:16:26 +1100
From: Sisyphus <kalinaubears@iinet.net.au>
Subject: Re: Perl running on Windows and Berkeley DB
Message-Id: <404532f9$0$22533$5a62ac22@freenews.iinet.net.au>
Researcher wrote:
> I did everything I could to install Berkeley DB for perl running on a
> windows system, I tryed unsuccessfully getting online help or reading
> the README file but I only found help on installing it on a UNIX
> machine. Can anybody help me?
>
> Regards.
>
> Pablo Borges
Perl 5.8:
ppm install http://theoryx5.uwinnipeg.ca/ppms/BerkeleyDB.ppd
Perl 5.6:
ppm install http://theoryx5.uwinnipeg.ca/ppmpackages/BerkeleyDB.ppd
Cheers,
Rob
--
To reply by email u have to take out the u in kalinaubears.
------------------------------
Date: 2 Mar 2004 19:02:21 -0800
From: jcapp@belzon.com (Jeremy)
Subject: PERL to VBScript help
Message-Id: <7ae3f23b.0403021902.7b937814@posting.google.com>
Hey VBScript gurus....
I'm a long time Perl programmer who recently learned VBScript and am
pretty familiar with VBScript, but not enough to solve this problem.
I've had serveral Perl scripts that I had written in the past that I
have had to convert to VBScript. Usually no problems.
Today, I was doing some converting, and ran across this code in Perl:
@union = @intersection = @difference = ();
%count = ();
foreach $element (@added, @subList) { $count{$element}++ }
foreach $element (keys %count) {
push @union, $element;
push @{ $count{$element} > 1 ? \@intersection : \@difference },
$element;
}
Basically, we're taking two arrays (@added & @subList) and comparing
them to see what different elemetns @added has vs. @subList and
putting the results into @intersection.
Anyone know how to do this in VBScript? :)
Thanks in advance,
Jeremy
------------------------------
Date: Wed, 03 Mar 2004 04:26:14 GMT
From: "Jürgen Exner" <jurgenex@hotmail.com>
Subject: Re: PERL to VBScript help
Message-Id: <G7d1c.14617$rW6.14250@nwrddc03.gnilink.net>
Jeremy wrote:
> Today, I was doing some converting, and ran across this code in Perl:
>
> @union = @intersection = @difference = ();
> %count = ();
> foreach $element (@added, @subList) { $count{$element}++ }
> foreach $element (keys %count) {
> push @union, $element;
> push @{ $count{$element} > 1 ? \@intersection : \@difference },
> $element;
> }
>
> Basically, we're taking two arrays (@added & @subList) and comparing
> them to see what different elemetns @added has vs. @subList and
> putting the results into @intersection.
Well, yeah, that is a verbatim copy from the FAQ
> Anyone know how to do this in VBScript? :)
Why are you asking in a Perl NG about VBScript?
jue
------------------------------
Date: Wed, 03 Mar 2004 01:03:12 GMT
From: Bryan Coon <bcoon@sequenom.com>
Subject: Regex to replace unsafe chars?
Message-Id: <k9a1c.19403$zH5.18179@newssvr29.news.prodigy.com>
I need to remove unsafe characters from a filename, and replace them all
with underscores.
The characters I need to search for and replace are:
!@#$%^*()'"{}[]<>
How do I search and replace for any of the group of special characters
like this?
I tried $filename =~ s/[\!\@\#\$\%\^\*\(\)\{\}\[\]\'\"\<\>]/_/g;
But I dont think they all need to be escaped and Im not sure this is the
right format anyways.
Thanks,
B
------------------------------
Date: Wed, 3 Mar 2004 02:10:28 +0100
From: Jaap Karssenberg <j.g.karssenberg@student.utwente.nl>
Subject: Re: Regex to replace unsafe chars?
Message-Id: <20040303021028.7536740a@Captain>
On Wed, 03 Mar 2004 01:03:12 GMT Bryan Coon wrote:
: I need to remove unsafe characters from a filename, and replace them
: all with underscores.
maybe it would be better to define the save characters, say a filename
should only contain letters, digits, '.' and '-' then you could do this:
$filename =~ s/[^\w\.\-]/_/g;
--
) ( Jaap Karssenberg || Pardus [Larus] | |0| |
: : http://pardus-larus.student.utwente.nl/~pardus | | |0|
) \ / ( |0|0|0|
",.*'*.," Proud owner of "Perl6 Essentials" 1st edition :) wannabe
------------------------------
Date: 3 Mar 2004 01:25:48 GMT
From: "A. Sinan Unur" <1usa@llenroc.ude>
Subject: Re: Regex to replace unsafe chars?
Message-Id: <Xns94A0CFD344216asu1cornelledu@132.236.56.8>
Bryan Coon <bcoon@sequenom.com> wrote in news:k9a1c.19403$zH5.18179
@newssvr29.news.prodigy.com:
> I need to remove unsafe characters from a filename, and replace them
> all with underscores.
You should decide what is safe and only allow those characters instead of
trying to figure out what is not safe.
Sinan.
--
A. Sinan Unur
1usa@llenroc.ude (reverse each component for email address)
------------------------------
Date: Wed, 03 Mar 2004 01:30:43 GMT
From: Bob Walton <invalid-email@rochester.rr.com>
Subject: Re: Regex to replace unsafe chars?
Message-Id: <404531B8.4020900@rochester.rr.com>
Bryan Coon wrote:
> I need to remove unsafe characters from a filename, and replace them all
> with underscores.
>
> The characters I need to search for and replace are:
> !@#$%^*()'"{}[]<>
>
> How do I search and replace for any of the group of special characters
> like this?
>
> I tried $filename =~ s/[\!\@\#\$\%\^\*\(\)\{\}\[\]\'\"\<\>]/_/g;
> But I dont think they all need to be escaped and Im not sure this is the
> right format anyways.
...
> B
>
This is probably best done with the translate operator [untested]:
$filename=~tr/!@#$%^*()'"{}[]<>/_/;
--
Bob Walton
Email: http://bwalton.com/cgi-bin/emailbob.pl
------------------------------
Date: Tue, 2 Mar 2004 20:32:58 -0500
From: Brad Baxter <bmb@ginger.libs.uga.edu>
Subject: Re: split into array
Message-Id: <Pine.A41.4.58.0403022009370.14326@ginger.libs.uga.edu>
On Mon, 1 Mar 2004, gnari wrote:
>
> I do not agree. I think the docs are quite clear, and your version
> is more confusing. the split() function is amazingly complicated,
> with lots of special cases. the docs do an admirable job of
> describing each effect separately in a clear way.
>
> gnari
I agree with gnari's disagreement. I remember a long ago discussion in
which I tried (for my own edification) to create examples that illustrated
the various permutations of split's behavior as described in the docs, and
was asking about some cases. At a crucial point in that discussion, I
believe it was Ilya who said that split was an abomination, because of the
plethora of special cases.
While I respect that viewpoint, I think it's only in rare occasions that
the documentation fails to cover an obscure corner of use. Perhaps a
perlsplittut is in order? (No, I'm not--shudder--volunteering.)
Regards,
Brad
------------------------------
Date: Wed, 03 Mar 2004 00:31:33 GMT
From: tiltonj@erols.com (Jay Tilton)
Subject: Re: Suppress "mytime redefined" message from Benchmark?
Message-Id: <40452724.353624537@news.erols.com>
Darren Dunham <ddunham@redwood.taos.com> wrote:
: Jeff Boes <jboes@nexcerpt.com> wrote:
: > $ perl -w -e 'no warnings; use Benchmark qw(:hireswallclock)'
: > Subroutine Benchmark::mytime redefined at
: > /usr/local/lib/perl5/5.8.3/Benchmark.pm line 456.
:
: > $ perl -w -e 'no warnings qw(redefine); use Benchmark qw(:hireswallclock)'
: > Subroutine Benchmark::mytime redefined at
: > /usr/local/lib/perl5/5.8.3/Benchmark.pm line 456.
:
: Both of those attempts won't work because the 'no warnings' isn't read
: until runtime, while the 'use' is done earlier.
Poppycock. 'use' and 'no' both happen during compilation.
------------------------------
Date: Tue, 2 Mar 2004 20:02:12 -0500
From: Brad Baxter <bmb@ginger.libs.uga.edu>
Subject: Re: undef or zero? (semantic question)
Message-Id: <Pine.A41.4.58.0403021955170.14326@ginger.libs.uga.edu>
> If you have one String, you can get the length of the String. But what
> happens if there is no String??? you would say:
>
> $string_length = undef;
>
> or
>
> $string_length = 0;
>
> to me the value should be undefined but zero can play the same role.
Perhaps:
$string_length = defined $string ? length $string : undef;
Then the definedness of $string_length would parallel that of $string.
Regards,
Brad
------------------------------
Date: Tue, 2 Mar 2004 22:32:09 -0600
From: "Michael Hill" <hillmw@charter.net>
Subject: webservices
Message-Id: <104antie14hmna5@corp.supernews.com>
Does anyone know of a good example of a perl webservice?
------------------------------
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 6206
***************************************