[11182] in Perl-Users-Digest
Perl-Users Digest, Issue: 4782 Volume: 8
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Fri Jan 29 21:07:16 1999
Date: Fri, 29 Jan 99 18:00:19 -0800
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)
Perl-Users Digest Fri, 29 Jan 1999 Volume: 8 Number: 4782
Today's topics:
Re: Can't assign an array to a hash key in a dbm file? (Brian Kendig)
Re: Can't assign an array to a hash key in a dbm file? <cdkaiser@delete.these.four.words.concentric.net>
Re: Compiling perl script for independent execution donaldwmonk@yahoo.com
converting %20 to spaces, etc cliffl@andrew.cmu.edu
Re: converting %20 to spaces, etc <jdf@pobox.com>
Do perl can be use for multicast (Gaetan Lord)
Re: Finding/Printing system uptime in perl (Alastair)
Fixed width, but varying # of fields - better way? <tharoldson@home.com>
Re: Fixed width, but varying # of fields - better way? <jdf@pobox.com>
Re: Floating point math errors (Abigail)
Re: Gosh, s// faster than m// (was Re: Counting charact <rra@stanford.edu>
Re: Help with @array (Charles DeRykus)
how to pass scalars AND variables to a sub? <ruedas@geophysik.uni-frankfurt.de>
Re: how to pass scalars AND variables to a sub? <jdf@pobox.com>
Re: OLE, parameter by reference, VARIANT DATE voronezh@geocities.com
Re: Perl Criticism (Randal L. Schwartz)
Re: Perl Criticism (K. Krueger)
Simple Perl Function Question for ya (KC )
Re: Simple Perl Function Question for ya (K. Krueger)
Re: Stopping a foreach loop (Charles DeRykus)
Re: Stopping a foreach loop (Abigail)
Re: strange behaviour with tr/// (Abigail)
Re: thousands digit separator (Abigail)
Special: Digest Administrivia (Last modified: 12 Dec 98 (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: 29 Jan 1999 16:22:46 -0800
From: fox-at-enchanter-net@SPAM.BLOCK (Brian Kendig)
Subject: Re: Can't assign an array to a hash key in a dbm file?
Message-Id: <78tjcm$863$1@shell11.ba.best.com>
Cameron Kaiser <cdkaiser@delete.these.four.words.concentric.net> writes:
>fox-at-enchanter-net@SPAM.BLOCK (Brian Kendig) writes:
>
>>(1) I want to take a multi-line field from a web form submission, turn
>>it into an array, and store that in a hash in a DBM file. Here's my
>>code to do that:
>
>> dbmopen(%DB, $db, undef);
>> $listname = $input{'listname'}; $listcontents = $input{'listcontents'};
>> $DB{$listname} = [ split($listcontents) ];
>> dbmclose(%DB);
>
>>Page 267 of the blue camel book leads me to believe that this should
>>work. However, the actual value which gets assigned to the hash key is
>>the string "ARRAY(0x1005fae4)". Why is this?
>
>Because you are not dereferencing the array reference returned by [ ].
How do I dereference the array reference? This is the part I can't
figure out. I want my hash values to be the arrays themselves, not
references to the arrays.
If I can only store references to the arrays, does this mean I can only
store scalar values in a DBM file? That doesn't seem very useful, so I
must be missing something. (A lesson I've learned: if it's a choice
between me being wrong or Perl being wrong, it's not Perl being wrong.)
>Most importantly, have you considered that you are not providing a pattern to
>split()?
That shouldn't be a problem, because I want to split on whitespace (\n
is the only whitespace in the input), and 'split' defaults to splitting
on whitespace.
>You can make sure you get a new array, if you really want to force the issue.
>
> my @fart = split($listcontents);
> $DB{$listname} = \@fart;
>
>Every time the my is run, a new instance of @fart within the block is
>created anew. Note "within the block".
But won't that just pass me a reference to another copy of the data, and
I'll still have a reference and be in the same boat?
>>I do a 'split' in a 'join' to change $listcontents from
>>newline-delimited to space-delimited; it's not the most efficient way,
>>but it should work, shouldn't it? It doesn't -- the 'join' function
>>isn't returning anything. What am I doing wrong here?
>
>If you want that, again, you should be providing a pattern to split().
>
> split(/\n/, $listcontents)
>
>should work delightfully.
Hmmm... I will try this, but assuming it does work, why does it work?
'whitespace' means '\s' which means '[ \t\n\r\f]'; is the camel book
wrong in saying that 'split' will split on whitespace if it isn't given
an argument?
>Cameron Kaiser * cdkaiser.cris@com * powered by eight bits * operating on faith
> -- supporting the Commodore 64/128: http://www.armory.com/~spectre/cwi/ --
> head moderator comp.binaries.cbm * cbm special forces unit $ea31 (tincsf)
>personal page http://calvin.ptloma.edu/~spectre/ * "when in doubt, take a pawn"
Commodore, ahh, those are the days... I cut my teeth on a C128 after
outgrowing a TI-99/4A, and I even wrote a Star Trek game for it which
used bitmap graphics on the 80-column screen. :)
Thank you very much for your help!
--
____ |\/| Brian Kendig
\ /\ / ..__. fox at enchanter net You are in a maze of twisty
\/ \__\ _/ http://www.enchanter.net/ little passages, all alike.
\__ __ \_ Be insatiably curious.
\____\___\ Ask "why" a lot.
------------------------------
Date: 29 Jan 1999 17:46:04 PST
From: Cameron Kaiser <cdkaiser@delete.these.four.words.concentric.net>
Subject: Re: Can't assign an array to a hash key in a dbm file?
Message-Id: <78to8s$793@journal.concentric.net>
fox-at-enchanter-net@SPAM.BLOCK (Brian Kendig) writes:
>>> dbmopen(%DB, $db, undef);
>>> $listname = $input{'listname'}; $listcontents = $input{'listcontents'};
>>> $DB{$listname} = [ split($listcontents) ];
>>> dbmclose(%DB);
>>>Page 267 of the blue camel book leads me to believe that this should
>>>work. However, the actual value which gets assigned to the hash key is
>>>the string "ARRAY(0x1005fae4)". Why is this?
>>Because you are not dereferencing the array reference returned by [ ].
>How do I dereference the array reference? This is the part I can't
>figure out. I want my hash values to be the arrays themselves, not
>references to the arrays.
You can't do that in Perl (store the arrays directly to the hash reference).
You can in some languages -- LPC comes to mind -- but not here.
To dereference the array reference, simply enclose it in
@{ }
@{$bletch}, for example, returns the list that $bletch is a reference to. For
a hash, you would %{ }, etc.
>If I can only store references to the arrays, does this mean I can only
>store scalar values in a DBM file? That doesn't seem very useful, so I
>must be missing something. (A lesson I've learned: if it's a choice
>between me being wrong or Perl being wrong, it's not Perl being wrong.)
No, you can continue to access the arrays, you just have to dereference them.
Try
my @dog;
$dog[0] = 5;
@{ \@dog }[0] = 10;
print $dog[0];
\@dog, as you probably already know, takes the reference to @dog. You
dereference it and you have your array back, ready for subscripting.
>>Most importantly, have you considered that you are not providing a pattern to
>>split()?
>That shouldn't be a problem, because I want to split on whitespace (\n
>is the only whitespace in the input), and 'split' defaults to splitting
>on whitespace.
That hasn't been my experience:
$hi = "wiffle doodle";
print scalar(split($hi)), "\n";
print scalar(split(/\s+/, $hi)), "\n";
You get 0 and 2. They are not the same. In fact, the 0 tells you it
didn't split at all. In any case, I wouldn't bank on this, even if it
does work for you.
>>You can make sure you get a new array, if you really want to force the issue.
>>
>> my @fart = split($listcontents);
>> $DB{$listname} = \@fart;
>>
>>Every time the my is run, a new instance of @fart within the block is
>>created anew. Note "within the block".
>But won't that just pass me a reference to another copy of the data, and
>I'll still have a reference and be in the same boat?
See above.
>Commodore, ahh, those are the days... I cut my teeth on a C128 after
>outgrowing a TI-99/4A, and I even wrote a Star Trek game for it which
>used bitmap graphics on the 80-column screen. :)
VDC graphics are a trip to use. I mostly do 64 stuff, but this particular
article was posted from a 128 running DesTerm.
--
Cameron Kaiser * cdkaiser.cris@com * powered by eight bits * operating on faith
-- supporting the Commodore 64/128: http://www.armory.com/~spectre/cwi/ --
head moderator comp.binaries.cbm * cbm special forces unit $ea31 (tincsf)
personal page http://calvin.ptloma.edu/~spectre/ * "when in doubt, take a pawn"
------------------------------
Date: Sat, 30 Jan 1999 00:49:06 GMT
From: donaldwmonk@yahoo.com
Subject: Re: Compiling perl script for independent execution
Message-Id: <78tktv$j9o$1@nnrp1.dejanews.com>
In article <19990127134310.14595.00004818@ng142.aol.com>,
daveotlc@aol.com (Daveotlc) wrote:
> I want to ship an application to some friends and use a Perl script to
> install it. Since they might not have Perl on their machine, it would
> be nice to be able to compile the install script. The application runs
> on a 32 bit Windows platform. Can you point me to information about the
> Perl compiler?
>
> Thanks,
> Dave Olson
>
Dave You can go to www.demobuilder.com and get "perl2exe" it will compile
your scripts to run on a win32 machine not running perl. However, you will
also need to get a copy of perlcrt.dll for the machine that is going to run
the code. After you download "perl2exe" and use it to transform a script you
can find the .dll in your system32 directory.
Let me know how it works for you.
wes
-----------== Posted via Deja News, The Discussion Network ==----------
http://www.dejanews.com/ Search, Read, Discuss, or Start Your Own
------------------------------
Date: Sat, 30 Jan 1999 01:19:00 GMT
From: cliffl@andrew.cmu.edu
Subject: converting %20 to spaces, etc
Message-Id: <78tmls$koe$1@nnrp1.dejanews.com>
What's the easiest way to converts a string with non-alphanumeric chars to %xx
like spaces to %20?
What I want to do is taking something like:
//friedrice/mp3/(Chopin) Nocturne in E Flat - Opus 9 No. 2.mp3
And convert it to a HREF:
<A
HREF="//friedrice/mp3/%28Chopin%29%20Nocturne%20in%20E%20Flat%20-%20Opus%209%2
0No.%202.mp3"><IMG ALIGN=absbottom BORDER=0 SRC="internal-gopher-unknown">
(Chopin) Nocturne in E Flat - Opus 9 No. 2.mp3</A>
Thanks,
-Cliff
-----------== Posted via Deja News, The Discussion Network ==----------
http://www.dejanews.com/ Search, Read, Discuss, or Start Your Own
------------------------------
Date: 30 Jan 1999 02:55:58 +0100
From: Jonathan Feinberg <jdf@pobox.com>
To: cliffl@andrew.cmu.edu
Subject: Re: converting %20 to spaces, etc
Message-Id: <m31zkd1q35.fsf@joshua.panix.com>
cliffl@andrew.cmu.edu writes:
> What's the easiest way to converts a string with non-alphanumeric
> chars to %xx like spaces to %20?
Get the libwww module suite from the CPAN, and use URI::Escape.
--
Jonathan Feinberg jdf@pobox.com Sunny Brooklyn, NY
http://pobox.com/~jdf
------------------------------
Date: 30 Jan 1999 01:08:42 GMT
From: gaetan@gotlib.montreal.sgi.com (Gaetan Lord)
Subject: Do perl can be use for multicast
Message-Id: <slrn7b4mpf.bi0.gaetan@gotlib.montreal.sgi.com>
Hi
I'm about to start a new project, and I will need to broadcast via multicast. I
look on deja news, for similar Q, but a lots of questions without any
response.
So, could it be possible to do multicast with perl, and is there is any
examples available on the web. This could be helpful to give me some idea on
the way I could create my applications.
Thank everybody
--
--
------------------------------------------------------------------
Gaetan Lord - FTA - gaetan@sgi.com - SGI - Montreal, Canada
pager: gaetan_p@montreal.sgi.com (200 car. max)
"There is no future in time traveling"
------------------------------------------------------------------
------------------------------
Date: Sat, 30 Jan 1999 01:17:54 GMT
From: alastair@calliope.demon.co.uk (Alastair)
Subject: Re: Finding/Printing system uptime in perl
Message-Id: <slrn7b4nfr.5o.alastair@calliope.demon.co.uk>
Tom Christiansen <tchrist@mox.perl.com> wrote:
> [courtesy cc of this posting sent to cited author via email]
>
>In comp.lang.perl.misc, abigail@fnx.com writes:
>:: (request for load average on redhat system)
>:print `uptime`;
>
>Abigail, Abigail, Abigail!
Evil!
--
Alastair
work : alastair@psoft.co.uk
home : alastair@calliope.demon.co.uk
------------------------------
Date: Fri, 29 Jan 1999 16:53:17 -0600
From: Terry Haroldson <tharoldson@home.com>
Subject: Fixed width, but varying # of fields - better way?
Message-Id: <36B23BDD.99E1FA9F@home.com>
Is there an easier way to do this? It seems cumbersome, although it
does it work.
How can I parse out this data that is somewhat fixed in length, but not
all fields are always present. My data looks something like this:
:
:
DN SEVERITY FAULT ADV DAYS F1 CA/PR F2 CA/PR
F3 CA/PR F4 CA/PR F5 CA/PR
-----------------------------------------------------------------------------------------------------------
BAD PAIR --- --- - *2R201/237
910-484-0027 PBT C&W 1 2R2/199 *2R201/299
BAD PAIR --- --- - *2R201/359
BAD PAIR --- --- - *2R201/360
BAD PAIR --- --- - *10/51
BAD PAIR --- --- - *10/73
:
:
I want to get the data in an array, so I put it out in comma-delimited
format, so I would like to see:
BAD PAIR,---,---,-,,*2R201/237 -- note 2 successive commas are important
555-484-0027,PBT, C&W,1,2R2/199,*2R201/299
BAD PAIR,---,---,-,,*2R201/359 -- note 2 successive commas are important
BAD PAIR,---,---,-,,*2R201/360 -- note 2 successive commas are important
BAD PAIR,---,---,-,*10/51
BAD PAIR,---,---,-,*10/73
:
:
It may not be clear above, but I know what the start column of each
field is (ie: 1,17,26,35,41,55,69,83,97). eg: in the 2nd record, the
5th field of data ('2R2/199') will always fall between 41 and 54, and
the 6th ('*2R201/299') will always fall between 55 and 68. But there
may not be any more data on the line. One other thing, if there is any
data at all, then there will always be data up to the 5th field (ie; to
at least column 47 or so).
Like I say, this does work, but thought there may be an easier way.
:
:
Elsif
(/^(.{16})(.{9})(.{9})(.{6})(.{0,14})(.{0,14})(.{0,14})(.{0,14})(.{0,14})/)
{
@data = ($1,$2,$3,$4,$5,$6,$7,$8,$9);
for ($i = 0; $i <=8; $i++) {
$data[$i] =~ s/^\s+//; # remove leading spaces
$data[$i] =~ s/\s+$//; # remove trailing spaces
}
$a = join(",", @data);
print LOG "$a\n";
:
:
Any thoughts are appreciated, but since it does work, if no one
responds, I won't be offended....Terry.
------------------------------
Date: 30 Jan 1999 02:48:10 +0100
From: Jonathan Feinberg <jdf@pobox.com>
To: Terry Haroldson <tharoldson@home.com>
Subject: Re: Fixed width, but varying # of fields - better way?
Message-Id: <m34sp91qg5.fsf@joshua.panix.com>
Terry Haroldson <tharoldson@home.com> writes:
> How can I parse out this data that is somewhat fixed in length, but
> not all fields are always present.
Have you looked into unpack()?
perldoc -f unpack
perldoc -f pack
--
Jonathan Feinberg jdf@pobox.com Sunny Brooklyn, NY
http://pobox.com/~jdf
------------------------------
Date: 29 Jan 1999 23:23:24 GMT
From: abigail@fnx.com (Abigail)
Subject: Re: Floating point math errors
Message-Id: <78tftc$ogh$1@client2.news.psi.net>
eharrington@paymentech.com (eharrington@paymentech.com) wrote on MCMLXXVI
September MCMXCIII in <URL:news:78qfs9$qf7$1@nnrp1.dejanews.com>:
..
.. I get a section of output that looks like this:
..
.. amt=2.23 totl=198.25
.. amt=2.24 totl=200.49
.. amt=2.25 totl=202.74
.. amt=2.26 totl=205
.. amt=2.27 totl=207.27
.. amt=2.27999999999999 totl=209.55
.. amt=2.28999999999999 totl=211.84
.. amt=2.29999999999999 totl=214.14
..
.. Can anything be done in Perl to prevent losing molecules from these pennies?
FAQ
Abigail
--
%0=map{reverse+chop,$_}ABC,ACB,BAC,BCA,CAB,CBA;$_=shift().AC;1while+s/(\d+)((.)
(.))/($0=$1-1)?"$0$3$0{$2}1$2$0$0{$2}$4":"$3 => $4\n"/xeg;print#Towers of Hanoi
------------------------------
Date: 29 Jan 1999 12:54:29 -0800
From: Russ Allbery <rra@stanford.edu>
Subject: Re: Gosh, s// faster than m// (was Re: Counting characters with tr/// (in perl))
Message-Id: <ylognh6bqy.fsf@windlord.stanford.edu>
Ilya Zakharevich <ilya@math.ohio-state.edu> writes:
> I do not know any system where the core malloc is less wasteful than
> Perl's one. Some are pretty close, but still on the wrong side. The
> only significant reason why hints contain mymalloc=n is inertia.
That's presenting the problem in terms of memory usage, isn't it, or are
you including speed in "less wasteful" as well? I can easily believe that
Perl's malloc, due to its bucket strategy, is likely to use up less memory
than pretty much any system malloc that isn't tuned for Perl, but I can
believe that system malloc may still be faster since it's simpler.
I thought I remembered from previous discussion that there was a speed vs.
memory usage tradeoff here.
--
#!/usr/bin/perl -- Russ Allbery, Just Another Perl Hacker
$^=q;@!>~|{>krw>yn{u<$$<[~||<Juukn{=,<S~|}<Jwx}qn{<Yn{u<Qjltn{ > 0gFzD gD,
00Fz, 0,,( 0hF 0g)F/=, 0> "L$/GEIFewe{,$/ 0C$~> "@=,m,|,(e 0.), 01,pnn,y{
rw} >;,$0=q,$,,($_=$^)=~y,$/ C-~><@=\n\r,-~$:-u/ #y,d,s,(\$.),$1,gee,print
------------------------------
Date: Sat, 30 Jan 1999 00:11:49 GMT
From: ced@bcstec.ca.boeing.com (Charles DeRykus)
Subject: Re: Help with @array
Message-Id: <F6CJ7p.Isx@news.boeing.com>
In article <36B05FB6.C71FE14C@mindspring.com>,
tszeto <tszeto@mindspring.com> wrote:
>Hi,
>
>I can't figure out why I can't print to screen an element of this array.
>I can print the whole array, but when I try to just print out $array[0],
>nothing comes up.
>
>open (infile, "file")
Check for open failure - you never know what evil lurks
where you'd never expect it:
open(...) or die "file open failed: $!";
>
>print @item_array, "\n";
^^^^
>print $iem_array[0];
^^^^
^^^^ spelling...?
The evil we do ourselves is more than enough to worry about... :)
hth,
--
Charles DeRykus
------------------------------
Date: Sat, 30 Jan 1999 01:32:20 +0100
From: Thomas Ruedas <ruedas@geophysik.uni-frankfurt.de>
Subject: how to pass scalars AND variables to a sub?
Message-Id: <36B25314.3359@geophysik.uni-frankfurt.de>
Hello,
probably it's an easy question, but I didn't find examples or any other
information I was able to understand:
I am calling a sub, passing one scalar and one array to it:
&usgs2gmt(1,@all);
Each entry of @all looks like this:
9901251819 17. 4.29 N 75.68 W 33 5.8 COLOMBIA
This is the subroutine:
sub usgs2gmt {
local ($flag,@data)=@_;
local (@dummy,$lon,$lat,$mag,$idat);
open(TMP,">psxy.tmp");
foreach (@data) {
@dummy=split(/ /,$_);
$lon=($dummy[3] ne "S") ? $dummy[2] : -$dummy[2];
$lat=($dummy[5] ne "W") ? $dummy[4] : -$dummy[4];
$mag=$dummy[7]/25.;
print TMP "$lon $lat $mag\n";
}
close(TMP);
# ... some other stuff...
}
It happens that the wrong array elements of @dummy are taken and that
$dummy[7] is empty in most cases although it should be e.g. 5.8 (in the
example line above). My impression is that the trouble is caused by the
way I'm passing the parameters to the sub.
Can anybody please tell me if that is true, and if so, how I have to do
it correctly?
Please also reply by email.
Thank you in advance,
--
--------------------------------------------
Thomas Ruedas
Institute of Meteorology and Geophysics,
J.W. Goethe University Frankfurt/Main
Feldbergstrasse 47 D-60323 Frankfurt/Main, Germany
Phone:+49-(0)69-798-24949 Fax:+49-(0)69-798-23280
e-mail: ruedas@geophysik.uni-frankfurt.de
http://www.geophysik.uni-frankfurt.de/~ruedas/
--------------------------------------------
------------------------------
Date: 30 Jan 1999 02:46:01 +0100
From: Jonathan Feinberg <jdf@pobox.com>
To: Thomas Ruedas <ruedas@geophysik.uni-frankfurt.de>
Subject: Re: how to pass scalars AND variables to a sub?
Message-Id: <m37lu51qjq.fsf@joshua.panix.com>
Thomas Ruedas <ruedas@geophysik.uni-frankfurt.de> writes:
> My impression is that the trouble is caused by the way I'm passing
> the parameters to the sub.
I don't see anything wrong with it. How do you know with certainty
that a given element of @data looks the way you say it does?
--
Jonathan Feinberg jdf@pobox.com Sunny Brooklyn, NY
http://pobox.com/~jdf
------------------------------
Date: Sat, 30 Jan 1999 00:18:16 GMT
From: voronezh@geocities.com
Subject: Re: OLE, parameter by reference, VARIANT DATE
Message-Id: <78tj3v$hr3$1@nnrp1.dejanews.com>
In article <36AC4101.BB98AF31@eml.ericsson.se>,
Matt Sergeant <matthew.sergeant@eml.ericsson.se> wrote:
> voronezh@geocities.com wrote:
> >
> > I'm trying to understand if ActiveSatte Perl and PerlScript meets my needs.
I
> > have couple questions: -- I have COM component (C++) with method foo( [out]
> > VARIANT *p1 ). Can I call this method from Perl and get data beck into p1 ?
I
> > mean that paramenter should be passed by reference. Does it work? Dow it
work
> > with all VARIANT subtypes? -- I'm useing OLE DATE type in my COM
components.
> > I would like to have set of functions to work with this type of DATE, e.g.
> > add/subtract dates, get week day, convert to string, etc. Is it possible
from
> > Perl ? Is there any special library/module to do it?
>
> perldoc Win32::OLE::Variant
>
> That'll tell you all the good news you want.
>
> --
> <Matt email="matt@teamamiga.org" />
>
> | Fastnet Software Ltd | Perl in Active Server Pages |
> | Perl Consultancy, Web Development | Database Design | XML |
> | http://come.to/fastnet | Information Consolidation |
>
It says:
*****
Variants by reference
Some OLE servers expect parameters passed by reference so that
they can be changed in the method call. This allows methods to
easily return multiple values. There is preliminary support for
this in the Win32::OLE::Variant module:
my $x = Variant(VT_I4|VT_BYREF, 0);
my $y = Variant(VT_I4|VT_BYREF, 0);
$Corel->GetSize($x, $y);
print "Size is $x by $y\n";
After the `GetSize' method call `$x' and `$y' will be set to the
respective sizes. They will still be variants. In the print
statement the overloading converts them to string representation
automatically.
VT_BYREF is now supported for all variant types (including
SAFEARRAYs). It can also be used to pass an OLE object by
reference:
my $Results = $App->CreateResultsObject;
$Object->Method(Variant(VT_DISPATCH|VT_BYREF, $Results));
*****
Sounds good. There is my test code:
-------- TEST.ASP -------------
<%@ LANGUAGE = PerlScript%>
<HTML>
<body>
<%
use Win32::OLE;
use Win32::OLE::Variant;
$atl = Win32::OLE->new("AtlFirst.Wiz1.1");
my $dt = Variant(VT_DATE, '1/29/1999');
my $dt1 = Variant(VT_DATE|VT_BYREF);
$atl->getData1( 1, $dt, $dt1 );
$err = $atl->LastError();
$Response->write( "<h3>$err</h3>" );
$Response->write( "<h3>PERL: $dt1</h3>");
%>
<SCRIPT language=VBScript runat=server>
Dim atl, dt, dt1
Set atl = Server.CreateObject("AtlFirst.Wiz1.1")
dt = "1/29/1999"
atl.getData1 1, dt, dt1
Response.Write( "<h3>VBSCRIPT: " & dt1 & "</h3>" )
</SCRIPT>
Function getData1(id, date1, date2) changes date2 to date1+1
</body>
</HTML>
-------- End of TEST.ASP -------------
----------- C++ implementation of getData1() ----------
STDMETHODIMP CWiz1::getData1(long nID, DATE dt, OUT VARIANT *pD1)
{
pD1->vt = VT_DATE;
pD1->date = dt + 1;
return S_OK;
}
----------- End C++ implementation of getData1() ----------
PerlScript part of this code does not work. There is the output:
VBSCRIPT: 1/30/99
PERL:
Which is not what I expect and need.
That was why I asked people to share their experience with me.
Thanks,
Alexey.
-----------== Posted via Deja News, The Discussion Network ==----------
http://www.dejanews.com/ Search, Read, Discuss, or Start Your Own
------------------------------
Date: 29 Jan 1999 16:55:44 -0800
From: merlyn@stonehenge.com (Randal L. Schwartz)
Subject: Re: Perl Criticism
Message-Id: <m13e4to9yn.fsf@halfdome.holdit.com>
>>>>> "K" == K Krueger <kirbyk@best.com> writes:
K> * Doing multi-dimensional arrays. (Which you _can_ do in Perl with
K> references. And this is the same way that C does them.)
The original DMR C didn't use pointers for multi-dim arrays. It was
merely a multiply trick. Items were stored in sequential order,
first-index-major. For an array char foo[10][20][30], to find
foo[i][j][k], you go to byte (foo + 30*20*i + 30*j + k). Notice that
the 10 isn't used in that formula... that's why you can dim formal
args (not variables) as foo[][20][30].
Modern C implementations may or may not do that, but DMR C did it that
way.
Followups to comp.lang.c.implementations :)
--
Name: Randal L. Schwartz / Stonehenge Consulting Services (503)777-0095
Keywords: Perl training, UNIX[tm] consulting, video production, skiing, flying
Email: <merlyn@stonehenge.com> Snail: (Call) PGP-Key: (finger merlyn@teleport.com)
Web: <A HREF="http://www.stonehenge.com/merlyn/">My Home Page!</A>
Quote: "I'm telling you, if I could have five lines in my .sig, I would!" -- me
------------------------------
Date: 29 Jan 1999 17:08:28 -0800
From: kirbyk@best.com (K. Krueger)
Subject: Re: Perl Criticism
Message-Id: <78tm2c$fm$1@shell2.ba.best.com>
In article <m13e4to9yn.fsf@halfdome.holdit.com>,
Randal L. Schwartz <merlyn@stonehenge.com> wrote:
>>>>>> "K" == K Krueger <kirbyk@best.com> writes:
>
>K> * Doing multi-dimensional arrays. (Which you _can_ do in Perl with
>K> references. And this is the same way that C does them.)
>
>The original DMR C didn't use pointers for multi-dim arrays. It was
>merely a multiply trick. Items were stored in sequential order,
>first-index-major. For an array char foo[10][20][30], to find
>foo[i][j][k], you go to byte (foo + 30*20*i + 30*j + k). Notice that
>the 10 isn't used in that formula... that's why you can dim formal
>args (not variables) as foo[][20][30].
>
I stand corrected. It's been (thankfully) too long since I lived in
the C world. The point still stands that references are a good way to
do multi-dimensional arrays in perl. And, hey, unlike C's version, you
don't have to declare sizes - things dynamically resize as they grow,
as if you made them with pointers in C.
--
Kirby Krueger O- kirbyk@best.com
<*> "Most .sigs this small can't open their own jump gate."
------------------------------
Date: Fri, 29 Jan 1999 17:38:49 -0700
From: collinkr@ucsu.colorado.edu (KC )
Subject: Simple Perl Function Question for ya
Message-Id: <collinkr-2901991738490001@128.138.113.195>
I want to call the ping command from inside
my perl script, then capture ONLY the return value, and
use it. I dont want ping to output anything - just
return the exit value into $value. This will be used for
a web page showing multiple machines' status after
being pinged.
If you can answer my question, you are the man! (or woman!)
THANKS
kris collins
ITS - University of Colorado
------------------------------
Date: 29 Jan 1999 17:04:57 -0800
From: kirbyk@best.com (K. Krueger)
Subject: Re: Simple Perl Function Question for ya
Message-Id: <78tlrp$t41$1@shell2.ba.best.com>
In article <collinkr-2901991738490001@128.138.113.195>,
KC <collinkr@ucsu.colorado.edu> wrote:
>I want to call the ping command from inside
>my perl script, then capture ONLY the return value, and
>use it. I dont want ping to output anything - just
>return the exit value into $value. This will be used for
>a web page showing multiple machines' status after
>being pinged.
>
You probably want to look at the Net::Ping module, available at
www.cpan.org.
You can also do a system("ping $foohost"), which returns the exit
value of the ping command - which is quick and dirty. I have no
idea as to the relative speeds of these approaches, how many useless
lines of code you import in the module, and such. The Module approach
is definitely more portable, and aesthetically appealing, though.
--
Kirby Krueger O- kirbyk@best.com
<*> "Most .sigs this small can't open their own jump gate."
------------------------------
Date: Sat, 30 Jan 1999 00:31:57 GMT
From: ced@bcstec.ca.boeing.com (Charles DeRykus)
Subject: Re: Stopping a foreach loop
Message-Id: <F6CK59.J7n@news.boeing.com>
In article <78ss5h$1e5$1@pegasus.csx.cam.ac.uk>,
M.J.T. Guy <mjtg@cus.cam.ac.uk> wrote:
>
>kill 'KILL', $$;
>
>is *much* more efficient. :-)
>
shouldn't you check your pulse afterwards :)
kill 'KILL', $$ or die "I hate it when this happens...\n";
ducking.
--
Charles DeRykus
------------------------------
Date: 29 Jan 1999 23:59:45 GMT
From: abigail@fnx.com (Abigail)
Subject: Re: Stopping a foreach loop
Message-Id: <78ti1h$p36$1@client2.news.psi.net>
Larry Rosler (lr@hpl.hp.com) wrote on MCMLXXVI September MCMXCIII in
<URL:news:MPG.111a8fe49fd538b89899df@nntp.hpl.hp.com>:
`` [Posted and a courtesy copy mailed.]
``
`` In article <78qkep$uqm$1@nnrp1.dejanews.com> on Thu, 28 Jan 1999
`` 21:22:44 GMT, Ryan.Haman@mci.com <Ryan.Haman@mci.com> says...
`` > Is there anyway to break (stop) a foreach loop?
``
`` perldoc -f last
`` perldoc -f return
`` perldoc -f exit
`` perldoc -f die
`` perldoc -f exec
``
`` even (ugh!)
``
`` perldoc -f goto
``
`` That's off the top of my head. Did I miss any?
perldoc -f dump
Abigail
--
perl -wle\$_=\<\<EOT\;y/\\\\n/\ /\;print\; -eJust -eanother -ePerl -eHacker -eEOT
------------------------------
Date: 30 Jan 1999 00:03:00 GMT
From: abigail@fnx.com (Abigail)
Subject: Re: strange behaviour with tr///
Message-Id: <78ti7k$p36$2@client2.news.psi.net>
Uri Guttman (uri@home.sysarch.com) wrote on MCMLXXVII September MCMXCIII
in <URL:news:x71zkermlf.fsf@home.sysarch.com>:
{} >>>>> "t" == tommy927 <tommy927@my-dejanews.com> writes:
{}
{} t> while (<>) {
{} t> tr/a-mA-Mn-zN-Z/n-zN-Za-mA-M/;
{} t> print;
{} t> }
{}
{} t> It works with everything i throw at it but when i try an underscore
{} t> (_), it returns M, which is kinda unexpected. I am using Perl
{} t> 5.004
{}
{} what would you want it to return?
{}
{} from perlop on tr///:
{}
{} Otherwise, if the REPLACEMENTLIST is shorter than the SEARCHLIST, the
{} final character is replicated till it is long enough.
So, where are there less characters, between a-m andr a-m? Or between
n-z and n-z? Or does capitalization on the replacement part yield
less characters than on the search list?
Abigail
--
perl -e '$_ = q *4a75737420616e6f74686572205065726c204861636b65720a*;
for ($*=******;$**=******;$**=******) {$**=*******s*..*qq}
print chr 0x$& and q
qq}*excess********}'
------------------------------
Date: 30 Jan 1999 00:53:05 GMT
From: abigail@fnx.com (Abigail)
Subject: Re: thousands digit separator
Message-Id: <78tl5h$pjf$1@client2.news.psi.net>
Eduardo Fernandez (efcspain@sistelnet.es) wrote on MCMLXXVII September
MCMXCIII in <URL:news:78sbgn$ecp$1@talia.mad.ttd.net>:
''
''
'' How can I print this like 65.545.444 euros, to make it more readable?
FAQ
Abigail
--
perl -MNet::Dict -we '(Net::Dict -> new (server => "dict.org")
-> define ("foldoc", "perl")) [0] -> print'
------------------------------
Date: 12 Dec 98 21:33:47 GMT (Last modified)
From: Perl-Request@ruby.oce.orst.edu (Perl-Users-Digest Admin)
Subject: Special: Digest Administrivia (Last modified: 12 Dec 98)
Message-Id: <null>
Administrivia:
Well, after 6 months, here's the answer to the quiz: what do we do about
comp.lang.perl.moderated. Answer: nothing.
]From: Russ Allbery <rra@stanford.edu>
]Date: 21 Sep 1998 19:53:43 -0700
]Subject: comp.lang.perl.moderated available via e-mail
]
]It is possible to subscribe to comp.lang.perl.moderated as a mailing list.
]To do so, send mail to majordomo@eyrie.org with "subscribe clpm" in the
]body. Majordomo will then send you instructions on how to confirm your
]subscription. This is provided as a general service for those people who
]cannot receive the newsgroup for whatever reason or who just prefer to
]receive messages via e-mail.
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.misc (and this Digest), send your
article to perl-users@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.
The Meta-FAQ, an article containing information about the FAQ, is
available by requesting "send perl-users meta-faq". The real FAQ, as it
appeared last in the newsgroup, can be retrieved with the request "send
perl-users FAQ". Due to their sizes, neither the Meta-FAQ nor the FAQ
are included in the digest.
The "mini-FAQ", which is an updated version of the Meta-FAQ, is
available by requesting "send perl-users mini-faq". It appears twice
weekly in the group, but is not distributed in the digest.
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 V8 Issue 4782
**************************************