[15530] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 2940 Volume: 9

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Wed May 3 21:10:32 2000

Date: Wed, 3 May 2000 18:10:23 -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: <957402623-v9-i2940@ruby.oce.orst.edu>
Content-Type: text

Perl-Users Digest           Wed, 3 May 2000     Volume: 9 Number: 2940

Today's topics:
        help! how to delete file? <snowphoton@mindspring.com>
    Re: help! how to delete file? <rootbeer@redcat.com>
    Re: help! how to delete file? <lauren_smith13@hotmail.com>
    Re: help! how to delete file? <snowphoton@mindspring.com>
    Re: help! how to delete file? <snowphoton@mindspring.com>
    Re: help! how to delete file? <rootbeer@redcat.com>
    Re: how do I catch user's input? (Randal L. Schwartz)
    Re: if file already exists then remove... <htp@mac.com>
    Re: if file already exists then remove... <lr@hpl.hp.com>
    Re: if file already exists then remove... <mjcarman@home.com>
    Re: if file already exists then remove... <rootbeer@redcat.com>
    Re: if file already exists then remove... <lr@hpl.hp.com>
    Re: if file already exists then remove... (Craig Berry)
    Re: If slices are so great... <lr@hpl.hp.com>
    Re: Keys of Hash (Bart Lateur)
        mixing module versions with mod perl and apache cavenewt@my-deja.com
    Re: mixing module versions with mod perl and apache <rootbeer@redcat.com>
    Re: Oct function does not work with binary <rootbeer@redcat.com>
    Re: perl in NT .BAT files Question <gellyfish@gellyfish.com>
    Re: perl intepreter <rootbeer@redcat.com>
    Re: perl intepreter <pl9a@cs.virginia.edu>
    Re: perl intepreter <rootbeer@redcat.com>
    Re: Perl subroutine...how to return HoHoH? <smckee@umich.edu>
    Re: printing to a jetdirect device from perl -- help <alager@csuchico.edu>
        problem reading &nbsp; from form generated message <badIII@yahoo.com>
    Re: problem reading &nbsp; from form generated message <rootbeer@redcat.com>
        Digest Administrivia (Last modified: 16 Sep 99) (Perl-Users-Digest Admin)

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

Date: Wed, 03 May 2000 16:04:41 -0700
From: james archer <snowphoton@mindspring.com>
Subject: help! how to delete file?
Message-Id: <3910B089.AA90B8C8@mindspring.com>

I know I'm gonna get some burn marks on my newbie ass for asking, but
how does one go about deleting a file in Perl?

I've spent several hours RingTFM and haven't found anything.

Any help would be much appreciated.  Thanks!! :o)


James

ICQ: 49636524
snowphoton@mindspring.com
http://www.mindspring.com/~snowphoton/




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

Date: Wed, 3 May 2000 16:10:55 -0700
From: Tom Phoenix <rootbeer@redcat.com>
Subject: Re: help! how to delete file?
Message-Id: <Pine.GSO.4.10.10005031607170.6766-100000@user2.teleport.com>

On Wed, 3 May 2000, james archer wrote:

> I know I'm gonna get some burn marks on my newbie ass for asking, but
> how does one go about deleting a file in Perl?
> 
> I've spent several hours RingTFM and haven't found anything.

Hours? Really? Wow. 

You want the unlink function, documented in the perlfunc manpage.

Would you please use the perlbug program on your system to request that
the entry for 'delete' in perlfunc should say something like "To delete a
file, see the 'unlink' function"? I'm assuming, of course, that you found
'delete' by the second or third hour. :-)

Thanks!

-- 
Tom Phoenix       Perl Training and Hacking       Esperanto
Randal Schwartz Case:     http://www.rahul.net/jeffrey/ovs/



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

Date: Wed, 3 May 2000 16:06:59 -0700
From: "Lauren Smith" <lauren_smith13@hotmail.com>
Subject: Re: help! how to delete file?
Message-Id: <8eqbdt$ct2$1@brokaw.wa.com>


james archer <snowphoton@mindspring.com> wrote in message
news:3910B089.AA90B8C8@mindspring.com...
> I know I'm gonna get some burn marks on my newbie ass for asking, but
> how does one go about deleting a file in Perl?
>
> I've spent several hours RingTFM and haven't found anything.

Hours RTFM'ing?  You've got to learn about perldoc.

perldoc perldoc
perldoc perl
perldoc perlfunc
perldoc -f unlink

(Type those into your command prompt.)

Lauren




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

Date: Wed, 03 May 2000 17:02:34 -0700
From: james archer <snowphoton@mindspring.com>
Subject: Re: help! how to delete file?
Message-Id: <3910BE1A.E4CEF3A4@mindspring.com>

> Hours RTFM'ing?  You've got to learn about perldoc.
>
> perldoc perldoc
> perldoc perl
> perldoc perlfunc
> perldoc -f unlink
>
> (Type those into your command prompt.)

*falls to knees in gratitude*

thanks! :o)

James

ICQ: 49636524
snowphoton@mindspring.com
http://www.mindspring.com/~snowphoton/




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

Date: Wed, 03 May 2000 17:03:16 -0700
From: james archer <snowphoton@mindspring.com>
Subject: Re: help! how to delete file?
Message-Id: <3910BE44.FA3BB17F@mindspring.com>

perl is great, but sometimes a little to creative when naming things :o)

somehow i think "erase" or "delete" or "rm" might have been nice...hehehe

thx for the help

James

ICQ: 49636524
snowphoton@mindspring.com
http://www.mindspring.com/~snowphoton/




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

Date: Wed, 3 May 2000 16:59:17 -0700
From: Tom Phoenix <rootbeer@redcat.com>
Subject: Re: help! how to delete file?
Message-Id: <Pine.GSO.4.10.10005031656330.6766-100000@user2.teleport.com>

On Wed, 3 May 2000, james archer wrote:

> perl is great, but sometimes a little to creative when naming things :o)
> 
> somehow i think "erase" or "delete" or "rm" might have been nice...hehehe

Not Larry's fault; when a function is primarily used as a gateway to the
underlying system call (unlink(2) in this case) it generally has the same
name in Perl. Renaming all of these would be just confusing.

And who would want to call it 'rm'? That's a silly name. DEL is a much
better choice. :-)

-- 
Tom Phoenix       Perl Training and Hacking       Esperanto
Randal Schwartz Case:     http://www.rahul.net/jeffrey/ovs/



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

Date: 03 May 2000 12:38:20 -0700
From: merlyn@stonehenge.com (Randal L. Schwartz)
Subject: Re: how do I catch user's input?
Message-Id: <m1zoq72zmb.fsf@halfdome.holdit.com>

>>>>> "Ulrich" == Ulrich Ackermann <UlleAckermann@t-online.de> writes:

Ulrich> print "Your name: ";
Ulrich> my $name = <>;    # long version: <STDIN> instead of <>

My rule of thumb - NEVER read from <> if you are prompting for an answer.
If you are using <> to either be STDIN or the @ARGV files, then your prompt
is likely being lost in some output mess.  If you are prompting, you
need to be reading just from STDIN.

-- 
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: Thu, 04 May 2000 07:50:52 +0930
From: Henry <htp@mac.com>
Subject: Re: if file already exists then remove...
Message-Id: <htp-B3C119.07505204052000@news.metropolis.net.au>

In article <MPG.137a2249602da84098a9de@nntp.hpl.hp.com>, Larry Rosler 
<lr@hpl.hp.com> wrote:

>>>> The usual caveats about unlink and file permissions apply.
>>> 
>>> Yes, and they should be diagnosed.  I think your advice to 'Just do 
>>> it!' and ignore any possible errors is spectacularly wrong-headed.
>> 
>> "Far better it is to dare mighty things, to win glorious triumphs,
>> even though checkered by failure, than to rank with those poor
>> spirits who neither enjoy much nor suffer much, because they live
>> in the grey twilight that knows not victory nor defeat."
>> - Theodore Roosevelt
> 
> Great quote.  That philosophy seems to have been adapted by NASA, at
> the cost of recent Mars fiascos.  I wouldn't care to design any
> nuclear reactors on that basis.

Perl is not certified for mission-critical tasks - you know that.

Besides, they lost the orbiter because some yanks forgot to convert 
crusty old units (like miles, feet, and pounds) into current, 
internationally accepted and approved units (like kilometres, metres, 
and kilograms).

All the diagnosis routines money could buy didn't help the fact that the 
underlying assumptions were wrong.

Simply unlinking a file is a perfectly valid approach, providing your 
filesystem has been set up and configured correctly in the first place.

In my book, it's much better to tackle the problem at it's source, 
rather than waste time dealing with symptoms.  I'm sure doctors, 
firemen, and a whole lot of other people would agree.

Henry.


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

Date: Wed, 3 May 2000 12:48:03 -0700
From: Larry Rosler <lr@hpl.hp.com>
Subject: Re: if file already exists then remove...
Message-Id: <MPG.137a2249602da84098a9de@nntp.hpl.hp.com>

In article <htp-9F5611.03141504052000@news.metropolis.net.au> on Thu, 04 
May 2000 03:14:15 +0930, Henry <htp@mac.com> says...
> In article <MPG.1379fe42616eb94b98a9d4@nntp.hpl.hp.com>, Larry Rosler 
> <lr@hpl.hp.com> wrote:
> 
> >> Err...  Why bother testing for it's existence at all?  Why not simply:
> >                                  ^^^^
> >                                  its
> 
> Not on a possessive, Larry.  Its fine to drop the apostrophe when the 
> long form reads 'it is' - but not in the case of ownership.  (Or, at 
> least, so I've been told by academics with lots of letters after their 
> names.)

Woe for the academics; woe for the English language.  You have a bit 
flipped.

Strunk and White, 'The Elements of Style', Chapter I, 'Elementary Rules 
of Usage':

A common error is to write _it's_ for _its_, or vice versa.  The first 
is a contraction, meaning "it is".  The second is a possessive.

   It's a wise dog that scratches its own fleas.

> >> The usual caveats about unlink and file permissions apply.
> > 
> > Yes, and they should be diagnosed.  I think your advice to 'Just do it!' 
> > and ignore any possible errors is spectacularly wrong-headed.
> 
> "Far better it is to dare mighty things, to win glorious triumphs, even 
> though checkered by failure, than to rank with those poor spirits who 
> neither enjoy much nor suffer much, because they live in the grey 
> twilight that knows not victory nor defeat." - Theodore Roosevelt

Great quote.  That philosophy seems to have been adapted by NASA, at the 
cost of recent Mars fiascos.  I wouldn't care to design any nuclear 
reactors on that basis.

-- 
(Just Another Larry) Rosler
Hewlett-Packard Laboratories
http://www.hpl.hp.com/personal/Larry_Rosler/
lr@hpl.hp.com


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

Date: Wed, 03 May 2000 17:59:21 -0500
From: Michael Carman <mjcarman@home.com>
Subject: Re: if file already exists then remove...
Message-Id: <3910AF49.282C3088@home.com>

Henry wrote:
> 
> Besides, they lost the orbiter because some yanks forgot to convert
> crusty old units (like miles, feet, and pounds) into current,
> internationally accepted and approved units (like kilometres, metres,
> and kilograms).

Oh geez, here's some OT bait for a flame war. These are all just units.
There is nothing intrinsically "better" about one set over the other.
(Consistency, however, is key.)

> Simply unlinking a file is a perfectly valid approach, providing your
> filesystem has been set up and configured correctly in the first place.

Proper configuration does not mean that you have permissions to delete
everything in sight. :-O

Simply unlinking the file is fine if it may or may not exist and you
don't much care whether it was successfully removed anyway. E.g. for a
temp file. But if you do care about failed attempts at deletion you
should include a die() or warn() diagnostic, in which case the
preliminary test with -e is good because it will save you spurious
errors.

> In my book, it's much better to tackle the problem at it's source,
> rather than waste time dealing with symptoms.  I'm sure doctors,
> firemen, and a whole lot of other people would agree.

Hrm. Isn't the -e test going to the source of the problem?

-mjc


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

Date: Wed, 3 May 2000 16:49:42 -0700
From: Tom Phoenix <rootbeer@redcat.com>
Subject: Re: if file already exists then remove...
Message-Id: <Pine.GSO.4.10.10005031643420.6766-100000@user2.teleport.com>

On Wed, 3 May 2000, Michael Carman wrote:

> Simply unlinking the file is fine if it may or may not exist and you
> don't much care whether it was successfully removed anyway. E.g. for a
> temp file. But if you do care about failed attempts at deletion you
> should include a die() or warn() diagnostic, in which case the
> preliminary test with -e is good because it will save you spurious
> errors.

Or, you could check the value of $! after an error message, and ignore it
if it were the expected error.

    use Errno qw/ ENOENT /;

    unless (unlink 'mango' or $! == ENOENT) {
	die "Can't unlink 'mango': $!";
    }

That should be just a touch more efficient. Less portable, though. :-P

-- 
Tom Phoenix       Perl Training and Hacking       Esperanto
Randal Schwartz Case:     http://www.rahul.net/jeffrey/ovs/



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

Date: Wed, 3 May 2000 16:44:24 -0700
From: Larry Rosler <lr@hpl.hp.com>
Subject: Re: if file already exists then remove...
Message-Id: <MPG.137a59ae938d81ad98a9eb@nntp.hpl.hp.com>

In article <htp-B3C119.07505204052000@news.metropolis.net.au> on Thu, 04 
May 2000 07:50:52 +0930, Henry <htp@mac.com> says...

 ...

> Perl is not certified for mission-critical tasks - you know that.

By whom?  What other languages *are* so certified?  C?  C++?  I doubt 
that Perl's bug rate is higher than those.

  perlfaq2: "Is there an ISO or ANSI certified version of Perl?"

  Certainly not. Larry expects that he'll be certified before Perl is.

What does this mean in practice?  Is someone confusing 'certified' with 
'standardized'?

 ...

> In my book, it's much better to tackle the problem at it's source, 
              ^^^^                                      XXXX

> rather than waste time dealing with symptoms.  I'm sure doctors, 
> firemen, and a whole lot of other people would agree.

Old habits die hard.  Chuckle...

-- 
(Just Another Larry) Rosler
Hewlett-Packard Laboratories
http://www.hpl.hp.com/personal/Larry_Rosler/
lr@hpl.hp.com


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

Date: Thu, 04 May 2000 00:26:02 GMT
From: cberry@cinenet.net (Craig Berry)
Subject: Re: if file already exists then remove...
Message-Id: <sh1gsq4lc3444@corp.supernews.com>

Henry (htp@mac.com) wrote:
: Simply unlinking a file is a perfectly valid approach, providing your 
: filesystem has been set up and configured correctly in the first place.

When you go to unlink a file, there are three possible outcomes, and a
reasonable program might wish to deal differently with each: 

1) The target file doesn't exist, so can't be deleted.
2) The target file exists, but can't be deleted for other reasons.
3) The target file is deleted.

Doing -e conditionally followed by an error-checking unlink is the
simplest way to discriminate between the three cases.

Merely doing an error check on unlink makes it hard to discriminate
between cases 1 and 2.  As a result, it is difficult to determine if the
file does or does not exist following the unlink.

: In my book, it's much better to tackle the problem at it's source, 
: rather than waste time dealing with symptoms.  I'm sure doctors, 
: firemen, and a whole lot of other people would agree.

Of course; this is why doctors witnessing a heart attack routinely respond
by lecturing the victim on proper diet and exercise, firemen issue
citations for improper storage of flammables to owners of burning
buildings, and so forth.

-- 
   |   Craig Berry - cberry@cinenet.net
 --*--  http://www.cinenet.net/users/cberry/home.html
   |   "The road of Excess leads to the Palace
      of Wisdom" - William Blake


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

Date: Wed, 3 May 2000 12:36:56 -0700
From: Larry Rosler <lr@hpl.hp.com>
Subject: Re: If slices are so great...
Message-Id: <MPG.137a1fafb01925f898a9dd@nntp.hpl.hp.com>

In article <39105FB5.39868B12@home.com> on Wed, 03 May 2000 12:19:49 -
0500, Michael Carman <mjcarman@home.com> says...

 ...

> ... I kind of like
> Larry's solution best for this, but would rewrite it thusly to make it
> more easily scalable:
> 
> @keep = $string =~ /(?:[^,]*,){2}?(.+)/ ? split /,/ => $1 : ();
                                   ^
Why the quantifier there?

Were it not for all the Golf activity, I might have done it that way 
also.  But the spec did say '2' explicitly.
 
> That takes a bit of effort to interpret, though. ;-)

Not if you're the one who wrote it (at least not for a few days :-).

-- 
(Just Another Larry) Rosler
Hewlett-Packard Laboratories
http://www.hpl.hp.com/personal/Larry_Rosler/
lr@hpl.hp.com


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

Date: Wed, 03 May 2000 22:19:21 GMT
From: bart.lateur@skynet.be (Bart Lateur)
Subject: Re: Keys of Hash
Message-Id: <3911a4e2.2297073@news.skynet.be>

Samay wrote:

>>for my $first (sort keys %X) {
>>  for my $second (sort keys %{$X{$first}}) {
>>    "you now have $first and $second - enjoy!";
>>  }
>>}
>>
>>print "Just another Perl hacker,"
>
>Thank you for the answer.
>However your answer uses 2 for loops and a sort etc..
>Which makes O(N*N) algorithm.

No it's not. You're iterating over the top level keys, and then over
each of the existing subkeys for each. So it's actually O(N), with N the
total number of subkeys.

Example:

	$x{a} = { B => 1, C => 2 };
	$x{b} = { D => 1, E => 2 };
	$x{c} = { F => 1, G => 2 };

Now, if you iterate over all of this, you'll do 2+2+2 = 6 steps. That is
the total number of subkeys.

-- 
	Bart.


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

Date: Wed, 03 May 2000 22:25:38 GMT
From: cavenewt@my-deja.com
Subject: mixing module versions with mod perl and apache
Message-Id: <8eq90h$2rc$1@nnrp1.deja.com>




I'm running slashcode on my site.  I've also got several virtual hosts,
and am attempting to 'test' new versions of the slash code.  However,
it appears that once a version of the slash.pm gets loaded by httpd, it
will not load the other version used by the other virtual host.


As I'm climbing the knowledge hill, I'd like to know if there are any
viable options to solve this?

--
http://www.nethole.com


Sent via Deja.com http://www.deja.com/
Before you buy.


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

Date: Wed, 3 May 2000 16:22:56 -0700
From: Tom Phoenix <rootbeer@redcat.com>
Subject: Re: mixing module versions with mod perl and apache
Message-Id: <Pine.GSO.4.10.10005031622090.6766-100000@user2.teleport.com>

On Wed, 3 May 2000 cavenewt@my-deja.com wrote:

> I'm running slashcode on my site.  I've also got several virtual
> hosts, and am attempting to 'test' new versions of the slash code.  
> However, it appears that once a version of the slash.pm gets loaded by
> httpd, it will not load the other version used by the other virtual
> host.

It sounds as if you want to search for the docs, FAQs, and newsgroups
about your webserver and how to get it to do what you want. Cheers!

-- 
Tom Phoenix       Perl Training and Hacking       Esperanto
Randal Schwartz Case:     http://www.rahul.net/jeffrey/ovs/



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

Date: Wed, 3 May 2000 12:53:13 -0700
From: Tom Phoenix <rootbeer@redcat.com>
Subject: Re: Oct function does not work with binary
Message-Id: <Pine.GSO.4.10.10005031251270.13677-100000@user2.teleport.com>

On Wed, 3 May 2000, Charles F. Radley wrote:

> Here is what the Activestate perl doc says about the  oct  function (I am
> using v 522):
> 
> oct EXPR
> Interprets EXPR as an octal string and returns the corresponding value. (If
> EXPR happens to start off with 0x, interprets it as a hex string. If EXPR
> starts off with 0b, it is interpreted as a binary string.)

It's a lie. :-)  No, just a goof. Binary support was added in 5.6. Somehow
that got into the docs ahead of schedule.

> I note that the camel book (1996 edition) makes no mention of the 0b
> binary behavior at all.

Yes, because in 1996 no one was yet planning on adding that feature.

Cheers!

-- 
Tom Phoenix       Perl Training and Hacking       Esperanto
Randal Schwartz Case:     http://www.rahul.net/jeffrey/ovs/



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

Date: 3 May 2000 19:03:22 +0100
From: Jonathan Stowe <gellyfish@gellyfish.com>
Subject: Re: perl in NT .BAT files Question
Message-Id: <8eppla$sv3$1@orpheus.gellyfish.com>

On Tue, 2 May 2000 13:34:52 -0400 BobS wrote:
> Thanks for the heads up. I'll keep that in mind. Since the proprietary
> C-ISAM library does file access, my thought is to let Perl control the file
> handler routines already in place. Hmmm, I wonder if Perl has a C-ISAM
> module ...
> 

I dont think there is though If you were to write a DBI/DBD interface to
the C-ISAM system you are using and submit it to CPAN I am sure there
would be cheering and applause in the streets ;-}

/J\
-- 
We'll die together, like a father and son should.
-- 
fortune oscar homer


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

Date: Wed, 3 May 2000 12:37:25 -0700
From: Tom Phoenix <rootbeer@redcat.com>
Subject: Re: perl intepreter
Message-Id: <Pine.GSO.4.10.10005031232580.13677-100000@user2.teleport.com>

On Wed, 3 May 2000, Rick Li wrote:

> I need to record all the Perl library calls a Perl script makes. One
> way to do that is to change the Perl interpreter. Whenever it finds
> the script call a function in the Perl library, it writes down the
> name of the function.

When you say "call a function in the Perl library", are you talking about
calling a function defined in a .pl (perl library) file, or something
else?

Maybe you want to know which modules are being loaded?

Maybe you want to know when require() is being called?

> However I am totally lost how to start my work. I don't know much
> about Perl. I can't understand the source code of Perl interpreter.

Nobody does. :-)

-- 
Tom Phoenix       Perl Training and Hacking       Esperanto
Randal Schwartz Case:     http://www.rahul.net/jeffrey/ovs/



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

Date: Wed, 03 May 2000 18:29:09 -0400
From: Rick Li <pl9a@cs.virginia.edu>
Subject: Re: perl intepreter
Message-Id: <3910A835.C954E27@cs.virginia.edu>



Tom Phoenix wrote:

> On Wed, 3 May 2000, Rick Li wrote:
>
> > I need to record all the Perl library calls a Perl script makes. One
> > way to do that is to change the Perl interpreter. Whenever it finds
> > the script call a function in the Perl library, it writes down the
> > name of the function.
>
> When you say "call a function in the Perl library", are you talking about
> calling a function defined in a .pl (perl library) file, or something
> else?
>

Yes, I want to record the function called, not the module.

>
> Maybe you want to know which modules are being loaded?
>
> Maybe you want to know when require() is being called?
>
> > However I am totally lost how to start my work. I don't know much
> > about Perl. I can't understand the source code of Perl interpreter.
>
> Nobody does. :-)
>
> --
> Tom Phoenix       Perl Training and Hacking       Esperanto
> Randal Schwartz Case:     http://www.rahul.net/jeffrey/ovs/



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

Date: Wed, 3 May 2000 15:58:25 -0700
From: Tom Phoenix <rootbeer@redcat.com>
Subject: Re: perl intepreter
Message-Id: <Pine.GSO.4.10.10005031554220.6766-100000@user2.teleport.com>

On Wed, 3 May 2000, Rick Li wrote:

> > > I need to record all the Perl library calls a Perl script makes. One
> > > way to do that is to change the Perl interpreter. Whenever it finds
> > > the script call a function in the Perl library, it writes down the
> > > name of the function.
> >
> > When you say "call a function in the Perl library", are you talking about
> > calling a function defined in a .pl (perl library) file, or something
> > else?

> Yes, I want to record the function called, not the module.

That's going to be a tough one. There's not really any difference between
a subroutine defined in a module and one defined in the main program text.
And autoloading is another matter entirely!

But if you can compile perl with the -DDEBUGGING option, the -Dt
command-line option may let you get some debugging information that could
be useful while a program is running. 

If you need something more than that, you may need to start hacking the
core. It'll certainly be an educational experience!

-- 
Tom Phoenix       Perl Training and Hacking       Esperanto
Randal Schwartz Case:     http://www.rahul.net/jeffrey/ovs/



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

Date: Wed, 3 May 2000 15:44:24 -0400
From: "Shawn McKee" <smckee@umich.edu>
Subject: Re: Perl subroutine...how to return HoHoH?
Message-Id: <tk%P4.339$R12.7124@news.itd.umich.edu>

Hi Ala,

Thanks for the tips.  My problem was compounded by another error in
the subroutine.  The following code works fine.  Thanks again,

Shawn
#
# Test returning HoHoH
#
sub Test_HoHoH{

    my %HoHoH;

    $HoHoH{FieldA1}{FieldB1}{FieldC1} = 1;
    $HoHoH{FieldA1}{FieldB2}{FieldC1} = 2;
    $HoHoH{FieldA1}{FieldB1}{FieldC2} = 3;
    $HoHoH{FieldA1}{FieldB2}{FieldC2} = 4;
    $HoHoH{FieldA2}{FieldB1}{FieldC1} = 5;
    $HoHoH{FieldA2}{FieldB2}{FieldC1} = 6;
    $HoHoH{FieldA2}{FieldB1}{FieldC2} = 7;
    $HoHoH{FieldA2}{FieldB2}{FieldC2} = 8;

    return \%HoHoH;
}

$Href = Test_HoHoH();
foreach $Afield (keys %{$Href}) {
  foreach $Bfield (keys %{$Href->{$Afield}}) {
    foreach $Cfield (keys %{$Href->{$Afield}{$Bfield}} ) {
 print "Found Afield:Bfield:Cfield $Afield:$Bfield:$Cfield...\n";
    }
  }
  print " Finished Afield $Afield...\n";
}
exit;


Ala Qumsieh <aqumsieh@hyperchip.com> wrote in message
news:7a8zxrr8g9.fsf@Merlin.i-did-not-set--mail-host-address--so-shoot-me...
>
> "Shawn McKee" <smckee@umich.edu> writes:
>
> > I have a Perl subroutine which generates a HoHoH:
> >
> >   mysub {
> >
> >     undef %a;
>
> You don't need to undef %a. Just declare it:
>
> my %a;
>
> > ...
> >     $a{$b}{$c}{$d} = $e;
> > ...
> >     return \%a;  # This doesn't work correctly (or maybe it does
> >  }                      #  but I don't know how to correctly dereference
it!
>
> This returns a reference to the hash. Good.
>
> > How do I return this to the caller correctly and how should the
> > caller dereference it?
> >
> > I tried:
> >
> > %new = mysub();
>
> This is wrong. mysub() returns a reference to a hash (not a hash). A
> reference is a scalar, so you would do something like:
>
> $new = mysub();
>
> Now, $new refers to the hash that was created in mysub().
>
> > foreach $akey (keys %new) {
>
> foreach $akey(keys %$new) {
>
> >    print " Found akey = $akey\n";
> >    foreach $bkey (keys %{$new{$akey}} ) {
>
> foreach $bkey (keys %{$new->{$akey}}) {
>
> >       print " Found akey:bkey $akey:$bkey\n";
> >       foreach $ckey ( keys %{{$new{$akey}{$bkey}}} {
>
> foreach $ckey (keys %{$new->{$akey}{$bkey}}) {
>
> >             print " Found akey:bkey:ckey $akey:$bkey:$ckey\n";
> >       }
> >    }
> > }
> >
> > The foreach loops don't work (Finds only 1 akey as a HASH value).
> >
> > Any pointers? Thanks,
>
> Yeah. You need to read more on references. Checkout the following
> docs:
>
> perlref
> perlsub
> perlreftut
> perllol
> perldsc
>
> --Ala




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

Date: Wed, 03 May 2000 13:28:33 -0700
From: Aaron <alager@csuchico.edu>
Subject: Re: printing to a jetdirect device from perl -- help
Message-Id: <39108BF1.6BAEBA76@csuchico.edu>



Tom Phoenix wrote:

> On Tue, 2 May 2000, Aaron wrote:
>
> > Can someone give me an example of how to print to a jetdirect device?
>
> You'll almost certainly need to find out what protocol the device desires
> that you use when you speak to it. Once you do, though, there are modules
> on CPAN for many common protocols, or you can make your own. You may wish
> to search for the docs, FAQs, and newsgroups about your hardware. Cheers!
>
> --
> Tom Phoenix       Perl Training and Hacking       Esperanto
> Randal Schwartz Case:     http://www.rahul.net/jeffrey/ovs/

Thanks Tom, I guess I was a little vague in my original post.  The
HP-Jetdirect box is setup for TCP/IP
communications and is connected to a line printer.  I searched the CPAN site
as you suggested, but found
nothing regarding printing protocols.  I guess I'm just not as good at
searching as some of the rest of you.
If you could find it in your heart to give me a little more specifics on
where I might search or read about
how to make perl talk to a jetdirect box over tcp/ip I would be very
grateful.

Aaron



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

Date: Wed, 03 May 2000 15:41:34 -0400
From: bruce <badIII@yahoo.com>
Subject: problem reading &nbsp; from form generated message
Message-Id: <391080EE.102F8B0C@yahoo.com>

I'm writing a little script that process results Emailed from an html
form.

The form Emails the results to me & then I save that message as a txt
file. The problem is that
the webmaster is formating these results with spaces (&nbsp;). The saved
messages are readable by my text editor, but when I process the saved
txt file w/ perl, instead of spaces, the &nbsp;'s are translating into a
non-ascii character (kind of an a w/ an accent mark). Has anyone dealt
w/ a situation similar to this?


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

Date: Wed, 3 May 2000 13:34:08 -0700
From: Tom Phoenix <rootbeer@redcat.com>
Subject: Re: problem reading &nbsp; from form generated message
Message-Id: <Pine.GSO.4.10.10005031331460.13677-100000@user2.teleport.com>

On Wed, 3 May 2000, bruce wrote:

> when I process the saved txt file w/ perl, instead of spaces, the
> &nbsp;'s are translating into a non-ascii character (kind of an a w/
> an accent mark).

perl isn't doing that, unless you're telling it to do that. Can you cut
your code down to a small stand-alone example program which shows the
behavior you're talking about? It should be no more than a few lines of
code. If others can try it, they'll be more likely to be able to help you.

Cheers!

-- 
Tom Phoenix       Perl Training and Hacking       Esperanto
Randal Schwartz Case:     http://www.rahul.net/jeffrey/ovs/



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

Date: 16 Sep 99 21:33:47 GMT (Last modified)
From: Perl-Users-Request@ruby.oce.orst.edu (Perl-Users-Digest Admin) 
Subject: Digest Administrivia (Last modified: 16 Sep 99)
Message-Id: <null>


Administrivia:

The Perl-Users Digest is a retransmission of the USENET newsgroup
comp.lang.perl.misc.  For subscription or unsubscription requests, send
the single line:

	subscribe perl-users
or:
	unsubscribe perl-users

to almanac@ruby.oce.orst.edu.  

| NOTE: The mail to news gateway, and thus the ability to submit articles
| through this service to the newsgroup, has been removed. I do not have
| time to individually vet each article to make sure that someone isn't
| abusing the service, and I no longer have any desire to waste my time
| dealing with the campus admins when some fool complains to them about an
| article that has come through the gateway instead of complaining
| to the source.

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 V9 Issue 2940
**************************************


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