[18971] in Perl-Users-Digest
Perl-Users Digest, Issue: 1166 Volume: 10
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Wed Jun 20 14:05:42 2001
Date: Wed, 20 Jun 2001 11:05:12 -0700 (PDT)
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)
Message-Id: <993060311-v10-i1166@ruby.oce.orst.edu>
Content-Type: text
Perl-Users Digest Wed, 20 Jun 2001 Volume: 10 Number: 1166
Today's topics:
Re: adding newline in binary files <bard.selbekk@edbteamco.NO_SPAMcom>
Re: adding newline in binary files <pne-news-20010620@newton.digitalspace.net>
capturing compilation messages <lhswartw@ichips.intel.com>
Re: double key for hashtable <torsten.drees@detecon.com>
Re: error making Archive::Zip (Helgi Briem)
Re: Fetching CGI data as a hash (was DBM in a CGI) nobull@mail.com
Re: fork and pass message while waiting <Jenda@Krynicky.cz>
Re: Get all the possibilities <joe+usenet@sunstarsys.com>
Re: Get info about stored procedures - and SQL prettypr <Jenda@Krynicky.cz>
Re: Graphical user interfacing? <mjcarman@home.com>
Re: How to send an email and have the result ? <Jenda@Krynicky.cz>
Re: I can't belive I'm asking this here... <Jenda@Krynicky.cz>
Re: Install Perl on HP <pne-news-20010620@newton.digitalspace.net>
int sub - strange behaviour (George Karabotsos)
Re: int sub - strange behaviour <pne-news-20010620@newton.digitalspace.net>
Re: int sub - strange behaviour (Greg Bacon)
Re: lock command on a Linux 2.0 ? (M.J.T. Guy)
Re: Mail Attachment from StdIn <Jenda@Krynicky.cz>
match exact n times? <bing-du-123@tamu.edu>
Re: match exact n times? (Randal L. Schwartz)
Re: match exact n times? <pne-news-20010620@newton.digitalspace.net>
my $ref; vs. my $ref = {}; <temp133@hotmail.com>
Re: my $ref; vs. my $ref = {}; <pne-news-20010620@newton.digitalspace.net>
need something similar to $input=$ENV{'QUERY_STRING'}; <lying_happy_eyes@hotmail.com>
Re: need something similar to $input=$ENV{'QUERY_STRING (Anno Siegel)
Re: Perl2Exe Decompiler? <andrew@mvt.ie>
Re: Reference-problem <todd@designsouth.net>
Re: Reference-problem nobull@mail.com
Re: Reference-problem <sserena@freesurf.ch>
Re: Regexps, using variables to get $1, $2, etc. googlenews@edge-web.com
Re: Regexps, using variables to get $1, $2, etc. <mjcarman@home.com>
Re: Regexps, using variables to get $1, $2, etc. nobull@mail.com
Re: Removing ^M characters <ned@bike-nomad.com>
test popst <shl@NOSPAMegret.net>
Time in milliseconds <glenn@surveystar.com>
Re: Time in milliseconds <pne-news-20010620@newton.digitalspace.net>
Urgent Help Required <ub98aa@brocku.ca>
Re: What is ${'string'} ? <mjcarman@home.com>
Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: 20 Jun 2001 15:29:30 GMT
From: Bard Selbekk <bard.selbekk@edbteamco.NO_SPAMcom>
Subject: Re: adding newline in binary files
Message-Id: <Xns90C6B1CB78FCBbardselbekkedbteamco@134.47.108.15>
Philip Newton <pne-news-20010620@newton.digitalspace.net> wrote in
news:meb1jt4b6hkk3rq4htaidilbumd0vkrs0m@4ax.com:
> I hope the real version checks the return value of the opens and the
> close :)
>
> Cheers,
> Philip
But off course! The real version even checks that the return value of read
is 448. But I wanted to keep it simple rather that robust in that posting.
:)
-Bard
------------------------------
Date: Wed, 20 Jun 2001 18:04:43 +0200
From: Philip Newton <pne-news-20010620@newton.digitalspace.net>
Subject: Re: adding newline in binary files
Message-Id: <1ci1jt8gspfv2e7i1k9e19mamvlcmmk9m2@4ax.com>
On 20 Jun 2001 15:29:30 GMT, Bard Selbekk
<bard.selbekk@edbteamco.NO_SPAMcom> wrote:
> The real version even checks that the return value of read is 448.
What do you do if it's not? (Can the last record of the file be short,
by the way?)
Cheers,
Philip
--
Philip Newton <nospam.newton@gmx.li>
Yes, that really is my address; no need to remove anything to reply.
If you're not part of the solution, you're part of the precipitate.
------------------------------
Date: Wed, 20 Jun 2001 10:08:03 -0700
From: "Swanthog" <lhswartw@ichips.intel.com>
Subject: capturing compilation messages
Message-Id: <9gql9k$lfd@news.or.intel.com>
I launch a perl script as a new process using the following:
Win32::Process::Create(
$new_proc,
'C:/perl/bin/perl.exe',
'perl //pdxsmb/svarchiv/legos/sendem_rc_server.pl', #
1, # Do inherit.
DETACHED_PROCESS, #
"$lego_dir")
or return( &print_error("Error Launching sendem_rc_server.pl"));
Unfortunately, however, if for whatever reason there is a complilation error
and the script fails to start the error messages are lost forever. Is there
any way to capture the error messages? I'd like to write them to a log file.
Thanks,
Larry S.
------------------------------
Date: Wed, 20 Jun 2001 16:59:13 +0200
From: "Torsten Drees" <torsten.drees@detecon.com>
Subject: Re: double key for hashtable
Message-Id: <34E1B02BAC87D3119F2700A0C970385E09E6F937@news.detecon.de>
thank you, i think i get clear now.
torsten
"Rafael Garcia-Suarez" <rgarciasuarez@free.fr> wrote in message
news:slrn9j1cl4.15c.rgarciasuarez@rafael.kazibao.net...
> Torsten Drees wrote in comp.lang.perl.misc:
> } Hi people,
> }
> } i have an interesting problem. i wrote two records in a hash table with
the
> } same key. Is it possible to get back, both records.
>
> No, it isn't.
>
> } If not, is it possible to define a subkey?
>
> You can store a reference to an array into a hash :
>
> $hash{'key'} = [ 'value_1', 'value_2' ];
>
> See the perlreftut and perlref manpages to know how to use references in
> Perl to construct complex data structures.
>
> --
> Rafael Garcia-Suarez / http://rgarciasuarez.free.fr/
------------------------------
Date: Wed, 20 Jun 2001 16:11:07 GMT
From: helgi@NOSPAMdecode.is (Helgi Briem)
Subject: Re: error making Archive::Zip
Message-Id: <3b30cad1.1841442404@news.isholf.is>
On 19 Jun 2001 08:59:25 -0700, gururaj@powertec.com (Gururaj
Upadhye) wrote:
>I am getting following error while making Archive::Zip. I am working
>on Windows NT 4.0, perl 5.6.0. THis is from output of perl -v
>This is perl, v5.6.0 built for MSWin32-x86-multi-thread
>
>Following is copied from command window:
>D:\shared\Download\Archive-Zip-0.11>perl makefile.pl
>Writing Makefile for Archive::Zip
>
>D:\shared\Download\Archive-Zip-0.11>nmake
>
>Microsoft (R) Program Maintenance Utility Version 6.00.8168.0
>Copyright (C) Microsoft Corp 1988-1998. All rights reserved.
>
> D:\Perl\bin\perl.exe -Id:\Perl\lib -Id:\Perl\lib
>-MExtUtils::Command -e cp crc32 b
>lib\script\crc32
> D:\Perl\bin\perl.exe -Id:\Perl\lib -Id:\Perl\lib -e "system
>qq[pl2bat.bat ].shift
>" blib\script\crc32
>The name specified is not recognized as an
>internal or external command, operable program or batch file.
Why are you doing it this way? Use PPM.
Regards,
Helgi Briem
------------------------------
Date: 20 Jun 2001 18:11:06 +0100
From: nobull@mail.com
Subject: Re: Fetching CGI data as a hash (was DBM in a CGI)
Message-Id: <u9zob36pqt.fsf@wcl-l.bham.ac.uk>
"Dave Neill" <dneill@snet.net> writes:
> use CGI qw(:cgi-lib);
>
> $query = new CGI;
> %fields = $query->Vars;
>
> Vars needs :cgi-lib imported.
No it does not (not in the OO style).
--
\\ ( )
. _\\__[oo
.__/ \\ /\@
. l___\\
# ll l\\
###LL LL\\
------------------------------
Date: Wed, 20 Jun 2001 16:32:35 GMT
From: Jenda Krynicky <Jenda@Krynicky.cz>
Subject: Re: fork and pass message while waiting
Message-Id: <1104_993054755@JENDA>
On 12 Jun 2001 22:04:51 GMT, rolf.krahl@gmx.net (Rolf Krahl) wrote:
> |
> | $SIG{CHLD} = \&handle_chld;
> |
>
> Note that these are fragments from some of my scripts that run on Unix
> systems. Since i only work with Unix, i have no idea if this might
> work with other OS's.
>
> --
> Rolf Krahl <rolf.krahl@gmx.net>
It would not on Win32.
Jenda
------------------------------
Date: 20 Jun 2001 13:02:33 -0400
From: Joe Schaefer <joe+usenet@sunstarsys.com>
Subject: Re: Get all the possibilities
Message-Id: <m3lmmn3x06.fsf@mumonkan.sunstarsys.com>
Ren Maddox <ren@tivoli.com> writes:
> On 19 Jun 2001, ren@tivoli.com wrote:
>
> [Solution to wrong problem snipped]
>
> Silly me... not until I saw Craig Berry's solution did I realized that
> I had solved the wrong problem. (Apologies to Greg Bacon and Jay
> Tilton for not noticing after either of their posts.)
Here's a completely different approach. It's much slower than Jay's
and Craig's answers (and probably inappropriate for a beginner to build
from), but it is memory-friendly and makes grabbing ranges of strings
fairly simple.
% cat try.pl
#!/usr/bin/perl -wl
use strict;
package ACGT;
use overload "++" => \&increment,
'""' => \"e,
'<>' => sub {$_[0]++},
'eq' => sub {quote($_[0]) eq $_[1]};
sub increment {
my $self = shift;
$$self="0", return $self unless defined $$self and length $$self;
my $lsd = chop $$self;
increment($self), $lsd = "0" unless ++$lsd % 4;
$$self .= $lsd;
return $self;
}
sub quote {
local $_ = ${$_[0]};
return "" unless defined $_ and length $_;
tr/0-3/ACGT/; # convert base 4 to ACGT
return $_;
}
sub new {
local $_ = defined $_[1] ? $_[1] : "";
tr/ACGT/0-3/; # use base 4 internally
bless \$_, ref $_[0] || $_[0];
}
my $len = shift || 4;
my $foo = ACGT->new(shift);
++$foo unless length $foo;
while (<$foo>) {
last unless length() <= $len;
print;
}
__END__
% ./try.pl 2
A
C
G
T
AA
AC
AG
AT
CA
CC
CG
CT
GA
GC
GG
GT
TA
TC
TG
TT
%
Joe Schaefer
--
"You may be a mighty king," he said. "But you're sitting in oobleck up to your
chin. And so is everyone else in your land. And if you won't even say you're
sorry, you're no sort of a king at all!"
-- Dr. Seuss
------------------------------
Date: Wed, 20 Jun 2001 16:14:11 GMT
From: Jenda Krynicky <Jenda@Krynicky.cz>
Subject: Re: Get info about stored procedures - and SQL prettyprinter
Message-Id: <1103_993053651@JENDA>
And once again. I should go and see a doctor maybe ...
On Tue, 19 Jun 2001 08:05:11 GMT, Jenda Krynicky <Jenda@Krynicky.cz> wrote:
> That's great, replying to my own post ...
>
> On Fri, 15 Jun 2001 11:09:23 GMT, Jenda Krynicky <Jenda@Krynicky.cz> wrote:
> > I need to read information about stored procedures in a MS SQL database within a program.
> >
> > I can get the list of procedures, their parameters, types and sizes of parameters via Win32::OLE
> > "SQLDMO.SQLServer".
> >
> > I can't find a way to find out two more things.
> >
> > 1) I can't find how to check whether some parameter has a default value.
> > I don't mind what the value is, I just need to know what parameters are required.
>
> I'd realy want to know this pretty please !
And there is another problem I have found. If the parameter to the stored procedure is
Number(6,2)
I get
type: Number
size: 7
from $sp->EnumParameters();
I don't know how to get the Scale and Precision.
It's not that a big problem though since you usualy don't use Numeric(x,y) directly but you define your own type
and then use that one. And when I read info about user defined types I do get the Scale and Precision.
So I am able to handle that.
> If you want to see the results (well it's still being modified, but it's working already)
> you can find them on http://Jenda.Krynicky.cz/perl/SP_COM_generator.1.1.zip
> It's Win32 only of course.
>
> Jenda
I expect 1.2 out soon.
Jenda
------------------------------
Date: Tue, 19 Jun 2001 08:05:07 -0500
From: Michael Carman <mjcarman@home.com>
Subject: Re: Graphical user interfacing?
Message-Id: <3B2F4E03.1215A041@home.com>
flash wrote:
>
> Is it possible to interface with a grapical program (GUI)?
> What modules?
>
> This would be on windows.
Your question seems a little ambigous to me. By "interface" do you mean
that you wish to interact with another application (like Excel) or that
you wish to create a program with it's own GUI?
For the former use the Win32::OLE module. For the latter you have
several choices. Tk is the most popular.
-mjc
------------------------------
Date: Wed, 20 Jun 2001 16:51:48 GMT
From: Jenda Krynicky <Jenda@Krynicky.cz>
Subject: Re: How to send an email and have the result ?
Message-Id: <1105_993055908@JENDA>
On Tue, 12 Jun 2001 01:24:54 +0000 (UTC), see-sig@from.invalid (David Efflandt) wrote:
> On Mon, 11 Jun 2001 14:58:12 +0200, CutMaster <cutmaster@fearlesss.com> wrote:
> > How to send an email, in Perl, but with having the result of this send :
> > (ie : fail to send, domain unavailable, etc).
Use Net::POP3 or Mail::POP3Client to read the mail servers response later :-}
When you send a mail you just pass it to YOUR mail server. The server doesn't
know immediately if the domain or username exists (unless you send it to a local user)
They just add your message the the queue and when they have tim they try to contact
the recipient's server and send it your message. And if for example the other server
is unaccessible your server tries to contact it several times. And only after preset number of
retries or preset time lets the sender know the mail was not send.
So you realy have no other chance to look into the senders mailbox. And it may tak days
before the non-delivery report appears.
The best you can get immediately is whether the mail was ACCEPTED for delivery by your
server. Nothing more.
Jenda
------------------------------
Date: Wed, 20 Jun 2001 16:59:39 GMT
From: Jenda Krynicky <Jenda@Krynicky.cz>
Subject: Re: I can't belive I'm asking this here...
Message-Id: <1106_993056379@JENDA>
On Mon, 18 Jun 2001 10:13:53 +0200, Philip Newton <pne-news-20010618@newton.digitalspace.net> wrote:
> [Please use a subject line that relates to the subject of your post]
>
> On Sun, 17 Jun 2001 23:14:55 GMT, Kim C <kimmfc@mydeja.com> wrote:
>
> > I have an embarrassingly simple question to ask: How does one copy an
> > entire directory (with sub directories if necessary)?
If you only want this under Win32 then use Win32::FileOp
http://jenda.krynicky.cz
Jenda
------------------------------
Date: Wed, 20 Jun 2001 17:40:33 +0200
From: Philip Newton <pne-news-20010620@newton.digitalspace.net>
Subject: Re: Install Perl on HP
Message-Id: <csg1jt00moe7q2s2jq2l3u4nkk9s9afe7q@4ax.com>
[Posted and CC'ed to ralphwang@hotmail.com]
Are you the same Ralph Wang who just sent me email asking essentially
the same question as you just posted in the newsgroup?
I got this when I tried to respond:
wang_yifu@yahoo.com.tw:
SMTP error from remote mailer after end of data:
host mx1.mail.tw.yahoo.com [202.1.238.35]:
554 delivery error:
dd This user doesn't have a yahoo.com.tw account
(wang_yifu@yahoo.com.tw) - mta103.mail.tpe.yahoo.com
I can't reply if you use an address that doesn't exist.
Cheers,
Philip
--
Philip Newton <nospam.newton@gmx.li>
Yes, that really is my address; no need to remove anything to reply.
If you're not part of the solution, you're part of the precipitate.
------------------------------
Date: 20 Jun 2001 08:10:48 -0700
From: karabot@canada.com (George Karabotsos)
Subject: int sub - strange behaviour
Message-Id: <d435cbbf.0106200710.5ff0f7f2@posting.google.com>
Hi everybody,
I run through a strange problem with the int subroutine. Please have
a look at the following:
> perl -e '$cc_amt=int(39.80*100.0);print("$cc_amt\n");'
3979
> perl -e '$cc_amt=39.80*100.0;print("$cc_amt\n");'
3980
As you can see when I use the int sub I get the wrong result while
when I do not use it I get the correct one.
I am guessing that the operations they do inside int cause the
creation of a float number that cannot be represented in a computer,
thus, the problem with the missing 1 value.
BTW, I running this under Slackware 7.1 and Perl 5.005_03
Do you guys now anything?
thanks,
George
------------------------------
Date: Wed, 20 Jun 2001 17:34:56 +0200
From: Philip Newton <pne-news-20010620@newton.digitalspace.net>
Subject: Re: int sub - strange behaviour
Message-Id: <ucg1jtotirjvcj5tkb57kg7rtvlerl7ua6@4ax.com>
On 20 Jun 2001 08:10:48 -0700, karabot@canada.com (George Karabotsos)
wrote:
> I am guessing that the operations they do inside int cause the
> creation of a float number that cannot be represented in a computer,
> thus, the problem with the missing 1 value.
No: one of the numbers you are calculating with is not exactly
representable in floating point, and the product is not representable
exactly either. So the result is not 3980.0000... but 3979.99..99xyz...
(on my machine it's 3979.99999999999950000000000000000000 to 32 decimal
places). So int() truncates that to 3979.
> Do you guys now anything?
Don't do maths with floating point if you expect to get exact answers.
For example, if you are calculating with money, do all your arithmetic
in cents rather then fractional dollars.
For similar things, try adding 0.1 to itself repeatedly and see what
happens, and read `perldoc -q decimals`.
Or you could try using sprintf() for rounding rather than int() for
truncating.
Cheers,
Philip
--
Philip Newton <nospam.newton@gmx.li>
Yes, that really is my address; no need to remove anything to reply.
If you're not part of the solution, you're part of the precipitate.
------------------------------
Date: Wed, 20 Jun 2001 17:55:26 -0000
From: gbacon@HiWAAY.net (Greg Bacon)
Subject: Re: int sub - strange behaviour
Message-Id: <tj1osejq6iljf4@corp.supernews.com>
In article <ucg1jtotirjvcj5tkb57kg7rtvlerl7ua6@4ax.com>,
Philip Newton <nospam.newton@gmx.li> wrote:
: Or you could try using sprintf() for rounding rather than int() for
: truncating.
...as long as you understand round-to-even. :-)
Greg
--
The right to dispose of one's income belongs to the producer, and if he
wishes to give it to an heir, a charity, or to flush it down the toilet--
that is the producer's right. It is not any of your concern, and it certainly
is not the concern of the government. -- Ayn Rand
------------------------------
Date: 20 Jun 2001 15:27:06 GMT
From: mjtg@cus.cam.ac.uk (M.J.T. Guy)
Subject: Re: lock command on a Linux 2.0 ?
Message-Id: <9gqfca$1j$1@pegasus.csx.cam.ac.uk>
helpmeplease <helpmeplese@helpmeplese.com> wrote:
>Anybody Know how to do a lock command on a Linux 2.0 ?
>
>After editing a text dat file i'm doing a :
>rename current.dat to current.old
>rename new.dat to current.dat
If you do that update the Right Way, using hard links, you don't need
any locking:
link 'current.dat', 'current.old' or die "link: $!\n";
rename 'new.dat', 'current.dat' or die "rename: $!\n";
Of course, you can only do that on a real operating system, but
fortunately you're using Linux.
Mike Guy
------------------------------
Date: Wed, 20 Jun 2001 17:14:50 GMT
From: Jenda Krynicky <Jenda@Krynicky.cz>
Subject: Re: Mail Attachment from StdIn
Message-Id: <1107_993057290@JENDA>
On Fri, 15 Jun 2001 09:09:42 +0200, "Robin Aly" <robin@aly.de> wrote:
> Hello,
>
> I need to extract an attachment of a Mime-EMail that comes from STDIN. The
> attachment will be the second part of the email. it will be a txt.File
> written on a windows system. Will encoding be a problem.
>
> thank you
> robin
Sorry I'm not sure I understand you well.
If you want to send a file that's somewhere on your disk you may use this :
use Mail::Sender;
$sender = new Mail::Sender ({smtp => 'your.servername.here'});
$sender->MailFile( { from => 'you@your.site',
to => 'someone@somewhere',
subject => 'Test STDIN',
message =>"See the attached filess.\n\nJenda\n",
file => 'c:\dir\file.txt',
ctype=> 'text/plain',
encoding => 'quoted-printable'
});
if you realy want to send something you read from STDIN you'd use
$sender->MailFile( { from => 'you@your.site',
to => 'someone@somewhere',
subject => 'Test STDIN',
message =>"See the attached filess.\n\nJenda\n",
file => '&STDIN',
ctype=> 'text/plain',
encoding => 'quoted-printable'
});
Of on the other hand you have a multipart mail message and want to split it to parts
and decode the attached files you should use MIME-tools
You may find both mentioned modules on cpan : http://search.cpan.org
HTH, Jenda
------------------------------
Date: Wed, 20 Jun 2001 11:51:44 -0500
From: test <bing-du-123@tamu.edu>
Subject: match exact n times?
Message-Id: <3B30D4A0.6883B490@tamu.edu>
Hi,
If {n} means matching exact n times, how come the output of the
following script is 'yes'? What did I do wrong?
#!/usr/local/bin/perl
$test = "ohello";
if ($test =~ /[0-9a-z]{5}/)
{
print "yes\n";
} else {
print "no\n";
}
Thanks,
Bing
------------------------------
Date: 20 Jun 2001 10:30:17 -0700
From: merlyn@stonehenge.com (Randal L. Schwartz)
Subject: Re: match exact n times?
Message-Id: <m1g0cvcb4m.fsf@halfdome.holdit.com>
>>>>> "test" == test <bing-du-123@tamu.edu> writes:
test> Hi,
test> If {n} means matching exact n times, how come the output of the
test> following script is 'yes'? What did I do wrong?
test> #!/usr/local/bin/perl
test> $test = "ohello";
test> if ($test =~ /[0-9a-z]{5}/)
test> {
test> print "yes\n";
test> } else {
test> print "no\n";
test> }
You didn't anchor it. You've asked the regex "does ohello contain
a substring that has exactly 5 alphanums?" and the answer is yes.
If you want "does ohello contain exactly 5 alphanums from start
to finish?" you need to add the "start" and "finish" requirements:
/^[0-9a-z]{5}$/
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: Wed, 20 Jun 2001 19:47:24 +0200
From: Philip Newton <pne-news-20010620@newton.digitalspace.net>
Subject: Re: match exact n times?
Message-Id: <9co1jtcefq3igomo4ii76h0utpgcnjvurt@4ax.com>
On 20 Jun 2001 10:30:17 -0700, merlyn@stonehenge.com (Randal L.
Schwartz) wrote:
> If you want "does ohello contain exactly 5 alphanums from start
> to finish?" you need to add the "start" and "finish" requirements:
>
> /^[0-9a-z]{5}$/
Or possibly /^[0-9a-z]{5}\z/, or it'll match "hello\n". But you knew
that.
Cheers,
Philip
--
Philip Newton <nospam.newton@gmx.li>
Yes, that really is my address; no need to remove anything to reply.
If you're not part of the solution, you're part of the precipitate.
------------------------------
Date: Wed, 20 Jun 2001 09:23:22 -0700
From: "Arvin Portlock" <temp133@hotmail.com>
Subject: my $ref; vs. my $ref = {};
Message-Id: <9gqimp$9jk$1@agate.berkeley.edu>
Is there a difference between declaring a hash reference as my $ref = {};
and as just plain my $ref; ? I've been using the former method because
I vaguely recall problems I have had with the latter but can't remember
now what that was. The former has the advantage of being somewhat
self-documenting, but I was wondering whether there were any other
more fundamental differences.
sub make_hash {
my ($key, $value) = @_;
my $hashref;
$hashref->{$key}++ if $value;
return $hashref;
}
------------------------------
Date: Wed, 20 Jun 2001 18:38:02 +0200
From: Philip Newton <pne-news-20010620@newton.digitalspace.net>
Subject: Re: my $ref; vs. my $ref = {};
Message-Id: <pvj1jtc86emusud4er8ov4c7j2proe21gc@4ax.com>
On Wed, 20 Jun 2001 09:23:22 -0700, "Arvin Portlock"
<temp133@hotmail.com> wrote:
> Is there a difference between declaring a hash reference as my $ref = {};
> and as just plain my $ref; ?
The first creates an anonymous hash and puts a reference to it into
$ref, the second leaves $ref with the undefined value.
Note that if you use an undefined value as if it were a hash reference,
Perl automagically conjures up an anonymous hash and sticks a reference
to it into the variable so that you can reference it. Thus, this:
$ref = undef;
$ref->{'foo'} = 42;
works, and $ref contains a hash reference afterwards.
> The former has the advantage of being somewhat self-documenting,
There is that.
> sub make_hash {
> my ($key, $value) = @_;
> my $hashref;
> $hashref->{$key}++ if $value;
> return $hashref;
> }
This doesn't make a whole lot of sense to me. You return either undef or
a reference to a hash with just one key.
Cheers,
Philip
--
Philip Newton <nospam.newton@gmx.li>
Yes, that really is my address; no need to remove anything to reply.
If you're not part of the solution, you're part of the precipitate.
------------------------------
Date: Tue, 19 Jun 2001 17:54:11 +0100
From: "lying_happy_eyes" <lying_happy_eyes@hotmail.com>
Subject: need something similar to $input=$ENV{'QUERY_STRING'};
Message-Id: <9gqkbj$blk$1@neptunium.btinternet.com>
I know that this, when appended to the end of a file, $ENV{'QUERY_STRING'};
can be put into a $. so i assume that there's something similar in perl that
i can use to get the complete URL of a file, you know, get it to see where
exactly it's located, and put it into a $??
i.e. if a perl script's located at mydomain.com/cgi-bin/perl.pl how can i
get it so that i can use it in the perl script???
I'm sorry if this doesn't make much sense, i think i know what i want to do
but know no jargon to go with it.
Thanks for anyone's help with this..
--
lying_happy_eyes
XXX
http://go.to/nypihas
http://balder.prohosting.com/thenyp/cgi-bin/ikonboard/ikonboard.cgi
------------------------------
Date: 20 Jun 2001 17:29:31 GMT
From: anno4000@lublin.zrz.tu-berlin.de (Anno Siegel)
Subject: Re: need something similar to $input=$ENV{'QUERY_STRING'};
Message-Id: <9gqmhr$pcr$1@mamenchi.zrz.TU-Berlin.DE>
According to lying_happy_eyes <lying_happy_eyes@hotmail.com>:
> I know that this, when appended to the end of a file, $ENV{'QUERY_STRING'};
> can be put into a $. so i assume that there's something similar in perl that
> i can use to get the complete URL of a file, you know, get it to see where
> exactly it's located, and put it into a $??
>
> i.e. if a perl script's located at mydomain.com/cgi-bin/perl.pl how can i
> get it so that i can use it in the perl script???
>
> I'm sorry if this doesn't make much sense, i think i know what i want to do
> but know no jargon to go with it.
You can get your script's location in the file system using the
module FindBin. How (and if) this translates to a URL is a matter
of your web server.
Anno
------------------------------
Date: Wed, 20 Jun 2001 16:07:48 +0100
From: "Andrew" <andrew@mvt.ie>
Subject: Re: Perl2Exe Decompiler?
Message-Id: <9gqe85$chg$1@kermit.esat.net>
"Deneb Pettersson" <Deneb.Pettersson@lmf.ericsson.se> wrote in message
news:3B2DCD02.8E625171@lmf.ericsson.se...
>
>
> > > > When you run a .exe file produced by perl2exe, I believe that it
> > > > unpacks the contents into a temp directory (C:\WINDOWS\TEMP on my
> > > > system) and then basically runs an embedded Perl interpreter on
them.
> > > > If you can somehow run the .exe but kill it before it has a chance
to
> > > > clean up those files, you might be able to recover the scripts
you're
> > > > trying to edit. --Or maybe not, if I'm mistaken about how it works,
> > > > but it might be worth a try.
> > >
> > > I watched my temp directory after executing one of my programs, but
the
> > > contents didn't change one bit.
> >
> > Hunh. I found all kinds of interesting stuff in mine when my program
> > crashed (Perl/Tk program).
> >
> > > Any other ideas? :-)
> >
> > I seem to be fresh out. Oh, well, I tried.
>
> You could run some tracker which monitros what is copied / installed to
the harddisk
> while you run the program you should get that out then. And you might jsut
go ahead
> and change the temp directory's write permissions... just to see how the
program
> behaves then .....
>
> And you should look at the temp during the program. not after it....
There are often a number of temporary directories used by various programs
in windows. Seems that an easy thing to do would be to write a small
program that waits for user input, then pass it through perl2exe and run it.
Windows' file find will allow you to search for files modified during the
last day, while the program is still running, and it may be possible to see
where the temporary files (if any) get written to.
Andrew
------------------------------
Date: Wed, 20 Jun 2001 15:09:55 GMT
From: "Todd Smith" <todd@designsouth.net>
Subject: Re: Reference-problem
Message-Id: <713Y6.172914$I5.49638641@news1.rdc1.tn.home.com>
"Stefan Serena" <sserena@freesurf.ch> wrote in message
news:9gq2b4$dds$1@news1.sunrise.ch...
> Hi!
>
> What's wrong? It doesn't cause an error, but I want it to print "Hello
> World!"...
>
> @foo = ('bar', 'anything');
> $$foo[0] = "Hello World!";
> print $bar;
>
> Thx!
key lookups are done last. It's looking for $foo to be a listref, and '$'
dereferences it but in an array kind of way, then [0] gets looked up:
[todd@co92 todd]$ perl
$foo = [1,2,3];
print $$foo[0];
1[todd@co92 todd]$
------------------------------
Date: 20 Jun 2001 18:12:23 +0100
From: nobull@mail.com
Subject: Re: Reference-problem
Message-Id: <u9y9qn6poo.fsf@wcl-l.bham.ac.uk>
"Stefan Serena" <sserena@freesurf.ch> writes:
> What's wrong?
Presedence.
> It doesn't cause an error, but I want it to print "Hello
> World!"...
>
> @foo = ('bar', 'anything');
> $$foo[0] = "Hello World!";
> print $bar;
You are actually setting the first element of an anonymous array to
"Hello World!" and storing a reference to that anonymous array in the
scalar variable $foo.
Change your code to:
use strict;
use warnings;
my ($bar, $anything);
my @foo = \ ($bar, $anything);
${$foo[0]} = "Hello World!";
print $bar;
Note: I've also changed the symbolic references to real refererences
and the package variables to lexicals because >99% of the time using
package variables and/or symbolic refererences is a bad idea.
--
\\ ( )
. _\\__[oo
.__/ \\ /\@
. l___\\
# ll l\\
###LL LL\\
------------------------------
Date: Wed, 20 Jun 2001 19:35:01 +0200
From: "Stefan Serena" <sserena@freesurf.ch>
Subject: Re: Reference-problem
Message-Id: <9gqmsc$hob$1@news1.sunrise.ch>
Thx, that was the point. I thought I understood that part... maybe I should
reread it :-)
Yes, I could use a hash, but I wanted to use references as I've never used
them until now...
"Rafael Garcia-Suarez" <rgarciasuarez@free.fr> schrieb im Newsbeitrag
news:slrn9j13rr.ul1.rgarciasuarez@rafael.kazibao.net...
> Stefan Serena wrote in comp.lang.perl.misc:
> } Hi!
> }
> } What's wrong? It doesn't cause an error, but I want it to print "Hello
> } World!"...
> }
> } @foo = ('bar', 'anything');
> } $$foo[0] = "Hello World!";
> } print $bar;
>
> You should write
> ${$foo[0]} = "Hello World!";
>
> Note also that this doesn't work with the 'strict' pragma enabled.
> The use of symbolic references is often discouraged when maintainability
> should be taken into account. Perhaps can you use a hash instead?
>
> --
> Rafael Garcia-Suarez / http://rgarciasuarez.free.fr/
------------------------------
Date: Wed, 20 Jun 2001 15:20:39 -0000
From: googlenews@edge-web.com
Subject: Re: Regexps, using variables to get $1, $2, etc.
Message-Id: <tj1fq7ojvvfmdf@corp.supernews.com>
Ren Maddox <ren@tivoli.com> tapped:
> Next you'll be wanting to handle $+, @+ and @-, right? :)
Of course. Full Perl functionality, and it'll have to work with 6.0 too, hehe (kidding about the latter).
I think I can figure out the rest though, I'm picking all your stuff apart to find out what you're doing so I can KNOW rather than parrot somebody else's code.
Thanks for the response, it's appreciated.
------------------------------
Date: Tue, 19 Jun 2001 15:28:19 -0500
From: Michael Carman <mjcarman@home.com>
Subject: Re: Regexps, using variables to get $1, $2, etc.
Message-Id: <3B2FB5E3.651C198D@home.com>
"googlenews@edge-web.com" wrote:
>
> I'd like to take a string, match and store patterns within the
> string using a regexp defined in a variable ($match) which
> stores values in $1, $2, $`, etc. Then I'd like to get the data
> contained in the read-only variables and manipulate it with
> another variable ($replace).
>
> $string = 'this.20010420162000.txt';
> $match = '^th(.*?)\.(\d{14})\.txt$';
> $replace = '$1.during.$2';
It sounds to me like you want to do this:
my $string = 'this.20010420162000.txt';
$string =~ s/^th(.*?)\.(\d{14})\.txt$/$1.during.$2/;
but are just making things more difficult than they need to be. Is this
an X/Y problem?
If the point is that the search/replace patterns are variables instead
of hard-coded, then you need to evaluate the RHS:
my $string = 'this.20010420162000.txt';
my $match = '^th(.*?)\.(\d{14})\.txt$';
my $replace = '"$1.during.$2"';
$string =~ s/$match/$replace/ee;
Note that I modified $replace slightly to make it into something which
can be eval'd.
> if($string =~ /$match/) {
> # what to do now? $replace should be 'is.during.20010420162000'
No, it won't be -- it's just a string.
> # I've tried:
> # $new = $replace;
This just copies $replace into $new.
> # $new = eval($replace);
This is close; you just need to make $replace into a valid expression,
as in my example above.
> # some other variants of the same
> # none work
> }
>
> If this is documented anywhere I'd love to see it, maybe I need
> to use map or something like that, I just can't figure it out.
A look at the perlre and perlop manpages (under the s/// operator) may
be helpful. While you might be able to work map() into this, it would
serve no purpose other than obfuscation. :)
It's still not clear to me just what you're trying to accomplish. Do you
want to modify $string? Or just extract values from it? Why do you want
the match/replace patterns stored in variables? If you can give us a
better explanation of what you have, what you want to end up with, and
why you think you need to do it the way you're trying to, we can provide
better advice.
-mjc
------------------------------
Date: 20 Jun 2001 09:39:00 -0700
From: nobull@mail.com
Subject: Re: Regexps, using variables to get $1, $2, etc.
Message-Id: <4dafc536.0106200838.87c4ad4@posting.google.com>
It's funny how questions come and go. I remember when this question
seemed to pop up every week but I've not seen it now for 7 weeks.
Egghead (googlenews@edge-web.com) wrote:
> $string = 'this.20010420162000.txt';
> $match = '^th(.*?)\.(\d{14})\.txt$';
> $replace = '$1.during.$2';
>
> if($string =~ /$match/) {
> # what to do now? $replace should be 'is.during.20010420162000'
> # I've tried:
> # $new = $replace;
> # $new = eval($replace);
I see there have been lots of answers to this already but nobody that
I've seen has offered what I think is the "obvious" solution. I
suggest yous "do the right thing". Store strings as strings, regex as
regex and stuff that logically speaking is code for deferred execution
as code:
$string = 'this.20010420162000.txt';
$match = qr/^th(.*?)\.(\d{14})\.txt$/;
$replace = sub{ "$1.during.$2" };
if($string =~ /$match/) {
$new = &$replace;
}
------------------------------
Date: Wed, 20 Jun 2001 08:29:16 -0700
From: Ned Konz <ned@bike-nomad.com>
Subject: Re: Removing ^M characters
Message-Id: <tj1g9mhqqalgc4@corp.supernews.com>
Thanh Q Lam wrote:
> Does anyone know how to remove the "^M" characters at the end of each line
> which without removing uppercase M that may have in the same line in perl?
>
> Examples:
> This is a book^M
> That is a Mango^M
You don't say whether this is in a program, or at the command line. And you
don't say what your operating system is, or what exactly is at the ends of
your lines (for instance, is there a 0D 0D 0A at the ends of your lines
under Windows)?
If you're just reading lines in Perl and want to trim this stuff before you
process it, you can do this (if you have a system that uses ASCII):
while (<FILE>)
{
tr/\015\012//d;
# now you have ^M (\r) and ^J characters deleted
}
To do this at the command line (i.e. to delete these in a file), you can do
this:
perl -pi 'tr/\015\012//d' filename
To do this and to keep a backup of the original:
perl -pi.bak 'tr/\015\012//d' filename
Of course, you have to make sure that your command interpreter passes
everything through literally; the single quotes may not work right, etc.
But this depends on your command interpreter, not on Perl.
------------------------------
Date: Wed, 20 Jun 2001 13:17:11 -0400
From: "Stephen Landman" <shl@NOSPAMegret.net>
Subject: test popst
Message-Id: <3b30db69$0$88181$1dc6e903@news.corecomm.net>
test
------------------------------
Date: Wed, 20 Jun 2001 16:26:36 GMT
From: Glenn <glenn@surveystar.com>
Subject: Time in milliseconds
Message-Id: <3B30CEF0.831C672D@surveystar.com>
Is there any way of getting a system time value which includes
milliseconds? I believe the default Perl time function only includes
seconds -- any chance further detail is there but just not reported? Or
any other way?
Thanks!
------------------------------
Date: Wed, 20 Jun 2001 18:39:51 +0200
From: Philip Newton <pne-news-20010620@newton.digitalspace.net>
Subject: Re: Time in milliseconds
Message-Id: <nbk1jtoj2kk959jft6f3q7p1rk3onf76ag@4ax.com>
On Wed, 20 Jun 2001 16:26:36 GMT, Glenn <glenn@surveystar.com> wrote:
> Is there any way of getting a system time value which includes
> milliseconds?
FAQ. `perldoc -q time` would have given you the answer. `perldoc -q
"time under a second"` will narrow it down for you.
Note that Time::HiRes is included in the latest development versions of
Perl (5.7.2 track).
> I believe the default Perl time function only includes seconds
Yes.
> -- any chance further detail is there but just not reported?
Not with time(), but some systems provide access to higher-resolution
values.
Cheers,
Philip
--
Philip Newton <nospam.newton@gmx.li>
Yes, that really is my address; no need to remove anything to reply.
If you're not part of the solution, you're part of the precipitate.
------------------------------
Date: Wed, 20 Jun 2001 12:21:36 -0400
From: Umair Tariq Bajwa <ub98aa@brocku.ca>
Subject: Urgent Help Required
Message-Id: <3B30CD8F.98782AF7@brocku.ca>
--------------6413897B12210FB71ED0320F
Content-Type: text/plain; charset=us-ascii
Content-Transfer-Encoding: 7bit
I have a GET and POST Method. I would like to store user input directly to hash while i am in GET section.
Is there a way to store user input to hash while I am in GET section? Any help will be greatly appreciated.
Thanks in advance.
Umair
--
Favorite Quotes:
===============
"The box said 'Windows 95 or better', so I installed Linux"
-- Unknown
"A computer without Windows is like a chocolate cake without mustard."
-- Unknown
--------------6413897B12210FB71ED0320F
Content-Type: text/html; charset=us-ascii
Content-Transfer-Encoding: 7bit
<!doctype html public "-//w3c//dtd html 4.0 transitional//en">
<html>
<pre>I have a GET and POST Method. I would like to store user input directly to hash while i am in GET section.</pre>
<pre>Is there a way to store user input to hash while I am in GET section? Any help will be greatly appreciated.</pre>
<pre>Thanks in advance.</pre>
<pre>Umair</pre>
<pre>--
Favorite Quotes:
===============
"The box said 'Windows 95 or better', so I installed Linux"
-- Unknown
"A computer without Windows is like a chocolate cake without mustard."
-- Unknown</pre>
</html>
--------------6413897B12210FB71ED0320F--
------------------------------
Date: Tue, 19 Jun 2001 15:55:33 -0500
From: Michael Carman <mjcarman@home.com>
Subject: Re: What is ${'string'} ?
Message-Id: <3B2FBC45.1FE1629@home.com>
Bart Lateur wrote:
>
> Michael Carman wrote:
>
> > [Quoting] is necessary if your keys [...]
> > happen to be keywords (like time).
>
> Wrong. That used to be the case in old Perls.
Oops! I learned it that way and never unlearned it. Time to clear out
some of the old cruft. :)
-mjc
------------------------------
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 1166
***************************************