[22635] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 4856 Volume: 10

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Thu Apr 17 03:05:50 2003

Date: Thu, 17 Apr 2003 00:05:10 -0700 (PDT)
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)

Perl-Users Digest           Thu, 17 Apr 2003     Volume: 10 Number: 4856

Today's topics:
    Re: Can I die and also write to a log file? <jkeen@concentric.net>
        changing qx{} shell <mordor@fly.srk.fer.hr>
    Re: changing the date <Steffen.Beyer@de.bosch.com>
    Re: conditional 'use' <jkeen@concentric.net>
        How to run Perl code ? <gzm@citiz.net>
    Re: How to run Perl code ? (Walter Roberson)
    Re: How to run Perl code ? <thepoet@nexgo.de>
    Re: How to run Perl code ? <bernard.el-hagin@DODGE_THISlido-tech.net>
        HTTP::Headers - getting request headers <iain@pcorp.nospam.com.au>
    Re: memproblem again (garbage collection) ctcgag@hotmail.com
    Re: Method inheritance? ctcgag@hotmail.com
    Re: My 1st japh!! ctcgag@hotmail.com
    Re: Need perl to conect to mysql database ctcgag@hotmail.com
        Nesting tables with perl CGI <rbinn@shaw.ca>
    Re: New Perl Beginners Site <prakashREMOVE@CAPITALSece.arizona.edu>
    Re: Pushing objects onto an array (Erick Bourgeois)
    Re: Pushing objects onto an array <uri@stemsystems.com>
    Re: Recusively search directory... <dfox@ia.net>
    Re: regular expression substitution and perl -p -i -e <garry@ifr.zvolve.net>
    Re: Remembering previous values of the form. <shah@typhoon.xnet.com>
    Re: Subroutines:: Return Type Vs Performance ctcgag@hotmail.com
    Re: Temporary Folder (Dr Trevor Hales)
        Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)

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

Date: 17 Apr 2003 03:21:32 GMT
From: "James E Keenan" <jkeen@concentric.net>
Subject: Re: Can I die and also write to a log file?
Message-Id: <b7l6js$43d@dispatch.concentric.net>


"Sherman Willden" <sherman.willden@hp.com> wrote in message
news:3a80d8d6.0304161141.260da490@posting.google.com...
> Can I use die and also write to a log file? I am using perl perl,
> v5.6.1 built for MSWin32-x86-multi-thread
>
> I quit using die because I had to also write to a log file. I am also
> generating a message that indicates the script and the line number as
> shown in _Progamming Perl, 2nd Edition_, page 157. So I open an error
> log (EL) and write to it like the if statement shown below.

If your objective was to make sure that you captured all instances where a
line failed some test and only then died, you could declare a variable that
notes the existence of failure and an array to hold the failed lines and die
only if the former variable was true.  Something like this:

my ($signal, @fails);
while (<INPUT>) {
    if ($line eq '') {
        push(@fails, $line);
        $signal++;
    }
}
if ($signal) {
    print LOG $_, "\n" foreach @fails;
    die "At least one line failed the test: $!";
}




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

Date: Thu, 17 Apr 2003 06:43:23 +0000 (UTC)
From: Zeljko Vrba <mordor@fly.srk.fer.hr>
Subject: changing qx{} shell
Message-Id: <slrnb9sj7h.8ha.mordor@fly.srk.fer.hr>

How to change the shell invoked by qx{}? I'm running some scripts
under Win32 with cygwin installed. The perl invokes cmd.exe and
nothing works (because of broken quoting, redirection, etc.). How
to make it call bash? Thanks!



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

Date: Thu, 17 Apr 2003 08:08:32 +0200
From: "Steffen Beyer" <Steffen.Beyer@de.bosch.com>
Subject: Re: changing the date
Message-Id: <b7lgd2$m54$1@ns2.fe.internet.bosch.com>

"Mario542" <member17678@dbforums.com> wrote:
> 
> Does anyone know if there is a way to change the date to the following
> day after someone enters it in a web form? I'm trying to get info from a
> date to another using the between command. If I enter 1.2.03 to 1.5.03
> it gives me the total for 1.2.03 to 1.4.03 instead of 1.5.03 because of
> the between command. What I would like to do is, if someone enters
> 1.5.03 I would like to change it to 1.6.03 before running the execute
> command. The first date would be entered in $name and the second date
> would be entered in $second. Here is my script.
> Thanks,
> Mario

I'm not sure what you need, but you should probably have
a look at Perl's extensive documentation:

perldoc -q date
perldoc -q yesterday
perldoc perlfaq4

Besides that, the module Date::Calc allows you to add
a month, a day or whatever very easily:

#!perl -w

use strict;
use Date::Calc qw(:all);

my(@date) = (2003,4,17);

my(@tomorrow)  = Add_Delta_Days(@date, +1);
my(@yesterday) = Add_Delta_Days(@date, -1);
my(@nextmonth) = Add_Delta_YM(@date, 0,+1);    # truncates day of month if necessary
my(@nxtmonwrp) = Add_Delta_YMD(@date, 0,+1,0); # wraps into following month if necessary

etc.

(Truncation/wrapping occurs when the day of month, e.g. 31,
does not exist in the month you end up with - e.g. February.
Truncation simply sets the day of month to 28 or 29 instead
(in this example), and wrapping would result in March 2nd or
3rd - depending on the resulting year being a leap year or not.)

Hope this helps.

Cheers,
Steffen



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

Date: 16 Apr 2003 23:15:22 GMT
From: "James E Keenan" <jkeen@concentric.net>
Subject: Re: conditional 'use'
Message-Id: <b7ko6a$436@dispatch.concentric.net>


"Mark Seger" <mark.seger@hp.com> wrote in message
news:3E9DA937.32029E07@hp.com...

I'm only addressing one of your questions here:

>
> I'm also not sure where is the best place to look for installed
> modules.
>

print "$_\n" foreach (@INC);




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

Date: Thu, 17 Apr 2003 13:45:28 +0800
From: "GZM" <gzm@citiz.net>
Subject: How to run Perl code ?
Message-Id: <b7leq4$2qeu$1@mail.cn99.com>

Hai:
        I want to know how to run Perl code such as:
            Print "test ";

        No display when I type "Perl Print 'test'" in bash shell .


        Asp Gao
=======================




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

Date: 17 Apr 2003 06:24:25 GMT
From: roberson@ibd.nrc-cnrc.gc.ca (Walter Roberson)
Subject: Re: How to run Perl code ?
Message-Id: <b7lhap$pk2$1@canopus.cc.umanitoba.ca>

In article <b7leq4$2qeu$1@mail.cn99.com>, GZM <gzm@citiz.net> wrote:
:        I want to know how to run Perl code such as:
:            Print "test ";
:        No display when I type "Perl Print 'test'" in bash shell .

You did not code any newline, so the bash prompt is overwriting
your output (presuming everything else wrong is just a typo!)

  perl -e 'print "test\n"'
-- 
The Knights Of The Lambda Calculus aren't dead --this is their normal form!


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

Date: Thu, 17 Apr 2003 08:30:03 +0200
From: "Christian Winter" <thepoet@nexgo.de>
Subject: Re: How to run Perl code ?
Message-Id: <3e9e49eb$0$18090$9b4e6d93@newsread4.arcor-online.net>

"GZM" <gzm@citiz.net> wrote:
> Hai:
>         I want to know how to run Perl code such as:
>             Print "test ";
> 
>         No display when I type "Perl Print 'test'" in bash shell .

Hi,

you should note that perl is case sensitive,
as is bash.
perl -e 'print "test\n"'
should print the word "test" on a line.
If this doesn't work, maybe the location of
the perl executable is not in your PATH.

'man bash'
shows you how to modify environment variables.
Having fixed that (if neccessary),
'perldoc perlrun'
would be a good point to start reading.
'perldoc perldoc' and 'perldoc perltoc'
should also be among the first readings on
perl, as they show you how and where to
retrieve information on a perl question.

HTH
-Christian



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

Date: Thu, 17 Apr 2003 06:39:28 +0000 (UTC)
From: Bernard El-Hagin <bernard.el-hagin@DODGE_THISlido-tech.net>
Subject: Re: How to run Perl code ?
Message-Id: <slrnb9sj09.4oa.bernard.el-hagin@gdndev25.lido-tech>

In article <b7lhap$pk2$1@canopus.cc.umanitoba.ca>, Walter Roberson wrote:
> In article <b7leq4$2qeu$1@mail.cn99.com>, GZM <gzm@citiz.net> wrote:
>:        I want to know how to run Perl code such as:
>:            Print "test ";
>:        No display when I type "Perl Print 'test'" in bash shell .
> 
> You did not code any newline, so the bash prompt is overwriting
> your output


No it's not.


Cheers,
Bernard
--
echo 42|perl -pe '$#="Just another Perl hacker,"'


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

Date: Thu, 17 Apr 2003 11:23:27 +0930
From: Iain <iain@pcorp.nospam.com.au>
Subject: HTTP::Headers - getting request headers
Message-Id: <3E9E0917.10700@pcorp.nospam.com.au>

I want to get some (any would do for now!) request headers, ie sent by 
the client to the server.  I'm using HTTP::Headers as follows, but I 
think I'm doing something wrong:

#! /usr/bin/perl

use strict;
use HTTP::Headers;
my $h = HTTP::Request->new;

print 'content-type:text/html', "\n\n";
# print head, body tags, etc...
# and then any of
print "<br>acc: ", $h->header('Accept');
print "<br>ath: ", $h->authorization_basic;
print "<br>has: ", $h->as_string;
print "<br>hct: ", $h->content_type;
print "<br>uag: ", $h->user_agent;

EOF

And I get nothing.  If I set a header (this one isn't a request header, 
I know):

$h->header('Content-Type' => 'text/plain');

and then try and get it, it works fine.  So I'm assuming that the
'my $h ...' line is giving me a clean slate, but how do I get the 
current headers?

Any help is much appreciated!  I've searched for ages to try and find 
some simple perl way of getting these headers!

perl --version:
This is perl, version 5.005_03 built for i386-freebsd
uname -mrs:
FreeBSD 4.5-RELEASE-p5 i386

TIA,
iain@pcorp.nospam.com.au



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

Date: 16 Apr 2003 23:18:58 GMT
From: ctcgag@hotmail.com
Subject: Re: memproblem again (garbage collection)
Message-Id: <20030416191858.094$qX@newsreader.com>

peter pilsl <pilsl_usenet@goldfisch.at> wrote:
> sorry for bothering you with my memory-problems all the time, but I have
> an application dealing with really big datastrutures and I get grey hairs
> ...
>
> I create an object with a big structure and upon the destruction of this
> object the memory should be released. Sometimes it does and sometimes it
> does not. Fortunately this is reproduceable, depending on the type of the
> structure.
> If the structure is a large string, then the mem is released. If its a
> big but empty anonymous array then its released too. If its an filled
> anonymous array then it is not ! And so it is with big anonymous
> hash-structures.

Perl is under no obligation to return released memory to the operating
system.  Often (usually, I think) it will keep that memory for it's
own re-use.

If you put a loop around the part of your code using method 2, you will see
that the memory usage does not keep going up, because perl is internally
reusing the memory that it didn't return to the OS.


>
> I simply dont unterstand. No circular references, just simple structures.

If there *were* a circular reference holding things, then not even
perl could reuse the memory.  As it is, it can and does reuse the
memory, it just doesn't return it to the OS.

> Even looping through the array and undefing each entry did not release
> the mem ...

Why do you care so much?  If perl can re-use the memory internally, let it.

As for why you see what you see, this is my guess:

Perl can only return whole pages of memory to the OS.  If a page
is carved up into chunks for use by many structures, then it's
difficult to know when the page can be returned (i.e. when every last
one of those structures has been destroyed).  So perl never or rarely
returns these carved-up pages to the OS, it just keeps track of the
free space so it can reuse it.

On the other hand, if an entire page is used for just one structure, then
when that structure is destroyed, the page can obviously be returned.

When you destroy an array, the overhead of the array itself is released.
If the array is large, this overhead might contain many entire pages, so
those pages can be released to the OS.

When an array is destroyed, it's contents may or may not be destroyed.
Even if the contents are destroyed, each one the contents is a different
structure. And if those structure are small, then no one of them will
occupy an entire page by itself , so that memory is kept for internal reuse
and not sent to the OS.

If you have a very large string, then it will stored across many pages, and
it will probably have most of those pages all to itself.  So when you
destroy a large string, most of the pages it occupied can be sent back to
the OS.

Xho

-- 
-------------------- http://NewsReader.Com/ --------------------
Usenet Newsgroup Service              New Rate! $9.95/Month 50GB


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

Date: 16 Apr 2003 23:29:45 GMT
From: ctcgag@hotmail.com
Subject: Re: Method inheritance?
Message-Id: <20030416192945.288$YY@newsreader.com>

Roy Marteen <rm@no-mail.com> wrote:
 ...
> Now I can use it using:
> ---[test.pl]---
> use DB;
> my $db = DB::->connect();
> my $dbh = $db->{dbh};
>
> I don't want it this way. I want to wrap it in such a way that I can
> access it using:
> ---[test.pl]---
> use DB;
> my $dbh = DB::->connect();
>
> How can I do this?

Don't inherit from DBI at all.

----[MyPackage.pm]---
package MyPackage;

sub get_dbh {
  return DBI->connect("DBI:mysql:dummy", "root", "mysql",
         { RaiseError => 1 });
};

----[test.pl]----
use MyPackage;
use DBI;

my $dbh=MyPackage::get_dbh();


Xho

-- 
-------------------- http://NewsReader.Com/ --------------------
Usenet Newsgroup Service              New Rate! $9.95/Month 50GB


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

Date: 16 Apr 2003 23:46:42 GMT
From: ctcgag@hotmail.com
Subject: Re: My 1st japh!!
Message-Id: <20030416194642.885$6t@newsreader.com>

Michele Dondi <bik.mido@tiscalinet.it> wrote:

> Well, thanks for the detailed information, but my actual problem was
> with pack()s: it seems that I have troubles understanding the docs.
> For example I tried to use unpack() to translate a string like
>
>   '12AC'
>
> into a list like
>
>   (1, 2, 10, 12)
>
> but I couldn't make it work...

Well, the problem is that the string "12AC" isn't packed, so
unpack isn't the right tool for that particular job.  (Not
that someone couldn't use unpack to do it, just that it's not
the obvious way!)

map hex, split //, "12AC";


Xho

-- 
-------------------- http://NewsReader.Com/ --------------------
Usenet Newsgroup Service              New Rate! $9.95/Month 50GB


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

Date: 16 Apr 2003 23:51:41 GMT
From: ctcgag@hotmail.com
Subject: Re: Need perl to conect to mysql database
Message-Id: <20030416195141.562$UU@newsreader.com>

"matt" <urzaserra@home.com> wrote:
> I need some perl code that will connect to a mysql database and display
> the results on the users browser, in exactly the same order as they are
> in the database.

1) The result of connecting to a database is a database handle.
These are abstract things with no meaningful graphical or textual
representations, so good luck displaying them.

2) Relational databases are unordered.

Xho

-- 
-------------------- http://NewsReader.Com/ --------------------
Usenet Newsgroup Service              New Rate! $9.95/Month 50GB


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

Date: Thu, 17 Apr 2003 07:03:17 GMT
From: rob <rbinn@shaw.ca>
Subject: Nesting tables with perl CGI
Message-Id: <3E9E44E7.35F0CEFE@shaw.ca>

Hello,
  I need help nesting tables within a 1 row 2 - 3 column table . The
tables to be nested are generated from mysql queries. If someone could
give me a brief demonstration I am sure I would be able to figure out my
mistakes. I could post the code if needed, but I think it is a standard
issue.
Thanks for any help offered...
Rob



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

Date: Wed, 16 Apr 2003 16:32:48 -0700
From: Jayaprakash Rudraraju <prakashREMOVE@CAPITALSece.arizona.edu>
Subject: Re: New Perl Beginners Site
Message-Id: <Pine.GSO.4.50.0304161631340.17792-100000@ece2.ece.arizona.edu>

Thanks for the perl portal.. but some of the links "books" on the main
page is crashing my netscape on unix machine.

Prakash

On Tue, 15 Apr 2003, Shlomi Fish wrote:

> I have set up a new Perl Beginners' portal at:
>
> http://perl-begin.berlios.de/
>
> This site is not intended as a replacement for learn.perl.org, but
> rather as a complement[1]. It covers various net resources more
> closely, has a nicer look and feel (at least, IMO), and the source
> code (in Web Meta Language) is online.
>
> There will be more resources as time goes by. Feel free to contribute.
> I will gladly make anyone a member of the project in BerliOS, and if
> he contributes enough, an admin as well. I wish it to be a true
> community web-site.
>
> Regards,
>
> 	Shlomi Fish
>
>
> [1] - I don't believe in concentration of effort. In PHP or VB for
> instance, there are many portals with a lot of activity in them, and
> it's not confusing for the users.
>


--
Prakash



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

Date: 16 Apr 2003 21:11:03 -0700
From: erick@jeb.ca (Erick Bourgeois)
Subject: Re: Pushing objects onto an array
Message-Id: <3ecefa21.0304162011.1c155607@posting.google.com>

tiltonj@erols.com (Jay Tilton) wrote in message news:<3e9dd1aa.100173313@news.erols.com>...
> erick@jeb.ca (Erick Bourgeois) wrote:
> 
> : I'm trying to push objects created with the new pragma in a loop.
> : However, when I read the array after the loop, the only object
> : I can access (with the proper methods) is the last one pushed on.
> : Furthermore, I do know that each object pushed does in fact have
> : a different address. For example,
> : 
> : (presuming Foo::Bar::id() exists and returns the contructor's 
> : original initializer, in this case $_, i.e. 0..5)
> 
> Is that presumption valid?  The available evidence suggests that it is
> not.
> 
> : my @array;
> : 
> : for (0..5)
> : {
> :         my $obj = new Foo::Bar($_);
> :         push(@array, $obj);
> :         # printing $obj produces all different memory addresses
> 
> How about printing $obj->id() here to make sure the constructor is
> doing the reasonable thing?
> 
> : }
> : for (0..5)
> : {
> :         my $o = $array[$_];
> :         my $id = $o->id();
> :         # printing $o produces all different memory addresses
> :         # HOWEVER, printing $id is always 5
> : }
> 
>     # dummy Foo::Bar class added to the above code
>     package Foo::Bar;
>     sub new {
>         my $proto = shift;
>         my $class = ref($proto) || $proto;
>         bless({ id => $_[0] }, $class);
>     }
>     sub id {
>         my $self=shift;
>         $self->{id} = shift if @_;
>         $self->{id};
>     }
> 
> I'm just not seeing it happen.  Either one of the methods is
> misbehaving or you're misinterpreting its usage documentation (like,
> say, using id() as an object method when it's really a class method).
> 
> 
> Either way, without seeing the real Foo::Bar code, this problem is
> impossible to diagnose.
> 
> I would first lay suspicion on the id() method.

Here is some code which behaves the way I have described:

<Foo::Bar>
package Foo::Bar;
my $ID;
sub new
{
        my $class = shift;
        my $arg = shift;
        my $self = {};
        bless($self, $class);
        $self->_init($arg);
        return $self;
}
sub _init
{
        my ($self, $arg) = (shift, shift);
        $ID = $arg;
}
sub id
{
	return $ID;
}

1;
</Foo::Bar>
And a script to test it:
<script.pl>
#!/usr/bin/perl

use strict;
use warnings;
use lib "./";
use Foo::Bar;

my @array;
for (0..5)
{
        my $obj = new Foo::Bar($_);
        push(@array, $obj);
        # printing $obj produces all different memory addresses
        print "obj: $obj\n";
        print "id: ".$obj->id()."\n";
}
for (0..5)
{
        my $o = $array[$_];
        my $id = $o->id();
	# printing $o produces all different memory addresses
        # HOWEVER, printing $id is always 5
        print "o: $o\n";
        print "id: $id\n";
}
exit(0);
</script.pl>

(Sorry about not having posted the code)

erick


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

Date: Thu, 17 Apr 2003 04:57:38 GMT
From: Uri Guttman <uri@stemsystems.com>
Subject: Re: Pushing objects onto an array
Message-Id: <x7he8xg1q6.fsf@mail.sysarch.com>

>>>>> "EB" == Erick Bourgeois <erick@jeb.ca> writes:


  EB> <Foo::Bar>
  EB> package Foo::Bar;
  EB> my $ID;
  EB> sub new
  EB> {
  EB>         my $class = shift;
  EB>         my $arg = shift;
  EB>         my $self = {};
  EB>         bless($self, $class);
  EB>         $self->_init($arg);
  EB>         return $self;
  EB> }
  EB> sub _init
  EB> {
  EB>         my ($self, $arg) = (shift, shift);
  EB>         $ID = $arg;
  EB> }
  EB> sub id
  EB> {
  EB> 	return $ID;
  EB> }

what the hell is $ID? where in the world did you get the idea that it
would be object specific? it is a file lexical and static relative to
all the created objects. this is EXACTLY the bug i suspected. 

i am still astounded you sought to blame push for this when your object
design is totally wrong.

read these perldoc object tutorials:

	perlboot	Beginner's Object-Oriented Tutorial
	perltoot	Tom's object-oriented tutorial for perl
	perlobj		

uri

-- 
Uri Guttman  ------  uri@stemsystems.com  -------- http://www.stemsystems.com
--Perl Consulting, Stem Development, Systems Architecture, Design and Coding-
Search or Offer Perl Jobs  ----------------------------  http://jobs.perl.org


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

Date: Wed, 16 Apr 2003 21:22:33 -0500
From: Dennis Fox <dfox@ia.net>
Subject: Re: Recusively search directory...
Message-Id: <v9s3va3gfd8n56@corp.supernews.com>

Kasp wrote:
> What do you suggest I should use to recursively list down the files present
> in a given directory & it's sub directories?
> I am using ActiveState's Perl 5.8.
> Thanks.
> --
> "Accept that some days you are the pigeon and some days the statue."
> "A pat on the back is only a few inches from a kick in the butt." - Dilbert.
> 
> 
I have found the File::List module extremely useful for this type of thing.

-Dennis



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

Date: Wed, 16 Apr 2003 23:55:51 -0000
From: Garry Williams <garry@ifr.zvolve.net>
Subject: Re: regular expression substitution and perl -p -i -e
Message-Id: <slrnb9rrc6.281.garry@zfw.zvolve.net>

On Mon, 14 Apr 2003 22:55:39 +0100, osx <osx@nospamntlworld.com> wrote:

> I've got thousands of files on my computer and I'd like to rename
> each so that they look much tidier and structured.         ^^^^^^
                                                             ^^^^^^
That's a hint.  

  perldoc -f rename

> I am trying to use the "perl -p -i -e" command to do so but am not
> getting the expected results.

Why would you transform the contents of a file, if you want to rename
it?  

> An example current filename: Quantum Computing.htm
> 
> I'd like to remove all capital letters and whitespace.  Ideally I'd
> like: quantum_computing.htm

Okay, it sounds like you want to call the rename function: 

  # untested
  my ($new_name, $old_name);
  ($new_name = $old_name = "Quantum Computing.htm") =~ tr/A-Z /a-z_/;
  rename $old_name, $new_name
      or die "can't rename `$old_name' to `$new_name': $!\n";

> I not very good with regular expressions (as you might have
> guessed!) and have had a Google but can not get it to work.
> 
> I've tried both of these and a few variations with single quotes but
> have had no success.
> 
> perl -p -i -e 'tr/A-Z/a-z/' 'Quantum Computing.htm'

This tr/// is on the mark except for the space to underscore you say
you want (if it were applied to the file's _name_ instead of its
contents).  

> perl -p -i -e 's/([A-Z])/([a-z])/gi' Quantum\ Computing.htm

This does not do what you seem to think it does.

You can see what it is doing by trying it in a test script: 

  $ perl -wle '($x = "Quantum Computing")' \
           -e ' =~ s/([A-Z])/([a-z])/gi;'  \
	   -e 'print $x'

You should examine the contents of that file to see what you did to it
with those commands.  The -i option (along with -p) edits the
_contents_ of the file specified on the command line.  It has nothing
to do with the file's _name_.  

I think you want to read the _directory_ and then call rename on each
file _name_ that you want to rename.  See the following: 

  perldoc -f opendir
  perldoc -f readdir
  perldoc -f closedir
  perldoc -f rename

And especially note "an existing file NEWNAME will be clobbered" in
the last manual page.  

-- 
Garry Williams


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

Date: Wed, 16 Apr 2003 22:22:33 +0000 (UTC)
From: Hemant Shah <shah@typhoon.xnet.com>
Subject: Re: Remembering previous values of the form.
Message-Id: <b7kl39$hiu$1@flood.xnet.com>

While stranded on information super highway kaeli wrote:
:)And the fire said to me...on Wed, 16 Apr 2003 17:58:26 +0000 (UTC) in 
:)article <b7k5k2$9of$1@flood.xnet.com>, shah@typhoon.xnet.com said:
:)> 
:)> Folks,
:)> 
:)>    I am writing timesheet entry system using perl CGI.pm and Javascript,
:)>    on Linux.
:)> 
:)>    I have completed the form that displays time already entered, and allows
:)>    the user to add/chage/delete time. My problem is trying to remember what
:)>    the timesheet looked like when it was displayed, so that I can somehow
:)>    compare it with the new values when user presses "Save" button.
:)> 
:)
:)Why?
:)Depending on the answer to that question, it may be better for you to do 
:)this server-side with the database and PL/SQL (or equivalent) trigger. 
:)DB procedures run much faster than client-side code and don't depend on 

 I am not sure how I would implement it on server side using stored 
 procedures. I need to know the changes made to the timesheet so I could 
 update only the rows that changed.


:)the user having script enabled. So if it's a history type thing you are 
:)looking for, use the DB.
:)If for some reason you want it to be done in javascript, have the Perl 
:)write the old values to a javascript array. When the user presses save, 
:)loop through the form values and compare to array values. You can make 
:)this even easier by using an associative array with names the same as 
:)your form element names. ie myArray[myElement.name] will refer to the 
:)array (old) value for the corresponding element (myElement.value, 
:)generally speaking). No hidden elements needed.
:)If you need more detail, let me know.

 I think using associative arrays would work. I will have to try it out and
 see if I can do it.

:)
:) 
:)----------------------------------------------------
:)     ~kaeli~
:)Never argue with an idiot! People may not be able to tell you apart.
:)Contrary to popular opinion, the plural of 'anecdote' is not 'fact'.
:)http://www.ipwebdesign.net/wildAtHeart/
:)http://www.ipwebdesign.net/kaelisSpace/
:)----------------------------------------------------

-- 
Hemant Shah                           /"\  ASCII ribbon campaign
E-mail: NoJunkMailshah@xnet.com       \ /  --------------------- 
                                       X     against HTML mail
TO REPLY, REMOVE NoJunkMail           / \      and postings      
FROM MY E-MAIL ADDRESS.           
-----------------[DO NOT SEND UNSOLICITED BULK E-MAIL]------------------
I haven't lost my mind,                Above opinions are mine only.
it's backed up on tape somewhere.      Others can have their own.


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

Date: 16 Apr 2003 22:13:47 GMT
From: ctcgag@hotmail.com
Subject: Re: Subroutines:: Return Type Vs Performance
Message-Id: <20030416181347.641$no@newsreader.com>

"Kasp" <kasp@epatra.com> wrote:
> "Subroutines :: The flexibility of returning multiple values (eg in array
> context) imposes a performace penalty." Is this true?

Yes.  However, a substantial amount of this penalty has already been paid
the moment you decided to use Perl.  Perl already has the overhead
necessary to support multiple value returns, whether you actually use them
or not.

BTW, note that the wantarray function should have been named wantlist.

> Can someone please explain why the performance is going to be hit if I
> return for eg. 10 values instead of 1?

Because in order to return 10 values, you need to copy 10 things, and
10 is more than 1.  How much does this cost you?  Not much, I'm thinking.

And, if you come up with some clumsy way of returning one thing rather
than ten when returning ten things is the natural thing to do, the
clumsiness is likely to cost you more than you'll save.

Xho

-- 
-------------------- http://NewsReader.Com/ --------------------
Usenet Newsgroup Service              New Rate! $9.95/Month 50GB


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

Date: Thu, 17 Apr 2003 02:43:26 GMT
From: t.hales@unimelb.edu.au (Dr Trevor Hales)
Subject: Re: Temporary Folder
Message-Id: <3e9e145b.172216171@news.unimelb.edu.au>

On Tue, 15 Apr 2003 12:53:28 +0530, "Kasp" <kasp@epatra.com> wrote:

>How is your question is related to Perl?
I am trying to use the Perl Net::FTP module..
However, I am unable to undertake the double login so that I am
original anonymous / guest and using the user command re-login during
the same session as username/password.
Thanks.
Regards
Trevor

>
>%SystemRoot%\TEMP is what gives you the path to the TEMP folder in Windows.
>Also you might want to try "echo %TEMP% %TMP%"
>--
>"Accept that some days you are the pigeon and some days the statue."
>"A pat on the back is only a few inches from a kick in the butt." - Dilbert.
>
>
>
>



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

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


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