[16844] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 4256 Volume: 9

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Fri Sep 8 06:05:30 2000

Date: Fri, 8 Sep 2000 03:05:14 -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: <968407513-v9-i4256@ruby.oce.orst.edu>
Content-Type: text

Perl-Users Digest           Fri, 8 Sep 2000     Volume: 9 Number: 4256

Today's topics:
        Adding dir's to @INC? <jpmeyer@uiuc.edu>
    Re: Adding dir's to @INC? (Rafael Garcia-Suarez)
    Re: Alta-Vista Remarq Access? Now costs 13.95 a Month? <kozloffNOkoSPAM@freewwweb.com.invalid>
    Re: Bug in perl 5.005_03 or 5.003_01? ("my" and loops) (Villy Kruse)
    Re: CGI.pm, taint & use strict?? <godzilla@stomp.stomp.tokyo>
    Re: CGI.pm, taint & use strict?? (Gwyn Judd)
    Re: CGI.pm, taint & use strict?? <godzilla@stomp.stomp.tokyo>
        copying multidimensional arrays <heydenreich@delta.de>
    Re: copying multidimensional arrays <uackermann@orga.com>
    Re: Export data to an Excel spreadsheet? mcnam@my-deja.com
    Re: Help Wanted: Perl modify job (Eric Bohlman)
        How can I extract files from a file? I'm using linux. richard@foxworth.com
    Re: How can I extract files from a file? I'm using linu <uackermann@orga.com>
        how can I tell the internet speed of visitor <nospam.tom@hotmail.com>
    Re: How to delete line #1 <heydenreich@delta.de>
    Re: how to restart apache (Rafael Garcia-Suarez)
        How to use a date (i.e. "Aug 1 2000") in utime? (Otto Wyss)
    Re: How to use a date (i.e. "Aug 1 2000") in utime? aqutiv@my-deja.com
    Re: Last day of month (David Wall)
    Re: Last day of month (Craig Berry)
    Re: Last day of month <stephenk@cc.gatech.edu>
    Re: Last day of month (Ilya Zakharevich)
    Re: Last day of month <anmcguire@ce.mediaone.net>
    Re: Last day of month (Abigail)
        last in a sub taking effect in caller <rajasankark@my-deja.com>
    Re: London =?ISO-8859-1?Q?=A330=2D35K?= Perl Programmer <tony@pyxis.blackstar.co.uk>
    Re: memory leak with subroutine references <oliver.ebenhoeh@rz.hu-berlin.de>
        New Perl Tutorial - www.perltutor.com huw_watkins@my-deja.com
        ODBC, OLE, ADO, WTF?? <bcaligari@my-deja.com>
    Re: ODBC, OLE, ADO, WTF?? <bcaligari@my-deja.com>
        Digest Administrivia (Last modified: 16 Sep 99) (Perl-Users-Digest Admin)

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

Date: Thu, 07 Sep 2000 23:23:16 -0500
From: Joel Meyer <jpmeyer@uiuc.edu>
Subject: Adding dir's to @INC?
Message-Id: <XLZt5.1061$Aq4.18057@vixen.cso.uiuc.edu>

Hi,

I recently installed Perl version 5.6 (I had been running 5.003_05 or
something like that) and when I execute certain programs I get an error
message telling me:

Can't locate somemodule.pm in @INC (@INC contains:
/usr/lib/perl5/5.005/i386-linux /usr/lib/perl5/5.005
/usr/local/lib/site_perl/i386-linux /usr/local/lib/site_perl
/usr/lib/perl5 .) at /usr/local/whatever line 12.

Is there a way to add directories to the @INC variable (permanently, not
every time some program runs)?  I found the lib module, but I don't know
if this will do what I want.

Thanks for your help.
Joel



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

Date: Fri, 08 Sep 2000 07:07:20 GMT
From: rgarciasuarez@free.fr (Rafael Garcia-Suarez)
Subject: Re: Adding dir's to @INC?
Message-Id: <slrn8rh4cs.64g.rgarciasuarez@rafael.kazibao.net>

Joel Meyer wrote in comp.lang.perl.misc:
>
>Is there a way to add directories to the @INC variable (permanently, not
>every time some program runs)?  I found the lib module, but I don't know
>if this will do what I want.

Define the PERLLIB environment variable, described in the perlrun
manpage.

-- 
Rafael Garcia-Suarez | http://rgarciasuarez.free.fr/


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

Date: Thu, 07 Sep 2000 22:51:02 -0700
From: Kozlovia <kozloffNOkoSPAM@freewwweb.com.invalid>
Subject: Re: Alta-Vista Remarq Access? Now costs 13.95 a Month?
Message-Id: <043f6adc.261298a6@usw-ex0107-049.remarq.com>

critical path bought RemarQ last january and is now MURDERing the
format for free usenet postings! Try a FREE one at http://newsone.net
who welcomes x-remarquers!


* Sent from Novell Discussion Forums http://novell.remarq.com The Internet's Discussion Network *
The fastest and easiest way to search and participate in Usenet - Free!



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

Date: 8 Sep 2000 07:31:08 GMT
From: vek@pharmnl.ohout.pharmapartners.nl (Villy Kruse)
Subject: Re: Bug in perl 5.005_03 or 5.003_01? ("my" and loops)
Message-Id: <slrn8rh5dr.8ga.vek@pharmnl.ohout.pharmapartners.nl>

On 08 Sep 2000 01:00:34 GMT, Abigail <abigail@foad.org> wrote:
>
>I don't understand. How could it print every other member? What would
>happen with the 2 for instance? shift() shifts of the first element.
>And since all elements that are shifted off are printed, how could you
>ever print the third element, and not the second?
>
>You don't remove the "next" member. You always remove the first one.
>That's what shift does - shift isn't relative to $_.
>
>Perhaps this will illustrate:
>
>    my @test_array = (1 .. 6);
>    foreach (@test_array) {
>        print "$_ ", shift (@test_array), "\n";
>    }
>    __END__
>    1 1
>    3 2
>    5 3
>
>


Could be foreach traverses the array using an index, so first iteration
would be the first element == 1, and the second iteration would use the
second element, now == 3 after the shift.


my @test_array = (1 .. 6);
for (my $ix = 0; defined $test_array[$ix]; $ix++ ) {
       $_ = $test_array[$ix];
       print "$_ ", shift (@test_array), "\n";
}
__END__
1 1
3 2
5 3



-- 
Villy


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

Date: Thu, 07 Sep 2000 22:30:28 -0700
From: "Godzilla!" <godzilla@stomp.stomp.tokyo>
Subject: Re: CGI.pm, taint & use strict??
Message-Id: <39B87974.7CF710F1@stomp.stomp.tokyo>

Pasquale wrote:

(snipped)

> Written this way, it will not work, but if I replace the "-T" with "-w"
> on the shebang line, it works fine.  I don't understand what perl sees
> is "tainted"?

> 1. Can "CGI.pm", "taint", & "use strict" be used together as above?
> 2. Can I use both "-w" & "-T" on the shebang line?
> 3. Can I use the %formdata parsing script(ie: require "formParse.pl";)

> with "use strict" & "-T" to parse the form information instead of using
> CGI.pm? When I was using this, I had the taint check working fine, but
> when I introduced "use strict" I had problems.
 
> Any suggestions on what to do or what to read would be much appreciated.
> I have been searching and reading, reading and searching, but I haven't
> found information to answer these questions.


A suggestion rather than a technical answer.

You will learn more and be a superior programmer to almost all
other Perl programmers, if you learn to write programs which
are safe and secure, without using cgi-pm/taint. Takes nothing
more than a bit of research, testing and, some hard work.

In a final analysis, by learning how to write sound programs
without a need for taint checking, strict and all that other
mule manure, you will discover you can write a read/parse 
routine and address security very well, in fifty lines of 
code or less, where cgi-pm uses well over six-thousand lines 
of code to perform the same. You will also discover how
most modules, pragma hints and the such, are useless. They
serve no real purpose to a talented programmer save for
a small handful of exceptions. 

Not only will you learn how to write short, lightning fast, 
safe and secure scripts, you will enjoy significant personal
pride in knowing, "I am a talented Perl programmer."

A spinoff of becoming a talented well learned programmer,
is you will avoid a myriad headaches given to you by
use of modules, especially cgi-pm.


Godzilla!
--
@© = (a .. z); @® = qw (7 15 4 26 9 12 12 1 18 15 3 11 19);
srand(time() ^ ($$ + ($$ << 15))); for ($§ = $®[$®[0]]; $§ < $®[0]; $§++)
{ sub G { rand(1000) < 500 ? "\u$1" : "\l$1" ; } foreach $¿ (@®) 
{ $¢ = $©[$¿-1]; $¢ =~ s¡([a-z])¡G($1)¡gie; $Ø = "$Ø$¢"; }
$Ø ="$Ø! "; $ø = substr ($Ø, $®[12] - $®[11], 0, " ");
$Ø =~ s¯(a)(r)¯$1 $2¯i; push (@Ø,$Ø); } foreach $¡ (@Ø)
{ print "$¡\n"; } @¶ = reverse (@Ø); foreach $¶ (@¶)
{ print "$¶\n"; } exit;


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

Date: Fri, 08 Sep 2000 05:56:43 GMT
From: tjla@guvfybir.qlaqaf.bet (Gwyn Judd)
Subject: Re: CGI.pm, taint & use strict??
Message-Id: <slrn8rgvso.6gp.tjla@thislove.dyndns.org>

I was shocked! How could Pasquale <pdmos23@geocities.com>
say such a terrible thing:
>Snippet of code:

<snip>

>Written this way, it will not work, but if I replace the "-T" with "-w"
>on the shebang line, it works fine.  I don't understand what perl sees
>is "tainted"?

You need to read the documentation. Type:

perldoc perlsec

at the command line.

>1. Can "CGI.pm", "taint", & "use strict" be used together as above?

yes

>2. Can I use both "-w" & "-T" on the shebang line?

yes (that is to say, perl doesn't care, your operating system might from
what it says in perlsec)

>3. Can I use the %formdata parsing script(ie: require "formParse.pl";)
>with "use strict" & "-T" to parse the form information instead of using
>CGI.pm? When I was using this, I had the taint check working fine, but
>when I introduced "use strict" I had problems.

Well that depends, -T doesn't really care what you do, it just checks on
your data and how you use it and all sorts of other stuff.

-- 
Gwyn Judd (print `echo 'tjla@guvfybir.qlaqaf.bet' | rot13`)
If any man wishes to be humbled and mortified, let him become president
of Harvard.
		-- Edward Holyoke


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

Date: Fri, 08 Sep 2000 00:58:34 -0700
From: "Godzilla!" <godzilla@stomp.stomp.tokyo>
Subject: Re: CGI.pm, taint & use strict??
Message-Id: <39B89C2A.DC4EEF19@stomp.stomp.tokyo>

Nicked Condom wrote:

> Another example: in a recent discussion on multitasking she
> was surprised to discover that a CPU can only handle one task
> at a time.


You will be surprised to learn of your illiteracy.
Study this expression "CPU" quite well and you
may come to realize it is a context sensitive
term and, your reading comprehension skills are
less than adequate, as often displayed by you.
Not too long back, D. Boy and Buttman displayed
this same degree of illiteracy regarding this
context sensitive word, CPU. Quite laughable.

Your article is ignorantly humorous. Some would say,

"You are a troll." 

My choice is to simply laugh at you and think to 
myself, 

"How sad this person has never bothered to attain
 a decent education. He consistently makes a first
 class fool of himself through illiteracy."


Godzilla!
--
Stereotypical Perl Monger.
  http://la.znet.com/~callgirl/monger.cgi


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

Date: Fri, 08 Sep 2000 11:40:04 +0200
From: Ralf Heydenreich <heydenreich@delta.de>
Subject: copying multidimensional arrays
Message-Id: <39B8B3F4.F5B30CA2@delta.de>

Hi,
at first some code:

while($condition)
{
	$index=0;
	@t=();
	push @t, $reftab, $schl;
	push @{ $reftabs[$index++] }, @t;
}

Now I have the two-dimensional array $reftabs. But, for some reasons I
have to pop the last element from reftabs and store it into another
variable:

$e=pop(@reftabs);

The question now is: how can I get my elements from $e ? If I try
something like print $e[0][0] I get an empty string.
Could you explain why?

[RH]


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

Date: Fri, 08 Sep 2000 11:49:57 +0200
From: Ulrich Ackermann <uackermann@orga.com>
Subject: Re: copying multidimensional arrays
Message-Id: <39B8B645.33FACFC7@orga.com>

Ralf Heydenreich wrote:
> 
> Hi,
> at first some code:
> 
> while($condition)
> {
>         $index=0;
>         @t=();
>         push @t, $reftab, $schl;
>         push @{ $reftabs[$index++] }, @t;
> }
> 
> Now I have the two-dimensional array $reftabs. But, for some reasons I
> have to pop the last element from reftabs and store it into another
> variable:
> 
> $e=pop(@reftabs);
> 
> The question now is: how can I get my elements from $e ? If I try
> something like print $e[0][0] I get an empty string.
> Could you explain why?
> 
> [RH]

Hi Ralf,
have you got the -w in your shebang line? And what about 'use strict;'?
Maybe the warnings you will receive could help you to fix it on your
own.

Ulrich
-- 
Ulrich Ackermann
ORGA Kartensysteme GmbH (SY-PEAT-STA)
Tel.:+49.5254.991-925 
mailto:uackermann@orga.com



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

Date: Fri, 08 Sep 2000 08:41:15 GMT
From: mcnam@my-deja.com
Subject: Re: Export data to an Excel spreadsheet?
Message-Id: <8pa8n8$1n2$1@nnrp1.deja.com>

In article <8p6lov$80$1@sun500.nas.nasa.gov>,
  "Joe Edgar" <jedgar@mail.arc.nasa.gov> wrote:
>
> I've got a program that displays a database in HTML.   My new
"assignment"
> is to let a user select certain fields of the database and then export
those
> fields to an excel spreadsheet.
> I've been trying to create a comma-separated-value (of the fields)
with a
> ".csv" extension, but that doesn't seem to work.
> I need the program to open an Excel spreadsheet and import the data
once the
> user clicks the submit button.


If you need to create a new Excel file have a look at the
Spreadsheet::WriteExcel module:

http://search.cpan.org/search?dist=Spreadsheet-WriteExcel

If you want to export the data to an existing Excel file you can use
Win32::OLE or DBI with the ODBC or ADO drivers.

John McNamara

--
before you die()


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


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

Date: 8 Sep 2000 05:58:42 GMT
From: ebohlman@netcom.com (Eric Bohlman)
Subject: Re: Help Wanted: Perl modify job
Message-Id: <8p9v6i$264$2@slb3.atl.mindspring.net>

Donna Zoerner (webmistress@net-aid.com) wrote:
: Hello,
: 
: I am looking for someone to modify a script(s) for me that I have
: running on a site http://www.net-aid.com/ for a reasonable price. Please

RFPs aren't appropriate in this group and, unlike offers for relatively 
permanent positions, aren't appropriate in jobs groups either.  Your best 
bet is probably to go to <URL:http://www.pm.org> and find a Perl Mongers 
group close to you and then get in touch with their contact person; they 
will likely have one or more people willing to give a quote for a project 
like this.

There *are* some Web sites specifically set up to let people with needs 
for one-off projects announce those needs.  The last time I checked them, 
I was rather unimpressed and therefore forgot the URLs to those sites, 
but a Google search on something like "perl freelance" should turn 
something up.



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

Date: Fri, 08 Sep 2000 05:40:37 GMT
From: richard@foxworth.com
Subject: How can I extract files from a file? I'm using linux.
Message-Id: <39b87c59.7045887@news.pnscla1.fl.home.com>

How can I extract files from a file? I'm using linux.
I need the cachefile name (or names if more than one) from the list
below that doesn't have a file extension to process though this
routine.

grep "SYMBOL=" filename | sed -n
'/SYMBOL=/s/^.*SYMBOL=\([A-Z0-9]*\).*/\1/p' | sort -u >> file

filename in the above script is what is needed for replacing each
time.

This Example File below was created with the following routine
extracting the lastest files from my Cache File:

find -mmin -5 > files
-------------------------------------------------------------------------------------------

 ./02
 ./02/cache39B7FE020A5032B.html
 ./03
 ./03/cache39B7F223061032B.JS
 ./1F
 ./1C
 ./1C/cache39B7FDFC0A0032B.shtml
 ./1C/cache39B7FDFC0A1032B.jpg
 ./1D
 ./1D/cache39B7FDFD0A2032B.GIF
 ./1D/cache39B7FDFD0A3032B.gif
 ./1D/cache39B7FDFD0A4032B.gif
 ./1A
 ./1A/cache39B7FDFA09F032B
 ./17
 ./15
 ./13
 ./10
 ./0D
 ./0F/cache39B7FDEF09D032B.gif
 ./0F/cache39B7FDEF09E032B.gif
 ./0C
 ./09
 ./06
 ./06/cache39B7FDE6089032B.gif
 ./06/cache39B7FDE608A032B.gif
 ./00
 ./00/cache39B7FDE0085032B
 ./14
 ./11
 ./11/cache39B7FE110B2032B.gif
 ./11/cache39B7FE110B3032B.class
 ./0E
 ./0E/cache39B7FDEE098032B.gif
 ./0E/cache39B7FF8E0BA032B
 ./0B
 ./0B/cache39B7FE0B0A6032B.gif
 ./0A
 ./07
 ./07/cache39B7FDE708F032B.gif
 ./07/cache39B7FDE7090032B.jpg
 ./07/cache39B7FDE7091032B.gif
 ./04
 ./01
 ./01/cache39B7FDE1086032B.js
 ./01/cache39B7FDE1087032B
 ./01/cache39B7FDE1088032B.gif
 ./1E
 ./1B
 ./18
-------------------------------------------------------------------


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

Date: Fri, 08 Sep 2000 08:53:00 +0200
From: Ulrich Ackermann <uackermann@orga.com>
Subject: Re: How can I extract files from a file? I'm using linux.
Message-Id: <39B88CCC.73EF6943@orga.com>

richard@foxworth.com wrote:
> 
> How can I extract files from a file? I'm using linux.
> I need the cachefile name (or names if more than one) from the list
> below that doesn't have a file extension to process though this
> routine.

*snipp*

> ./1D/cache39B7FDFD0A2032B.GIF
> ./1D/cache39B7FDFD0A3032B.gif
> ./1D/cache39B7FDFD0A4032B.gif
> ./1A
> ./1A/cache39B7FDFA09F032B

*snipp*

Hi Richard,
If the files you are looking for alwasy end up with hex numbers use a
regex for this. As far as I remember, there is an expression for hex
numbers in the most recent versions of perl (looks like [:xdigit:], I
think; see perldoc perlre).

Then this should do the work:

my @files = <CACHE_FILE>;
my @needed_files;
for (@files) {
	$_ =~ /(cache[:xdigit:]+)$/;
	push @needed_files, $1;
}

But I have not tested the code. Use with care.

HTH, Ulrich
-- 
Ulrich Ackermann
ORGA Kartensysteme GmbH (SY-PEAT-STA)
Tel.:+49.5254.991-925 
mailto:uackermann@orga.com



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

Date: Fri, 8 Sep 2000 15:20:08 +0800
From: Denson Tang <nospam.tom@hotmail.com>
Subject: how can I tell the internet speed of visitor
Message-Id: <MPG.142225e31062a8cd989688@news.newsguy.com>

I want to know the internet speed connection of a website visitor, how 
can I achieve that we PERL?


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

Date: Fri, 08 Sep 2000 11:47:15 +0200
From: Ralf Heydenreich <heydenreich@delta.de>
Subject: Re: How to delete line #1
Message-Id: <39B8B5A3.DD2F206E@delta.de>

Mike Grimes schrieb:
> 
> Howdy y'all,
> 
> I would like to delete the first line of a log file. Is there an expert who
> could give me some advide on how I might accomplish this?
> 
> I open a file for reading and writing, read each line and perform some
> operations then use seek to go back to the top of the file. Truncate deletes
> from the first line on. How can I then delete just the first line?
> 
> Appreciate any help,
> Mike

perhaps you can try this:

$firstflag=0;
open(FILE, "< yourlogfile.log");
open(NEWLOG, "> newlogfile.log");
while(<FILE>)
{
	next if( $firstflag++ == 0 );
	print NEWLOG $_;
}
close(NEWLOG);
close(FILE);


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

Date: Fri, 08 Sep 2000 07:03:12 GMT
From: rgarciasuarez@free.fr (Rafael Garcia-Suarez)
Subject: Re: how to restart apache
Message-Id: <slrn8rh453.64g.rgarciasuarez@rafael.kazibao.net>

Anthony Frost wrote in comp.lang.perl.misc:
>In message <slrn8rff6v.5af.rgarciasuarez@rafael.kazibao.net>
>          rgarciasuarez@free.fr (Rafael Garcia-Suarez) wrote:
>
> > Kirk R. Wythers wrote in comp.lang.perl.misc:
> > >Where does red hat put apachectl in a standard install? I know it's
> > >installed but I can't seem to find and apache/sbin dir.
> > 
> > perl -MFile::Find -e 'find(sub{/^apachectl$/&&print"$File::Find::name\n"},"/")'
> >
>
>Or...
>
>locate apachectl
>
>:-)

Yes, but in Perl newsgroups, Perl answers should be given to non-Perl
questions.

-- 
Rafael Garcia-Suarez | http://rgarciasuarez.free.fr/


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

Date: Fri, 8 Sep 2000 09:28:09 +0200
From: otto.wyss@bluewin.ch (Otto Wyss)
Subject: How to use a date (i.e. "Aug 1 2000") in utime?
Message-Id: <1egmqk4.ay4sxaoquy8oN%otto.wyss@bluewin.ch>

Probably a very simple question but neither "perldoc -q date" nor
"perldoc -f utime" gives any clue how to do it. 

In a more generalized form: How do I convert a date in string form to a
numeric date, possibly written in a localized manner (i.e. "1. Aug.
2000").

O. Wyss


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

Date: Fri, 08 Sep 2000 09:48:38 GMT
From: aqutiv@my-deja.com
Subject: Re: How to use a date (i.e. "Aug 1 2000") in utime?
Message-Id: <8pacli$5r5$1@nnrp1.deja.com>

In article <1egmqk4.ay4sxaoquy8oN%otto.wyss@bluewin.ch>,
  otto.wyss@bluewin.ch (Otto Wyss) wrote:
> Probably a very simple question but neither "perldoc -q date" nor
> "perldoc -f utime" gives any clue how to do it.
>
> In a more generalized form: How do I convert a date in string form to
a
> numeric date, possibly written in a localized manner (i.e. "1. Aug.
> 2000").
>
> O. Wyss
>

utime() does only accepts time in perl's time() format.
You can convert from localtime() format, which is more human, to time()
by using POSIX's mktime(), for example:

use POSIX;
print "it works\n" if mktime(localtime) == time;

which should always be true...

For a string, you could use some regular expressions to pull out the
time and date...
Try those:
perldoc perlre
perldoc -f time
perldoc -f localtime
perldoc POSIX




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


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

Date: 8 Sep 2000 00:06:07 -0400
From: darkon@one.net (David Wall)
Subject: Re: Last day of month
Message-Id: <8FA9D001darkononenet@206.112.192.118>

srhi@home.com (Me) wrote in 
<CHXt5.15138$AW2.194877@news1.rdc2.pa.home.com>:

>I wrote a Perl script (under Unix) that works well. Now, I
>would like it to do some special end of month reporting on
>the last day of each month. The trouble is that I can't seem to
>figure out how to use localtime to determine if "today" is the
>last day of the month. A search through the date modules on
>CPAN didn't prove enlightening. If anyone has a solution to
>this problem, please post it on this newsgroup or let me know.

Here's one that Abe Timmerman (I think) posted some time ago.  Give it the 
month and year and it returns the number of days in the month.

sub last_mday { #$month: 0..11; $year: CCYY
	my ($month, $year) = @_;
	( qw(31 0 31 30 31 30 31 31 30 31 30 31) )[$month] ||
		28 + (($year % 100 && !($year % 4))|| !($year % 400));
}

Works for me.  

-- 
David Wall
darkon@one.net


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

Date: Fri, 08 Sep 2000 04:12:46 GMT
From: cberry@cinenet.net (Craig Berry)
Subject: Re: Last day of month
Message-Id: <srgppug1ljn6@corp.supernews.com>

Stephen Kloder (stephenk@cc.gatech.edu) wrote:
: Just check if tomorrow is the first of the month:
: 
: if ((localtime(time()+60*60*24))[3] == 1) {
:   # end of month stuff
: }
: 
: perldoc -f localtime

This could conceivably run aground on DST issues, though not for current
US DST rules.

-- 
   |   Craig Berry - http://www.cinenet.net/~cberry/
 --*--  "Every force evolves a form."
   |              - Shriekback


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

Date: Fri, 08 Sep 2000 00:05:42 -0400
From: Stephen Kloder <stephenk@cc.gatech.edu>
Subject: Re: Last day of month
Message-Id: <39B86596.7B35A11D@cc.gatech.edu>

Logan Shaw wrote:

>
> >Just check if tomorrow is the first of the month:
> >
> >if ((localtime(time()+60*60*24))[3] == 1) {
> >  # end of month stuff
> >}
>
> If you want to be anal-retentive and consider the fact that not
> all days are 24 hours long, then you have to do something else.
>

This is irrelevant, since the only 2 days in the year that are not 24 hours
long are not at the beginning or end of the month.  Similarly, leap seconds
are too short and too rare to pose a problem.

--
Stephen Kloder               |   "I say what it occurs to me to say.
stephenk@cc.gatech.edu       |      More I cannot say."
Phone 404-874-6584           |   -- The Man in the Shack
ICQ #65153895                |            be :- think.




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

Date: 8 Sep 2000 06:08:46 GMT
From: ilya@math.ohio-state.edu (Ilya Zakharevich)
Subject: Re: Last day of month
Message-Id: <8p9vpe$rh4$1@charm.magnus.acs.ohio-state.edu>

[A complimentary Cc of this posting was sent to Stephen Kloder 
<stephenk@cc.gatech.edu>],
who wrote in article <39B86596.7B35A11D@cc.gatech.edu>:
> > If you want to be anal-retentive and consider the fact that not
> > all days are 24 hours long, then you have to do something else.
> >
> 
> This is irrelevant, since the only 2 days in the year that are not 24 hours
> long are not at the beginning or end of the month.  Similarly, leap seconds
> are too short and too rare to pose a problem.

Eh??!!!  The number of hours in a given day of the year is decided by
voting in appropriate political bodies (parlaments etc).  There is no
way to guarantee *anything* about this.

Ilya


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

Date: Fri, 8 Sep 2000 01:49:19 -0500
From: "Andrew N. McGuire " <anmcguire@ce.mediaone.net>
Subject: Re: Last day of month
Message-Id: <Pine.LNX.4.21.0009080148020.5430-100000@hawk.ce.mediaone.net>

On 8 Sep 2000, David Wall quoth:

~~ Date: 8 Sep 2000 00:06:07 -0400
~~ From: David Wall <darkon@one.net>
~~ Newsgroups: comp.lang.perl.misc
~~ Subject: Re: Last day of month
~~ 
~~ srhi@home.com (Me) wrote in 
~~ <CHXt5.15138$AW2.194877@news1.rdc2.pa.home.com>:
~~ 
~~ >I wrote a Perl script (under Unix) that works well. Now, I
~~ >would like it to do some special end of month reporting on
~~ >the last day of each month. The trouble is that I can't seem to
~~ >figure out how to use localtime to determine if "today" is the
~~ >last day of the month. A search through the date modules on
~~ >CPAN didn't prove enlightening. If anyone has a solution to
~~ >this problem, please post it on this newsgroup or let me know.
~~ 
~~ Here's one that Abe Timmerman (I think) posted some time ago.  Give it the 
~~ month and year and it returns the number of days in the month.
~~ 
~~ sub last_mday { #$month: 0..11; $year: CCYY
~~ 	my ($month, $year) = @_;
~~ 	( qw(31 0 31 30 31 30 31 31 30 31 30 31) )[$month] ||
~~ 		28 + (($year % 100 && !($year % 4))|| !($year % 400));
~~ }
~~ 
~~ Works for me.  

I am afraid this code is broken.

print &last_mday(8, 1752); # ;-)

anm
-- 
Andrew N. McGuire
anmcguire@ce.mediaone.net
perl -le'print map?"(.*)"?&&($_=$1)&&s](\w+)]\u$1]g&&$_=>`perldoc -qj`'



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

Date: 08 Sep 2000 06:59:41 GMT
From: abigail@foad.org (Abigail)
Subject: Re: Last day of month
Message-Id: <slrn8rh3h2.vlt.abigail@alexandra.foad.org>

Andrew N. McGuire  (anmcguire@ce.mediaone.net) wrote on MMDLXV September
MCMXCIII in <URL:news:Pine.LNX.4.21.0009080148020.5430-100000@hawk.ce.mediaone.net>:
== On 8 Sep 2000, David Wall quoth:
== 
== ~~ Here's one that Abe Timmerman (I think) posted some time ago.  Give it the
== ~~ month and year and it returns the number of days in the month.
== ~~ 
== ~~ sub last_mday { #$month: 0..11; $year: CCYY
== ~~ 	my ($month, $year) = @_;
== ~~ 	( qw(31 0 31 30 31 30 31 31 30 31 30 31) )[$month] ||
== ~~ 		28 + (($year % 100 && !($year % 4))|| !($year % 400));
== ~~ }
== ~~ 
== ~~ Works for me.  
== 
== I am afraid this code is broken.
== 
== print &last_mday(8, 1752); # ;-)


Even in England and its colonies, the last day of September 1752 was
the 30th. The most recent day the above code fails on is February 1700,
although it will be correct for that day in many parts of Western Europe.



Abigail
-- 
sub _ {$_ = shift and y/b-yB-Y/a-yB-Y/                xor      !@ _?
       exit print                                                  :
            print and push @_ => shift and goto &{(caller (0)) [3]}}
            split // => "KsvQtbuf fbsodpmu\ni flsI "  xor       & _


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

Date: Fri, 08 Sep 2000 08:30:17 GMT
From: Rajasankar <rajasankark@my-deja.com>
Subject: last in a sub taking effect in caller
Message-Id: <8pa82r$11u$1@nnrp1.deja.com>



Hi,

The following code breaks the 'while' loop in the caller.
Though the code is erroneous, the behavior looks odd.
Can't perl handle it in a better way?
Can't it just return from the function?


#-- start listing
sub func
{
 last;
}

$i = 20;
while ($i--)
{
  print $i;
  func();
}
print "After the loop\n";

#---End of listing


--
---------------------------
Raja


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


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

Date: Fri, 08 Sep 2000 09:25:26 GMT
From: Tony Bowden <tony@pyxis.blackstar.co.uk>
Subject: Re: London =?ISO-8859-1?Q?=A330=2D35K?= Perl Programmers Required
Message-Id: <ag2u5.7426$vo6.100947@news2-win.server.ntlworld.com>

Russ Jones <russ_jones@rac.ray.com> wrote:
> Since I only piss for two or three hours a day, I'd starve on that. 

That's 30 seconds every 5 minutes or so ...

You sure do piss a lot ...

Tony
-- 
-----------------------------------------------------------------------------
 Tony Bowden | tony@blackstar.co.uk               http://www.blackstar.co.uk/
  Black Star |    The UK's Biggest Video & DVD store * Free Postage Worldwide
-----------------------------------------------------------------------------


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

Date: Fri, 08 Sep 2000 10:42:48 +0200
From: Oliver =?iso-8859-1?Q?Ebenh=F6h?= <oliver.ebenhoeh@rz.hu-berlin.de>
Subject: Re: memory leak with subroutine references
Message-Id: <39B8A688.1B738C1C@rz.hu-berlin.de>

nobull@mail.com wrote:
> =

> Oliver Ebenh=F6h <oliver.ebenhoeh@rz.hu-berlin.de> writes:
> =

> >   my $rs;
> >   eval "\$rs =3D sub \{ ".$code."\}";
> =

> That is more tidily written as:
> =

>    my $rs =3D eval "sub { $code }";


Thanks! This does it!


> =

> > This works fine but somehow dereferencing does not seem to work.
> =

> I don't think you mean dereferencing, I think you mean garbage
> collection.
> =

> > When I enter something like (in my little shell):
> >
> > for($i=3D0;$i<1000;$i++){$f =3D $foo->to_sub}
> >
> > the memory used by the program increases by 4MB!
> =

> > Does someone know how to avoid this memory leak?
> =

> Are you running Perl with the -d switch?  This is a known bug in the
> debugger.  And no, short of not using the -d switch I don't know how
> to avoid it.
> =

> --
>      \\   ( )
>   .  _\\__[oo
>  .__/  \\ /\@
>  .  l___\\
>   # ll  l\\
>  ###LL  LL\\


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

Date: Fri, 08 Sep 2000 09:21:04 GMT
From: huw_watkins@my-deja.com
Subject: New Perl Tutorial - www.perltutor.com
Message-Id: <8pab1j$47f$1@nnrp1.deja.com>

Anyone new to Perl might find the following link useful:

http://perltutor.com

PerlTutor.com is a free Perl tutorial, mainly aimed at
complete newbies, but also possibly of use to those with
some experience in Perl.

It features Javascript quiz questions to test progress,
plus exercises with sample answers.

The tutorial is incomplete as yet, but I'm adding new
lessons at a rate of one or two per week.

There are currently twelve complete lessons:
Getting Started, Scalar Data, Operators, Control Structures,
Lists and Arrays, The $_ variable, Associative Arrays,
Command Line Arguments, Subroutines, Logical Operators,
Working with Files, File Test Operators.

I hope someone out there finds this useful!

Huw Watkins
--


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


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

Date: Fri, 08 Sep 2000 07:17:18 GMT
From: Brendon Caligari <bcaligari@my-deja.com>
Subject: ODBC, OLE, ADO, WTF??
Message-Id: <8pa3pl$rce$1@nnrp1.deja.com>



Suppose I have some nice scripts filtering tons of data that has to be
eventually imported into an table in a MS-Access db.  The problem as
usual lies as to where to get started!!!

Any pointing in a right direction is appreciated!!

Brendon
++++


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


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

Date: Fri, 08 Sep 2000 07:23:59 GMT
From: Brendon Caligari <bcaligari@my-deja.com>
Subject: Re: ODBC, OLE, ADO, WTF??
Message-Id: <8pa464$sns$1@nnrp1.deja.com>

In article <8pa3pl$rce$1@nnrp1.deja.com>,
  Brendon Caligari <bcaligari@my-deja.com> wrote:
>
>
> Suppose I have some nice scripts filtering tons of data that has to be
> eventually imported into an table in a MS-Access db.  The problem as
> usual lies as to where to get started!!!
>
> Any pointing in a right direction is appreciated!!
>
> Brendon
> ++++

forgot to add that i'm running win2k (sp1) and activestate perl build
617.  I have tried to go through the docs but all I got was a
headache...tried to use Win32::ODBC and failed miserably.

Brendon
++++





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


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

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


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