[10425] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 4018 Volume: 8

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Tue Oct 20 11:03:59 1998

Date: Tue, 20 Oct 98 08:00:18 -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, 20 Oct 1998     Volume: 8 Number: 4018

Today's topics:
        All perl works with CGI????? <steveadams@ozemail.com.au>
    Re: Avoid excessive punctuation? (Walter Tice USG)
    Re: CGI quandaries <marty@catnmoose.com>
        File locking with FNCTL.pm <claytonn@psi.com>
    Re: Glob Prob (Abigail)
        help shorten one-liner jkane@my-dejanews.com
    Re: how to process fixes length record files <barnett@houston.Geco-Prakla.slb.com>
    Re: Newbie needs help transposing two words in a file (Andrew M. Langmead)
    Re: Perl & window.open droby@copyright.com
    Re: PERL and a DATABASE.. (William D. Reardon)
    Re: Perl Y2K copmliance (William D. Reardon)
    Re: Perl Y2K copmliance (I R A Aggie)
        Rounding Problem <andrew.simpson@matcomcorp.com>
    Re: Rounding Problem <haverlan@agric.gov.ab.ca>
        Sambar help <enyoung@echo-on.net>
        re: sorting file entries by time <lee@juno.ltd.uk>
    Re: sql <info@edoc.co.za>
        strip leading zeros <tim.schelfhout@telenet.be>
    Re: strip leading zeros <dfc@phys.ufl.edu>
    Re: strip leading zeros <Tony.Curtis+usenet@vcpc.univie.ac.at>
    Re: strip leading zeros <pholser@americasm01.nt.com>
    Re: What isn't Perl good for? (Snowhare)
    Re: What isn't Perl good for? <earlw@kodak.com>
        Special: Digest Administrivia (Last modified: 12 Mar 98 (Perl-Users-Digest Admin)

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

Date: Wed, 21 Oct 1998 00:28:53 +1000
From: "Steve Adams" <steveadams@ozemail.com.au>
Subject: All perl works with CGI?????
Message-Id: <70i6u2$m1o$2@reader1.reader.news.ozemail.net>

Hi all,

Please help me as this is getting kind of urgent. I have written a perl
script which works fine as a stand alone script to create a .forward file
and ftp it to a server. This is that script:

#!/usr/bin/perl
print "E-mail Forwarding By Steve Adams\n\n";
print "Enter your UserID : ";
chomp ($ozuserid=<STDIN>);
print "Enter your password : ";
chomp ($ozpassword=<STDIN>);
print "Enter the e-mail address to forward to : ";
chomp($fwdemail=<STDIN>);
$filename = "$ozuserid.ftp";
open(FOO,">$filename") || die("Abandon Ship! \n $!");
print FOO "user $ozuserid $ozpassword\nput $ozuserid.forward\nrename
$ozuserid.forward .forward\nbye";
close(FOO);
$filename = "$ozuserid.forward";
open(FOO,">$filename") || die("Abandon Ship! \n $!");
print FOO "$fwdemail";
close(FOO);
system("ftp -nv ftp.ozemail.com.au <$ozuserid.ftp");
system("rm $ozuserid.ftp");
system("rm $ozuserid.forward");
print "\nMail Forwarding Complete!\n";

The perl script was not intended to be the final solution but I had to get
the basics of the perl script working before I added the web page interface
to a cgi script. I have done the HTML and began the cgi script which looks
like this :

#!/usr/bin/perl
read(STDIN, $buffer, $ENV{'CONTENT_LENGTH'});
@pairs = split(/&/, $buffer);

foreach $pair (@pairs)
{
    ($name, $value) = split(/=/, $pair);
    # Un-Webify plus signs and %-encoding
    $value =~ tr/+/ /;
    $value =~ s/%([a-fA-F0-9][a-fA-F0-9])/pack("C", hex($1))/eg;
    # Stop people from using subshells to execute commands
    # Not a big deal when using sendmail, but very important
    # when using UCB mail (aka mailx).
    $value =~ s/~!/ ~!/g;
    $FORM{$name} = $value;
}

I should then be able to refer to the variables from the web page as
$FORM{'name'}  which I can do fine to print to a web page but when I add the
main body of my original perl script I keep getting internal server errors.
Am I able to issue all perl commands inside a cgi script? If so why doesn't
the cgi script work that does work fine as a normal perl script. The part of
the original perl script that I was trying to add to the cgi script above is
this.

$filename = "$FORM\{'ozuserid'}.ftp";
open(FOO,">$filename") || die("Abandon Ship! \n $!");
print FOO "user $FORM\{'ozuserid'} $FORM\{'ozpassword'}\nput
$FORM\{'ozuserid'}.forward\nrename $FORM\{'ozuserid'}.forward
 .forward\nbye\n";
close(FOO);
$filename = "$FORM\{'ozuserid'}.forward";
open(FOO,">$filename") || die("Abandon Ship! \n $!");
print FOO "$FORM\{'fwdaddress'}";
close(FOO);
system("ftp -nv ftp.ozemail.com.au <$FORM\{'ozuserid'}.ftp");
system("rm $FORM\{'ozuserid'}.ftp");
system("rm $FORM\{'ozuserid'}.forward");
print "\nMail Forwarding Complete!\n";

Any help that would lead to a solution that works would be GREATLY
appreciated. Thanks in advance for any help offered.

Steve Adams




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

Date: 20 Oct 1998 14:28:23 GMT
From: tice@hunch.zk3.dec.com (Walter Tice USG)
Subject: Re: Avoid excessive punctuation?
Message-Id: <70i6m7$aru@zk2nws.zko.dec.com>

I'm rereading 'Effective Perl Programming', which is just a great
book.  I do have a style objection to a specific suggestion on pp 34 
"Item 10: Avoid excessive punctuation."  I'm sure the idiomatic
crowd thinks it's a good idea to be able to to call functions without
the explicit ampersand, or even worse use a plus sign (pp 32) ack!

My objection is two-fold:

#1. It's a matter of clarity/definition. If one writes the code, 
    sure, you know that 'myfunc' is a function, but what about
    maintenance?  You have to parse the whole pattern into your
    brain before you say 'aha! function'.  It's similar to reading
    some long English sentence with a bang at the end, you might be
    2/3 of the way through before you realize you've been reading
    it flat.  In some languages the bang comes first, so you know upfront.

#2. Since the ampersand is required if one wants to use a keyword for
    a func name, you could end up with mixed use, which is even less
    clear.

Naturally, it's a personal choice, but brevity isn't always clear, and
excessive coolness isn't always wise - or appreciated by those that 
follow.
-- 

JAIPH (just another intermediate perl hacker)

"Do you want to go back to where I found you?


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

Date: Tue, 20 Oct 1998 09:03:36 -0400
From: Marty Landman <marty@catnmoose.com>
Subject: Re: CGI quandaries
Message-Id: <362C8A28.D6B29A7D@catnmoose.com>

Well I tried adding my parm as an additional path qualifier and get a server
error.  I've seen other sites invoke counters as images with a '?name=val'
type of arg appended to the cgi script and wonder if this is a restriction of
my server.

I also don't understand how the additional qualifier even CAN work, isn't the
server supposed to then locate a module with the full path name?  It's kind of
easy for me, I'll just plead ignorance which is unfortunately the case.

Another thing I'm really curious about is how to get to a link.  I've found
that I can open a file on my own site, so I could then read it and spit it out
to the client browser for rendering.  What if I wanted to get a link from
anywhere on the web?  How's that done.

<rant>I've found Perl the absolutely hardest thing in the world to learn.  but
I'm beginning to realize it isn't the language's fault but rather the lack of
my understanding of CGI, which is merely an application, albeit common and
important one of the Perl language.</rant>

Matt Pryor wrote:

> Hmmm.. strange.
>
> Have you tried sending the arguments as additional path information
> instead?
>
> <!-#exec cgi="/cgi-bin/count.cgi/page001"-->
>
> Matt
> --
>
> Marty Landman wrote:
> >
> > I have some questions and comments/guesses based on my limited
> > experience regarding my logging programs for my site.  I am finding that
> > using SSI to call my log pgm from within an SHTML file gives me a valid
> > HTTP_REFERRER field but will not accept an argument which would allow me
> > to know that the page is being hit.
> >
> > i.e. <!--#exec cgi="./cgi-bin/count.cgi"--> works, but if I do
> > ...count.cgi?page=first... then it won't work, I get an invalid
> > directive msg which I presume is from the server.
> >
> > So I wrote a logging pgm invoked as an image tag which spits out a 1x1px
> > gif file and does accept an argument, it even logs it.  Now on telnet I
> > can see it work and also on a browser (NE4.05) w/o an argument.  But
> > once I add the argument if I look an NE3 I get a big old broken link,
> > although the parm is evidently passed to my pgm and the pgm runs since
> > the log is appropriately updated... nonetheless with the parm I get a
> > server error, w/o the parm it runs fine.
> >
> > Am I running into a restriction on my server?  It seems like I can only
> > successfully parameterize a CGI call when it's in a link.  The nature of
> > logging would seem to be passive since I want to know when someone gets
> > to a page, they don't necessarily have to DO anything once they get
> > there.  But I can't seem to use a parameterized CGI call for such a
> > passive situation.
> >
> > Sorry about my ignorance, I've probably come further than I should have
> > w/o reading the Camel book, Amazon assures me it's in the mail.  Any
> > leads would be appreciated.
> > --
> > Marty Landman           Cat 'n Moose Web Site Design & Development
> >
> > Living Glass            http://www.catnmoose.com/livinglass
> > Web Safe Color Picker   http://www.catnmoose.com/wsc.shtml
> > Tic-Tac-Toe             http://www.catnmoose.com/tictac.shtml
>
> --
> Matt's daily comic strip
> Porridge and Fartcakes
> http://www.whiterabbit.co.uk/cartoons



--
Marty Landman           Cat 'n Moose Web Site Design & Development

Living Glass            http://www.catnmoose.com/livinglass
Web Safe Color Picker   http://www.catnmoose.com/wsc.shtml
Tic-Tac-Toe             http://www.catnmoose.com/tictac.shtml




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

Date: Tue, 20 Oct 1998 10:44:12 -0400
From: "niki clayton" <claytonn@psi.com>
Subject: File locking with FNCTL.pm
Message-Id: <70i7kb$gnt$1@usenet1.interramp.com>

I need to use fnctl() to lock files. My books do not tell me

1. how to create the third, packed return buffer value to lock the file
2. how to unlock the file when I am done writing to it.

use fnctl;

open (PWDOUT, ">>passwords.txt") || die "Cannot open file $!\n";

 fcntl(PWDOUT, F_GETFL, $packed_return_buffer) or die "can't fcntl F_GETFL:
$!\n";





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

Date: 20 Oct 1998 14:17:29 GMT
From: abigail@fnx.com (Abigail)
Subject: Re: Glob Prob
Message-Id: <70i61p$4l8$1@client3.news.psi.net>

Martin (minich@globalnet.co.uk) wrote on MDCCCLXXV September MCMXCIII in
<URL:news:70ftr1$i89$1@newnews.global.net.uk>:
++ Hi!
++ 
++ I have the following:
++ 
++ @threads = <*.*>;
++ 
++ which won't include in the array files with no extension. Is there anyway to
++ modify the glob to let it do that?


If you want to include files with no extensions, don't ask for files
with extensions only.



Abigail
-- 
perl -we '$@="\145\143\150\157\040\042\112\165\163\164\040\141\156\157\164".
             "\150\145\162\040\120\145\162\154\040\110\141\143\153\145\162".
             "\042\040\076\040\057\144\145\166\057\164\164\171";`$@`'


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

Date: Tue, 20 Oct 1998 13:22:01 GMT
From: jkane@my-dejanews.com
Subject: help shorten one-liner
Message-Id: <70i2pp$g3r$1@nnrp1.dejanews.com>

I am new to perl, and am trying to learn it.  As a learning tool I am counting
things in a perl script.

I am trying to count the number of lines that have code and comments in them.
i.e.

   $_ =~ tr/A-Z/a-z/;                  # Translate it to all lower case.

While NOT counting the lines that are ONLY comments, blank, or have a # as
part of the text in the code.  (I am helping myself by putting spaces after
all #'s that are comments.)  i.e.

 # Number of args left, plus the current one, give the remainder divided by 2.
    # If there are not an even number of arguments, it MUST be wrong.

 if (($#ARGV+1)%2) {

Those four lines should NOT match at all!

So, my "personal" goal is to make a single command I can run from a prompt
that will do this and keep it under 80 columns! :{ )  I have come up with
three lines that all do this, and only one is short enough to keep me happy. 
Of course, the file name makes a difference here for length.  I am keeping it
short for example, but in real life, it is 20 chars long!

# The minus one is because the pattern matches itself in the script.
# I am keeping a copy of this line in it as an example for future referance.
 a=`perl -ne 'print if /(;|{|}).*# .*/' perl_script | wc -l`;expr $a - 1
 perl -ne 'if(/(;|{|}).*# .*/){$a++;print $a-1,"\n";}' perl_script |tail -1
 perl -e 'while(<>){if(/(;|{|}).*# .*/){$a++;}}print $a-1,"\n";' perl_script

Anybody have a better way of doing this??  The shortest one has to use 'wc -l'
and `expr`.  I want to make this ONLY perl.

I will be using this to figure out how many lines there are in future programs
also.  I have other strings that are short that count other things.  Just that
this one needs the minus 1 and that makes it so much longer than the rest.

FYI:  The pattern is looking for a semicolon, right curly brace, or left curly
brace followed by anything, a #, a space, and finally anything more.  I figure
that there will never be comments in the middle of a line that does not have
one of these chars delimiting the end of it.  Am I wrong?

-Jeff Kane
jeffkane@northwesternmutual.com

-----== Posted via Deja News, The Leader in Internet Discussion ==-----
http://www.dejanews.com/rg_mkgrp.xp   Create Your Own Free Member Forum


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

Date: Tue, 20 Oct 1998 08:15:27 -0500
From: Dave Barnett <barnett@houston.Geco-Prakla.slb.com>
To: Tim Schelfhout <tim.schelfhout@telenet.be>
Subject: Re: how to process fixes length record files
Message-Id: <362C8CEF.B8758C9D@houston.Geco-Prakla.slb.com>

[courtesy cc to cited author]
[follow-ups set]

Tim Schelfhout wrote:
> 
> Hi there,
> 
> I've been trying to process files with a fixed length records content
> (fields of 25 bytes).
> Is there perhaps a function I don't know about that would take care of this
> ?  Some of the fields are not filled in so I can't do it wit split !!
> 
> I've done it with <read TEST,$veld,25> but I think it's rather stupid.
> there must be a more intelligent way to go about it.
> 
> Thanks beforehand
> 
> See ya
Tim:

Three things:
1.  comp.lang.perl is dead, use comp.lang.perl.* instead.
2.  perldoc -f unpack
3.  perldoc -f pack

unpack allows you to extract fixed length (and many other types of)
records, and pack allows you to create them.  (Not to mention the fact
that pack also gives you the template codes you will need, specifically
'a', or 'A' depending....)

HTH.

Cheers,
Dave

-- 
Dave Barnett	Software Support Engineer	(281) 596-1434


Depression is merely anger without enthusiasm.


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

Date: Tue, 20 Oct 1998 14:11:39 GMT
From: aml@world.std.com (Andrew M. Langmead)
Subject: Re: Newbie needs help transposing two words in a file
Message-Id: <F14q3F.8Io@world.std.com>

Ala Qumsieh <aqumsieh@columba.matrox.com> writes:

>I did not mean to imply that Larry doesn't test before he posts.
>The truth is that I thought that the email address supplied by my
>newsreader (aqumsieh@tigre.matrox.com) was actually fine. 

Which just proves Larry's original point, doesn't it.
-- 
Andrew Langmead


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

Date: Tue, 20 Oct 1998 14:41:50 GMT
From: droby@copyright.com
Subject: Re: Perl & window.open
Message-Id: <70i7fe$kgg$1@nnrp1.dejanews.com>

In article <70a9bs$eek$1@toto.tig.com.au>,
  "Andrew Scott" <andrewcs@tig.com.au> wrote:
>
> Tom Phoenix <rootbeer@teleport.com> wrote in message
> Pine.GSO.4.02A.9810151320520.26848-100000@user2.teleport.com...
> >On Thu, 15 Oct 1998 tomkrowas@my-dejanews.com wrote:
> >
> >> What I am wanting to do is to have a new browser window open when the
> >> URL is clicked.
> >
> >That sounds as if you want to ask a browser to do something. The docs,
> >FAQs, and newsgroups about browsers should be of help to you. Good luck!
>
>     You are beginning to sound like a broken record.......
>

Because he repeatedly gives the same nice polite answer to the constantly
repeating class of stupidly directed questions?

Tom is trying to persuade people to put their questions in the right place. 
If he wants to use a cut & paste operation to avoid extra typing, that's
fine.

I'd much rather see these polite redirects than incorrect or incomplete
Javascript/HTML/Browser/Webserver "answers".

Not that there's much hope.  Most of these people don't read the group, and
expect the answers by email.  If they read the group, they'd have seen the
redirects before and know that these questions belong elsewhere.


-----------== Posted via Deja News, The Discussion Network ==----------
http://www.dejanews.com/       Search, Read, Discuss, or Start Your Own    


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

Date: Tue, 20 Oct 1998 13:12:41 GMT
From: wdr1@pobox.com (William D. Reardon)
Subject: Re: PERL and a DATABASE..
Message-Id: <F14nD5.r7@midway.uchicago.edu>

In article <70hjhl$1dg$1@flex.london.pipex.net>,
DPortal Webmaster <webmaster_NO*SPUDS*@dportal.co.uk> wrote:
>I would like to query a database using PERL (and something like SQL), but I
>can only seem to be able to do this on NT, does anyone know of any
>UNIX/LINUIX database's that I can query using PERL. (If there FREE then even
>better ;-) ).

	Check out DBI (for the Perl portion), and mSQL or MySQL (for
the db portion).

-Bill
-- 
William Reardon	  ----   http://www.nhma.com/~wdr1/   ----   wdr1@pobox.com
    I wish I was the radio song, the one that you couldn't turn up


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

Date: Tue, 20 Oct 1998 13:11:02 GMT
From: wdr1@pobox.com (William D. Reardon)
Subject: Re: Perl Y2K copmliance
Message-Id: <F14nAF.po@midway.uchicago.edu>

In article <70hpgu$s83$1@pilot.njin.net>,
David Alan Black <dblack@pilot.njin.net> wrote:
>finsol@ts.co.nz writes:
>
>>Ron
>>An article I had published last week describes what could be a major
>>problem with some Perl applications (and several other languages) - the booby
>>trap code problem. Check it out at:
>>http://www.idg.co.nz/WWWfeat/Y2000/amon1005.htm
>
>I don't see a single reference to Perl in this article.  It's all about
>the BIOS on PCs, and how it interacts with Micros**t.
>
>Please (yawn) check out the usual archives and references for this
>topic as it actually relates to Perl.

	Well, since it affects Microsoft systems, and Perl runs on
Microsoft systems, in the end, a person's Perl program may not work as
expected in the year 2000.  While the problem is not particular to
Perl, it may be something that a Perl programmer need be aware of.[1]
	I'd call that appropriate for clp.misc & on topic for this thread.

-Bill

[1] Depending, of course, on if the Win32 versions of Perl do have
this problem.  (I don't know, but would like to.)
-- 
William Reardon	  ----   http://www.nhma.com/~wdr1/   ----   wdr1@pobox.com
    I wish I was the radio song, the one that you couldn't turn up


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

Date: Tue, 20 Oct 1998 09:42:03 -0500
From: fl_aggie@thepentagon.com (I R A Aggie)
Subject: Re: Perl Y2K copmliance
Message-Id: <fl_aggie-2010980942030001@aggie.coaps.fsu.edu>

In article <F14nAF.po@midway.uchicago.edu>, wdr1@pobox.com (William D.
Reardon) wrote:

+ In article <70hpgu$s83$1@pilot.njin.net>,
+ David Alan Black <dblack@pilot.njin.net> wrote:

+ >I don't see a single reference to Perl in this article.  It's all about
+ >the BIOS on PCs, and how it interacts with Micros**t.

+         Well, since it affects Microsoft systems, and Perl runs on
+ Microsoft systems, in the end, a person's Perl program may not work as
+ expected in the year 2000.  While the problem is not particular to
+ Perl, it may be something that a Perl programmer need be aware of.[1]
+         I'd call that appropriate for clp.misc & on topic for this thread.

I wouldn't.

+ [1] Depending, of course, on if the Win32 versions of Perl do have
+ this problem.  (I don't know, but would like to.)

The most straight forward way is to obtain the time from the OS. That's
how its done under unix, anyway.

Is Win95/Win98/WinNT Y2K compliant? Last I looked, NT had not been judged
to be compliant...

James


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

Date: Tue, 20 Oct 1998 08:26:06 -0500
From: "Drew" <andrew.simpson@matcomcorp.com>
Subject: Rounding Problem
Message-Id: <70i3a0$hm9$1@nntp.gulfsouth.verio.net>


I am having trouble rounding certain numbers.
Originally I used sprintf to do the rounding, but
when

$var = 0.325;
$rslt = sprintf("%.3f",$var);

resulted in 0.324, I delved into all the FAQs,
Perl sites, etc. and discovered that 0.325
is stored as 0.32499999 --> to 20 places?
When rounded it obviously becomes 0.324.

I then used the borrowed code

sub roundnum
{
    my ($number, $precision) = @_;
    $precision = 2 unless defined $precision;
    $number    = 0 unless defined $number;
    my $multiplier = (10 ** $precision);
    return int(($number * $multiplier) + .5) / $multiplier;
}

which still seems to cause the same problems.

SYSTEM/VERSION INFORMATION
SunOS 5.5.1 Generic_103640-20 sun4u sparc SUNW,Ultra-1
This is perl, version 5.003 with EMBED
        built under solaris at Oct 31 1996 10:54:50
        + suidperl security patch




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

Date: Tue, 20 Oct 1998 08:16:18 -0600
From: Gordon Haverland <haverlan@agric.gov.ab.ca>
Subject: Re: Rounding Problem
Message-Id: <362C9B32.B97BDCA3@agric.gov.ab.ca>

Drew wrote:
> 
> I am having trouble rounding certain numbers.
[...]
> resulted in 0.324, I delved into all the FAQs,
> Perl sites, etc. and discovered that 0.325
> is stored as 0.32499999 --> to 20 places?
> When rounded it obviously becomes 0.324.

>From my humble point of view, your borrowed code
(now deleted) should have worked.  Your problem
may lie at a deeper level.

First off, 0.32499999..... rounded to 3 decimal
places is 0.325.  0.325 CHOPPED at 3 places is
0.324.  In terms of hardware, chopping is much easier
than rounding.  Second, perl by default is using double
precision numbers.  In IEEE arithmetic, a double
precision number has 16+ significant figures, not 20!
Third, your supplied subroutine does not do what
is intended for negative numbers.  You need to
deal with the sign before you do the add 0.5 business.
And then put the sign back in later.  Fourth, some
decimal (base 10) numbers will never be exactly
represented in base 2.  If what you are working 
towards is to print strings of rounded numbers,
you probably should be doing the rounding as
a string function, not a numeric function.

# something like
$string = sprintf("%f",$var);
$prec_m1 = $prec - 1;
$prec_p1 = $prec + 1;
if( $string =~ /^(\d{1,$prec_m1})(\d)(\d{$prec_p1,$prec_p1})/ ) {
  # true all the time if we have a number in the first place
  if( $3 =~ /[5-9]/ ) {
    # round up
 ...

This psuedo code does not check for the precision
number being positive (negative numbers don't make sense).
It also doesn't properly handle what happens if $3 is equal
to 5 (if needs to check the next digit, and possibly the
next, ....).

Gordon Haverland
#include <disclaimer.h>


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

Date: Tue, 20 Oct 1998 10:45:18 -0400
From: Errol <enyoung@echo-on.net>
Subject: Sambar help
Message-Id: <362CA1FE.621A5E58@echo-on.net>

I am trying to run a script through the CGI on the Sambar Server that I
installed on my computer.  I have a file \windows\host with "127.0.0.1
localhost" in it.  When I call up www.localhost I get the Sambar Server
home
page as I am supposed to so all that seems set up well.

I tried to get a small script to run and am having problems.  I read the

part of the book a number of times and I am probably missing something.

I got the script from the web site for the book so I know that it
works.  (I
will write it myself for practice once I get the CGI thing working.)  I
changed the first line to locate my Perl.exe.  I put the script in the
Sambar/cgi-bin directory.

I cannot figure out what the URL of the file should be.  Can you help me

over this hump?

Thanks in advance.

errol




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

Date: Tue, 20 Oct 1998 14:54:28 +0100
From: lee <lee@juno.ltd.uk>
Subject: re: sorting file entries by time
Message-Id: <362C9614.7002FF99@juno.ltd.uk>


>That's why the sort should use the built-in sort routine,
>rather than an explicitly defined one.
>
>Something like this will do nicely:
>
>@sorted_lines =
> map { substr($_,8) }
>  sort
>  map { substr($_,25,8).$_ }
> @unsorted _lines;
>
>The substring to be sorted by begins at offset 25 (from 0),
>and has a length of 8.
>
>--
>John "Many Jars" Porter

maybe i'm just doing something stupid, but i can't seem to
get this working.

i have formatted the text in the file so that the part to be
sorted by is always at the same offset.

the script i'm now trying is:

open(T, "writefile");
$line = <T>;

while ($line ne "") {
    chop($line);
    @words = $line;
    @words2 =
    map {substr($_,6) }
    sort
    map (substr($_,25,6),$_}
    @words;
    $line = <T>;
    print ("@words\n");
}

with the lines to be sorted now in the form :

 ....
 ....
BUNDDEC98 BUY  19981008 155036 50132 ....
BUNDDEC98 BUY  19981008 155036 50133 ....
BUNDDEC98 SELL 19981008 080902 259     ....
BUNDDEC98 BUY  19981008 162531 55819 ....
 ....                                               |-------|
 ....                 these six digits are the timestamps
that the lines should be sorted by, as you can see
the time jumps all over the place.

in the script i have tried changing the figures for
the substring to see the effects, but i can't get it
to sort the lines.

lee.



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

Date: Mon, 19 Oct 1998 13:47:11 +0200
From: Nico <info@edoc.co.za>
Subject: Re: sql
Message-Id: <362B26BF.4101@edoc.co.za>

Tom Phoenix wrote:
> 
> On Tue, 13 Oct 1998, Michael Nguyen wrote:
> 
> > Does anybody know of a good resource to learn how to use SQL and mSQL?
> > Books? Websites? Newgroups?
> 
www.yahoo.com  /   Software/computers etc / software ///sql


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

Date: 20 Oct 1998 13:02:02 GMT
From: "Tim Schelfhout" <tim.schelfhout@telenet.be>
Subject: strip leading zeros
Message-Id: <01bdfc29$9586cca0$4737000a@tl000143>

Hi there,

another newbie question.  Is there any way to strip leading zeros from
numbers.

ex. 000005	--> 5
     000032	--> 32

Thanks


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

Date: Tue, 20 Oct 1998 10:15:18 -0400
From: "Daniel F. Crisman" <dfc@phys.ufl.edu>
To: Tim Schelfhout <tim.schelfhout@telenet.be>
Subject: Re: strip leading zeros
Message-Id: <Pine.SOL.3.96.981020101427.29960A-100000@neptune.phys.ufl.edu>

$num =~ s/^0*//;

> Hi there,
> 
> another newbie question.  Is there any way to strip leading zeros from
> numbers.
> 
> ex. 000005	--> 5
>      000032	--> 32
> 
> Thanks
> 
> 

***********************
Daniel Crisman
dfc@phys.ufl.edu
***********************



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

Date: 20 Oct 1998 16:24:05 +0200
From: Tony Curtis <Tony.Curtis+usenet@vcpc.univie.ac.at>
Subject: Re: strip leading zeros
Message-Id: <83vhlfs456.fsf@vcpc.univie.ac.at>

Re: strip leading zeros, Tim <tim.schelfhout@telenet.be>
said:

Tim> Hi there, another newbie question.  Is there any way to
Tim> strip leading zeros from numbers.

Tim> ex. 000005 --> 5 000032 --> 32

Put the value into an integer context, viz.

    $v = '000000005';

    $w = int $v;

hth
tony
-- 
Tony Curtis, Systems Manager, VCPC,    | Tel +43 1 310 93 96 - 12; Fax - 13
Liechtensteinstrasse 22, A-1090 Wien,  | <URI:http://www.vcpc.univie.ac.at/>
"You see? You see? Your stupid minds!  | private email:
    Stupid! Stupid!" ~ Eros, Plan9 fOS.| <URI:mailto:tony_curtis32@hotmail.com>


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

Date: Tue, 20 Oct 1998 09:20:56 -0500
From: Paul Holser <pholser@americasm01.nt.com>
Subject: Re: strip leading zeros
Message-Id: <362C9C48.B917BE90@americasm01.nt.com>

Tim Schelfhout wrote:
> 
> Hi there,
> 
> another newbie question.  Is there any way to strip leading zeros from
> numbers.

Several, I'm sure.  Two that pop into my mind:

   $number_to_strip =~ s/^0+//;

and a slight tweak of a nifty substitution from
"Effective Perl Programming", pp. 245-246:

   $number_to_strip =~ s/\G0//g;

perldoc perlre and perldoc perlop for more details.
You might do well in the future to get comfy with this
documentation before posting.  You can answer your own
questions quite often by spending a few minutes with this
stuff without having to post, staving off potential
flame-age.

All the same, I'm happy to help.

cheers,
p

-- 
// Paul Holser ~ Northern Telecom, Inc. ~ Richardson TX USA
// These thoughts are mine, take 'em or leave 'em.
// Be a person, not a persona; have a life, not a lifestyle;
// have character, don't be one.  --PRH


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

Date: 20 Oct 1998 05:13:41 GMT
From: snowhare@devilbunnies.org (Snowhare)
Subject: Re: What isn't Perl good for?
Message-Id: <70h665$lfg$1@nnrp4.snfc21.pbi.net>



Nothing above this line is part of the signed message.

In article <wBSW1.38$6a4.217717@nsw.nnrp.telstra.net>,
Martien Verbruggen <mgjv@comdyn.com.au> wrote:
>In article <362BE5F4.BB56E2AF@erols.com>,
>	WMWilson <m.v.wilson@erols.com> writes:
>> I'm pretty new to this whole perl/programming thing and I'm curious 
>> as to what Perl is really horrible with (besides the obvious device 
>> driver, etc.) and when it becomes time to fumble through C or 
>> another lower level language.
>
>trolling?
>
>Perl isn't horrible at anything. And it is always time to use C.

Computational mathematics is clearly not Perl's strong suit. Perl is 
very good at what it does best - but like _all_ languages it is not 
good at _everything_. To answer the question: Use Perl for handling
things that tend to be 'textish'. Use C to handle things that tend
to be 'bittish' or that need to push the performance envelope. Use
assembly language when absolutely nothing else will do the job.

IOW: Use the tool that best matches your problem.

Benjamin Franz


Version: 2.6.2

iQCVAwUBNiwdb+jpikN3V52xAQH5zAQAq6vm/wWLdfi3La8n9n8YZud0kIjcW1s0
pzG6mI6FBn2Tcwb5uCXfuFQ9biPzB+Mr2vVh2k+cUNFwudPBNvZ40v9k4Nha7EAi
ccDE4AYK3P35lDjP+Fzc4jY8DgA23pGRT6D1XF6WBV6I65wAGCtHsHRALcHMRfLQ
ZaFQz5tM2rU=
=EFSq
-----END PGP SIGNATURE-----


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

Date: Tue, 20 Oct 1998 10:26:08 -0400
From: Earl Westerlund <earlw@kodak.com>
Subject: Re: What isn't Perl good for?
Message-Id: <362C9D80.4325@kodak.com>

Elaine -HappyFunBall- Ashton wrote:

> The day Perl makes coffee and muffins
> for me in the morning, I'll never have eyes for another language. :)

So which language does this?? :)

-- 
+-----------------+----------------------------------------+
| Earl Westerlund | Kodak's Homepage: http://www.kodak.com |
+-----------------+----------------------------------------+
|  The opinions expressed herein are mine and mine alone   |
|     (most people don't seem to want them anyway)         |
+----------------------------------------------------------+


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

Date: 12 Jul 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 Mar 98)
Message-Id: <null>


Administrivia:

Special notice: in a few days, the new group comp.lang.perl.moderated
should be formed. I would rather not support two different groups, and I
know of no other plans to create a digested moderated group. This leaves
me with two options: 1) keep on with this group 2) change to the
moderated one.

If you have opinions on this, send them to
perl-users-request@ruby.oce.orst.edu. 


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

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