[23710] in Perl-Users-Digest
Perl-Users Digest, Issue: 5916 Volume: 10
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Tue Dec 9 14:05:44 2003
Date: Tue, 9 Dec 2003 11: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 Tue, 9 Dec 2003 Volume: 10 Number: 5916
Today's topics:
Re: #!/usr/bin/perl (Tad McClellan)
Re: #!/usr/bin/perl <roqetman@hotmail.com>
Re: #!/usr/bin/perl <karlheinz.weindl@oooonlinehome.de>
Re: #!/usr/bin/perl <noreply@gunnar.cc>
Re: Another sort question. <asu1@c-o-r-n-e-l-l.edu>
Re: can some one please explain this regex?! (Tad McClellan)
Re: can some one please explain this regex?! <emschwar@pobox.com>
Re: escape sequence for tab not working (Tad McClellan)
Re: escape sequence for tab not working nobull@mail.com
HTTP::Request problem with reading long uri (Newbie)
Re: Idiom for array index that I'm foreach'ing over? <bik.mido@tiscalinet.it>
Re: Idiom for array index that I'm foreach'ing over? <bik.mido@tiscalinet.it>
It's simple... <Abyss@Dev.Null>
Multi-dimensional Data Structures <agbiotec@vt.edu>
Re: Multi-dimensional Data Structures <noreply@gunnar.cc>
Re: Multi-dimensional Data Structures <agbiotec@yahoo.com>
Re: Multi-dimensional Data Structures <richard@zync.co.uk>
Re: Multi-dimensional Data Structures <asu1@c-o-r-n-e-l-l.edu>
Re: open/seek vs IO::Open/setpos <jwillmore@remove.adelphia.net>
Proposal: new module, Array::Each? <bmb@ginger.libs.uga.edu>
What is '_' <goz02451@yahoo.com>
Re: What is '_' <richard@zync.co.uk>
Re: What is '_' (Malcolm Dew-Jones)
Re: Why does ne always work (Tad McClellan)
WIN32::Internet <BOHIM789@AOL.COM>
Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: Tue, 9 Dec 2003 08:25:10 -0600
From: tadmc@augustmail.com (Tad McClellan)
Subject: Re: #!/usr/bin/perl
Message-Id: <slrnbtbmq6.rgm.tadmc@magna.augustmail.com>
Roman Khutkyy <roman@sky.lviv.ua> wrote:
> I write CGI scripts on the Win32 computer, then I transport it to the Unix
Use "ASCII" or "text" mode when you ftp the file.
--
Tad McClellan SGML consulting
tadmc@augustmail.com Perl programming
Fort Worth, Texas
------------------------------
Date: Tue, 09 Dec 2003 09:40:17 -0500
From: Dominic <roqetman@hotmail.com>
Subject: Re: #!/usr/bin/perl
Message-Id: <W7lBb.3$JG6.17862@news.nyc.globix.net>
Dave Saville wrote:
> On Tue, 9 Dec 2003 10:37:02 +0200, Roman Khutkyy wrote:
>
>
>>Hi all,
>>is there any ability in Perl to write the first string in script as
>>alternative string for different platforms.
>>I write CGI scripts on the Win32 computer, then I transport it to the Unix
>>server, and each time i need to rewrite this string. Is there universal
>>string for both platforms?
>>
>
>
> One way is to use perl <command> on one platform and <command> on the
> other. If you use the former and also have a shebang line perl will
> obey the switches on it but not try and find the executable. At least
> this is true for the 5.8.0 OS/2 port.
>
>
> Regards
>
> Dave Saville
>
> NB switch saville for nospam in address
>
>
Here's some advice I got from someone else (it works):
Under Windows, create c:\usr, and inside it c:\usr\bin.
Then copy perl.exe from c:\perl\bin to c:\usr\bin.
Now all your scripts - on both platforms - can start with
#!/usr/bin/perl
- Dom
------------------------------
Date: Tue, 09 Dec 2003 15:51:21 +0100
From: Karlheinz Weindl <karlheinz.weindl@oooonlinehome.de>
Subject: Re: #!/usr/bin/perl
Message-Id: <br4ni1$oms$1@online.de>
Matt Garrish schrieb:
> "Karlheinz Weindl" <karlheinz.weindl@oooonlinehome.de> wrote in message
> news:br47ko$4ok$1@online.de...
>
>>ko schrieb:
>>
>>>If you're using Active State Perl you can keep the shebang line intact -
>>>its ignored, [...]
>>
>>Not necessarily true. The OP transfers CGI scripts from Win32 to UNIX,
>>so presumably running Apache under Windows, which in turn requires the
>>shebang line to be present (and correct of course).
>>
>
>
> That's not entirely true either. You can specify to use the registry in your
> Apache config file on Windows, and then just keep the shebang line for the
> Unix system.
You are absolutely right.
Admittedly I didn't recognize ScriptInterpreterSource until you stubbed
me into it. But on my experience I believe for the purpose mentioned
(developing on Win and transfering to UNIX) the "mimiking an Unix file
system approach" has some advantages over using a "windowish" Apache
directive.
------------------------------
Date: Tue, 09 Dec 2003 16:49:06 +0100
From: Gunnar Hjalmarsson <noreply@gunnar.cc>
Subject: Re: #!/usr/bin/perl
Message-Id: <br4rij$271uvq$1@ID-184292.news.uni-berlin.de>
Roman Khutkyy wrote:
> Gunnar Hjalmarsson wrote:
>> Roman Khutkyy wrote:
>>> I write CGI scripts on the Win32 computer, then I transport it
>>> to the Unix server, and each time i need to rewrite this
>>> string. Is there universal string for both platforms?
>>
>> On my Win32 computer, I have a C:/usr/bin directory where I have
>> an extra copy of perl.exe. That makes '#!/usr/bin/perl' work
>> there as well.
>
> Yes it works when you are using ISS, but under Apache it needs
> correct path.
I'm doing it with an Apache server on W98. Maybe I should mention that
the autoexec.bat file adds the path to the 'regular' perl bin with all
the perl related .exe and .bat files.
HTH
--
Gunnar Hjalmarsson
Email: http://www.gunnar.cc/cgi-bin/contact.pl
------------------------------
Date: 9 Dec 2003 17:14:45 GMT
From: "A. Sinan Unur" <asu1@c-o-r-n-e-l-l.edu>
Subject: Re: Another sort question.
Message-Id: <Xns944C7C9283766asu1cornelledu@132.236.56.8>
anno4000@lublin.zrz.tu-berlin.de (Anno Siegel) wrote in news:br45qo$h4e$1
@mamenchi.zrz.TU-Berlin.DE:
> A. Sinan Unur <asu1@c-o-r-n-e-l-l.edu> wrote in comp.lang.perl.misc:
>> mpatt644@yahoo.com (Mal) wrote in news:66f79aeb.0312081510.8a12e64
>> @posting.google.com:
>>
>> > I figured out that replacing
>> >
>> > $aHourField <=> $bHourField with
>> > (($aHourField+17) %24) <=> (($bHourField+17) %24)
>> >
>> > does what I need.
>>
>> Could you explain that please?
>
> With a 24-hour clock it shifts the start of day from midnight to 7 am.
Anno,
Thank you, I understand that. However, the OP's request was:
>> > I want to change it so that the time fields after 17:00
>> > are sorted first, and times before 17:00 sort last.
Now:
# mmm.pl
use strict;
use warnings;
my @n = (0 .. 23);
print (map { "$_," } sort { (($a + 17) % 24) <=> (($b + 17) % 24) } @n);
print "\n";
__END__
C:\Home> mmm.pl
7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,0,1,2,3,4,5,6,
It seems to me like the OP ought to be adding 7 instead of 17. After
changing the the line above to:
print (map { "$_," } sort { (($a + 17) % 24) <=> (($b + 17) % 24) } @n);
C:\Home\asu1> mmm.pl
17,18,19,20,21,22,23,0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,
--
A. Sinan Unur
asu1@c-o-r-n-e-l-l.edu
Remove dashes for address
Spam bait: mailto:uce@ftc.gov
------------------------------
Date: Tue, 9 Dec 2003 07:50:42 -0600
From: tadmc@augustmail.com (Tad McClellan)
Subject: Re: can some one please explain this regex?!
Message-Id: <slrnbtbkpi.rgm.tadmc@magna.augustmail.com>
Geoff Cox <geoff.cox@blueyonder.co.uk> wrote:
>>> >> open(DATA, "$namehtml");
>>> > ^ ^
>>> >
>>> > perldoc -q vars
>>> >
>>> > What's wrong with always quoting "$vars"?
>
> I assuem you mean simply that there is no need to have the quotes
> round $vars if it is on its own?
Yes.
--
Tad McClellan SGML consulting
tadmc@augustmail.com Perl programming
Fort Worth, Texas
------------------------------
Date: Tue, 09 Dec 2003 11:33:46 -0700
From: Eric Schwartz <emschwar@pobox.com>
Subject: Re: can some one please explain this regex?!
Message-Id: <etoiskpg7sl.fsf@fc.hp.com>
Geoff Cox <geoff.cox@blueyonder.co.uk> writes:
>>> On Sun, 7 Dec 2003 17:59:08 -0600, tadmc@augustmail.com (Tad
>>> McClellan) wrote:
>>>
>>> >Geoff Cox <geoff.cox@blueyonder.co.uk> wrote:
>>> >
>>> >> open(DATA, "$namehtml");
>>> > ^ ^
>>> >
>>> > perldoc -q vars
>>> >
>>> > What's wrong with always quoting "$vars"?
>
> I assuem you mean simply that there is no need to have the quotes
> round $vars if it is on its own?
No, he means you should run 'perldoc -q vars' in a shell window, and
read the answer titled 'What's wrong with always quoting "$vars"?'.
It sounds like you should probably run 'perldoc perldoc' as well.
Perl comes with probably the best built-in documentation I've seen for
a programming language, but it's useless if you don't spend a bit of
time learning how to read it.
-=Eric
--
Come to think of it, there are already a million monkeys on a million
typewriters, and Usenet is NOTHING like Shakespeare.
-- Blair Houghton.
------------------------------
Date: Tue, 9 Dec 2003 07:58:32 -0600
From: tadmc@augustmail.com (Tad McClellan)
Subject: Re: escape sequence for tab not working
Message-Id: <slrnbtbl88.rgm.tadmc@magna.augustmail.com>
dn_perl@hotmail.com <dn_perl@hotmail.com> wrote:
> my $this_str, $sub_str ;
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.
Like this one.
--
Tad McClellan SGML consulting
tadmc@augustmail.com Perl programming
Fort Worth, Texas
------------------------------
Date: 9 Dec 2003 09:43:39 -0800
From: nobull@mail.com
Subject: Re: escape sequence for tab not working
Message-Id: <4dafc536.0312090943.2602ef3d@posting.google.com>
anno4000@lublin.zrz.tu-berlin.de (Anno Siegel) wrote in message news:<br4881$jvg$1@mamenchi.zrz.TU-Berlin.DE>...
> dn_perl@hotmail.com <dn_perl@hotmail.com> wrote in comp.lang.perl.misc:
>
> > $sub_str = "abc" ;
> > $this_str = sprintf "%s\t%s", $sub_str, $sub_str ;
>
> This sets $this_str to "abc", followed by a literal tab, followed by
> "abc".
>
> > system( "echo $this_str") ;
> Your question is more about the shell than about Perl. You need to find
> out how to make your shell's "echo" (or the system's /bin/echo) print a
> tab character. For my sh, that's 'echo -e "abc\tabc"' (note inner quotes).
For my sh a real tab character escaped with \ works too.
So in general you can protect $this_str from being word-split by the
shell using quotemeta().
system( "echo \Q$this_str\E"); # \E technically redundant
BTW: Someone whose oppinion I usually respect once told me the above
will not always work but was unable to offer an example where it
wouldn't.
------------------------------
Date: 9 Dec 2003 07:01:05 -0800
From: diwaneel@yahoo.com (Newbie)
Subject: HTTP::Request problem with reading long uri
Message-Id: <8a54fd80.0312090701.6515c468@posting.google.com>
Code:
my $ua = LWP::UserAgent->new;
my $request = HTTP::Request->new(GET => $QueryString);
Here $QueryString is of the form:
http://<machine on network>/<somestring>/jsp_page.jsp?personauri=<something>&chaturi=<some
other thing>&welcomenote=Hi
There!>
$response = $ua->request($request);
Here the request method of UserAgent is called -->
(Needless to say the functions request and simple_request are defined
in UserAgent.pm in perl package, and are standard )
sub request
{
my($self, $request, $arg, $size, $previous) = @_;
LWP::Debug::trace('()');
my $response = $self->simple_request($request, $arg, $size);
...
}
Now when simple_request is called,
sub simple_request
{
my($self, $request, $arg, $size) = @_;
local($SIG{__DIE__}); # protect agains user defined die handlers
my($method, $url) = ($request->method, $request->uri);
...
}
Here, $method is getting the value 'GET', but $url is getting <undef>.
The $request object is properly built. Though 'content' has nothing,
but method has 'GET' and uri also has its valuewhen in function
request, but somehow, it is not assigned to $url on the LHS.
If it has something to do with the length of the uri, then even just
http://<machine on network>/<somestring>/jsp_page.jsp as $QueryString
is not working.
Any clues what could be the reason for $url not getting the value in
simple_request function?
Thanks
------------------------------
Date: 9 Dec 2003 15:03:39 GMT
From: Michele Dondi <bik.mido@tiscalinet.it>
Subject: Re: Idiom for array index that I'm foreach'ing over?
Message-Id: <e8amtv4eeldg8fad6kmb9gdjrrrqisboed@4ax.com>
On Sat, 6 Dec 2003 12:53:52 +0000 (UTC), Ben Morrow
<usenet@morrow.me.uk> wrote:
>Err...
>
>| "undef" is always treated as numeric, and in particular is changed
>| to 0 before incrementing (so that a post-increment of an undef value
>| will return 0 rather than "undef").
>
>This is from perlop in 5.8.2.
Still 5.8.0 here, and unless I've gone completely dumb, that bit is
not in perlop.
Michele
--
# This prints: Just another Perl hacker,
seek DATA,15,0 and print q... <DATA>;
__END__
------------------------------
Date: 9 Dec 2003 15:03:40 GMT
From: Michele Dondi <bik.mido@tiscalinet.it>
Subject: Re: Idiom for array index that I'm foreach'ing over?
Message-Id: <q0sotv49cr080v9mvnvu5vk6rohpkdvhea@4ax.com>
On 07 Dec 2003 21:56:41 GMT, Abigail <abigail@abigail.nl> wrote:
>Well, yes, of course. This is after all Perl5, which like every other
>main stream language I know about allows optional whitespace between
>tokens. The whitespace isn't significant.
>
>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?
Michele
--
# This prints: Just another Perl hacker,
seek DATA,15,0 and print q... <DATA>;
__END__
------------------------------
Date: Tue, 9 Dec 2003 12:35:59 +0000
From: "Lariean Poringa" <Abyss@Dev.Null>
Subject: It's simple...
Message-Id: <2RkBb.22406$LI6.451@news-binary.blueyonder.co.uk>
MAKE MONEY!!!
MAKE THOUSANDS!!!
I found this on a bulletin board and decided to try it: I don't care about the useless pre-fabricated crap this message usually says. All I say is, it works. Continue pre-fab crap.
WELL GUESS WHAT!!!
Within seven days, I started getting money in the mail!! I
was shocked!! I figured it would end soon, but the money just kept
coming in. In my first week, I made about $25.00. By the end of the second week I had
made a total of more than $1000.00!! In the third week I had more than
$10,000.00 and it's still growing!! This is now my fourth week and I have made a total of $42,000.00 and it's still coming rapidly. It's certainly worth $6.00 and six stamps, and I have spent more than that on the lottery without ever winning!!!
Let me tell you how this works and most important, why it works..........
also make sure you print this out NOW, so you can get the information off of it, as you will need it. I promise you that if you follow the directions exactly that you
will start making more money than you thought possible by doing something so easy!!
Suggestion: Read this entire message carefully!! (Print it out or download it)
Follow the simple directions and watch the money come in!! It's easy.
It's legal. And, your investment is only $6.00 (Plus postage) !!!
IMPORTANT:
This is not a rip-off, it is decent; it's legal; and it is virtually no risk - it really works!! If all the following instructions are adhered to, you will receive extraordinary dividends.
PLEASE NOTE:
Please follow the directions EXACTLY, and $50,000 or more can be yours
in 20 to 60 days. This program remains successful because of the honesty and
integrity of the participants. Please continue its success by carefully adhering to
the instructions. You will now become apart of the Mail Order business. You
are in the business of developing Mailing Lists. Many large corporations are
happy to pay big bucks for quality lists. However, the money made from the
mailing lists is secondary to income which is made from people like you and me asking to be included in that list. Here are the four easy steps to success.
STEP ONE:
Get six separate pieces of paper and write the following on
each piece of paper "PLEASE PUT ME ON YOUR MAILING LIST."
Now get 6 U.S. $1.00 bills and place ONE inside of EACH of the six pieces of paper so the bill will not be seen through the envelope (to prevent thievery). Next, place one paper in each of the six envelopes and seal them. You now should have six sealed envelopes, each with a piece of paper stating the above phrase, your name and address, and a $1.00 bill. What you are doing is creating a service.
THIS IS ABSOLUTELY LEGAL!!!!!
You are requesting a legitimate service and you are paying for it!! Like
most of us I was a little skeptical and little worried about the legal aspects
of it all. So I checked it out with the U.S. Post Office (1-800-238-5355) and they
confirmed that it is indeed legal!!
Mail the six envelopes to the following addresses:
1) R. X.
3720 Royal Crest Street #26
Las Vegas, Nevada
2) Andreas Swart
Hoornschediep 11
9727 GA Groningen
The Netherlands
3) W. Edens
4829 Bud Ln
Lexington, KY 40514
4) L.Lessard
40 Martins Ferry Rd
Hooksett,NH 03106
5) J. Safian
6950 W. Forest Presrv. Dr., #115
Norridge, IL 60706-1324
6) A. L. Alexander
12 Briggate
Elland Bridge
Elland
HX5 9DP
England
STEP TWO:Now take the #1 name off the list that you see above, move the other names up (six becomes 5, 5 becomes 4, and etc.) and add YOUR NAME as number 6 on the list.
STEP THREE:
Change anything you need to but try to keep this article as close to original as possible. Now post your amended article to at least 200 news groups. :
(I think there are close to 24,000 groups) All you need is 200, but remember, the more you post, the more money you make!! This is perfectly legal!! If you have any doubts, refer to Title 18 Sec. 1302 & 1341 of the Postal Lottery laws. Keep a copy of these steps for yourself and whenever you need money, you can use it again, and again. PLEASE REMEMBER that this program remains successful because of the honesty and integrity of the participants and by their carefully adhering to directions. Look at it this way. If you were of integrity, the program will continue and the money that so many others have received will come your way.
NOTE: You may want to retain every name and address sent to you,
either on a computer or hard copy and keep the notes people send you.
This VERIFIES that you are truly providing a service. (Also, it might be a good idea to wrap the $1 bill in dark paper to reduce the risk of mail theft). So, as each post is downloaded and the directions carefully followed, all members will be reimbursed for their participation as a List Developer with one dollar each. Your name will move up the list geometrically so that when your name reaches the #1 position you will be receiving thousands of dollars in CASH!!! What an opportunity for only $6.00 ( $1.00 for each of the first six people listed above) Send it now, add your own name to the list and you're in business!!!
*****DIRECTIONS FOR HOW TO POST TO NEWS GROUPS!!!*****
STEP ONE: You do not need to re-type this entire letter to do your own
posting. Simply put your cursor at the beginning of this letter and drag your
cursor to the bottom of this document, and select 'copy' from the edit menu. This
will copy the entire letter into the computer's memory.
STEP TWO:
Open a blank 'notepad' file and place your cursor at the top
of the blank page. From the 'edit' menu select 'paste'. This will paste a copy
of the letter into the notepad so that you will add your name to the list.
STEP THREE:
Save your new notepad file as a text file. If you want to do your posting in different settings, you'll always have this file to go back to.
STEP FOUR:
You can use a program like "postXpert" to post to all the newsgroeps at once.
You can find this program at <http://www.download.com>. If you don't understand how it works you can email me at: <mailto:andreass@orange.nl>
(this is only when my name is in the list, so send a copy of my address as well.
put this in the header: make millions very easy + my full name )
Use Netscape or Internet Explorer and try searching for various new
groups (on- line forums, message boards, chat sites, discussions.)
STEP FIVE:
Visit message boards and post this article as a new message by highlighting the text of this letter and selecting paste from the edit menu. Fill in the subject, this will be the header that everyone sees as they scroll through the list of postings in a particular group, click the post message button. You're done.
Congratulations!!!!!!
THAT'S IT!! All you have to do, and It Really works!!!
Best Wishes
------------------------------
Date: Tue, 09 Dec 2003 11:36:18 -0500
From: Konstantinos <agbiotec@vt.edu>
Subject: Multi-dimensional Data Structures
Message-Id: <br4tka$6a9$1@solaris.cc.vt.edu>
Hi all,
I need help in the following topic :
I create a Multi-dimensional Data Structure within a subroutine, and I
want to keep calling this subroutine recursively, passing each time the
MD-data structure. How am I gonna achieve this ? 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).
Thank ya all,
Konstantinos
------------------------------
Date: Tue, 09 Dec 2003 17:56:04 +0100
From: Gunnar Hjalmarsson <noreply@gunnar.cc>
Subject: Re: Multi-dimensional Data Structures
Message-Id: <br4vg6$28vgis$1@ID-184292.news.uni-berlin.de>
Konstantinos wrote:
> I create a Multi-dimensional Data Structure within a subroutine,
> and I want to keep calling this subroutine recursively, passing
> each time the MD-data structure. How am I gonna achieve this ?
> 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).
Which script? Would you mind sharing a minimal program that
illustrates the problem?
Until we have seen that, the only thing I can say is that you should
probably declare a reference to the data structure somewhere outside
the sub.
--
Gunnar Hjalmarsson
Email: http://www.gunnar.cc/cgi-bin/contact.pl
------------------------------
Date: Tue, 09 Dec 2003 12:49:48 -0500
From: Konstantinos <agbiotec@yahoo.com>
Subject: Re: Multi-dimensional Data Structures
Message-Id: <br51u4$clp$1@solaris.cc.vt.edu>
It a program that you can say creates something like a binary tree;
It not exactly that, because it is used to classify biological samples,
based on their gene expression data. The difference between regular
binary trees is that it does not use a single value as discriminator at
each split of the parent node to the daughter ones, but a range of
values-attributes instead. The problem arises from the fact, that the
first time I call the sub, a parent node splits to the left and right
daughter ones which are stored as Multi-D structure CREATED INSIDE THE
SUB. Then I have to use these left and right daughter nodes as parental
this time, to make further splits of the tree nodes, by calling
recursively the sub, and feeding these daughter nodes again to the
sub...But since they are created inside the scope of the sub the first
time it is called, how can they be fed again to it in a next call ? (I
try to send them when I do recursive calls of the sub, by using pass by
reference-> a reference TO THIS STRUCTURES CREATED INSIDE THE SUB, but
they do not seem to get into the next call of the sub)... When you do
recursive call, aren't you supposed to GET OUT of the sub, and then call
it and GET IN AGAIN, so as you go out, any memory addresses that are
made in the scope of the sub are released-emptied ?
Cheers,
Konstantinos
Gunnar Hjalmarsson wrote:
> Konstantinos wrote:
>
>> I create a Multi-dimensional Data Structure within a subroutine,
>> and I want to keep calling this subroutine recursively, passing
>> each time the MD-data structure. How am I gonna achieve this ?
>> 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).
>
>
> Which script? Would you mind sharing a minimal program that
> illustrates the problem?
>
> Until we have seen that, the only thing I can say is that you should
> probably declare a reference to the data structure somewhere outside
> the sub.
>
------------------------------
Date: Tue, 09 Dec 2003 17:52:34 +0000
From: "Richard Gration" <richard@zync.co.uk>
Subject: Re: Multi-dimensional Data Structures
Message-Id: <br5252$kkj$1@news.freedom2surf.net>
In article <br4tka$6a9$1@solaris.cc.vt.edu>, "Konstantinos"
<agbiotec@vt.edu> wrote:
> Hi all,
>
> I need help in the following topic :
> I create a Multi-dimensional Data Structure within a subroutine, and I
> want to keep calling this subroutine recursively, passing each time the
> MD-data structure. How am I gonna achieve this ? 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).
> Thank ya all,
> Konstantinos
>
Create the Multi-dimensional Data Structure (tm) (IOW your top level hash
or array) in the calling code and pass a reference to it into the sub. I
believe this is called re-entrant coding.
Rich
eg. (untested, but will create you a 10_000 element structure)
#!/usr/bin/perl
use strict;
my $mdds = [];
stuff($mdds);
sub stuff {
my $ref = shift;
my ($n1,$n2);
foreach $n1 (1 .. 100) {
foreach $n2 (1 .. 100) {
$ref->[$n1]->[$n2] = rand();
}
}
}
------------------------------
Date: 9 Dec 2003 18:03:59 GMT
From: "A. Sinan Unur" <asu1@c-o-r-n-e-l-l.edu>
Subject: Re: Multi-dimensional Data Structures
Message-Id: <Xns944C84EB8B067asu1cornelledu@132.236.56.8>
Do not top post
Do not blindly quote messages in full
Do read the posting quidelines:
http://mail.augustmail.com/~tadmc/clpmisc/clpmisc_guidelines.html
And it seems like you might benefit from reading:
http://www.catb.org/~esr/faqs/smart-questions.html
as well.
Konstantinos <agbiotec@yahoo.com> wrote in news:br51u4$clp$1
@solaris.cc.vt.edu:
> Gunnar Hjalmarsson wrote:
>
>> Konstantinos wrote:
>>
>>> I create a Multi-dimensional Data Structure within a subroutine,
>>> and I want to keep calling this subroutine recursively, passing
>>> each time the MD-data structure. How am I gonna achieve this ?
>>> 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).
>>
>>
>> Which script? Would you mind sharing a minimal program that
>> illustrates the problem?
>
> It a program that you can say creates something like a binary tree;
Please follow Gunnar's suggestion and post a minimal script that
illustrates your problem.
> The problem arises from the fact, that the first time I call the sub, a
> parent node splits to the left and right daughter ones which are stored
> as Multi-D structure CREATED INSIDE THE SUB. Then I have to use these
> left and right daughter nodes as parental this time, to make further
Does the following link help?
http://iis1.cps.unizar.es/Oreilly/perl/cookbook/ch11_16.htm
--
A. Sinan Unur
asu1@c-o-r-n-e-l-l.edu
Remove dashes for address
Spam bait: mailto:uce@ftc.gov
------------------------------
Date: Tue, 09 Dec 2003 18:00:13 GMT
From: James Willmore <jwillmore@remove.adelphia.net>
Subject: Re: open/seek vs IO::Open/setpos
Message-Id: <20031209130012.194334b7.jwillmore@remove.adelphia.net>
On Tue, 9 Dec 2003 09:11:50 +0000
news@roaima.freeserve.co.uk wrote:
<snip>
> I can't get this to work at all - I get a runtime usage error,
> "Usage: IO::Seekable::setpos(handle, pos) at ..."
>
> e.g.
> $h = new IO::File ... # O_RDWR or "+> file", etc.
> $h->print ...
my $pos = $h->getpos();
Then ....
> $h->setpos (0, SEEK_SET) # use Fcntl qw/:DEFAULT :seek/
You have to 'getpos' first - if I read the documentation properly.
Then, 'setpos'.
From IO::Seekable ....
$io->setpos
Uses the value of a previous getpos call to return to
a previously visited position. Returns "0 but true" on
success, "undef" on failure.
HTH
--
Jim
Copyright notice: all code written by the author in this post is
released under the GPL. http://www.gnu.org/licenses/gpl.txt
for more information.
a fortune quote ...
Malek's Law: Any simple idea will be worded in the most
complicated way.
------------------------------
Date: Tue, 9 Dec 2003 12:58:45 -0500
From: Brad Baxter <bmb@ginger.libs.uga.edu>
Subject: Proposal: new module, Array::Each?
Message-Id: <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
------------------------------
Date: Tue, 09 Dec 2003 13:00:49 -0500
From: Jason Mather <goz02451@yahoo.com>
Subject: What is '_'
Message-Id: <3FD60DD1.8060503@yahoo.com>
Several places in File/Find.pm there are tests like:
if (-d _) {
What is '_'? Is it the same as '$_'?
-- Jason
------------------------------
Date: Tue, 09 Dec 2003 18:23:39 +0000
From: "Richard Gration" <richard@zync.co.uk>
Subject: Re: What is '_'
Message-Id: <br53vb$l9r$1@news.freedom2surf.net>
In article <3FD60DD1.8060503@yahoo.com>, "Jason Mather"
<goz02451@yahoo.com> wrote:
> Several places in File/Find.pm there are tests like:
> if (-d _) {
> What is '_'? Is it the same as '$_'?
Nope.
When you get perl to stat a file (ie you ask perl for information about
the file, eg is it a directory, how long is the file, what is its mod
time, etc) perl uses a system function called stat, which returns a lot of
information about the file. The results of the stat are cached. The '_'
causes perl to consult the stored stat results instead of statting the
file again.
Rich
------------------------------
Date: 9 Dec 2003 10:32:44 -0800
From: yf110@vtn1.victoria.tc.ca (Malcolm Dew-Jones)
Subject: Re: What is '_'
Message-Id: <3fd6154c@news.victoria.tc.ca>
Jason Mather (goz02451@yahoo.com) wrote:
: Several places in File/Find.pm there are tests like:
: if (-d _) {
: What is '_'? Is it the same as '$_'?
: -- Jason
No, it is not the same.
Perldoc -f -x (-x is the function name eh?)
at the end, all the gory details, and examples.
------------------------------
Date: Tue, 9 Dec 2003 08:08:02 -0600
From: tadmc@augustmail.com (Tad McClellan)
Subject: Re: Why does ne always work
Message-Id: <slrnbtblq2.rgm.tadmc@magna.augustmail.com>
[ Please choose one posting address and stick with it.
Please do not top-post.
Please do not full-quote.
Thank you.
]
Gary Mayor <gary@tgpmakers.com> wrote:
> That's what i mean $blah ne $blah does not always return false.
Yes it does.
> if ($blah ne $blah1) {
That is not "$blah ne $blah", that is something else.
If you change the question the answer is likely to change too.
> This message is probably useless without a real example.
Right.
--
Tad McClellan SGML consulting
tadmc@augustmail.com Perl programming
Fort Worth, Texas
------------------------------
Date: 09 Dec 2003 12:32:53 GMT
From: BOHIM <BOHIM789@AOL.COM>
Subject: WIN32::Internet
Message-Id: <2003129-133253-41466@foorum.com>
Hi
I want to change local directory (lcd in dos) and no reference to this method in
the documentation ?
Thanks
--
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: 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 5916
***************************************