[7727] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 1353 Volume: 8

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Fri Nov 21 08:09:49 1997

Date: Fri, 21 Nov 97 05:00:54 -0800
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)

Perl-Users Digest           Fri, 21 Nov 1997     Volume: 8 Number: 1353

Today's topics:
     Re: (URGENT) How can i validate a date? (Steffen Beyer)
     Re: (URGENT) How can i validate a date? (Steffen Beyer)
     -w flag (Keith Willis)
     2 Dimensional Arrays - how? (Greg Wake)
     Re: 2 quicks questions, really <dformosa@st.nepean.uws.edu.au>
     Re: ^D not working <ged@fortec.tuwien.ac.at>
     Re: Accessing /usr/adm/binary.errlog from Perl (Keith Willis)
     Copy files <miran.sepic4@mss.tel.hr>
     Re: date (Steffen Beyer)
     Re: DBM-speed <markm@nortel.ca>
     Re: DBM-speed <mortensi@idt.ntnu.no>
     Re: giving up on flock <zenin@best.com>
     Grade the perlishness <robert.friberg@your_clothes.eductus-vast.com>
     Help: PERL -> mySQL database <eeikbn@eei.ericsson.se>
     Re: Here's a simple one <david.martin@biotek.uio.no>
     Re: How To Test if number is ODD or EVEN? <robert.friberg@your_clothes.eductus-vast.com>
     Re: Intermediary compiled perl? (Malcolm Beattie)
     Re: is it possible to reference a sub-array? <zenin@best.com>
     Re: JavaScript < -------- > Perl (CGI) <david.martin@biotek.uio.no>
     Mkdir - permissions <miran.sepic4@mss.tel.hr>
     open(), seek() and email monitoring <andrewe@technologyXchange.com>
     Perl and Sybase <gregs@bigfoot.com>
     Perl and Sybase <gregs@bigfoot.com>
     Problem with the editor (I think) <kobe@technologist.com>
     Re: Q: How many elements in a %HASH ? (I am a fool) (Gerben Wierda)
     Regex for three equal characters <markus.bubendorf@siemens.ch>
     Re: Regex for three equal characters (Casper K. Clausen)
     Re: Statistics for comp.lang.perl.misc (Keith Willis)
     Re: Year2000 problem with localtime(); (Keith Willis)
     Digest Administrivia (Last modified: 8 Mar 97) (Perl-Users-Digest Admin)

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

Date: 21 Nov 1997 11:18:04 GMT
From: sb@en.muc.de (Steffen Beyer)
Subject: Re: (URGENT) How can i validate a date?
Message-Id: <653qlc$16d$1@en1.engelschall.com>

Carlos Urbano <curbano@ccg.uc.pt> wrote:

> Ex:

> DD/MM/YY

> 31/02/97 is not a valid date but
> 29/02/96 is a valid date

> Thanks
> Urbano

Olha, tem extensoes para Perl que fazem exatamente isso.

Procure "Date::DateCalc", por exemplo (pode ser encontrado sob o endereco
http://www.engelschall.com/u/sb/download/ ou em qualquer CPAN ftp server).

Modelo de fazer:

#!/sw/bin/perl -w

use Date::DateCalc qw(:all);

$date1 = "31/02/97";
$date2 = "29/02/96";

@date = reverse split('/', $date1); $date[0] += 1900;
print $date[2], "-", substr(month_name_tab($date[1]),0,3), "-", $date[0];
print " ($date1) ", check_date(@date)?"IS":"is NOT";
print " a valid date.\n";

@date = reverse split('/', $date2); $date[0] += 1900;
print $date[2], "-", substr(month_name_tab($date[1]),0,3), "-", $date[0];
print " ($date2) ", check_date(@date)?"IS":"is NOT";
print " a valid date.\n";

Isso da como resultado:

:> ./test.pl

31-Feb-1997 (31/02/97) is NOT a valid date.

29-Feb-1996 (29/02/96) IS a valid date.

Espero que isso te ajude.

Muitas lembrancas,
-- 
    Steffen Beyer <sb@sdm.de> http://www.engelschall.com/u/sb/
     "There is enough for the need of everyone in this world,
      but not for the greed of everyone." - Mahatma Gandhi
   >> Unsolicited commercial email goes directly to /dev/null <<


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

Date: 21 Nov 1997 11:22:33 GMT
From: sb@en.muc.de (Steffen Beyer)
Subject: Re: (URGENT) How can i validate a date?
Message-Id: <653qtp$16d$2@en1.engelschall.com>

Carlos Urbano <curbano@ccg.uc.pt> wrote:

> Ex:

> DD/MM/YY

> 31/02/97 is not a valid date but
> 29/02/96 is a valid date

> Thanks
> Urbano

"Perl modules are your friend", as someone else here in this newsgroup often
says... :-)

Check out "Date::DateCalc" (available from
http://www.engelschall.com/u/sb/download/ or any CPAN ftp server)
or "Date::Manip" (see CPAN).

Hope this helps.

Yours,
-- 
    Steffen Beyer <sb@sdm.de> http://www.engelschall.com/u/sb/
     "There is enough for the need of everyone in this world,
      but not for the greed of everyone." - Mahatma Gandhi
   >> Unsolicited commercial email goes directly to /dev/null <<


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

Date: Fri, 21 Nov 1997 12:04:30 GMT
From: keith_willis.junk@non-hp-unitedkingdom-om1.om.hp.com (Keith Willis)
Subject: -w flag
Message-Id: <347577e4.1480138@elf.bri.hp.com>


Just a thought...

I see _so_many_ posts responding to people who have done something
naive or dumb telling them that if they had only used the -w flag
usually in conjunction with "use strict", they would have seen the
reason for the problem immediately.

I suggest that there is a case for modifying the standard perl
distribution so that the -w flag is ON by default, but may be switched
OFF by the use of the command line argument.

Any takers?
----------------------------------------------------------------------
The above message reflects my own views, not those of Hewlett Packard.
When emailing me, please note that there is no '.junk' in my address.


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

Date: Fri, 21 Nov 1997 08:57:29 GMT
From: greg@geographe.com.au (Greg Wake)
Subject: 2 Dimensional Arrays - how?
Message-Id: <34754cab.366625719@192.168.3.61>


Sorry, just starting to get a grip on Perl.

How can you implement 2 dimensional arrays??

Any pointers greatly appreciated.

Thanks.
------------------------------------------------------------------------
Greg Wake			|    Phone: +61 97 911 915
Systems Manager			|
Geographe Replacement Parts	|      Fax: +61 97 911 916
P.O. Box 350			|
BUNBURY  6231			|   E-Mail: greg@geographe.com.au
Western Australia		|
-----------------------------------------------------------------------


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

Date: 21 Nov 1997 12:01:48 GMT
From: ? the platypus {aka David Formosa} <dformosa@st.nepean.uws.edu.au>
Subject: Re: 2 quicks questions, really
Message-Id: <880113625.353699@cabal>

In <34727FAF.8F40C78E@interport.net> Alan <ahecker@interport.net> writes:

>1:\BThis is a test
>2:\BThe time is:\T

[...]

>Now, I've been having a hell of a time trying to get this to work out.
>First, I tried:

>($loop, $b, $text, $t) = (\d)\:\\(\w)(.*)\\(*);

>and variations thereof. Most of the time, I get many "undefined
>variable" messages

The problem your haveing is most likly related to the fact that sometimes
'\B' is present and other times its not.  Assuming the \B postion is fixed
I beleave the following will work

if (/^(\d)\:(.*)$/) {
   $loop=$1;
   if (s/^\\(*)(.*)$/$2/) {
     $b=$1;
   }
   if (/^(.*)\\(*)$/) {
      $text=$1;
      $t=$1;
   } else {
      $text=$_;
   }
}


--
Please excuse my spelling as I suffer from agraphia see the url in my header. 
Never trust a country with more peaple then sheep. I do not reply to mungged 
Support NoCeM http://www.cm.org/                   addresses.  
I'm sorry but I just don't consider 'because its yucky' a convincing argument


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

Date: Fri, 21 Nov 1997 13:44:59 -0800
From: Georg Edelmayer <ged@fortec.tuwien.ac.at>
Subject: Re: ^D not working
Message-Id: <347600DB.30E0@fortec.tuwien.ac.at>

Hi

brian d foy wrote:

> ^D is a Unix sort of thing.  perhaps that other OS has a different key?  how
> do you normally signal the end of input?
Ctrl C schould do it in dos (which then prints ^C on the screen)

Georg


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

Date: Fri, 21 Nov 1997 12:35:55 GMT
From: keith_willis.junk@non-hp-unitedkingdom-om1.om.hp.com (Keith Willis)
Subject: Re: Accessing /usr/adm/binary.errlog from Perl
Message-Id: <34767f6f.3411845@elf.bri.hp.com>

On Mon, 17 Nov 1997 12:53:14 -0600, stockman@rdbewss.redstone.army.mil
wrote:

>#!/usr/local/bin/perl

	Use the -w flag!!

>$file1 = "/usr/adm/binary.errlog";
>$size = -s $file1;      # remember how big this file is
>
>
>print STDERR "$file1 is $size bytes long\n";
>
>die "\a$file1 does not exist or has no data\n" unless $size;
>open (IN, $file1) || die "Can't open $file1, $!\n";
>while (<IN>) {
>   print "REC $IN \n";

Where did this $IN come from?  The data will be in $_ unless you
change your while to

while ($IN = <IN>) {

>}
>
>close (IN) || die "Can't close $file1, $!\n";

----------------------------------------------------------------------
The above message reflects my own views, not those of Hewlett Packard.
When emailing me, please note that there is no '.junk' in my address.


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

Date: 21 Nov 1997 09:59:30 GMT
From: "Miran Sepic" <miran.sepic4@mss.tel.hr>
Subject: Copy files
Message-Id: <01bcf664$23fdf660$7a02a8c0@pc_miran>

I haven't find a solution for copying files from directory to directory
---- only the remove function ..... 
I have several problems with File::Copy module. Any other suggestions? 

Thanks, Miran


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

Date: 21 Nov 1997 11:37:22 GMT
From: sb@en.muc.de (Steffen Beyer)
Subject: Re: date
Message-Id: <653rpi$1q8$1@en1.engelschall.com>

Indu Bingham <indu@healtheon.com> wrote:

> Anyone know how I could get a script to get a date range for a week.

> For example I have a week 46 and I would like to get the the begin date
> of the week 46 and the end date.

>>date '%W' -> will give the week

> I would like to pass this week value and get the date range...

> any suggestions??

The module "Date::DateCalc" does exactly this.

Available from http://www.engelschall.com/u/sb/download/ or any CPAN ftp
server.

The relevant functions are:

  ($year,$mm,$dd) = calc_new_date($year,$mm,$dd,$offset);
  ($week,$year) = week_number($year,$mm,$dd);
  ($year,$mm,$dd) = first_in_week($week,$year);
  $weeks = weeks_in_year($year);

Example:

#!/sw/bin/perl

use Date::DateCalc qw(:all);

@any_date = (1997,11,21);

@week_number = week_number(@any_date);

@first_day_that_week = first_in_week(@week_number);

@last_day_that_week = calc_new_date(@first_day_that_week,+6);

print date_to_short(@any_date), " lies in week #", $week_number[0];
print " of ", $week_number[1], ".\n";

print "First day of that week: ", date_to_short(@first_day_that_week), ".\n";

print "Last day of that week: ", date_to_short(@last_day_that_week), ".\n";

This example prints:

Fri 21-Nov-1997 lies in week #47 of 1997.

First day of that week: Mon 17-Nov-1997.

Last day of that week: Sun 23-Nov-1997.

Hope this helps.

Yours,
-- 
    Steffen Beyer <sb@sdm.de> http://www.engelschall.com/u/sb/
     "There is enough for the need of everyone in this world,
      but not for the greed of everyone." - Mahatma Gandhi
   >> Unsolicited commercial email goes directly to /dev/null <<


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

Date: 21 Nov 1997 05:12:05 -0500
From: Mark Mielke <markm@nortel.ca>
Subject: Re: DBM-speed
Message-Id: <lq1afeyzhca.fsf@bmers2e5.nortel.ca>

Morten Simonsen <mortensi@idt.ntnu.no> writes:
> I plan to build a database using the regular DBM's of Perl. This
> database may grow quite large and I am therefore interested in the
> speed of such a database.
> 
> If I have a database at 100 MB:
> -how long will it take to find a key?
> -how will it perform with respect to memory?
> -how long will it take to insert a new key?
> 
> For the sake of the argument, let's say the machine is a regular PC,
> 32 MB RAM, 200 MHz Pentium.
> 
> It's possible to answer these questions exact, but if someone has an
> qualified opion, I would like to hear it.

For exact numbers on your particular machine/setup/os? :-) Only you could
give those timings.

The qualified opinion you want can come from:
    $ perldoc AnyDBM_File

mark

--                                                  _________________________
 .  .  _  ._  . .   .__    .  . ._. .__ .   . . .__  | Northern Telecom Ltd. |
|\/| |_| |_| |/    |_     |\/|  |  |_  |   |/  |_   | Box 3511, Station 'C' |
|  | | | | \ | \   |__ .  |  | .|. |__ |__ | \ |__  | Ottawa, ON    K1Y 4H7 |
  markm@nortel.ca  /  al278@freenet.carleton.ca     |_______________________|


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

Date: 21 Nov 1997 10:28:04 GMT
From: Morten Simonsen <mortensi@idt.ntnu.no>
Subject: Re: DBM-speed
Message-Id: <653nnk$5sb$2@due.unit.no>

Mark Mielke <markm@nortel.ca> wrote:
: Morten Simonsen <mortensi@idt.ntnu.no> writes:
: > I plan to build a database using the regular DBM's of Perl. This
: > database may grow quite large and I am therefore interested in the
: > speed of such a database.
: > 
: > If I have a database at 100 MB:
: > -how long will it take to find a key?
: > -how will it perform with respect to memory?
: > -how long will it take to insert a new key?
: > 
: > For the sake of the argument, let's say the machine is a regular PC,
: > 32 MB RAM, 200 MHz Pentium.
: > 
: > It's      possible to answer these questions exact, but if someone has an
        ^^^^^
It should of course be "NOT possible to answer these questions exact,.."(argh..:)

: > qualified opion, I would like to hear it.

: For exact numbers on your particular machine/setup/os? :-) Only you could
: give those timings.

: The qualified opinion you want can come from:
:     $ perldoc AnyDBM_File

: mark

: --                                                  _________________________
: .  .  _  ._  . .   .__    .  . ._. .__ .   . . .__  | Northern Telecom Ltd. |
: |\/| |_| |_| |/    |_     |\/|  |  |_  |   |/  |_   | Box 3511, Station 'C' |
: |  | | | | \ | \   |__ .  |  | .|. |__ |__ | \ |__  | Ottawa, ON    K1Y 4H7 |
:   markm@nortel.ca  /  al278@freenet.carleton.ca     |_______________________|


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

Date: 21 Nov 1997 10:15:59 GMT
From: Zenin <zenin@best.com>
Subject: Re: giving up on flock
Message-Id: <880107508.91515@thrush.omix.com>

[ posted & mailed ]

Eric Bohlman <ebohlman@netcom.com> replied to Steve <syarbrou@ais.net> with:
: Your problem isn't with flock.

	About this, your right, but not the rest.  For a real answer to the
	question see the end part of this post.

: It's with the way you're opening your file.

	Yes, and no.  Read on.

: If you would take a look at the entry for open() in perlfunc(3),

	You need to reread this entry yourself, it would seem...

: you would find that prefixing the name of a file to be opened with "+>>" 
: is supposed to do what it's doing to you, namely creating a new file (if 
: there's an old one, it will get wiped out), and then opening it for both 
: reading and appending.

	No, no, no...  That not at all what it does.  You're thinking of
	just plain "+>", but we're talking about "+>>" here.  We don't
	want either for this. -Well, we "half" want "+>", depending on
	how we do this, but probably not at all.

: In that same documentation, you will also see the 
: correct syntax for doing what you want to do, namely opening an existing 
: file for both read and append.

	But "+>>" IS the correct syntax for read and append, you just don't
	understand what is "really" meant by "append" or read()s in O_APPEND
	mode.

Steve (syarbrou@ais.net) originally asked:
: I've pretty much had it with flock.  I open a file to read and
: append(+>>) and it just doesn't seem to work.  My file keeps getting
: cleared.  Can flock only work for reading or writing?

	I get the feeling you're thinking that append is doing something
	different than it really does.

	When you open a file for append, the position of "0" is NOT the
	actual start of the file, but rather the start of the APPEND. eg,
	the position of EOF when you first opened it.  Which, in a warped
	way makes some sense since you did ask to append to it.

	This meens you CAN NOT READ what is already in the file, only what
	you've appended yourself since a seek() to 0 will only bring you
	to the original EOF location.  Lame yes, I know.

	This might explain why your file might "look" cleared to your
	program.

	So, how does one open a file for read/write access, creating it
	if it doesn't exist, yet not nuking any data that's in it if it
	does exist?  Two ways.  Either you can test the file's existance
	first, and open() with "+<" or "+>" depending:
		if (-e $file) {
		    open SESAME, "+< $file" or die $!;
		} else {
		    open SESAME, "+> $file" or $die $!;
		}

	Of course, this doesn't help if said file does exist, but happends
	not to be a plain file, but the die() will (may...) catch that. :-)

	The other way is to use sysopen() and be vary explicit about what
	you want (see man 2 open for options, including flock() options I
	use below):
		use Fcntl;
		sysopen SESAME, $file, O_CREAT|O_RDWR|O_EXLOCK, 0644
		    or die $!;
		seek SESAME, 0, 2
		    or die $!;

	The seek() is because, unlike a raw O_APPEND, we start out at the
	head of the file like a normal open, so to "append" anything we'd
	need to get to the end manually.

	Hope this helps!

-- 
-Zenin
 zenin@best.com


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

Date: 21 Nov 1997 11:00:01 GMT
From: "Robert Friberg" <robert.friberg@your_clothes.eductus-vast.com>
Subject: Grade the perlishness
Message-Id: <01bcf5ca$96848f40$c82da8c0@akilles.ittek.org>

Hi all,

Just kluged up a 'graphical' ping host-monitor with perl.
Any comments are appreciated, my thoughts and questions
are embedded in the script.

BTW, I downloaded several chapters of 'Effective Perl
Programming' by Joseph N. Hall at www.effectiveperl.com
(pdf-format) If you're learning perl (like me) then go get 'em!
It's a good piece of work which I'll definitely buy when
it's released.

-- 
/robban

============================== gping.pl ============
#!/usr/bin/perl -w

# Init some vars...
   $max = $min = $count = $avg = 0;

# Set default host-name
   $remotehost = $ARGV[0] || 'quake.uiah.fi';

# The remaining commandline should be passed to ping
   $pars = join ' ', @ARGV[1..$#ARGV];
   open CHN, "ping $remotehost $pars |" or die "$!";
   print "$0: pinging $remotehost ...\n";

# I just want to throw away the first line from ping
# Is there a better way than using an assignment?
   $bs = <CHN>;

# This loops until killed
   while (defined($_ = <CHN>)) {        #read a line
      $time = (split(/ /))[-2];         #get the time
      $time =~ s/time=//;               

# Keep track of min, max and average ping times
      $max = $time if $time > $max;     
      $min = $time if $time < $min;
      $count++;
      $avg += ($time - $avg)/$count;

# Here's the graphics section :?)
# The scale is 0 - 960
      print '-'x(($time/12)%80),"x\n";
   }

# Hmm.. this last code is never reached because
# I interrupt the script with ctrl-c
#
# I don't think there's a simple way to achieve
# the desired effect
#
# For now if i absolutely want the stats i start
# the script in the background (./gping.pl&), and
# kill the ping which ends the script...

   print "Average time: $avg ms\n";
   print "Max time:     $max ms\n";
   print "Min time:     $min ms\n";
   print "Packets:      $count\n";


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

Date: Fri, 21 Nov 1997 11:43:20 +0000
From: Kevin Boylan <eeikbn@eei.ericsson.se>
Subject: Help: PERL -> mySQL database
Message-Id: <347573D7.D8AE3C46@eei.ericsson.se>

Hi,
I need help to do the following:
I have a web page form that enters in information in categories i.e.
Name=xxxx
Age=yy
This info should be kept in a database (either mySQL or PostgreSQL)
which then allows the search by name,age etc.. How can I do this using
PERL5.

/Kevin




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

Date: Fri, 21 Nov 1997 12:36:15 +0100
From: David Martin <david.martin@biotek.uio.no>
Subject: Re: Here's a simple one
Message-Id: <3475722F.5132876E@biotek.uio.no>

Kevin Eson wrote:
> 
> Myles Lawrence wrote:
> 
> > I've got a script that has a name and password field on it. When I run the
> > form, I verify the values. If the name is verified, I would like to call
> > form1.pl, if not I'd like to call form2.pl. Whats more I'd like to send the
> > name to form1.pl?$name. Is this possible?
> > myleslawrence@msn.com
> 
> Yes it is.  With javascript doing the up-front verification and then it decides
> which server process to call.


ugh. so anyone who looks at the source javascript can go whereever they
want anyway


you should use CGI.pm
and an array %NAMES of passwords indexed by name 
try something like

if (&check_password(param('name'),param('passwd'))) { call script 1}
else {call script 2}

and 

sub check_password {
if ($_[1] eq $NAMES{$_[0]}) {return 1;}
else {return 0;}
}

Keeps it all invisible to the browser, unlike using JavaScript.

 ..d
-- 
* David Martin - Atherosclerosis and Thrombosis research group  *
* http://www.uio.no/~damartin/      david.martin@biotek.uio.no  *
* Lab +47 22 95 84 54 Fax +47 22 69 41 30  GSM +47 90 74 27 65  *


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

Date: 21 Nov 1997 12:03:15 GMT
From: "Robert Friberg" <robert.friberg@your_clothes.eductus-vast.com>
Subject: Re: How To Test if number is ODD or EVEN?
Message-Id: <01bcf675$0ea174c0$c82da8c0@akilles.ittek.org>


print $number && 1 ? 'Odd!': 'Even!', "\n";

-- 
/robban



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

Date: 21 Nov 1997 10:13:10 GMT
From: mbeattie@sable.ox.ac.uk (Malcolm Beattie)
Subject: Re: Intermediary compiled perl?
Message-Id: <653mrm$9n4$1@news.ox.ac.uk>

In article <EJu33L.6ny@awt.nl>, Gerben Wierda <G.C.Th.Wierda@AWT.nl> wrote:
>I know someone is working on a perl compiler. I was wondering something else, 
>namely: is it possible to store the result of perl *after* perl compiles your 
>script, but before perl starts executing it (a sort of perl bytecode)?

That's what the Bytecode backend of the compiler does.

--Malcolm

-- 
Malcolm Beattie <mbeattie@sable.ox.ac.uk>
Oxford University Computing Services
"I permitted that as a demonstration of futility" --Grey Roger


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

Date: 21 Nov 1997 12:33:55 GMT
From: Zenin <zenin@best.com>
Subject: Re: is it possible to reference a sub-array?
Message-Id: <880115783.450523@thrush.omix.com>

[ posted & mailed ]

Bart Lateur <bart.mediamind@tornado.be> wrote:
: 	&function([@ary[2..$#ary]]);
: This one DOES work as you'd want it to work.

	No, it doesn't.  It's close though, but you're not
	passing references to anything in @ary, but rather to a new,
	anonymous list.  This meens you can't modify the values and
	have it change the ones you passed.  eg, It passes A reference,
	but it does not "pass BY reference".  Try this:

	$ cat test.pl
	#!/usr/local/bin/perl -w

	use strict;

	sub function {
		my $ary = shift;
		## Try to modify passed values (won't work, but hey)
		$ary->[0] = 'I can not';
		$ary->[1] = 'do this';
	}

	sub foo {
		my @ary = @_;
		print "${ $ary[0] } ${ $ary[2] }\n";
	}

	sub bar {
		my @ary = @_;
		## Here we can modify the passed values
		${ $ary[0] } = 'cat';
		${ $ary[2] } = 'dog';
	}

	sub function {
		my $ary = shift;
		$ary->[0] = 'I can not';
		$ary->[1] = 'do this';
	}

	&function([@ARGV[2..$#ARGV]]);

	&foo ( \(@ARGV[0..$#ARGV]) );
	&foo ( \(@ARGV[1..$#ARGV]) );

	&bar ( \(@ARGV[0..$#ARGV]) );
	&bar ( \(@ARGV[1..$#ARGV]) );

	&foo ( \(@ARGV[0..$#ARGV]) );
	&foo ( \(@ARGV[1..$#ARGV]) );

	$ ./foo.pl one three two four
	one two
	three four
	cat dog
	cat dog

: But this one triggered a question for the Perl gurus: Why do these both
: return the last array element
: 	$ary[$#ary]
: 	$ary[-1]
: but this slice doesn't do anything?
: 	@ary[2.. -1]
: (replacing "-1" by "$#ary" makes it work)
: This behaviour doesn't seem consequent.

	Why?  Think about it.  Your slice is the same as:
		@ary[ (2 .. -1) ];
	Which expands out more to:
		@ary[ (2, 1, 0, -1) ];

	Look up the ".." operator in perlop man page.

-- 
-Zenin
 zenin@best.com


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

Date: Fri, 21 Nov 1997 12:43:52 +0100
From: David Martin <david.martin@biotek.uio.no>
To: Myles Lawrence <myleslawrence@email.msn.com>
Subject: Re: JavaScript < -------- > Perl (CGI)
Message-Id: <347573F8.673743C9@biotek.uio.no>

Myles Lawrence wrote:
> 
> I've started to do this a bit but am stuck getting perl variables , $vars,
> into the jscripts. I use Roth' ODBC pm to fill perl vars and would like to
> get the data into a java script. Have you done this?

No, but this shouldn't be too difficult. If you know what variable names
you want to use (for whatever reason) you can insert them in a seperate
'header' script before the sourced script like:


> >Me too.. but I prefer to reference a library rather than a HEREDOC.
> >
> >my $JAVASCRIPT='http:// ....';
> >...

<SCRIPT> Define variables here as part of your script output ie. script
dependent </SCRIPT>

> ><SCRIPT SRC="$JAVASCRIPT"></SCRIPT>
> >
> >thus allowing my javascript library to be reused as many times as I feel
> >like.

Any declarations in the library will overwrite those in the header.

Someone has probably got a really nice and elegant way of getting this
done rather than this (which requires knowing your library well).

If you create objects in your library that you want to assign valuse to
directly then you have to add this code _after_ you import the library
as JavaScript is implemented top down rather than wherever.

I hope this helps.

 ..d
-- 
* David Martin - Atherosclerosis and Thrombosis research group  *
* http://www.uio.no/~damartin/      david.martin@biotek.uio.no  *
* Lab +47 22 95 84 54 Fax +47 22 69 41 30  GSM +47 90 74 27 65  *


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

Date: 21 Nov 1997 10:05:54 GMT
From: "Miran Sepic" <miran.sepic4@mss.tel.hr>
Subject: Mkdir - permissions
Message-Id: <01bcf665$095a3d90$7a02a8c0@pc_miran>

What are the permissions in octal value?

Thanks , Miran


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

Date: Fri, 21 Nov 1997 17:36:27 +0800
From: Andrew Ellerton <andrewe@technologyXchange.com>
Subject: open(), seek() and email monitoring
Message-Id: <3475561B.F18CBAC7@technologyXchange.com>

Hi all,

I'm trying to write some code to monitor email spool files and do
anything once new email is received.

Although the approach may be wrong, I'm presently trying this code
virtually straight out of Programming Perl:

for (;;) {
        while (<SPOOL>) {
        
                process_in_whatever_way();
        }
        sleep $for_a_while;
        seek SPOOL, 0, 1; # reset end-of-file error
}

Is the sleep-then-seek method a reasonable way to handle this? If anyone
has any suggestions on an alternative, and/or the use of Mail::Header to
extract header information, I'd be most thankful. 

Thanks,
Andrew

--
Andrew Ellerton                          andrewe@technologyXchange.com
Software Engineer                                      +61 8 9367 7006
International Technology Exchange                  Fax +61 8 9367 7343
Australia                             http://www.technologyXchange.com


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

Date: Fri, 21 Nov 1997 06:55:37 -0500
From: Greg Stanfield <gregs@bigfoot.com>
To: gregs@bigfoot.com
Subject: Perl and Sybase
Message-Id: <347576B8.222B6482@bigfoot.com>

I am relatively new to combining Perl and Sybase, and could use some
help, if anyone has the time.

I am trying to connect to a Sybase database from a Perl script.  I have
the isql statement ready to go, but cannot figure out the right/best way
to connect to the database to pass the isql statement.  Everything I am
doing is behind a firewall, so getting Perl modules is somewhat of a
headache for me, but if that is the only way, I'll give it a try.

If anyone knows what module or code I could use to do this, it would
help greatly.

TIA
--
Greg Stanfield




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

Date: Fri, 21 Nov 1997 06:59:45 -0500
From: Greg Stanfield <gregs@bigfoot.com>
To: gregs@bigfoot.com
Subject: Perl and Sybase
Message-Id: <347577B1.6211F348@bigfoot.com>

I am relatively new to combining Perl and Sybase, and could use some
help, if anyone has the time.

I am trying to connect to a Sybase database from a Perl script.  I have
the isql statement ready to go, but cannot figure out the right/best way
to connect to the database to pass the isql statement.  Everything I am
doing is behind a firewall, so getting Perl modules is somewhat of a
headache for me, but if that is the only way, I'll give it a try.

If anyone knows what module or code I could use to do this, it would
help greatly.

TIA
--
Greg Stanfield




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

Date: Fri, 21 Nov 1997 13:01:10 +0100
From: Kobe Lenjou <kobe@technologist.com>
Subject: Problem with the editor (I think)
Message-Id: <34757805.F91312D0@technologist.com>

Hello,

I'm a novice Perl writer and I have a serious problem, when I load my
perfect Perl Script to the server, set all the modes and stuff It won't
work, I think the problem is with my editor. Becouse when I DL'ed a Perl
script from the server ot looked real weerd. I use Notepad as editor.
Can someone give me advice on this one.

Kobe Lenjou - Belgium
kobe@technologist.com



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

Date: Fri, 21 Nov 1997 10:11:44 GMT
From: G.C.Th.Wierda@AWT.nl (Gerben Wierda)
Subject: Re: Q: How many elements in a %HASH ? (I am a fool)
Message-Id: <EJzqzK.MLC@AWT.NL>

comdog@computerdog.com (brian d foy) wrote:
>In article <EJw059.CCr@AWT.NL>, G.C.Th.Wierda@AWT.nl (Gerben Wierda) wrote:
>
>>aml@world.std.com (Andrew M. Langmead) wrote:
>
>>>timethese (100000, {
>>>  use_keys => q($n = keys %TEST;),
>>>  use_loop => q($n=0;while(($k,$v) = each %TEST) {$n++}),
>>>  use_array => q(@TEST=%TEST; $n=@TEST/2)
>>>});
>
>>Benchmark: timing 100000 iterations of use_array, use_keys, use_loop...
>> use_array: 171 secs (129.28 usr  0.67 sys = 129.95 cpu)
>>  use_keys:  1 secs ( 0.53 usr  0.02 sys =  0.55 cpu)
>>  use_loop: 164 secs (143.39 usr  0.48 sys = 143.88 cpu)
>
>>So:
>
>>sub size_hash {
>
>>}
>
>
>
>perhaps i'm missing the point of your post.  the use of keys in the
>scalar context is almost 200 times faster than the other methods, but
>you suggest a loop subroutine.  why?

ARGH! Because I am a fool, that's why! I did not look closely at the output 
and did not notice that the tests were in a different order than the 
outcomes. So I took the second outcome as fastest and assumed that was the 
second test.

Apologies to all:

---
Gerben Wierda,

Stafmedewerker Adviesraad voor het Wetenschaps- en Technologiebeleid.
Staff member Advisory Council for Science and Technology Policy
Javastraat 42, 2585 AP, Den Haag/The Hague, The Netherlands
Tel (+31) 70 3639922	Fax (+31) 70 3608992
http://www.AWT.nl/prive/wierda/

The fox knows many things, but the hedgehog knows one big thing.

"Passion is inversely proportional to the amount of real information 
available."
  - Benford's Law of Controversy, Gregory Benford, 1980.



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

Date: Tue, 18 Nov 1997 13:16:02 +0100
From: Markus Bubendorf <markus.bubendorf@siemens.ch>
Subject: Regex for three equal characters
Message-Id: <34718702.E20CA18@siemens.ch>

Helo world,

I'm looking for a regex which matches three or more consecutive equal
characters. Any ideas?

Markus

--

*=*=*=*=*=*=*=*=*=*=*=*==*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*= \___/ =
# Markus Bubendorf                                *---________-o o- #
# Siemens Schweiz AG                                *|  ##     \Y/  #
# Steinenschanze 2        PHONE: +41 61 276 76 28  * | ____ #_ |    #
# CH - 4051 Basel         FAX:   +41 61 276 76 71  * |/|/  |/|/     #
# Switzerland             mailto:bbf@siemens.ch   ** W W   W W #    #
*=*=*=*=*=*=*=*=*=*=*=*==*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=





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

Date: 21 Nov 1997 13:14:02 +0100
From: ckc@hobbes.ejoper.dmi.min.dk (Casper K. Clausen)
Subject: Re: Regex for three equal characters
Message-Id: <wvp90uibg1h.fsf@hobbes.ejoper.dmi.min.dk>

Markus Bubendorf <markus.bubendorf@siemens.ch> writes:

> Helo world,

<bad admin joke>
Is this an SMTP session?
</bad admin joke>

> I'm looking for a regex which matches three or more consecutive equal
> characters. Any ideas?

That'd be something along the lines of:

/([a-zA-Z0-9])\1\1+/

You can, of course, change the character class [a-zA-Z0-9] to fit your
needs.

Let me also use this opportunity to plug Friedl's "Mastering Regular
Expressions" from O'Reilly publishing. If you see yourself ever
working with regexes again, this book will save you endless amounts of
grief.

Regards,
Kvan.

-- 
-------Casper Kvan Clausen------ | 'Ah, Warmark, everything that passes
----------<ckc@dmi.dk>---------- |  unattempted is impossible.'
           Lokal  544            |   
I do not speak for DMI, just me. |        - Lord Mhoram, Son of Variol.      


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

Date: Fri, 21 Nov 1997 10:03:53 GMT
From: keith_willis.junk@non-hp-unitedkingdom-om1.om.hp.com (Keith Willis)
Subject: Re: Statistics for comp.lang.perl.misc
Message-Id: <34765be9.87369310@elf.bri.hp.com>

On Mon, 17 Nov 1997 15:14:52 GMT, aml@world.std.com (Andrew M.
Langmead) wrote:

>danny@lennon.postino.com (Danny Aldham) writes:
>
>I have been toying with an idea that may alleviate the situation. If
>the frequent posters to comp.lang.perl.* put a header in their posts
>that are answers to FAQs (maybe with the contents of the header being
>a URL to the source of their answers.) others may find a way to kill
>both the response and its originating question. They reason that I'm
>thinking of putting the URL in the header is to differentiate the
>posts between absolutely factual answers and replies that are contain
>they authors opinions.

Or use a technique that is frequently found in the much-spammed binary
groups; prefix the subject with a fixed string, say "FAQ:".  Then it
becomes a trivial matter for those who wish to to set up a kill filter
to zap all those FAQ answers.

klw
----------------------------------------------------------------------
The above message reflects my own views, not those of Hewlett Packard.
When emailing me, please note that there is no '.junk' in my address.


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

Date: Fri, 21 Nov 1997 10:05:31 GMT
From: keith_willis.junk@non-hp-unitedkingdom-om1.om.hp.com (Keith Willis)
Subject: Re: Year2000 problem with localtime();
Message-Id: <34775cc2.87586132@elf.bri.hp.com>

On Mon, 17 Nov 1997 09:54:51 -0800, Tom Phoenix
<rootbeer@teleport.com> wrote:

>On 14 Nov 1997, Mr. Yen-Ming Chen wrote:
>
>>  In a DEC Alpha, the localtime can present up to year 2038, Jan. 19th,
>> 11:14:07. So that means it(Unix) will have a "year 2038" problem?? :)
>
>Many of us are planning to retire from the world of programming at the end
>of 2037. :-) 

I'll be 79 going on 80 when the time_t rolls over!

----------------------------------------------------------------------
The above message reflects my own views, not those of Hewlett Packard.
When emailing me, please note that there is no '.junk' in my address.


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

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

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