[23714] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 5920 Volume: 10

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Wed Dec 10 09:05:48 2003

Date: Wed, 10 Dec 2003 06:05:12 -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           Wed, 10 Dec 2003     Volume: 10 Number: 5920

Today's topics:
    Re: Beginners Program (Sam Holden)
    Re: Beginners Program <matthew.garrish@sympatico.ca>
    Re: Beginners Program (Anno Siegel)
    Re: Character class [\W_] clarification (Anno Siegel)
    Re: escape sequence for tab not working <nani3skip45@hotmail.com>
    Re: escape sequence for tab not working <me@privacy.net>
    Re: escape sequence for tab not working (Anno Siegel)
    Re: escape sequence for tab not working nobull@mail.com
    Re: escape sequence for tab not working <flavell@ph.gla.ac.uk>
    Re: Getting array indices matching some criterion <REMOVEsdnCAPS@comcast.net>
    Re: How to run _init for all ancestor classes in diamon <tassilo.parseval@rwth-aachen.de>
        HOWTO remove empty lines with Regex <torfinnk@hotmail.com>
    Re: Idiom for array index that I'm foreach'ing over? <REMOVEsdnCAPS@comcast.net>
        Memory: measuring 5 limitations (Bart Van der Donck)
    Re: Memory: measuring 5 limitations <nospam@bigpond.com>
        MIME::Lite / Net::SMTP question <gsanuser_member@newsguy.com>
    Re: Multi-dimensional  Data Structures <REMOVEsdnCAPS@comcast.net>
    Re: Perl script to process file list.... <bik.mido@tiscalinet.it>
    Re: Proposal: new module, Array::Each? (Bryan Castillo)
    Re: Proposal: new module, Array::Each? (Anno Siegel)
        Querying SQLServer from Perl on Unix (Yash)
    Re: Rounding up to 2 decimal places (Anno Siegel)
    Re: What is '_' <bart.lateur@pandora.be>
    Re: What is '_' (Randal L. Schwartz)
    Re: Why does ne always work (Anno Siegel)
    Re: WIN32::Internet <BOHIM789@AOL.COM>
    Re: WIN32::Internet <theaney@cablespeed.com>
        windows services (Jexxa)
        Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)

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

Date: 10 Dec 2003 05:37:17 GMT
From: sholden@flexal.cs.usyd.edu.au (Sam Holden)
Subject: Re: Beginners Program
Message-Id: <slrnbtdc8d.fkp.sholden@flexal.cs.usyd.edu.au>

On Tue, 9 Dec 2003 21:24:54 -0500,
	Matt Garrish <matthew.garrish@sympatico.ca> wrote:
> 
> "Sam Holden" <sholden@flexal.cs.usyd.edu.au> wrote in message
> news:slrnbtd04e.bfa.sholden@flexal.cs.usyd.edu.au...
>>
>> As an aside, for those who might know:
>>
>> Why is
>> print "@";
>> OK, but
>> print "$";
>> isn't?
>>
> 
> $" is a predefined variable. How would you then use it in a double-quoted
> string if the above were not an error?

Well, on my perl (5.8.2) you can't...

print "$""; # gives an error.

Of course you can simply use:

print qq{$"};

or 

print "$\""; # I'm not sure I like this one... :)


My query is why I can include a @ at the end of a qouble quoted string and
have it work as a literal @. Doing the same with a $ causes a compile error,
with perl complaining: "Final $ should be \$ or $name at ..."

I agree with the error, what I can't understand is why a trailing @ doesn't
cause the same error, after all @foo interpolates in a double quoted string
and hence the same problem should be occuring.

-- 
Sam Holden


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

Date: Wed, 10 Dec 2003 07:57:47 -0500
From: "Matt Garrish" <matthew.garrish@sympatico.ca>
Subject: Re: Beginners Program
Message-Id: <4LEBb.943$aF2.192112@news20.bellglobal.com>


"Sam Holden" <sholden@flexal.cs.usyd.edu.au> wrote in message
news:slrnbtdc8d.fkp.sholden@flexal.cs.usyd.edu.au...
> On Tue, 9 Dec 2003 21:24:54 -0500,
> Matt Garrish <matthew.garrish@sympatico.ca> wrote:
> >
> > "Sam Holden" <sholden@flexal.cs.usyd.edu.au> wrote in message
> > news:slrnbtd04e.bfa.sholden@flexal.cs.usyd.edu.au...
> >>
> >> As an aside, for those who might know:
> >>
> >> Why is
> >> print "@";
> >> OK, but
> >> print "$";
> >> isn't?
> >>
> >
> > $" is a predefined variable. How would you then use it in a
double-quoted
> > string if the above were not an error?
>
> Well, on my perl (5.8.2) you can't...
>
> print "$""; # gives an error.
>
> Of course you can simply use:
>
> print qq{$"};
>
> or
>
> print "$\""; # I'm not sure I like this one... :)
>
>
> My query is why I can include a @ at the end of a qouble quoted string and
> have it work as a literal @. Doing the same with a $ causes a compile
error,
> with perl complaining: "Final $ should be \$ or $name at ..."
>

Sorry, that was a horribly worded last sentence on my part.. What I was
trying to get at is that $" is a variable, but @" is not. It's like using a
\ at the end of a string. To Perl, you're escaping the last quote unless you
escape the \. If you use a $ at the end of a double-quoted string, Perl sees
it (can Perl see?) as the special variable. If you use an @ at the end of a
string, however, the only thing it could be is a literal @.

Matt




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

Date: 10 Dec 2003 13:25:39 GMT
From: anno4000@lublin.zrz.tu-berlin.de (Anno Siegel)
Subject: Re: Beginners Program
Message-Id: <br76sj$mej$1@mamenchi.zrz.TU-Berlin.DE>

Matt Garrish <matthew.garrish@sympatico.ca> wrote in comp.lang.perl.misc:
> 
> "Sam Holden" <sholden@flexal.cs.usyd.edu.au> wrote in message
> news:slrnbtd04e.bfa.sholden@flexal.cs.usyd.edu.au...
> >
> > As an aside, for those who might know:
> >
> > Why is
> > print "@";
> > OK, but
> > print "$";
> > isn't?
> >
> 
> $" is a predefined variable. How would you then use it in a double-quoted
> string if the above were not an error?

So is @" (though Perl doesn't use it), that's not the point.

Perl treats interpolation of arrays differently than interpolation of
scalars.  Array interpolation was introduced rather late in the game.
To make the transition as smooth as possible, Perl treats "@" in a string
as a normal character whenever possible.  The rather complex handling of
"$" was already in place at the time and was, of course, not changed.

So there really is no good reason for the different behavior, only
history.

Anno


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

Date: 10 Dec 2003 12:22:02 GMT
From: anno4000@lublin.zrz.tu-berlin.de (Anno Siegel)
Subject: Re: Character class [\W_] clarification
Message-Id: <br735a$jq6$1@mamenchi.zrz.TU-Berlin.DE>

Fiaz Idris <ifiaz@hotmail.com> wrote in comp.lang.perl.misc:
> Keywords: Character Class Regex Regular Expression Regular Expressions \W_ \W
> 
> I know that [\W] matches [^a-zA-Z_0-9]
> 
> From Mastering Algorithms with Perl (Page.110), I see a character class
> [\W_] that does the following
> 
> s/[\W_]+//g
> 
> i.e. to replace (all non-word character and underscore) with (nothing).

Yes, that's what it does.

> First, I couldn't understand the above that is because I interpreted
> above regex as *** replace "\W" with "^a-zA-Z_0-9" ***

I don't understand what your interpretation was.  Did you think it
changes the two characters "\W" to something else?  Or do you mean
you thought it changes the behavior of "\W" for the rest of the program?

> s/[^a-zA-Z_0-9_]+//g                     -------------->(regex XXX)
> 
> That is to replace (non-word characters including underscore) with (nothing)
> and thought that the last underscore is infact unnecessary.

Well, it is.  Any character need only appear once in a character class,
whether negated or not.

> My question is where in the documentation (anywhere) that says
> the [\W] will infact work with the interpretation as below:
> 
> [~`!@#$%^&*()-[]:;<,./"? ........and so on] but not the interpretation
> give in (regex XXX) above.

I'm still not sure what discrepancy you are seeing.  /[^a-zA-Z_0-9]/
and /\W/ match exactly the same things, as well as the redundant
[^a-zA-Z_0-9_].

Anno


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

Date: Tue, 9 Dec 2003 21:39:26 -0800
From: "naniwadekar" <nani3skip45@hotmail.com>
Subject: Re: escape sequence for tab not working
Message-Id: <br6bh9$293aem$1@ID-75735.news.uni-berlin.de>


"Tad McClellan" <tadmc@augustmail.com> wrote -
>
>     Do not re-type Perl code
>
>         Use copy/paste or your editor's "import" function rather than
>         attempting to type in your code. If you make a typo you will get
>         followups about your typos instead of about the question you are
>         trying to get answered.
>

I re-typed the perl code because I can't access internet
from my workstation at my workplace. But since the
followup tackled the typo AND (not INsteaDOf) my
question, I need have no regrets. *This* time, at any rate.

I do run my code under strict but I excuse myself from
re-typing it when I submit queries to the forum.

To Anno Siegel - Thanks for the help.
I did not use perl's print because I wanted the output to
go to a file instead of stdout.

Thanks, again.




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

Date: Wed, 10 Dec 2003 23:07:55 +1300
From: "Tintin" <me@privacy.net>
Subject: Re: escape sequence for tab not working
Message-Id: <br6rgm$29n6or$1@ID-172104.news.uni-berlin.de>


"naniwadekar" <nani3skip45@hotmail.com> wrote in message
news:br6bh9$293aem$1@ID-75735.news.uni-berlin.de...
>
> To Anno Siegel - Thanks for the help.
> I did not use perl's print because I wanted the output to
> go to a file instead of stdout.

Believe it or not, Perl can actual output to files too.

It would be a little limiting having a language that only deals with
stdin/stdout.




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

Date: 10 Dec 2003 10:39:56 GMT
From: anno4000@lublin.zrz.tu-berlin.de (Anno Siegel)
Subject: Re: escape sequence for tab not working
Message-Id: <br6t5s$es2$1@mamenchi.zrz.TU-Berlin.DE>

naniwadekar <naaaani345@hotmail.com> wrote in comp.lang.perl.misc:
> 
> "Tad McClellan" <tadmc@augustmail.com> wrote -
> >
> >     Do not re-type Perl code
> >
> >         Use copy/paste or your editor's "import" function rather than
> >         attempting to type in your code. If you make a typo you will get
> >         followups about your typos instead of about the question you are
> >         trying to get answered.
> >
> 
> I re-typed the perl code because I can't access internet
> from my workstation at my workplace.

Then test it again before you send it.

>                                       But since the
> followup tackled the typo AND (not INsteaDOf) my
> question, I need have no regrets. *This* time, at any rate.

Great.  You can't be bothered to make sure the code you submit is
correct.  Never mind if people have to correct few spurious errors
along the way, as long as they also answer the original question.

It's nice to learn that you don't have regrets, but I do.

> I do run my code under strict but I excuse myself from
> re-typing it when I submit queries to the forum.

Oh no.  It's far easier to make a dozen experts find your stricture
violations manually.

> To Anno Siegel - Thanks for the help.

Thanks for making your attitude clear.

> I did not use perl's print because I wanted the output to
> go to a file instead of stdout.

Nonsense.

Anno


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

Date: 10 Dec 2003 04:49:01 -0800
From: nobull@mail.com
Subject: Re: escape sequence for tab not working
Message-Id: <4dafc536.0312100449.7c062b7a@posting.google.com>

"naniwadekar" <nani3skip45@hotmail.com> wrote in message news:<br6bh9$293aem$1@ID-75735.news.uni-berlin.de>...
> "Tad McClellan" <tadmc@augustmail.com> wrote -
> >
> >     Do not re-type Perl code
> >
> >         Use copy/paste or your editor's "import" function rather than
> >         attempting to type in your code. If you make a typo you will get
> >         followups about your typos instead of about the question you are
> >         trying to get answered.
> >
> 
> I re-typed the perl code because I can't access internet
> from my workstation at my workplace.

Could I suggest removable media?

> But since the followup tackled the typo AND (not INsteaDOf) my
> question, I need have no regrets.

Believing that you need have no regets because you got what you wanted
even though you pissed people off in the process is not something that
most people would mention in public.  (Because it makes you sound like
a bit of a sociopath).

> I do run my code under strict but I excuse myself from
> re-typing it when I submit queries to the forum.

Indeed, there's no moral requirement to actually include "use strict"
and "use warnings" in the code fragments you post.  There is a moral
requirement to ensure there are not mistakes that would have been
detected by their use.

> To Anno Siegel - Thanks for the help.

Usenet is a threaded medium.  If you wish to follow-up stuff in Anno's
response you should do so in a follow-up to Anno's response.

> I did not use perl's print because I wanted the output to
> go to a file instead of stdout.

Perl's print() is the usual way to write to files in Perl.


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

Date: Wed, 10 Dec 2003 12:53:18 +0000
From: "Alan J. Flavell" <flavell@ph.gla.ac.uk>
Subject: Re: escape sequence for tab not working
Message-Id: <Pine.LNX.4.53.0312101252300.26145@ppepc56.ph.gla.ac.uk>

On Tue, 9 Dec 2003, naniwadekar wrote:

> I re-typed the perl code
[..]

> I need have no regrets.

The result is inevitable.  Bye.


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

Date: Wed, 10 Dec 2003 06:14:10 -0600
From: "Eric J. Roode" <REMOVEsdnCAPS@comcast.net>
Subject: Re: Getting array indices matching some criterion
Message-Id: <Xns944D49E7F892Fsdn.comcast@216.196.97.136>

-----BEGIN xxx SIGNED MESSAGE-----
Hash: SHA1

anno4000@lublin.zrz.tu-berlin.de (Anno Siegel) wrote in
news:br4jb2$mbq$7@mamenchi.zrz.TU-Berlin.DE:

> Eric J. Roode <REMOVEsdnCAPS@comcast.net> wrote in
comp.lang.perl.misc:
> 
> [...]
> 
>> #--->     @list = indexes_where {code} @list;
>> #
>> # Change History:
> 
> YOU CAN'T CHANGE HISTORY

:-)

 ...
> Grep can still do the job, if you don't mind a little obscurity:
> 
>     sub indexes_where_b (&@) {
>         my $test = shift;
>         grep { local $_ = $_[ $_]; $test->() } 0 .. $#_;
>     }

I must have posted an old version of my routine. :-(
Benjamin Goldberg pointed out the same thing some time ago, and I had
updated the routine to use grep.

- -- 
Eric
$_ = reverse sort $ /. r , qw p ekca lre uJ reh
ts p , map $ _. $ " , qw e p h tona e and print
-----BEGIN xxx SIGNATURE-----
Version: GnuPG v1.2.1 (MingW32) - WinPT 0.5.13

iD8DBQE/1w52Y96i4h5M0egRAvFcAJ93vs4nzQLNe5yUpfby9DOv6Y908gCgng6w
57OnQ7CRygEVA6Baqfrm/AU=
=g+n8
-----END PGP SIGNATURE-----


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

Date: 10 Dec 2003 07:11:35 GMT
From: "Tassilo v. Parseval" <tassilo.parseval@rwth-aachen.de>
Subject: Re: How to run _init for all ancestor classes in diamond inheritance
Message-Id: <br6gv7$e1h$1@nets3.rz.RWTH-Aachen.DE>

Also sprach Uri Guttman:

>>>>>> "TvP" == Tassilo v Parseval <tassilo.parseval@rwth-aachen.de> writes:
> 
>  TvP>     sub _class_init {
>  TvP>         my ($self, %args) = @_;
>  TvP>         for (@SolarCar::ISA) {
>  TvP>             my $init = $_->can("_init")
>  TvP>                 and $self->$init;
> 
> i would double check if that works. there is a well known problem with
> refering to a my var in the statement that declares it. the second $init
> refers to a previously existing $init and is not strict safe. i would
> write that as:
> 
> 	if (my $init = $_->can("_init") ) {
> 		$self->$init;
> 	}
> 
> and that is my safe and even clearer IMO.

You are right, sorry. I was too concerned with condensing it into one
statement for no reason.

Tassilo
-- 
$_=q#",}])!JAPH!qq(tsuJ[{@"tnirp}3..0}_$;//::niam/s~=)]3[))_$-3(rellac(=_$({
pam{rekcahbus})(rekcah{lrePbus})(lreP{rehtonabus})!JAPH!qq(rehtona{tsuJbus#;
$_=reverse,s+(?<=sub).+q#q!'"qq.\t$&."'!#+sexisexiixesixeseg;y~\n~~dddd;eval


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

Date: Wed, 10 Dec 2003 14:41:03 +0100
From: "tor" <torfinnk@hotmail.com>
Subject: HOWTO remove empty lines with Regex
Message-Id: <3fd72270$0$9780$edfadb0f@dread14.news.tele.dk>

Hi
I wan't to remove all empty lines in a file.
How can I do that with a regex:
s/<something>//;
What is this <something>

Torfinn




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

Date: Wed, 10 Dec 2003 06:19:10 -0600
From: "Eric J. Roode" <REMOVEsdnCAPS@comcast.net>
Subject: Re: Idiom for array index that I'm foreach'ing over?
Message-Id: <Xns944D4AC12E4CFsdn.comcast@216.196.97.136>

-----BEGIN xxx SIGNED MESSAGE-----
Hash: SHA1

Michele Dondi <bik.mido@tiscalinet.it> wrote in
news:q0sotv49cr080v9mvnvu5vk6rohpkdvhea@4ax.com:

> On 07 Dec 2003 21:56:41 GMT, Abigail <abigail@abigail.nl> wrote:
> 
>>Unlike Perl6, which just throws out 50 years of programming
language
>>design out of the window, passes Python on the wrong side and
makes
>>whitespace significant in new painful and revolting ways.
> 
> Just out of curiosity: is this definitive or are there chances
that
> such "features" may be removed/changed before before Perl6 is
actually
> released in productive form?

Alas, very slim.  :-(  I have this nagging feeling that version 6 is
going to be the worst thing that ever happened to Perl.

- -- 
Eric
$_ = reverse sort $ /. r , qw p ekca lre uJ reh
ts p , map $ _. $ " , qw e p h tona e and print
-----BEGIN xxx SIGNATURE-----
Version: GnuPG v1.2.1 (MingW32) - WinPT 0.5.13

iD8DBQE/1w+jY96i4h5M0egRAml7AJ9tDxJsIzrhWlGO+pTdrzI3t90D7wCgpdp3
RRhonHoRGuZerY3Gue1XFzA=
=jgan
-----END PGP SIGNATURE-----


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

Date: 10 Dec 2003 01:24:14 -0800
From: bart@nijlen.com (Bart Van der Donck)
Subject: Memory: measuring 5 limitations
Message-Id: <b5884818.0312100124.33c67272@posting.google.com>

Hello,

My hosting provider uses these limitations for perl programs:

Size of Core Files - 0 MB
CPU Time Used - 30 seconds
Memory Size - 16 MB
Number of Open Files - 32
Number of Simultaneous Processes - 8

Now I am gonna make a more advanced perl script and I want to make
sure that it will be OK with these requirements. I am looking for a
way to easily display these things for my script. The script will get
data out of a db table (prices) and then calculate them according to
valuta, rate, markup dealers, etc. and then it starts comparing each
one to get the cheapest. I believe it will use heavy memory, because
it is about a lot of prices.

I did some research at Perldoc and Google. 

/usr/bin/top: no permission (can't change that)

Use of perl's $ENV{PERL_DEBUG_MSTATS}: unknown $ENV variable (can't
change that either)

`` use Devel::Peek; mstat(); ´´
Devel::Peek = ok
but mstat() apparantly requires that perl was built in a non-standard
way. I can't change this either.

Then I try to call perl with the -dl flag: this seems to work.
And then I write
``  do 'lib/auto/POSIX/autosplit.ix'; ´´
But then I come in some kind of other shell I think... Toink :-)
I played around with it, but all seems very complex. Moreover I get
the impression that it is only about the memory size (=the 16 MB that
is maximum) and not about the other limits.

Quotation from
http://www.perldoc.com/perl5.8.0/pod/perldebguts.html:
"
There are two Perl-specific ways to analyze memory usage:
$ENV{PERL_DEBUG_MSTATS} and -DL command-line switch. The first is
available only if Perl is compiled with Perl's malloc(); the second
only if Perl was built with -DDEBUGGING. See the instructions for how
to do this in the INSTALL podpage at the top level of the Perl source
tree.
"

So, 1 basic question: is there a command like:
`` memory myscript.pl ´´
that would display the memory of my script?

I don't want to code an entire program and then find out that I can't
use it because of memory restrictions.

Thanks,
Bart


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

Date: Wed, 10 Dec 2003 19:31:21 +1000
From: Gregory Toomey <nospam@bigpond.com>
Subject: Re: Memory: measuring 5 limitations
Message-Id: <2743529.fYxpOCuRSR@gregs-web-hosting-and-pickle-farming>

It was a dark and stormy night, and Bart Van der Donck managed to scribble:

> Hello,
> 
> My hosting provider uses these limitations for perl programs:
> 
> Size of Core Files - 0 MB
> CPU Time Used - 30 seconds
> Memory Size - 16 MB
> Number of Open Files - 32
> Number of Simultaneous Processes - 8
> 

Do like I did - change ISPs - and look at www.linode.com or other UML linux provider

gtoomey


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

Date: 10 Dec 2003 04:11:53 -0800
From: gsanuser <gsanuser_member@newsguy.com>
Subject: MIME::Lite / Net::SMTP question
Message-Id: <81058313.0000a563.043@drn.newsguy.com>

Hello,

We are using MIME::Lite (ver 2.117) and Net::SMTP (ver 2.19) for sending mail
from a Solaris box (perl 5.6.1).
We have a method which simplified looks like: 
sub sendMail ( 
    my $msg = build MIME::Lite(...) ; 
    attach $msg (...attachement ....) ; 
    $msg->send_by_smtp() || return 0; 
    return 1; 
) 
we are finally checking if sendMail() returns 0 or 1 in order to flag mails
correctly sent or not.

It appears that this way we are able to trap errors like "cannot connect to
host", or some STMP errors (like 500 Syntax error) but not all, i.e. error 452
(insufficient system storage) is not detected (that is, our sendMail() returns 1
as it were no problems).
 
Particularly errors from dataend() are not trapped. Following code from
MIME::Lite ver 2.117):

my $smtp = MIME::Lite::SMTP->new(@args) or Carp::croak("Failed to connect to
mail server: $!\n");
$smtp->mail($from) or Carp::croak("SMTP MAIL command failed:
$!\n".$smtp->message."\n");
$smtp->to(@to_all) or Carp::croak("SMTP RCPT command failed:
$!\n".$smtp->message."\n");
$smtp->data() or Carp::croak("SMTP DATA command failed:
$!\n".$smtp->message."\n");
$self->print_for_smtp($smtp);
$smtp->dataend() ;

Just asking group if this is a bug or a feature, and what is the best way to
correct this issue.

Just adding something like:

$smtp->dataend() or Carp::croak("SMTP DATAEND command failed:
$!\n".$smtp->message."\n");

or 

unless (($smtp->code())== 250){Carp::croak("Mail is Not Correltly Delivered via
SMTP");}

Thanks much,
Gabriel



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

Date: Wed, 10 Dec 2003 06:22:40 -0600
From: "Eric J. Roode" <REMOVEsdnCAPS@comcast.net>
Subject: Re: Multi-dimensional  Data Structures
Message-Id: <Xns944D4B590A2C4sdn.comcast@216.196.97.136>

-----BEGIN xxx SIGNED MESSAGE-----
Hash: SHA1

Konstantinos <agbiotec@vt.edu> wrote in
news:br4tka$6a9$1@solaris.cc.vt.edu:

> ...Since the references to
> memory adresses for this MD-data structure are created within the
scope
> of the subroutine, aren't these memory slots emptied each time the
sub
> ends ? (I think that is my problem, and my script does not work).

In Perl, memory is not reclaimed when variables go out of scope, but
rather when there are no extant references to the variables.  In C,
it's very bad to use a pointer to an auto variable after the function
has ended; in Perl, it's perfectly fine to use a reference to a my
variable after the function (or other scope) has ended.

- -- 
Eric
$_ = reverse sort $ /. r , qw p ekca lre uJ reh
ts p , map $ _. $ " , qw e p h tona e and print
-----BEGIN xxx SIGNATURE-----
Version: GnuPG v1.2.1 (MingW32) - WinPT 0.5.13

iD8DBQE/1xB2Y96i4h5M0egRAoLSAJ4/xsOAqsdUGFTIAmS9vxP5MIUCXACfdpfr
IIQZ4A2u3w50nOrzcJECU5k=
=eymj
-----END PGP SIGNATURE-----


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

Date: 10 Dec 2003 13:51:36 GMT
From: Michele Dondi <bik.mido@tiscalinet.it>
Subject: Re: Perl script to process file list....
Message-Id: <9mertvka2cp26918ev26sjd0eshr0crd40@4ax.com>

On 8 Dec 2003 17:36:07 -0800, carterave@yahoo.com (Jim Carter) wrote:

>I have directory, C:\Carter and it it has around 100 file names (ex:
>test1.txt, test2.txt, test3.txt......test100.txt).
>
>1. First, I need another list with all these 100 file names with no
>".txt" extension at the end (ex: test1, test2,test3, ....test100).
>2. Then I want these two lists as key and value pair in a hash.
>(EX: test1, test1.txt, test2, test2.txt, test3, test3.txt, ......,
>test100, test100.txt).

OK, too late, but... one more WTDI:

  my %a = map {my $t=$_; s/\.txt$//; $_, $t} glob "test*.txt";

not exactly what the OP asked, but possibly a good approximation, and
could be made better if needed (e.g. "test*[0-9].txt").


Michele
-- 
# This prints: Just another Perl hacker,
seek DATA,15,0 and  print   q... <DATA>;
__END__


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

Date: 9 Dec 2003 23:16:09 -0800
From: rook_5150@yahoo.com (Bryan Castillo)
Subject: Re: Proposal: new module, Array::Each?
Message-Id: <1bff1830.0312092316.54fb33f5@posting.google.com>

Brad Baxter <bmb@ginger.libs.uga.edu> wrote in message news:<Pine.A41.4.58.0312091240460.6362@ginger.libs.uga.edu>...
> [This stems somewhat from discussions in the thread:
> Idiom for array index that I'm foreach'ing over?]
> 
> I'm considering making a new module with the tentative name Array::Each.
> 
> A draft is available here:
> 
> http://www.vitabrevis.ws/perl/modules/Array/Each.pm
> http://www.vitabrevis.ws/perl/modules/Array/Each.pod.html
> 
> It's incomplete, but I want to discuss the idea before proceeding further.
> 
> 1. Is Array::Each acceptable?  Perhaps Array::Parallel, or
> Array::Iteration?
> 
> 2. Are the subroutine names acceptable?  In particular, I expect negative
> reactions to each(), since it would clobber each( %hash ), so alternative
> suggestions are welcome.
> 
> 3. Is this a good approach?  Are all those options needed?  Does it matter
> that it doesn't return lvalues like foreach ( @array )?
> 
> 4. Should someone else do this/Has someone else done this?  I did study
> the CPAN module list and didn't find a close match.  That I missed one
> would not surprise me.
> 
> 5. I imagine sometime adding an OO interface along these lines:
> 
>   my $set = Array::Each->new( @x, @y );
>   my( $i, $x, $y ) = $set->each();
> 
> Among other things, this should allow iterating over the same set of
> arrays using different iterators.  Should I bother?
> 
> 
> All feedback is appreciated.
> 
> Thanks,
> 
> Brad

The code below ............

use strict;
use warnings;
use Array::Each qw/them rewind/;
$|=1;
while (1) {
  my @array = map{rand}(1..10);
  while (my ($k,$v) = them(@array)) {
    print "[$k:$v]";
    last if ($k == 0);
  }
  print "\nnext -> ";
  ### rewind(@array); # would fix it
}

produces..............

next -> [1:0][2:8]
next -> [0:4]
next -> [1:4][2:0]
next -> [0:1]
next -> [1:0][2:3]
next -> [0:0]
next -> [1:9][2:9]
next -> [0:1]
next -> [1:6][2:4]
next -> [0:1]
next -> [1:0][2:7]
next -> [0:0]


I realize that this occurs, because the variable has the same
reference
even though it has completely changed.  You might want to note
something
about breaking out of iteration and how you should call rewind if you
are
going to be using the same variable in a loop.  

Anyway, I could see how someone might write code that leaves entries
in your %set variable which are never deleted.  This might be a
problem for a daemon.


Perhaps, some type of syntax as shown below would work.....
Without keeping a global hash.......
Of course it would have to be modified to iterate over multiple
arrays.

(I like your syntax better, I just don't like the way context is
maintained.
 Although I don't see any better way to do it, while keeping your
syntax.)

use strict;
use warnings;

sub on_each(&@) {
  my $code = shift;
  for (my $i=0; $i<=$#_; $i++) {
    $code->($i, $_[$i]);
  }
}

on_each {
  print "Index = $_[0] and Value = $_[1]\n";
} (1..10);


I really don't like the idea of the function being named each, but
that is just my opinion.


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

Date: 10 Dec 2003 11:30:41 GMT
From: anno4000@lublin.zrz.tu-berlin.de (Anno Siegel)
Subject: Re: Proposal: new module, Array::Each?
Message-Id: <br7051$h2a$1@mamenchi.zrz.TU-Berlin.DE>

Brad Baxter  <bmb@ginger.libs.uga.edu> wrote in comp.lang.perl.misc:
> [This stems somewhat from discussions in the thread:
> Idiom for array index that I'm foreach'ing over?]
> 
> I'm considering making a new module with the tentative name Array::Each.
> 
> A draft is available here:
> 
> http://www.vitabrevis.ws/perl/modules/Array/Each.pm
> http://www.vitabrevis.ws/perl/modules/Array/Each.pod.html
> 
> It's incomplete, but I want to discuss the idea before proceeding further.
> 
> 1. Is Array::Each acceptable?  Perhaps Array::Parallel, or
> Array::Iteration?
> 
> 2. Are the subroutine names acceptable?  In particular, I expect negative
> reactions to each(), since it would clobber each( %hash ), so alternative
> suggestions are welcome.
> 
> 3. Is this a good approach?  Are all those options needed?  Does it matter
> that it doesn't return lvalues like foreach ( @array )?
> 
> 4. Should someone else do this/Has someone else done this?  I did study
> the CPAN module list and didn't find a close match.  That I missed one
> would not surprise me.
> 
> 5. I imagine sometime adding an OO interface along these lines:
> 
>   my $set = Array::Each->new( @x, @y );
>   my( $i, $x, $y ) = $set->each();

By all means, go for an OO approach.  This stuff has been shouting
"object" from the moment we introduced the %i hash with its keys to
distinguish different iterators.

The user will have to create an iterator object (instead of "spontaneously"
saying "( $i, $x, $y) = each( @x, @y)"), but it will be much clearer
what's happening.

> Among other things, this should allow iterating over the same set of
> arrays using different iterators.  Should I bother?

That's one of the advantages of explicit iterators.

> All feedback is appreciated.

Make each() return the index last (after the array elements) instead
of first.  That way the first n values correspond to the n arrays, and
the index is easy to ignore when it isn't needed.

Anno


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

Date: 10 Dec 2003 05:56:17 -0800
From: yashgt@yahoo.com (Yash)
Subject: Querying SQLServer from Perl on Unix
Message-Id: <5a373b1d.0312100556.76f4d4e1@posting.google.com>

Hi,

Is there a way I can access an MS SQL Server2000 database running on a
Win2000 server, using Perl on HP-Unix? I want to execute plain SELECT
queries. Any pointers will be of great help.

Thanks
Yash


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

Date: 10 Dec 2003 10:55:03 GMT
From: anno4000@lublin.zrz.tu-berlin.de (Anno Siegel)
Subject: Re: Rounding up to 2 decimal places
Message-Id: <br6u27$es2$2@mamenchi.zrz.TU-Berlin.DE>

Walt Mankowski  <waltman@pobox.com> wrote in comp.lang.perl.misc:
> On 2003-12-10, R.Mariotti(at)FinancialDataCorp.com (Bob Mariotti) <> wrote:

> > You might want to try something as simple as this:
> >
> > my $VALUE=0.3325;
> > $value=sprintf("%.2f",$VALUE);
> > print "value=$value\n";
> 
> Er, that doesn't work.  Gary said he always wants it to round *up*.
> Your code rounds *down* and prints out 0.33.
> 
> The trick I've always used in situations like this is to add 0.005 to it
> before passing it to printf.

That (sprintf "%.2f", 0.33 + 0.005) rounds 0.33 up to 0.34, whereas
ceil( 100*0.33)/100 is 0.33.  This stuff is tricky, and it's best to
use the standard library functions if available.

Anno


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

Date: Wed, 10 Dec 2003 08:00:32 GMT
From: Bart Lateur <bart.lateur@pandora.be>
Subject: Re: What is '_'
Message-Id: <8gkdtvc30l9oruvsn7o3gk33mh4smu2gja@4ax.com>

Sara wrote:

>Curious, just consulted Camel v3, don't see this documented, or at
>least if its there, it's not obvious. Is it a secret only revealed to
>newsgroup readers? :)

I think it's in perlfunc, under "stat".

	If stat is passed the special filehandle consisting of an
	underline, no stat is done, but the current contents of the stat
	structure from the last stat or filetest are returned.

It's a good place to find out about it, when you're checking out stat(),
but the reverse, looking up what "_" means, isn't obvious -- as shown
here.

-- 
	Bart.


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

Date: Wed, 10 Dec 2003 12:41:36 GMT
From: merlyn@stonehenge.com (Randal L. Schwartz)
Subject: Re: What is '_'
Message-Id: <3ee5831b4098a829e5a6decd16cfc777@news.teranews.com>

>>>>> "John" == John W Krahn <krahnj@acm.org> writes:

John> Yes, but what have you done lately?   :-)

I know that was in jest, but I've been trying to keep my ear on the
ground on both the perl5 and perl6 tracks, and poke my nose in
occasionally to voice an opinion or two.

In general, they don't need me.  That's nice. :-) I can focus on
cranking out 2.5 columns a month and managing my micro-herd of Perl
trainers and consultants.

print "Just another Perl hacker,"

-- 
Randal L. Schwartz - Stonehenge Consulting Services, Inc. - +1 503 777 0095
<merlyn@stonehenge.com> <URL:http://www.stonehenge.com/merlyn/>
Perl/Unix/security consulting, Technical writing, Comedy, etc. etc.
See PerlTraining.Stonehenge.com for onsite and open-enrollment Perl training!


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

Date: 10 Dec 2003 11:32:17 GMT
From: anno4000@lublin.zrz.tu-berlin.de (Anno Siegel)
Subject: Re: Why does ne always work
Message-Id: <br7081$h2a$2@mamenchi.zrz.TU-Berlin.DE>

Gary E. Ansok <ansok@alumni.caltech.edu> wrote in comp.lang.perl.misc:
> In article <br4hu3$mbq$6@mamenchi.zrz.TU-Berlin.DE>,
> Anno Siegel <anno4000@lublin.zrz.tu-berlin.de> wrote:
> >Gary Mayor  <gary@tgpmakers.com> wrote in comp.lang.perl.misc:
> >> > Gary Mayor  <gary@tgpmakers.com> wrote in comp.lang.perl.misc:
> >> > 
> >> >>Hi,
> >> >>Whilst i'm here i might as well see if anyone else has noticed strange 
> >> >>things with if ($blah ne $blah) sometimes it works sometimes it doesn't. 
> >> 
> >> This message is probably useless without a real example. When I come 
> >> accross it again i'll post it up. I was just wondering if anyone else 
> >> had seen this problem.
> >
> >I think you are confusing "ne" with "!=".  If you compare two different
> >strings *numerically*, the result may be that they're equal because
> >they represent the same number, as in "003" and "3".  String comparison
> >(with "eq", "ne" and friends) always compares strings "as-is".
> 
> Another possibility is that one of the strings has leading or
> trailing whitespace.

There is only one string in "$blah ne $blah".

[snip]

Anno


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

Date: 10 Dec 2003 08:43:14 GMT
From: BOHIM <BOHIM789@AOL.COM>
Subject: Re: WIN32::Internet
Message-Id: <20031210-94314-50667@foorum.com>


Thanks

I use Win32::Internet because i've got problems between Net::Ftp and ithreads , 
and my script only runs on windows ...

I have an object where i do the chdir but the chdir works well and get method 
get the file in the bin path (in the object path) then i thought that a method 
like lcd in ftp dos would help me ...
I try to change dir before new Win32::Internet but nothing ...

I resolve my problem adding the complete path.




-- 
Ce message a ete poste via la plateforme Web club-Internet.fr
This message has been posted by the Web platform club-Internet.fr

http://forums.club-internet.fr/


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

Date: Wed, 10 Dec 2003 08:20:15 -0500
From: Tim Heaney <theaney@cablespeed.com>
Subject: Re: WIN32::Internet
Message-Id: <87smjs24j4.fsf@mrbun.watterson>

BOHIM <BOHIM789@AOL.COM> writes:
>
> I have an object where i do the chdir but the chdir works well and
> get method get the file in the bin path (in the object path) then i
> thought that a method like lcd in ftp dos would help me ...  I try
> to change dir before new Win32::Internet but nothing ...
>
> I resolve my problem adding the complete path.

I don't understand. If I do

  print "Remote directory: ", $Session->Pwd, "\n";
  $Session->Cd('Perl-Win32');
  print "Remote directory: ", $Session->Pwd, "\n";

  print "Local directory: ", cwd, "\n";
  chdir 'Download';
  print "Local directory: ", cwd, "\n";

  $Session->Get('README');

Then README will be in my Download directory. All paths are relative
and nothing like a $Session->Lcd is required.

Tim





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

Date: 10 Dec 2003 02:09:22 -0800
From: jeremy@emmjay.freeserve.co.uk (Jexxa)
Subject: windows services
Message-Id: <90225942.0312100209.1c34b9cf@posting.google.com>

Hi, I had a look on cpan for a module to control windows 2000
services. eg turing on and off and status information. Nothing jumped
out at me. Have I found the one area that perl has not infiltrated?
will I have to write my own module?
Any answers or comments gratefully received.


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

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.  

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 5920
***************************************


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