[12113] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 5713 Volume: 8

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Tue May 18 12:07:28 1999

Date: Tue, 18 May 99 09:00:22 -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           Tue, 18 May 1999     Volume: 8 Number: 5713

Today's topics:
    Re: -> Folkert Meeuw: Value of <HANDLE> can be "0"; tes <fmee@lfi.uni-hannover.de>
        ->Folkert Meeuw: syntax error at 1.8.pl line 11, near " <fmee@lfi.uni-hannover.de>
    Re: ->Folkert Meeuw: syntax error at 1.8.pl line 11, ne <fmee@lfi.uni-hannover.de>
    Re: Accents Sensitivity <pm@univie.ac.at>
    Re: Anyone can help ?? (Larry Rosler)
    Re: backspace in file output question <gellyfish@gellyfish.com>
    Re: backspace in file output question <ebohlman@netcom.com>
    Re: can someone help me with locking??? <marc.dietrich@physik.uni-giessen.de>
    Re: can someone help me with locking??? <ebohlman@netcom.com>
    Re: can someone help me with locking??? <gellyfish@gellyfish.com>
    Re: counting lines in another file <aqumsieh@matrox.com>
    Re: DBI not thread safe. Another way? (Juho Cederstrom)
    Re: get date <gellyfish@gellyfish.com>
    Re: get date (Larry Rosler)
        Help w/ /tr func <sshort@ribi.com>
    Re: How to create modules? <gellyfish@gellyfish.com>
    Re: inserting a byte into a file <swarren@www.wwwdotorg.org>
    Re: MacPerl (Kevin Reid)
        nested substring problem <berislav.vlahovic@sympatico.ca>
    Re: No classes.zip file found (Juho Cederstrom)
    Re: Perl to C translator? (Juho Cederstrom)
    Re: Simple Time Manipulation <gellyfish@gellyfish.com>
    Re: Simple Time Manipulation (Larry Rosler)
    Re: Simple Time Manipulation <hannum@ohio.edu>
        sort non-alpha characters <hvermeulen@correctnl.com>
    Re: sort non-alpha characters (Stefaan A Eeckels)
        Sorting a colon separated file eliot5581@my-dejanews.com
    Re: Sorting a colon separated file <gellyfish@gellyfish.com>
        undef of namespaces <marc.dietrich@physik.uni-giessen.de>
        Y2K.  localtime(time) (Hans Xie)
    Re: Y2K.  localtime(time) (Jed Parsons)
    Re: Y2K.  localtime(time) (Harry Broomhall)
    Re: Y2K.  localtime(time) (Johannes K. Lehnert)
        Special: Digest Administrivia (Last modified: 12 Dec 98 (Perl-Users-Digest Admin)

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

Date: Tue, 18 May 1999 16:55:10 +0200
From: Folkert Meeuw <fmee@lfi.uni-hannover.de>
Subject: Re: -> Folkert Meeuw: Value of <HANDLE> can be "0"; test with defined()
Message-Id: <37417F4E.AABBA0CA@lfi.uni-hannover.de>

Hi Bill Montana,

Bill Montana wrote:

> I'm no perl expert,

And I'm from my mother language not english speaking.

> just a newbie.

I'm too.

> But these look like only warnings
> to me. Using the -w flag causes perl to list things that could
> POSSIBLY cause problems in your code.

Thats "Using perl with -w" a verry good suggestion.

> This doesn't mean the code will
> not work. However, there IS a typo in line 8: $lines should be $line.

Yes, it's a write error by me.

> Note that this code doesn't provide any output.

While it's so, today I debug the code and look on the
expressions that the perl-debugger shows.
I start perl with flag -d for debugging.


> So you won't even know
> if it works when it does. Add some code at the end to print out
> @friends. This will do the trick:
>
> $i = 0;
>
> while ($i++ < @friends)
> {
>  print "$friends[$i]\n";
> }
>

Ok, I will test this, to see.
Thanks !

> HTH,
> Bill Montana

NG Folkert Meeuw




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

Date: Tue, 18 May 1999 17:33:43 +0200
From: Folkert Meeuw <fmee@lfi.uni-hannover.de>
Subject: ->Folkert Meeuw: syntax error at 1.8.pl line 11, near "$freund (" Execution of 1.8.pl aborted due to compilation errors.
Message-Id: <37418857.1D116F53@lfi.uni-hannover.de>

Hi Dear Friendly Readers,
the next day and the next problem.
I 've got another problem with perl yet.

#!/usr/local/bin/perl -w
# 1.8 Lists

open (IN, "friends");
$frriends = <IN>;
close IN;
chomp @friends;
print "Please, type ypur name:\n";
$name = <STDIN>;
chop $name;
foreach $friend (@friends)
{
 if ($name eq $friends)
 {
  print "Hallo $name, good old boy\n";
 }
 else
 {
  print "Hallo, $name\n";
 }
}

Who knows ?

NG Folkert Meeuw



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

Date: Tue, 18 May 1999 17:36:44 +0200
From: Folkert Meeuw <fmee@lfi.uni-hannover.de>
Subject: Re: ->Folkert Meeuw: syntax error at 1.8.pl line 11, near "$freund  ("Execution of 1.8.pl aborted due to compilation errors.
Message-Id: <3741890C.AC3A2573@lfi.uni-hannover.de>

Sorry !
it must be:
if ($name eq $friend)

Folkert Meeuw wrote:

>  if ($name eq $friends)

NG Folkert Meeuw




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

Date: 18 May 1999 15:30:35 GMT
From: Peter Marksteiner <pm@univie.ac.at>
Subject: Re: Accents Sensitivity
Message-Id: <7hs12r$47mi$1@www.univie.ac.at>

amenrique@my-dejanews.com wrote:
: I have developed a search engine in Spanish. It works fine. The problem
: is that users are trying to find words without writing the accents used
: in spanish, i.e. they search for Maria with no results, as the right
: spelling is Marma (with an accent on the i)

: Is there an easy way the make the search "not sensitive" to the
: accents, so a search for Maria would return all findings with Marma?

Choose a "canonical spelling", for example all-lowercase and no accents:

tr /[A@Ba`bIHJihjMLNmlnSRTsrtZY[zy{Qq/[aaaaaaeeeeeeiiiiiioooooouuuuuunn]/;
tr /[A-Z]/[a-z]/;

Transform to canonical spelling both when building the indexes (I suppose
your search engine uses indexes?) and when processing the query string.

-- 
Peter Marksteiner
Vienna University Computer Center


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

Date: Tue, 18 May 1999 08:02:46 -0700
From: lr@hpl.hp.com (Larry Rosler)
Subject: Re: Anyone can help ??
Message-Id: <MPG.11ab20ed816fe65e989a95@nntp.hpl.hp.com>

[Posted and a courtesy copy sent.]

In article <7hrldg$ji9$2@justice.csc.cuhk.edu.hk> on 18 May 1999 
12:11:28 GMT, Austin Ming <austin95002887@yahoo.com> says...
> 
> #!/usr/bin/perl

Start right now to use the '-w' flag on the first line, and 'use 
strict;' as the second line.  Lots of things will become clearer faster.

> $myVar = 3;
> mySub($myVar);
> print $myVar;
> print youSub();
> 
> sub mySub { $myVar = $myVar + 2 ; }
> sub youSub { $a=1 ; $b=2; $a; }
> 
> I do not know if the above script is correct to use 
>  call by reference and call by value.

As you are not using in mySub() the argument you passed to it, the 
question is irrelevant.  You are modifying a global variable.

You should read perlsub, which discusses the argument-passing interface.

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


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

Date: 18 May 1999 15:45:23 +0100
From: Jonathan Stowe <gellyfish@gellyfish.com>
Subject: Re: backspace in file output question
Message-Id: <37417d03@newsread3.dircon.co.uk>

papakee@aol.com wrote:
> I wrote my first perl program which simply
> takes input from STDIN and printf's it to
> an output file.  If I have to backspace to
> correct a typo, the offending characters and the
> backspace appears in the output file also.
> This is on a DOS/Win version of perl.  Anyone
> know how to process the backspace before it
> appears in the file?
> 

Assuming that your backspace character is a ctrl-H like it is most places
then you can do something like:

  $string = s/.\cH//g;

Which will remove every character followed by a ^H (and the control char 
as well ).

/J\
-- 
Jonathan Stowe <jns@gellyfish.com>



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

Date: Tue, 18 May 1999 15:23:55 GMT
From: Eric Bohlman <ebohlman@netcom.com>
Subject: Re: backspace in file output question
Message-Id: <ebohlmanFBxpFv.A0E@netcom.com>

Jonathan Stowe <gellyfish@gellyfish.com> wrote:
: Assuming that your backspace character is a ctrl-H like it is most places
: then you can do something like:

:   $string = s/.\cH//g;
             ^
typo alert.

: Which will remove every character followed by a ^H (and the control char 
: as well ).

That won't properly handle sequences of multiple backspaces,
which have to be dealt with "inside out"; to do that, you need to
repeatedly rescan the string until no more substitutions can be made: 

1 while $string=~s/[^\008]\cH//g;

'.' needs to be replaced with '[^\008]' because you *don't* want to 
replace two consecutive backspaces with nothing!



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

Date: Tue, 18 May 1999 16:49:44 +0200
From: Marc Dietrich <marc.dietrich@physik.uni-giessen.de>
Subject: Re: can someone help me with locking???
Message-Id: <37417E08.CBB61108@physik.uni-giessen.de>

try the flock mechanism. See perldoc -f flock or man flock. This only
works on Unix Systems.

Marc


Martin Lynch wrote:
> 
> Hi
> 
> (...)

-- 
Marc Dietrich                marc.dietrich@physik.uni-giessen.de


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

Date: Tue, 18 May 1999 15:26:16 GMT
From: Eric Bohlman <ebohlman@netcom.com>
Subject: Re: can someone help me with locking???
Message-Id: <ebohlmanFBxpJs.A5G@netcom.com>

Martin Lynch <mlynch@bfsec.bt.co.uk> wrote:
: What i want to ensure is that if two people are submitting simultaneously, i
: dont loose one set of data.  So i need to employ some sort of locking to
: avoid this happening.....

: Thing is i dont know where or how to do this........

The sections of perlfaq5 beginning with "How do I lock a file?" should be 
quite helpful.



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

Date: 18 May 1999 16:38:34 +0100
From: Jonathan Stowe <gellyfish@gellyfish.com>
Subject: Re: can someone help me with locking???
Message-Id: <3741897a@newsread3.dircon.co.uk>

Marc Dietrich <marc.dietrich@physik.uni-giessen.de> wrote:
> try the flock mechanism. See perldoc -f flock or man flock. This only
> works on Unix Systems.
> 

Er no.  It only *doesnt* work on Windows 95 and 98 as far as I know.

/J\
-- 
Jonathan Stowe <jns@gellyfish.com>



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

Date: Tue, 18 May 1999 10:41:53 -0400
From: Ala Qumsieh <aqumsieh@matrox.com>
Subject: Re: counting lines in another file
Message-Id: <x3y3e0uwibz.fsf@tigre.matrox.com>


Frank de Bot <debot@xs4all.nl> writes:

> open(FILE, "address.txt");

You forgot to check the results of your open().

	open FILE, 'address.txt' or die "Couldn't open file: $!\n";

> @file = <FILE>;

This will read in the whole file into memory. What if the file is
100MB large? This wastes too much memory.

> close (FILE);

Again, you should check the result of your close().

> print $#file + 1;

This is an awkward way of saying:

	print scalar @file;

> This is also possible:
> 
> open(FILE, "address.txt");
> @file = <FILE>;
> close(FILE);
> 
> $count = 0;
> foreach $line(@file) {  # Look at every part of the array seperatly. The will
> become the string $line in this case.
>     $count++;
> }
> print $count;

The following:
		$count = @file;

replaces your last 5 lines, is much faster, and requires a lot less
typing.

A better way of doing things would be:

	open F, 'file' or die $!;
	1 while <F>;
	$count = $.;
	close F or warn $!;

An even better way would be to checkout perlfaq5:

	How do I count the number of lines in a file?

HTH,
Ala



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

Date: Mon, 17 May 1999 20:16:35 +0300
From: cederstrom@kolumbus.REMOVE_THIS.fi (Juho Cederstrom)
Subject: Re: DBI not thread safe. Another way?
Message-Id: <slrn7k0jnj.9ba.cederstrom@vortex.cede.net>

On Sun, 16 May 1999 09:53:03 -0400, 
Darrel Davis <darreld@his.com> wrote:
> strings and sends tem back to the client.  I read last night that DBI is
> not thread safe and is recommended to NOT open DBI with > 1 thread.

Does that mean, that I can't run multiple instances of a program or that 
I can't have multiple threads in a program?

-- 
#!/usr/bin/perl -wT # Please take a look at my mail address when replying
use CGI;$a=reverse"r56%b6%36%16%H02%l27%56%P02%r56%86%47%f6%e6%A02%t37%".
"57%J=japh";$b=new CGI($a);$c=$b->param(lc(reverse("JAPH")));print"$c\n";


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

Date: 18 May 1999 16:03:32 +0100
From: Jonathan Stowe <gellyfish@gellyfish.com>
Subject: Re: get date
Message-Id: <37418144@newsread3.dircon.co.uk>

Raymond Ip <rwmip@glink.net.hk> wrote:
> Me <g9D!G
> 
>> Raymond Ip wrote:
>> >
>> > How do I get the current date and use it as a filename ??
>> >
>> > eg 990517.log
>> >
>> > Thanks and Best Regards
>> >
>> > Raymond Ip
>>
>> you can use localtime() eg.
>>
>> ($sec,$min,$hr,$mday,$mon,$yr,$wday,$yday,$isdat)=localtime(time);
>> ....
>> --
>>
> 
> 
> Thanks for your information.
> 
> I try to use the follow command, why the $mon has one month difference,
> today's month is May, but return is April.
> 

But it doesnt return April, whatever made you think that ?  It might
return '4' for the month but if you had read the documentaion for
localtime() in the perlfunc manpage then you would have known that the
month starts at zero - I would recommend you must strongly to read this
documentation as you will almost certainly run into further surprises
later on.

Infact I would put it a little more strenuously - do not use the localtime
or gmtime functions until you have read the documentation for them.

/J\
-- 
Jonathan Stowe <jns@gellyfish.com>



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

Date: Tue, 18 May 1999 08:20:08 -0700
From: lr@hpl.hp.com (Larry Rosler)
Subject: Re: get date
Message-Id: <MPG.11ab24fd665aef70989a96@nntp.hpl.hp.com>

[Posted and a courtesy copy sent.]

In article <37416A8C.1588820@glink.net.hk> on Tue, 18 May 1999 21:26:36 
+0800, Raymond Ip <rwmip@glink.net.hk> says...
> I try to use the follow command, why the $mon has one month difference,
> today's month is May, but return is April.

No.  The return is not the string 'April'.  It is the integer 4.

Did you read the documentation of the function before posting this 
question?  You would have gotten your answer sooner.  You would also 
have learned something about the $year value which may surprise you.  
Better now than on January 1.

RTFM.  On your very own computer.

perldoc -f localtime

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


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

Date: Tue, 18 May 1999 09:10:31 -0600
From: Steve Short <sshort@ribi.com>
Subject: Help w/ /tr func
Message-Id: <374182E7.780125B4@ribi.com>

I would like to use either the tr/ or s/ function to remove all
occurances of carriage returns from a text variable. What searchtext
character should I try??

I tried \n & \r but neither worked. Sometimes people will add these CR's

to the forms, and I'm writing a tab delimeted file with these forms, so
the extra CR's are being intepreted as record delimeters in my
database.... Help!!





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

Date: 18 May 1999 16:15:59 +0100
From: Jonathan Stowe <gellyfish@gellyfish.com>
Subject: Re: How to create modules?
Message-Id: <3741842f@newsread3.dircon.co.uk>

Ron Frazier <ldkronos@umd.umich.edu> wrote:
> How do I create and use modules? Say I have a function called Test() that I
> want to put in another file (we'll call it subs.pm). Then I want to use the
> Test() function is testing.pl. How do I define everything (in both the
> subs.pm and the testing.pl files).
> 
> Thanks to anyone who can help. If you dont mind, please email me your
> response.
> 

You will probably want to look at the perlmod & perlmodlib manpages
and no doubt perlobj on the side .  You might also want to look at the
utility h2xs that will create a module template for you - however you
will definitely want to read the docs first.

/J\
-- 
Jonathan Stowe <jns@gellyfish.com>



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

Date: Tue, 18 May 1999 10:58:54 -0400
From: "Stephen Warren" <swarren@www.wwwdotorg.org>
Subject: Re: inserting a byte into a file
Message-Id: <7hrvac$1t8$1@owl.slip.net>

Alexandre Kuhn <akuhn@iphysiolsg1.unil.ch> wrote in message
news:374141CD.5373664B@iphysiolsg1.unil.ch...
> Hi,
>
> I am trying to read and write to a file. I thus opened my file with the
> following:
> open(FILEHANDLE, "+<filename");
> I then read several lines until I wish to insert something. As I am
> already to far in the file I use a "tell-seek" combination to move back.
> The problem is that when I then use a "print" command it only overwrites
> the current byte, instead of inserting my byte.

Naturally. There is no direct way of inserting bytes into a file! Just
think - someone has to shuffle the bytes along to make space for the new
data. It would be an overly complex (and probably inefficient, since it
would be extremely difficult to generally optimize) function to put into an
OS. For this reason, it's left to the application programmer.

> I was adviced to overcome this problem by simultaneously writing a
> second file as I am reading the original one. Then print the insertion
> to the second one, and complete it by reading-writing the rest of the
> original one.

This is the correct way to go.

> Does a command exist with which I would be able to easily insert
> something in my file?

Not that I'm aware of, but it would only take maybe 10-20 lines of Perl,
depending on exactly how you determine where/what to insert and whether you
want locking etc. etc.

--
Stephen Warren, Snr Systems Engineer, Technology House, San Francisco
mailto:swarren@techhouse.com                http://www.techhouse.com/
mailto:swarren@wwwdotorg.org                http://www.wwwdotorg.org/
              MIME, S/MIME and HTML mail are acceptable





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

Date: Tue, 18 May 1999 11:42:23 -0400
From: kpreid@ibm.net (Kevin Reid)
Subject: Re: MacPerl
Message-Id: <1dry4sj.hl3ald1j7ippmN@[192.168.0.1]>

Chris Nandor <pudge@pobox.com> wrote:

> Its biggest problem, though, is that the GUI modules are still kinda buggy
> in some ways.  I would much rather do a GUI in MacPerl than C, if it were
> more stable.

My experience is that the GUI modules are stable if your code is
well-written (checks for errors and handles them, disposes of memory,
etc.).

-- 
 Kevin Reid: |    Macintosh:      
  "I'm me."  | Think different.
    


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

Date: Tue, 18 May 1999 15:00:16 GMT
From: Berislav Vlahovic <berislav.vlahovic@sympatico.ca>
Subject: nested substring problem
Message-Id: <927039947.629984254@news1.on.sympatico.ca>

Hello,

I'm trying to solve a problem that involves large recursion due to nested
substrings.

I have

1) A fairly large database of phrases (circa 2000 records)

2) A large number of html files (circa 300 3k files) containing those phrases,
that need to be linked to a cgi, with the unique id of the phrase contained in
the url

The problem:

The problem is that roughly 10% of the database is recursive phrases.  IE some
of the phrases are substrings of other phrases.

My solution so far:

Go through the database, and find those words that will cause problems, and use
a regular expression that sets up an either-or situation for the problematic
phrases.

The Problem with that:

Some of the substrings the database finds, are substrings of other, larger
words, and the either-or situation with those larger words, creates more
recursion.
IE:
(the law of fooland|foo|law)
 but foo is a substring of fooibus maximus, and, when the
(fooibus maximus|foo)
substitution is run, foo also picks up "the law of fooland," creating bad html
such as

<a href='... prase url ...'>the law of <a href='... phrase url...'>foo</a><a
href='.. phrase url ...'> land</a></a>


Thus, I can see one option,  requiring a great deal of memory to execute:

Recursively go through the range of problematic words, in a while loop, until
no further problematic words can be found, or do so from a recursive sql select.
Generate a very large search string surrounded by pattern memory brackets, with
each word seperated by pipes sorted alphabetically descending.


Because of the large amount of memory this requires, it is not really an
option.  Also:  I'm not sure if there is a limitation to the length of
pipe-delimited substitution strings, in perl.  These substitution strings could
get quite large (circa 400 characters or more.)


If you can think of another option, possibly one that doesn't require 10
gigabytes of ram to run, please post a reply.


Thank you


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

Date: Mon, 17 May 1999 20:27:29 +0300
From: cederstrom@kolumbus.REMOVE_THIS.fi (Juho Cederstrom)
Subject: Re: No classes.zip file found
Message-Id: <slrn7k0kc1.9ba.cederstrom@vortex.cede.net>

On Mon, 17 May 1999 09:08:47 -0400, 
Frank Siegel <NorthernSnow@worldnet.att.net> wrote:
> I recently installed Java1.2.1 and do not have a classes.zip

Perl isn't yet compatible with Java1.2.1. So you don't need classes.zip
to program in Perl.

BTW, I made a little research that you might be interested in. Check
this:

--- 
#!/usr/bin/perl -w
use strict;

my @langs = qw( Perl Java );

for( @langs ) {
	print "$_ is Perl!\n"		if	/Perl/;
	print "$_ is *NOT* Perl!\n"	unless	/Perl/;
}
---

In the future you should use my program to check whether you should
send your question to comp.lang.perl.misc. The program will show you
something like this:

Perl is Perl!
Java is *NOT* Perl! 

-- 
#!/usr/bin/perl -wT # Please take a look at my mail address when replying
use CGI;$a=reverse"r56%b6%36%16%H02%l27%56%P02%r56%86%47%f6%e6%A02%t37%".
"57%J=japh";$b=new CGI($a);$c=$b->param(lc(reverse("JAPH")));print"$c\n";



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

Date: Mon, 17 May 1999 20:30:11 +0300
From: cederstrom@kolumbus.REMOVE_THIS.fi (Juho Cederstrom)
Subject: Re: Perl to C translator?
Message-Id: <slrn7k0kh3.9ba.cederstrom@vortex.cede.net>

On Mon, 17 May 1999 17:40:30 +0100, 
Sebastian Ahrens <dataadm@elfi2.rz.ruhr-uni-bochum.de> wrote:
>   perlcc is your friend (perldoc perlcc should bring up the man page)...

--- 8< --- 8< --- 8< --- 8< --- 8< --- 8< --- 8< --- 8< --- 8< --- 
vortex:~/perl$ perl -v
This is perl, version 5.005_03 built for i386-linux
 ..
vortex:~/perl$ perldoc perlcc
No documentation found for "perlcc".
vortex:~/perl$   
--- 8< --- 8< --- 8< --- 8< --- 8< --- 8< --- 8< --- 8< --- 8< --- 

CPAN?

-- 
#!/usr/bin/perl -wT # Please take a look at my mail address when replying
use CGI;$a=reverse"r56%b6%36%16%H02%l27%56%P02%r56%86%47%f6%e6%A02%t37%".
"57%J=japh";$b=new CGI($a);$c=$b->param(lc(reverse("JAPH")));print"$c\n";


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

Date: 18 May 1999 15:42:41 +0100
From: Jonathan Stowe <gellyfish@gellyfish.com>
Subject: Re: Simple Time Manipulation
Message-Id: <37417c61@newsread3.dircon.co.uk>

Newsworthy <hannum@ohio.edu> wrote:
> Hello,
> 
> I want to be able to add 24 hours to the (timelocal) funciton.  Could
> somebody tell me how I can best do this?
> 

I assume you mean localtime ?

$time = localtime(time + 86400);

Which of course might fail at some places at certain times of the year but
its usually good enough ;-}

/J\
-- 
Jonathan Stowe <jns@gellyfish.com>



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

Date: Tue, 18 May 1999 08:38:24 -0700
From: lr@hpl.hp.com (Larry Rosler)
Subject: Re: Simple Time Manipulation
Message-Id: <MPG.11ab294592b0a86f989a97@nntp.hpl.hp.com>

[Posted and a courtesy copy sent.]

In article <FBxI1F.2En@boss.cs.ohiou.edu> on Tue, 18 May 1999 12:48:33 
GMT, Newsworthy <hannum@ohio.edu> says...
> I want to be able to add 24 hours to the (timelocal) funciton.  Could
> somebody tell me how I can best do this?

You cannot add anything to a function.  Oh, you mean to the value 
returned by the function?  How about:

    my $next_day = 24 * 60 * 60 + timelocal(0, 0, 0, 18, 4, 99);

Then you can hand that to localtime() or whatever.

Now all our yesterdays will be tomorrows.

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


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

Date: Tue, 18 May 1999 15:42:47 GMT
From: "Newsworthy" <hannum@ohio.edu>
Subject: Re: Simple Time Manipulation
Message-Id: <FBxq3s.I10@boss.cs.ohiou.edu>

Thanks Jonathan,

That's what I thought it was, but I just was not sure if localtime(time) was
in seconds or miliseconds.

Dave



Jonathan Stowe <gellyfish@gellyfish.com> wrote in message
news:37417c61@newsread3.dircon.co.uk...
> Newsworthy <hannum@ohio.edu> wrote:
> > Hello,
> >
> > I want to be able to add 24 hours to the (timelocal) funciton.  Could
> > somebody tell me how I can best do this?
> >
>
> I assume you mean localtime ?
>
> $time = localtime(time + 86400);
>
> Which of course might fail at some places at certain times of the year but
> its usually good enough ;-}
>
> /J\
> --
> Jonathan Stowe <jns@gellyfish.com>
>




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

Date: Tue, 18 May 1999 16:28:24 +0200
From: Henry Vermeulen <hvermeulen@correctnl.com>
Subject: sort non-alpha characters
Message-Id: <37417908.1031D218@correctnl.com>

Hi all, its me again.
I'm trying to sort a list like this:

<option value="verzend_biljet/psion_nederland.html">Psion
Nederland</option>
<option value="verzend_biljet/abms.html">ABMS</option>
<option value="verzend_biljet/itcs.html">I.T.C.S. bv</option>
<option value="verzend_biljet/deltron.html">Deltron</option>

Only with about 600 lines.
It must be sorted on the names between > and </option>.
Almost every piece of documentation is about nummeric sort.
Or is much to complicated for me.
(Or i'm too stupid too understand and is very easy)

Anyway, i've split up a large html file in 3 pieces and one of them
contains only the lines as above. This file is going to be opened by a
file handler, sorted, and must be written back. It all works fine, exept
for the sort.
Somehow i can't get it to work.
Who can give me a push in the right direction?

Thanx
Henry Vermeulen



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

Date: 18 May 1999 15:39:26 GMT
From: Stefaan.Eeckels@ecc.lu (Stefaan A Eeckels)
Subject: Re: sort non-alpha characters
Message-Id: <7hs1je$bp2$3@justus.ecc.lu>

In article <37417908.1031D218@correctnl.com>,
	Henry Vermeulen <hvermeulen@correctnl.com> writes:
> Hi all, its me again.
> I'm trying to sort a list like this:
> 
> <option value="verzend_biljet/psion_nederland.html">Psion
> Nederland</option>
> <option value="verzend_biljet/abms.html">ABMS</option>
> <option value="verzend_biljet/itcs.html">I.T.C.S. bv</option>
> <option value="verzend_biljet/deltron.html">Deltron</option>
> 
> Only with about 600 lines.
> It must be sorted on the names between > and </option>.
> Almost every piece of documentation is about nummeric sort.
> Or is much to complicated for me.
> (Or i'm too stupid too understand and is very easy)
> 
> Anyway, i've split up a large html file in 3 pieces and one of them
> contains only the lines as above. This file is going to be opened by a
> file handler, sorted, and must be written back. It all works fine, exept
> for the sort.
> Somehow i can't get it to work.
> Who can give me a push in the right direction?

What's so difficult about:
$ cat tosort
<option value="verzend_biljet/psion_nederland.html">Psion</option>
<option value="verzend_biljet/abms.html">ABMS</option>
<option value="verzend_biljet/itcs.html">I.T.C.S. bv</option>
<option value="verzend_biljet/deltron.html">Deltron</option>

$ sort -t ">" +1 -o sorted tosort; mv sorted tosort
$ cat tosort
<option value="verzend_biljet/abms.html">ABMS</option>
<option value="verzend_biljet/deltron.html">Deltron</option>
<option value="verzend_biljet/itcs.html">I.T.C.S. bv</option>
<option value="verzend_biljet/psion_nederland.html">Psion</option>

Take care,

-- 
Stefaan
-- 

PGP key available from PGP key servers (http://www.pgp.net/pgpnet/)
___________________________________________________________________
Perfection is reached, not when there is no longer anything to add,
but when there is no longer anything to take away. -- Saint-Exupiry



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

Date: Tue, 18 May 1999 15:00:06 GMT
From: eliot5581@my-dejanews.com
Subject: Sorting a colon separated file
Message-Id: <7hrv9l$bf5$1@nnrp1.deja.com>

Hi,

I'm fairly new to perl and have written a script which manipulates a
colon separated file of the form;

1:Joe:05:18:08:00:10:00:Meeting client:Mobile
2:Joe:05:19:10:00:12:30:Board Meeting:Not contactable
3:Joe:05:17:12:30:14:00:Lunch with sales team:Mobile
(the fields are entry_no, name, month, day, start_hour, start_minutes,
end_hour, end_minutes, location, contact_details)

Basically the script reads the file, strips out field 1, sorts it on
the 2nd, 3rd and 4th fields (month, day, start hour,) via an unwieldy
shell script and a temp file, and then reads the temp file and writes
it with new entry_no to the original file. The problem is that the file
starts off as an ascii text file but the last part of the manipulation
(reading lines from temp file , inserting entry_no at start and then
writing to original file) causes the file type to be changed to data
and the contents become unusable.

I'm very puzzled by this as although I'll admit the code isn't exactly
pretty I can't see why the file type changes.

Any help would be appreciated.

Regards
Eliot Finnigan
Network Analyst, Netstore Group Ltd


--== Sent via Deja.com http://www.deja.com/ ==--
---Share what you know. Learn what you don't.---


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

Date: 18 May 1999 16:23:03 +0100
From: Jonathan Stowe <gellyfish@gellyfish.com>
Subject: Re: Sorting a colon separated file
Message-Id: <374185d7@newsread3.dircon.co.uk>

eliot5581@my-dejanews.com wrote:
> Hi,
> 
> I'm fairly new to perl and have written a script which manipulates a
> colon separated file of the form;
> 

<snip>

>                                            The problem is that the file
> starts off as an ascii text file but the last part of the manipulation
> (reading lines from temp file , inserting entry_no at start and then
> writing to original file) causes the file type to be changed to data
> and the contents become unusable.
> 
> I'm very puzzled by this as although I'll admit the code isn't exactly
> pretty I can't see why the file type changes.
> 

No neither can we without seeing any code.

/J\
-- 
Jonathan Stowe <jns@gellyfish.com>



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

Date: Tue, 18 May 1999 16:46:05 +0200
From: Marc Dietrich <marc.dietrich@physik.uni-giessen.de>
Subject: undef of namespaces
Message-Id: <37417D2D.4699E47E@physik.uni-giessen.de>

Hello out there,

can someone please tell me, how to undefine complete namespaces (like
Q::). I have some variables in the Q namespace ($Q::a, @Q::b, ...) and
undef(%Q::) doesn't work.

Thanks, Marc


-- 
Marc Dietrich                marc.dietrich@physik.uni-giessen.de


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

Date: Fri, 14 May 99 00:22:08 GMT
From: hans.xie@its.CSIRO.AU (Hans Xie)
Subject: Y2K.  localtime(time)
Message-Id: <7hfqbg$fk_001@its.csiro.au>
Keywords: y2k, localtime

Hi,

I am in the middle of our Y2K testing.  I am puzzled by the localtime() return 
value.  Out system date is: Sun Jan  2 10:10:51 EST 2000

I noticed a strange thing.  I put it in the below script to make the 
situation simple and clear:
  #!/usr/local/bin/perl
  ($sec,$min,$hour,$mday,$mon,$year,$wday,$yday,$isdst) = localtime(time);
  print $year;

It prints 100, instead of 2000 or 00.

Any idea?  Thanks in advance.

environment:
Solaris 2.6, Perl 5.005_02


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

Date: 18 May 1999 15:54:21 GMT
From: jed@socrates.berkeley.edu (Jed Parsons)
Subject: Re: Y2K.  localtime(time)
Message-Id: <7hs2fd$moa$1@agate.berkeley.edu>
Keywords: y2k, localtime

That's the documented behavior of localtime.  You have to add 1900 to the 
year.  

Jed

-- 
Jed Parsons                                        jed@socrates.berkeley.edu
                                      http://www.ocf.berkeley.edu/~jparsons/
----------------------------------------------------------------------------
($qq=qq[-7-00+18+15-00-19+9+79+16+3-8+13-78-36-4+17+76-67+3-15-6-9+38+82])=~


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

Date: 18 May 1999 15:51:47 GMT
From: haeb@haeb.noc.easynet.net (Harry Broomhall)
Subject: Re: Y2K.  localtime(time)
Message-Id: <7hs2aj$58g$1@quince.news.easynet.net>

In article <7hfqbg$fk_001@its.csiro.au>,
	hans.xie@its.CSIRO.AU (Hans Xie) writes:
> Hi,
> 
> I am in the middle of our Y2K testing.  I am puzzled by the localtime() return 
> value.  Out system date is: Sun Jan  2 10:10:51 EST 2000
> 
> I noticed a strange thing.  I put it in the below script to make the 
> situation simple and clear:
>   #!/usr/local/bin/perl
>   ($sec,$min,$hour,$mday,$mon,$year,$wday,$yday,$isdst) = localtime(time);
>   print $year;
> 
> It prints 100, instead of 2000 or 00.

  Correct.

> 
> Any idea?  Thanks in advance.

  This is documented in the Camel book. Basicaly the call is a reflection
of the underlying unix call.  The year value is based on 1900.

  So add your 100 to the base and you get 2000, which is correct.

  Regards,
     Harry.



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

Date: 18 May 1999 15:55:43 GMT
From: lehnert@jupiter.uni-trier.de (Johannes K. Lehnert)
Subject: Re: Y2K.  localtime(time)
Message-Id: <7hs2hv$gne$1@fu-berlin.de>

In article <7hfqbg$fk_001@its.csiro.au>,
	hans.xie@its.CSIRO.AU (Hans Xie) writes:

>   #!/usr/local/bin/perl
>   ($sec,$min,$hour,$mday,$mon,$year,$wday,$yday,$isdst) = localtime(time);
>   print $year;
> 
> It prints 100, instead of 2000 or 00.
> 

You did not read the manual entry for localtime, did you?

>From perldoc -f localtime

  [...] Also, $year is the number of years since 1900, that is, $year 
        is 123 in year 2023. [...]

Just use the documentation...

Johannes K.

-- 
Johannes K. Lehnert    E-Mail: lehnert@jupiter.uni-trier.de 
                       WWW: http://www.informatik.uni-trier.de/CIP/lehnert/


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

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


Administrivia:

Well, after 6 months, here's the answer to the quiz: what do we do about
comp.lang.perl.moderated. Answer: nothing. 

]From: Russ Allbery <rra@stanford.edu>
]Date: 21 Sep 1998 19:53:43 -0700
]Subject: comp.lang.perl.moderated available via e-mail
]
]It is possible to subscribe to comp.lang.perl.moderated as a mailing list.
]To do so, send mail to majordomo@eyrie.org with "subscribe clpm" in the
]body.  Majordomo will then send you instructions on how to confirm your
]subscription.  This is provided as a general service for those people who
]cannot receive the newsgroup for whatever reason or who just prefer to
]receive messages via e-mail.

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

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