[8669] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 2286 Volume: 8

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Thu Apr 9 19:07:20 1998

Date: Thu, 9 Apr 98 16:01:39 -0700
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, 9 Apr 1998     Volume: 8 Number: 2286

Today's topics:
    Re: Q About Perl module and Data Structures (Andrew M. Langmead)
    Re: Q About Perl module and Data Structures (Joonas Timo Taavetti Kekoni)
    Re: question about &parse_form_data... (Jonathan Stowe)
        reading sh scripts to set environment variables <wdgreene@oracle.com>
    Re: RMS should be invited to O'Reilly's "Free Software  (Ilya Zakharevich)
    Re: RMS should be invited to O'Reilly's "Free Software  (Chris Adams)
    Re: RMS should be invited to O'Reilly's "Free Software  (Jeremy Allison)
    Re: RMS should be invited to O'Reilly's "Free Software  (Torsten Poulin Nielsen)
    Re: Running Perl CGI in a Personal Web Server. (Jonathan Stowe)
        spliting up long fields <sharwood@cs.uiowa.edu>
    Re: spliting up long fields (Jonathan Stowe)
    Re: Strange "Modification of a read-only value attempte <james.a.squire@boeing.com>
    Re: substituting text in a var (beginner question) (Jonathan Stowe)
    Re: substituting text in a var (beginner question) (Jason Gloudon)
    Re: system command (Jonathan Stowe)
    Re: system command (Craig Berry)
    Re: Tail-like functionality (Kees Hendrikse)
        Time::Local bug/weirdness? <mps@shellus.com>
    Re: UNIX, system(), and text that isn't output. (Jonathan Stowe)
    Re: Week of Month <dcameron@nospam.bcs.org.uk>
        Digest Administrivia (Last modified: 8 Mar 97) (Perl-Users-Digest Admin)

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

Date: Thu, 9 Apr 1998 21:06:44 GMT
From: aml@world.std.com (Andrew M. Langmead)
Subject: Re: Q About Perl module and Data Structures
Message-Id: <Er5zz9.J5z@world.std.com>

s2410377@techst02.technion.ac.il (Fliess Alon ) writes:

>My first question is:
>I am trying to create modules in PERL5. 
>I looked for it in some books and I can't figure out how it should work.
>Can anyone help me and show me the way to create modules.

There is a utility called h2xs that takes care of writing a lot of the
boilerplate stuff needed for a module. Its useful even if you aren't
making a module that uses XS.

     h2xs -AX -nMyModule

and then fill in MyModule/MyModule.pm. Anything you want visible to
the calling code put their name in the @EXPORT array, for things you
want optionally available, put in @EXPORT_OK. (For anything trickier,
take a look at the Exporter module.)

If you mean a module that links C functions to perl, still use h2xs to
create the module, but tell it which header file contains the
functions you want to use. Also take a look at the perlxs and
perlxstut man pages for details on the perl to C interface.

>My second question is:
>I know (from programming in C) how to create data structures and how to create array. In c it is very easy to combine them. (array of structures or pointers to structures). How can it be done in Perl?

Take a look at the perlref, perllol and perldsc man pages. Then take a
look at perlref again, and it will make much more sense than it did
the first time.
-- 
Andrew Langmead


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

Date: 9 Apr 1998 22:04:01 GMT
From: jkekoni@cc.hut.fi (Joonas Timo Taavetti Kekoni)
Subject: Re: Q About Perl module and Data Structures
Message-Id: <6gjgkh$t6u$1@hiekkalaatikko.cs.hut.fi>

Jean-Damien Durand (ddurand@hpplus11.cern.ch) wrote:
:   man perlmod
:   man perldata
:   Well, I think that 'man perl' will redirect you too all info you need.
how about shuting this group down ?

, but seriously one more man page:
man Class::Struct

and here is quite incomplete example that uses
packages in conjuction with Structs.

---
#!/usr/bin/perl -w
#
#
#       this is a container class for free form tree
#

package Tree;
use strict;
use Class::Struct;

struct( l_item =>     {   name=>'$',    # name here
                          httplink=>'$',# http here
                          pointer=>'$', # pointers to another if any
                      }
      );

struct(  level => [ items=>'@', #item[]
                   nameto=>'%',
                   current=>'$',
                 ]
      );

##################################################
## the object constructor (simplistic version)  ##
##################################################
sub new()
{       my $pself=\new level;
        bless($pself);
        $$pself->current(0);
        #my $t=new l_item;
        return $pself;

}

sub add($$$;$)
{       my $self=shift(@_);
        my($name,$httplink,$pointer)=(@_);

        package main;
                my $litem= new l_item ;
        package Tree;

        $litem->name($name);
        $litem->httplink($httplink);
        $litem->pointer("");
        $litem->pointer($pointer) if(defined $pointer );
        push (@{$$self->items()},$litem);
}
#!/usr/bin/perl -w
#
#
#       this is a container class for free form tree
#

package Tree;
use strict;
use Class::Struct;

struct( l_item =>     {   name=>'$',    # name here
                          httplink=>'$',# http here
                          pointer=>'$', # pointers to another if any
                      }
      );

struct(  level => [ items=>'@', #item[]
                   nameto=>'%',
                   current=>'$',
                 ]
      );

##################################################
## the object constructor (simplistic version)  ##
##################################################
sub new()
{       my $pself=\new level;
        bless($pself);
        $$pself->current(0);
        #my $t=new l_item;
        return $pself;

}

sub add($$$;$)
{       my $self=shift(@_);
        my($name,$httplink,$pointer)=(@_);

        package main;
                my $litem= new l_item ;
        package Tree;

        $litem->name($name);
        $litem->httplink($httplink);
        $litem->pointer("");
        $litem->pointer($pointer) if(defined $pointer );
        push (@{$$self->items()},$litem);
}
sub addsub($$;$)
{       my $self=${shift @_};
        my($sub_level,$num)=@_;

        unless( defined($num) )
        {       $num=$self->current;
        }
        if( ref( $sub_level) ne "Tree" )
        {       print "INVALID ITEM: ".$sub_level."*\n";
        }
        #my $a=$self->items;
        #$$a[$num]->pointer($sub_level);
        ${$self->items}[$num]->pointer($sub_level);

}


sub printall($;$)
{       my $self=${shift @_};
        my ($count)=@_;
        $count=0 unless( defined $count );

        foreach $_ (@{$self->items} )
        {       print ">" x $count.$_->name."=". $_->name."\n";
                if( ref( $_->pointer ) )
                {       $_->pointer()->printall($count+1);
                }
        }
}

1;  # so the require or use succeeds

-- 
	_-  Joonas Kekoni       OH2MTF	    I                           -_
	_-internet:	jkekoni@cc.hut.fi   I       DO NOT EAT.         -_
	_-slowmail:	j{mer{ntaival 7a176 I                           -_
	_-		02150Espoo          I      It is a monitor      -_
	_-		Finland/Europe      I                           -_


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

Date: Thu, 09 Apr 1998 01:33:26 GMT
From: Gellyfish@btinternet.com (Jonathan Stowe)
Subject: Re: question about &parse_form_data...
Message-Id: <352c0867.90643111@news.btinternet.com>

On Thu, 09 Apr 1998 11:06:09 -0400, David Swain <dswain@thetsn.com>
wrote:

<snip code>
>...The error I get when running it off the server is:
>Undefined subroutine &main::parse_form_data called at secure.cgi line 3
>
>so my question is...what is parse_form_data, isn't is included with
>Perl?  I have version 5.003, on red hat linux box.  This has been a big
<etc>

I think you will find that the aforenamed function is actually
described in your book - in a kind of demonstration function library.
You will need to copy this into a file and then "require" it into your
script.

There is a  "standard" CGI library which is included with later
distributions of perl.  This is the module CGI.pm.  You may need to
get a perl 5.004 for whatever platform you are running on - I am not
entirely sure at what point this module came to be standard.

The CGI module comes with a shed-load of excellent documentation and
allows you to write a program without worrying overly with the CGI
implementation.

/J\ 
Jonathan Stowe
See the MetaFaq at http://www.btinternet.com/~gellyfish/resources/wwwfaq.htm


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

Date: Thu, 09 Apr 1998 14:18:40 -0700
From: William Greene <wdgreene@oracle.com>
Subject: reading sh scripts to set environment variables
Message-Id: <352D3B30.EDC5C4F0@oracle.com>

Hi,

I am attempting to read a series of bourne shell scripts to set
environment
variables inside the perl execution context.  I'm having trouble with
the
PATH variable, which is set via a loop:

for pathseg in `echo $PATH | sed "s/:/ /g"`
do
  if test -f "$pathseg/exec"    -o -f "$pathseg/exec3"  -o \
          -f "$pathseg/exec2" -o -f "$pathseg/exec4" -o \
          -f "$pathseg/exec5"; then
    if test -f "$pathseg/dirname"; then
      forpath="$forpath:$pathseg"
    fi
  else
    forpath="$forpath:$pathseg"
  fi
done

PATH="$forpath"
export PATH


Any suggestions for interpreting this set of commands?


Thanks,




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

Date: 9 Apr 1998 21:30:44 GMT
From: ilya@math.ohio-state.edu (Ilya Zakharevich)
Subject: Re: RMS should be invited to O'Reilly's "Free Software Summit"
Message-Id: <6gjem4$f61$1@mathserv.mps.ohio-state.edu>

[A complimentary Cc of this posting was sent to Stefaan A Eeckels
<Stefaan.Eeckels@ecc.lu>],
who wrote in article <6giid7$2j0$1@justus.ecc.lu>:

> People writing software they want to share with other people,
> and assure that their work will remain accessible, should
> use the GPL. 

Wrong.  They should use AL or BSD-type license.  Fortunately, I know
only one piece of fine software which uses GPL and does not come from
FSF, and it is EMX.

> Better still, they should assign the copyright to
> the FSF. I'm quite sure (I'd bet my last dollar on that) RMS
> and the FSF will never pull a TOG on us.

This is absolutely irrelevant, since putting GPL on your software
makes it useless for a significant fraction of usages, and severy
cripples those usages that are allowed.

> Think about this - would you rather have GPL'd software maintained
> and serviced by programmers, or Microsoft bloatware with regular,
> expensive, incompatible updates, maintained and serviced by the
> cheapest people MS can employ in their 'Customer Service' 
> department?

People who resolve to use arguments like this one show they are not up
to the argument.  I will prefer AL and BSD-L to both situations.

Ilya


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

Date: 9 Apr 1998 22:16:30 GMT
From: cadams@ro.com (Chris Adams)
Subject: Re: RMS should be invited to O'Reilly's "Free Software Summit"
Message-Id: <6gjhbu$k1f$1@news.ro.com>

According to Ilya Zakharevich <ilya@math.ohio-state.edu>:
>This is absolutely irrelevant, since putting GPL on your software
>makes it useless for a significant fraction of usages, and severy
>cripples those usages that are allowed.

How does the GPL make software useless?
-- 
Chris Adams - cadams@ro.com
System Administrator - Renaissance Internet Services
I don't speak for anybody but myself - that's enough trouble.


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

Date: Thu, 9 Apr 1998 22:20:54 GMT
From: jeremy@netcom.com (Jeremy Allison)
Subject: Re: RMS should be invited to O'Reilly's "Free Software Summit"
Message-Id: <jeremyEr63Eu.3tv@netcom.com>

ilya@math.ohio-state.edu (Ilya Zakharevich) writes:

>Wrong.  They should use AL or BSD-type license.  Fortunately, I know
>only one piece of fine software which uses GPL and does not come from
>FSF, and it is EMX.

Hmmmm. Samba (which I help write) is generally considered to be
(sorry for tooting our own horn here :-) 'fine software' (At
least a lot of the Fortune 500 companies who use it say nice
things about it on our survey page :-).

It uses the GPL and has nothing to do with the FSF.

>This is absolutely irrelevant, since putting GPL on your software
>makes it useless for a significant fraction of usages, and severy
>cripples those usages that are allowed.

How does having the GPL on Samba make it useless for your use ?
You can still serve MS clients with it - you can sell it, you
can even add a proprietary GUI front end (people have). The 
only thing you can't do is make proprietary changes. How does 
this hurt you ?

Jeremy Allison,
Samba Team.


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

Date: 9 Apr 1998 22:26:58 GMT
From: torsten@diku.dk (Torsten Poulin Nielsen)
Subject: Re: RMS should be invited to O'Reilly's "Free Software Summit"
Message-Id: <slrn6iqiph.h6f.torsten@ask.diku.dk>

On 8 Apr 1998 05:45:30 GMT, Michael Funk <mwfunk@uncc.campus.mci.net> wrote:
>On 8 Apr 1998 04:18:54 GMT, Ilya Zakharevich <ilya@math.ohio-state.edu> wrote:

>>No it is not.  You are mixing "free" and "free".
>
>And doing so quite freely. :)

Which you are of course free to do (couldn't help it, sorry).

-Torsten


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

Date: Thu, 09 Apr 1998 01:33:23 GMT
From: Gellyfish@btinternet.com (Jonathan Stowe)
Subject: Re: Running Perl CGI in a Personal Web Server.
Message-Id: <352bf9df.87019105@news.btinternet.com>

On Wed, 8 Apr 1998 18:47:36 -0500, "Rich Dickeson" <rcdick@radiks.net>
wrote:

<snip>
>    Can anyone shed somelight on Frontpage 98 and Perl Scripts!!
>
Forget about Frontpage '98.  OK it has created your cgi-bin for you
etc ... On win32 you need to do the same thing to run perl as CGI as
you would to run a .bat file or a QBasic program or a Tcl or python
script.  You need to add some stuff to your registry.  

I would suggest looking at comp.infosystems.www.servers.ms-windows for
a while where this *must* be a FAQ.  Alternatively you might try
searching www.microsoft.com for "Script map".

/J\ 
Jonathan Stowe
See the MetaFaq at http://www.btinternet.com/~gellyfish/resources/wwwfaq.htm


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

Date: Thu, 09 Apr 1998 15:43:06 -0500
From: shane michael harwood <sharwood@cs.uiowa.edu>
Subject: spliting up long fields
Message-Id: <352D32DA.2781@cs.uiowa.edu>

hi,
i have a script that emails results from a form
back to me...but the problem is one of the fields in the 
form is a text box and can span many lines...and the 
script is just putting htis whole field on one line when
it emails it....so i am wondering if there is a way to 
automatically split up this field so that it spans many lines?


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

Date: Thu, 09 Apr 1998 01:59:03 GMT
From: Gellyfish@btinternet.com (Jonathan Stowe)
Subject: Re: spliting up long fields
Message-Id: <352c270e.98017067@news.btinternet.com>

On Thu, 09 Apr 1998 15:43:06 -0500, shane michael harwood
<sharwood@cs.uiowa.edu> wrote:

No really Text::Wrap

/J\
Jonathan Stowe
See the MetaFaq at http://www.btinternet.com/~gellyfish/resources/wwwfaq.htm


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

Date: Thu, 9 Apr 1998 22:19:29 GMT
From: James A Squire 312 M 193884 <james.a.squire@boeing.com>
Subject: Re: Strange "Modification of a read-only value attempted" error
Message-Id: <352D4971.5337@boeing.com>

M.J.T. Guy wrote:
> 
> James A Squire 312 M 193884  <james.a.squire@boeing.com> wrote:
> >
> >In the meantime, if I "use diagnostics" as was suggested in the
> >WELCOME message I got after my first post to this group, will perl
> >actually tell me which entity on line 302 (or whatever) it thinks is
> >the read-only value instead of just giving me the line number?  That
> >additional information might help me.  I'm just guessing it was
> >talking about the array, but I could be wrong.
> 
> No.  I'm afraid Perl currently doesn't remember which the offending
> value was.

Confirmed.  All diagnostics gives you is the same text as what is in the
documentation.

> Your best hope is to run under the debugger, setting a breakpoint at
> the offending line.   Then sniff at each of the values involved to try
> to identify the culprit.

Tried that and got nowhere.

However, I just found a suitable sub-example which does duplicate the
problem, and after further investigation I have discovered that Oraperl
is causing the problem, because when I take that out of my sub-example,
all of a sudden everything works fine.  Even with Oraperl in the mix, if
I take the corresponding command line option and move it to the
beginning of the command line options, that also causes it to work
(i.e., if I rearrange the command line options to my script it works
even with Oraperl).

<sigh>  I think I have a workaround, but I have no clue what it is that
Oraperl is clobbering or how it is clobbering it.
-- 
James Squire             Send my Spam to mailto:webmaster@cyberpromo.com
MDA^H^H^HBoeing St. Louis                          http://www.boeing.com
------------------------------------------------------------------------
Hey Novell, is it too much to ask that when I log out of NetWare, it
should ACTUALLY record that I've logged out, so that it doesn't have to
scramble around the house laboriously when I try to log back in, forcing
me to ring the door bell 20 times??????
Opinions expressed here are my own and NOT my company's
------------------------------------------------------------------------
"We were talking the other day about how nobody's seen a Vorlon before
 and he said that according to legend, one human did see a Vorlon...he
 turned to stone."
	-- Laurel Takeshima, "The Gathering"


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

Date: Thu, 09 Apr 1998 01:59:05 GMT
From: Gellyfish@btinternet.com (Jonathan Stowe)
Subject: Re: substituting text in a var (beginner question)
Message-Id: <352c280d.98272194@news.btinternet.com>

On Thu, 09 Apr 1998 14:11:32 -0600, jf@medianook.com wrote:

<snip>

>###
>$referer=$ENV{"HTTP_REFERER"};
This is a different name to the one you refer below
>$hiddenreferrer="<INPUT TYPE=\"hidden\" NAME=\"myreferrer\" VALUE=\
>"$myreferer\">";
>###
>

$hiddenreferrer="<INPUT TYPE='hidden' NAME='myreferrer' VALUE='" .
$myreferrer . "'>";

Perhaps.

/J\
Jonathan Stowe
See the MetaFaq at http://www.btinternet.com/~gellyfish/resources/wwwfaq.htm


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

Date: Thu, 09 Apr 1998 22:26:16 GMT
From: jgloudon@manitoba.bbn.com (Jason Gloudon)
Subject: Re: substituting text in a var (beginner question)
Message-Id: <slrn6iqij7.3vq.jgloudon@manitoba.bbn.com>

jf@medianook.com <jf@medianook.com> wrote:
 .
>$referer=$ENV{"HTTP_REFERER"};
>$hiddenreferrer="<INPUT TYPE=\"hidden\" NAME=\"myreferrer\" VALUE=\
>"$myreferer\">";
   ^^^^^^^^^ What's the connection between this and $referrer ?
 .
>###
>
>Then, in my template file, I place:

How are you outputting this template ? $hiddenreferrer should contain
the value of $myreferer based on what you have above

-- 
Jason Gloudon


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

Date: Thu, 09 Apr 1998 01:58:59 GMT
From: Gellyfish@btinternet.com (Jonathan Stowe)
Subject: Re: system command
Message-Id: <352c26a4.97910787@news.btinternet.com>

On Thu, 09 Apr 1998 15:11:13 -0500, shane michael harwood
<sharwood@cs.uiowa.edu> wrote:

Text::Wrap ?

/J\
Jonathan Stowe
See the MetaFaq at http://www.btinternet.com/~gellyfish/resources/wwwfaq.htm


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

Date: 9 Apr 1998 22:49:03 GMT
From: cberry@cinenet.net (Craig Berry)
Subject: Re: system command
Message-Id: <6gjj8v$33t$1@marina.cinenet.net>

shane michael harwood (sharwood@cs.uiowa.edu) wrote:
: i have a perl script to read a form and then print it to a file.. my
: problem is that one of the fields in the form is a text box and can span
: for many lines.  is there anyway to get the script to format this field
: so that when it prints to the file that it spans many lines and not just
: long line???  
: There is the the fold system command which does basically what i want to
: happen..so is there anyway to call fold?

A better idea is to use Text::Wrap.

---------------------------------------------------------------------
   |   Craig Berry - cberry@cinenet.net
 --*--    Home Page: http://www.cinenet.net/users/cberry/home.html
   |      Member of The HTML Writers Guild: http://www.hwg.org/   
       "Every man and every woman is a star."


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

Date: Thu, 9 Apr 1998 22:24:58 GMT
From: kees@echelon.nl (Kees Hendrikse)
Subject: Re: Tail-like functionality
Message-Id: <Er63LM.p4@echelon.nl>

In <Er3MzG.HE@world.std.com> aml@world.std.com (Andrew M. Langmead) writes:

> kees@echelon.nl (Kees Hendrikse) writes:
> 
> >I'm looking for a way to add unix-like tail functionality to a perl
> >script. As I'm only interested in the last 10-20 lines of output,
> 
> How about instead of print()ing, saying:
> 
> push @output, $line;
> shift @output if @output > 20;
> 
> (maybe "shift @output while @output > 20" as defensive programming)
> 
> and at the end, simply
> 
> print @output;

Thanks, this idea was just what I needed. To make it work, you have to
take into account the length of the lines, as $#output increases by
the length of $line, not by 1. Luckily, my lines are all of equal length,
so this works fine:
	$length = 73;
	$tail = 10;
	push @output, $line;
	shift @output while @output > $length * $tail;

-- 
Kees Hendrikse                               | email:     kees@echelon.nl
                                             | web:        www.echelon.nl
ECHELON consultancy and software development | phone: +31 (0)53 48 36 585
PO Box 545, 7500AM Enschede, The Netherlands | fax:   +31 (0)53 43 37 415


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

Date: Thu, 09 Apr 1998 16:19:29 -0500
From: Matt Sisk <mps@shellus.com>
Subject: Time::Local bug/weirdness?
Message-Id: <352D3B61.D01AA168@shellus.com>

I'm getting inconsistent values from Time::Local on two version of perl.

Can anyone explain/repeat the following on the same machine?  The
machine is a:

  SunOS 5.5.1 sun4m sparc SUNW,SPARCstation-20

The older release of perl is version 5.003, and the newest is version
5.004_60.

The script looks like this:

   use Time::Local;
   # March 7, 98, my bday - arbitrary date
   $time = timelocal(0,0,0,7,3,98); 
   @lt = localtime($time);
   print join(',',@lt),"\n";
   # Recalculate - except make it the 1st of the month.
   $lt[3] = 1;
   $tltime=timelocal(@lt);
   print "  time: $time\ntltime: $tltime\n";

The older version of perl produces:

   0,0,0,7,3,98,2,96,1
     time: 891925200
   tltime: 891403200

And the newer version of perl produces:

   0,0,0,7,3,98,2,96,1
     time: 891925200
   tltime: 891410400

As you can see, timelocal gives different values.  7200 seconds is the
difference, or 2 hours.  This behavior didn't surface in my applications
until recently, and given that it's 2 hours that are involved I am
suspicious of something having to do with daylight savings time.

Any ideas/corroboration would be appreciated.

-- 
Matt Sisk                           mps@shellus.com


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

Date: Thu, 09 Apr 1998 01:33:32 GMT
From: Gellyfish@btinternet.com (Jonathan Stowe)
Subject: Re: UNIX, system(), and text that isn't output.
Message-Id: <352c1660.94082076@news.btinternet.com>

On Wed, 08 Apr 1998 15:47:41 -0700, Nathaniel Meyers
<Nathaniel.Meyers@ucop.edu> wrote:

<snip>
>
>Sometimes UNIX commands write to the screen and this is not regular
>output (usually error or status messages)....

<snip>

You might want to see the item in perlfaq8  entitled:

 How can I capture STDERR from an external command?
 
Which will give you a number of options.

/J\
Jonathan Stowe
See the MetaFaq at http://www.btinternet.com/~gellyfish/resources/wwwfaq.htm


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

Date: 9 Apr 1998 21:33:54 GMT
From: "Duncan Cameron" <dcameron@nospam.bcs.org.uk>
Subject: Re: Week of Month
Message-Id: <01bd63ff$2bc9d5e0$053763c3@dns.btinternet.com>

Brian

If all you want is days 1-7 to be week 1, days 8-14 to be week 2 etc then,
in a non-Perl language with integer arithmetic, you want:

week = ((day-1)/7)+1

You can force Perl to do integer arithmetic by, I think, use Integer which
applies to the end of the enclosing block.  There is also the int function
which returns the integer portion of an expression.

I would guess that floating point arithmetic shouldn't be a problem on
numbers of this scale so: 

$week = int(($day - 1) / 7) + 1;

HTH
-- 
Remove 'nospam.' to get my return address.

Brian Rankin <brankin@wested.org> wrote in article
<352D07FC.B4EA94BF@wested.org>...
> I need to calculate the week of month for any given date, i.e.:
> 
> April 5 = week1
> April 12 = week 2
> April 19 = week 3
> April 26 = week 4
> 
> I've done this thru a rather clumsy script; any better scripting ideas
> would be greatly appreciated:
> 
> use Date::Manip;
> $now_string= localtime;
> $now_string=&DateCalc("7 days ago", $now_string, \$err);
> $wday = UnixDate($now_string, '%d');
> ## get week of month in $num
> $test=$wday/7;
> ($num, $extra) = split(/\./, $test);
> if ($extra) { $num++; }
> 
> Brian Rankin
> 
> 
> 


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

Date: 8 Mar 97 21:33:47 GMT (Last modified)
From: Perl-Request@ruby.oce.orst.edu (Perl-Users-Digest Admin) 
Subject: Digest Administrivia (Last modified: 8 Mar 97)
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.misc (and this Digest), send your
article to perl-users@ruby.oce.orst.edu.

To submit articles to comp.lang.perl.announce, send your article to
clpa@perl.com.

To request back copies (available for a week or so), send your request
to almanac@ruby.oce.orst.edu with the command "send perl-users x.y",
where x is the volume number and y is the issue number.

The Meta-FAQ, an article containing information about the FAQ, is
available by requesting "send perl-users meta-faq". The real FAQ, as it
appeared last in the newsgroup, can be retrieved with the request "send
perl-users FAQ". Due to their sizes, neither the Meta-FAQ nor the FAQ
are included in the digest.

The "mini-FAQ", which is an updated version of the Meta-FAQ, is
available by requesting "send perl-users mini-faq". It appears twice
weekly in the group, but is not distributed in the digest.

For other requests pertaining to the digest, send mail to
perl-users-request@ruby.oce.orst.edu. Do not waste your time or mine
sending perl questions to the -request address, I don't have time to
answer them even if I did know the answer.


------------------------------
End of Perl-Users Digest V8 Issue 2286
**************************************

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