[12206] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 5806 Volume: 8

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Thu May 27 17:07:20 1999

Date: Thu, 27 May 99 14: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           Thu, 27 May 1999     Volume: 8 Number: 5806

Today's topics:
        Access a hard disk on a local network <marine.seiliez@wanadoo.fr>
        ASPSESSIONID, LWP, Cookies and redirects. <kmcfadden@claravista.com>
    Re: Can someone help me on this challenging problem? <g.courtemanche2@sympatico.ca>
        Can someone tell me what this means? (Sawnews)
    Re: Can someone tell me what this means? <dgris@moiraine.dimensional.com>
    Re: Can someone tell me what this means? phu@mobility.com
        Compiling perl under linux 2.2.9 jlargent2@juno.com
        Connecting to IBM DB2 database using DBD-DB2 <salk@forrest.cz>
    Re: date conversion and comparison routines emarkert@my-deja.com
    Re: Debug works-standard DOESN'T <jwarner@tivoli.com>
    Re: FAQ 4.16: Does Perl have a year 2000 problem? Is Pe <rra@stanford.edu>
    Re: FAQ 4.16: Does Perl have a year 2000 problem? Is Pe (Ilya Zakharevich)
    Re: Hash question <ludlow@us.ibm.com>
    Re: HTTP Upload using CGI.pm (Alastair)
    Re: Ineed major help creating a CGI script with PERL (Alastair)
    Re: is there a perl sdk? (Alastair)
    Re: missing dates in ascii files (Larry Rosler)
    Re: My first working script; comments, hints? (Tad McClellan)
    Re: Nested Data in MySQL.. getting at it with DBI.. mmatz@my-deja.com
        Passing arguments in SSI <deeto@yahoo.com>
    Re: Perl and FUD [was: Safe.pm necessary for secure CGI emarkert@my-deja.com
    Re: Perl compiler...If or when (Ilya Zakharevich)
    Re: Reading text file (Tad McClellan)
        Really dumb problem <jhecker@iago.nac.net>
    Re: Sorting Problem <aef@pangea.ca>
    Re: unexponentialize field from text file (Ilya Zakharevich)
    Re: Use of parenthesis : General question <ludlow@us.ibm.com>
    Re: why doesn't my first program work?? (ok , third or  <cassell@mail.cor.epa.gov>
        Special: Digest Administrivia (Last modified: 12 Dec 98 (Perl-Users-Digest Admin)

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

Date: Thu, 27 May 1999 22:42:15 +0200
From: "marine.seiliez" <marine.seiliez@wanadoo.fr>
Subject: Access a hard disk on a local network
Message-Id: <7ikaug$ort$2@wanadoo.fr>

Hello !

I would like to access to files that are on another PC than the HTTP server.
This computer is connected to the server through a local network (under Win
NT), in another network group. I know the IP computer, I know its name and
its group, but I don't know how to access it in my Perl script.

Could anybody help me ? Thanks...

(I am rather a newbie in Perl)




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

Date: Thu, 27 May 1999 19:56:43 GMT
From: Kevin <kmcfadden@claravista.com>
Subject: ASPSESSIONID, LWP, Cookies and redirects.
Message-Id: <7ik81q$6nc$1@nnrp1.deja.com>

I'm writing a LWP client that accesses an ASP site.  During a
discussion, I learned that the ASPSESSIONID variable is set based upon
the browser id (a value that is created everytime you execute a new
browser.)

In my client, I access the first page of the site and then POST the
username and password.  Two different ASPSESSIONIDs get recorded.  Does
LWP handle the browser id when creating session ids, or is this
something special that I need to find a workaround for?

Also, the page after the login ends up redirecting, and for this
I get a 302 Object Moved error.  This seems to be a problem
regardless...

<testcode snippet>

  $ua = new LWP::UserAgent;
  $ua->agent('Mozilla/5.0');
  $jar = HTTP::Cookies::Netscape->new();
  $ua->cookie_jar($jar);

  $request = new HTTP::Request('GET', 'https://site');
  $response = $ua->simple_request($request);

  print $response->as_string(), "\n\n";

  $request = POST 'https://emagine.teligent.com/login.asp',
    [ LOGIN     => 'user',
      PASSWORD  => 'password',
    ];

  $response = $ua->simple_request($request);

  print $response->as_string(), "\n\n";

<end testcode snippet>

My understanding is that setting $ua->cookie_jar() will cause the
requests to automatically handle cookies and that simple_request()
enables server redirects.   Is this correct?

Thanks for any help,

Kevin


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


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

Date: Thu, 27 May 1999 20:36:54 GMT
From: "Yves Gauvreau" <g.courtemanche2@sympatico.ca>
Subject: Re: Can someone help me on this challenging problem?
Message-Id: <G1i33.25133$8z3.20234@news20.bellglobal.com>

Hi,

If I read this correctly you could look for graph theory or more
specifically the Prim algorithm, the Kruskal algorithm or the ADD algorithm.
If you don`t find anything write me back I might have some thing for you.

Hope this helps

YG

Ralph Emerson <uyv_IGNORE_r@hotmail.com> wrote in message
news:7ihfpl$t3u@dfw-ixnews11.ix.netcom.com...
> I thought of this one on my own but because it just seems so common, I'm
> sure someone else out there has done something very similar.  The way I'm
> thinking of working it won't work for big input files.
>
> The number 1 connects to numbers 4,5,8 and 9.
> The number 2 connects to numbers 4 and 8.
> The number 3 connects to 5 and 6.
> ........
> The number 7 connects to nothing.
> ......
> The number 9 connects to 2,5 and 8.
>
> The input file looks like this
> -----------
> 9 {The number of connectors}
> 3 4 5 8 9
> 4 8 9
> 1 5 6
> 1 2 8
> 1 3 9
> 3
> 0
> 1 2 4 9
> 5 2 8
> --------------
> I bet you can see what I'm asking already.  Find the shortest connection
> path between two numbers.  For example the shortest connection between 1
and
> 2 is 1-4-2.  The shortest connection between 6 and 2 is 6-3-5-9-2.
>
> I'm thinking a good old recursive function that calles itself with all the
> numbers in it's row and stops when it hits the number it wants. (I
wouldn't
> have it loop back to itself somehow).  There's got to be a better way to
do
> this so that it will work for list 5000 long with 10-12 connectors each.
I
> cross posted so that I could get all the ideas I can and even though I can
> read the languages I posted to, please post back ideas/Visual English and
> Report Language++ and not real code so that others can comment.
>
>




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

Date: 27 May 1999 19:21:34 GMT
From: sawnews@aol.com (Sawnews)
Subject: Can someone tell me what this means?
Message-Id: <19990527152134.16536.00002988@ng69.aol.com>

Can't locate LWP/Simple.pm in @INC (@INC contains:
/usr/lib/perl5/5.00503/i386-linux /usr/lib/perl5/5.00503
/usr/lib/perl5/site_perl/5.005/i386-linux /usr/lib/perl5/site_perl/5.005 .) at
/usr/local/etc/httpd/sites/southernchristian.com/cgi-bin/ffsadmin.pl line 130.
BEGIN failed--compilation aborted at
/usr/local/etc/httpd/sites/southernchristian.com/cgi-bin/ffsadmin.pl line 130.
[Thu May 27 13:45:15 1999] [error] [client 205.188.196.26] Premature end of
script headers:
/usr/local/etc/httpd/sites/southernchristian.com/cgi-bin/ffsadmin.pl


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

Date: Thu, 27 May 1999 19:29:01 GMT
From: Daniel Grisinger <dgris@moiraine.dimensional.com>
Subject: Re: Can someone tell me what this means?
Message-Id: <12h33.1059$x11.4614@wormhole.dimensional.com>

sawnews@aol.com (Sawnews) writes:

> Can't locate LWP/Simple.pm in @INC

You need to install LWP.

dgris
-- 
Daniel Grisinger          dgris@moiraine.dimensional.com
perl -Mre=eval -e'$_=shift;;@[=split//;;$,=qq;\n;;;print 
m;(.{$-}(?{$-++}));,q;;while$-<=@[;;' 'Just Another Perl Hacker'


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

Date: Thu, 27 May 1999 20:39:12 GMT
From: phu@mobility.com
Subject: Re: Can someone tell me what this means?
Message-Id: <7ikahg$8i2$1@nnrp1.deja.com>

It says perl failed to find the module file "LWP/Simple.pm" which is
used somewhere in your ffsadmin.pl.
If you know where the directory LWP is, let's say
it's /usr/local/perl_mod/LWP/, then one way to deal with this is to add
-I/usr/local/perl_mod/ in the command line of your ffsadmin.pl , that
is:
if ffsadmin.pl starts like this:
#!/usr/local/bin/perl
You'll need to change it to:
#!/usr/local/bin/perl -I/usr/local/perl_mod/

If you don't have LWP, then you have to go and get it from somewhere.
-Peter

In article <19990527152134.16536.00002988@ng69.aol.com>,
  sawnews@aol.com (Sawnews) wrote:
> Can't locate LWP/Simple.pm in @INC (@INC contains:
> /usr/lib/perl5/5.00503/i386-linux /usr/lib/perl5/5.00503
> /usr/lib/perl5/site_perl/5.005/i386-
linux /usr/lib/perl5/site_perl/5.005 .) at
> /usr/local/etc/httpd/sites/southernchristian.com/cgi-bin/ffsadmin.pl
line 130.
> BEGIN failed--compilation aborted at
> /usr/local/etc/httpd/sites/southernchristian.com/cgi-bin/ffsadmin.pl
line 130.
> [Thu May 27 13:45:15 1999] [error] [client 205.188.196.26] Premature
end of
> script headers:
> /usr/local/etc/httpd/sites/southernchristian.com/cgi-bin/ffsadmin.pl
>


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


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

Date: Thu, 27 May 1999 20:42:27 GMT
From: jlargent2@juno.com
Subject: Compiling perl under linux 2.2.9
Message-Id: <374dad8d.178658547@news.iu.net>

When I run the Configure script it finds my nsl and crypt libs( says
they are cached) but then when it get to where it compiles try.c in
the CC dir. it fails with ld unable to load -lnsl and if I change the
linking order putting -lnsl last it fails on -lcrypt.

Any suggestions?




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

Date: Thu, 27 May 1999 18:25:42 +0200
From: Salkowich <salk@forrest.cz>
Subject: Connecting to IBM DB2 database using DBD-DB2
Message-Id: <374D7206.2198F3F5@forrest.cz>

	Hi,

can anybody help me, please? Very important.

I need to make connection from one RS/6000 to another 
with DB2 on AIX 4.3.2.
I downloaded DBD-DB2 Perl module. I can't copile it because
I haven't some header files (sqlcli.h, sqlcli1.h, sqlext.h)
and db2 library for AIX. It seems those files are included
in DB2 UDB Developers Edition. But I am not sure.

So I need:
1) the header files and the library
or
2) DBD-DB2 perl module in binary.

Thanks for interest.

Salk

 +-----------------------------------------------+
 |   //////  //////  //     //  // @forrest.cz   |
 |   //      //  //  //     // //  @forrest.cz   |
 |   //////  //////  //     ///    @forrest.cz   |
 |       //  //  //  //     // //  @forrest.cz   |
 |   //////  //  //  ////// //  // @S110Rko.cz   |
 +-----------------------------------------------+
 | FORREST GUMP MULTIMEDIA http://www.forrest.cz |
 +-----------------------------------------------+

-- 
 +-----------------------------------------------+
 |   //////  //////  //     //  // @forrest.cz   |
 |   //      //  //  //     // //  @forrest.cz   |
 |   //////  //////  //     ///    @forrest.cz   |
 |       //  //  //  //     // //  @forrest.cz   |
 |   //////  //  //  ////// //  // @S110Rko.cz   |
 +-----------------------------------------------+
 | FORREST GUMP MULTIMEDIA http://www.forrest.cz |
 +-----------------------------------------------+


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

Date: Thu, 27 May 1999 19:06:07 GMT
From: emarkert@my-deja.com
Subject: Re: date conversion and comparison routines
Message-Id: <7ik52s$4f5$1@nnrp1.deja.com>

Date::Manip is a very nice module that allows you to do all sorts of
date manipulations, calculations, etc.

>
>    http://www.perl.com/CPAN/modules/by-module/Date
>


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


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

Date: Thu, 27 May 1999 15:23:45 -0500
From: John Warner <jwarner@tivoli.com>
Subject: Re: Debug works-standard DOESN'T
Message-Id: <374DA9D1.FB83AE4@tivoli.com>

Yours is the second time I have seen people have problems referencing
Win32::OLE.  I too am running ActiveState Perl 5.005_03 build 516 but
have been unable to reproduce the problem.  I recently delved into OLE
programming with Perl and had few problems.  My own efforts used
Win32::OLE, DBI, and DBD::Oracle to grab some info from an Oracle db and
crank it into an Excel spreadsheet to update some graphs, and publish
that to a intranet web server.

The only problem I encountered was that my OLE connections to Excel
seemed to break easily when attempting to pass the OLE handle to a
subroutine.  I also figured out that if you open multiple Excel
spreadsheets, you can't selectively close them.  All of this I
attributed to my own ignorance as I had never done any OLE programming
before.  However, at no time was I forced to use old syntax to refer to
the OLE module.

So my question is:  what is different between our setups?  Output from
running perl -v on my machine is below:

C:\>perl -v
This is perl, version 5.005_03 built for MSWin32-x86-object
(with 1 registered patch, see perl -V for more detail)

Copyright 1987-1999, Larry Wall

Binary build 516 provided by ActiveState Tool Corp.
http://www.ActiveState.com
Built 19:54:31 May 14 1999
[license stuff omitted]
===end output===

Given that what I did worked and yours didn't using the same build of
Perl leads me to believe something else is afoot.  Did you perchance
download, compile, and install the OLE module separately?

Sample working code:
#!/usr/local/bin/perl
use Win32::OLE;
use DBI;
use DBD::Oracle;

#Local definitions
local $ex;    #Handle to invoke Excel
local $DEBUG = 1;   #override cfg file

&StartExcel;  #Fire up the old OLE engine
if ($DEBUG){print "DEBUG:  Main:  Finished processing\n";}
$ex->Quit;   #Close Excel
close LOG;
exit;
#=============================================================
#=============================================================
#sub StartExcel: Set up OLE connection to Excel
#=============================================================
sub StartExcel{
    my $errmsg;
    $errmsg = "Oops, cannot start Excel";

    # use existing instance if Excel is already running
    eval {$ex = Win32::OLE->GetActiveObject('Excel.Application', sub
{$_[0]->Quit;})};
    die "Excel not installed" if $@;     #Bail if eval() returned an
error

    # start Excel if not running
    unless (defined $ex) {
        $ex = Win32::OLE->new('Excel.Application', sub {$_[0]->Quit;})
or die $errmsg;
    }
}

kgentes@gentek.net wrote:

> Hey!  I figured it out!
>
> Activestate Perl wants me to reference
> OLE as "use OLE", where the standard
> distribution wants me to to this "use Win32::OLE".
> Still use the
>
>   "use Win32::OLE::Const 'Microsoft Excel';"
>
> but make all other references to "Win32::OLE"
> (in this program) instead use "OLE" only.
> AGAIN this is only for ActiveState Perl.
>
> That change fixes the problem.
>
> Weird...
>
> Kim
>
> In article <7ijv47$vnu$1@nnrp1.deja.com>,
>   kgentes@gentek.net wrote:
> > Folks,
> >
> >   I am running Perl (activestate 516) on NT.
> >   When I try to use Perl code that instantiates
> >   OLE objects (ADO and Excel, specifically),
> >   I can get this to happen in debug mode.  I
> >   cannot get it to work in non-debug mode.
> >   We installed Perl (Build 516) on another
> >   NT and get the same results.
> >
> >   We have installed Perl on a few test NTs
> >   and this is reproducable behaviour.  Is this
> >   a bug , or am I doing something consistantly
> >   wrong?
> >
> > Kim
> >
> >   The error shows up as follows:
> >
> > =============================================
> > "C:\SPIn>wkt-csv.pl
> >
> > Enter the name of the file to convert from wk1 : cpt_001.wk1
> > Can't locate object method "CreateObject" via package "OLE" at
> > C:\SPIn\wkt-csv.pl line 79, <STDIN> chunk 1.
> >
> > ================================================
> >
> > the code looks like this :
> > ===========================================
> > # specify the defined packages we wish to include with our
> > # current build.
> > use Cwd;
> > use Win32::OLE;
> > use Win32::OLE::Const 'Microsoft Excel';
> >
> >       # use existing instance if Excel is already running
> >       eval {$excel =
> > Win32::OLE->GetActiveObject('Excel.Application')};
> >       die "Excel not installed" if $@;
> >       unless (defined $excel) {
> >               $excel = CreateObject OLE "Excel.Application"
> >                        or die "Oops, cannot start Excel";
> >       }
> >
> > =================================================

--

John Warner                           Tivoli Systems Inc.
Sales Support Engineer           9442 Capital Of Texas Hwy North
Sales Infrastructure Group       Austin, TX 78759
john_warner@tivoli.com




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

Date: 27 May 1999 12:44:14 -0700
From: Russ Allbery <rra@stanford.edu>
Subject: Re: FAQ 4.16: Does Perl have a year 2000 problem? Is Perl Y2K compliant?
Message-Id: <ylk8tumh69.fsf@windlord.stanford.edu>

In comp.lang.perl.misc, finsol <finsol@ts.co.nz> writes:

> Tom, thought you may be interested to know that I'm not the only
> mis-guided soul using the term "programming language" to describe CGI
> for expedience.

Do you use the term "cat" to describe dogs for expedience too?

"Hey, all these other people are illiterate, so obviously it's okay that I
am too!  And I can't be bothered to read the documentation for anything
before actually using it, so it all sucks!"

Pathetic.

Please go bother religious extremists, isolationists, food hoarders, or
someone else whose grasp of technical problems equals your own and get the
hell out of technical newsgroups until you've actually learned a
programming language.

-- 
#!/usr/bin/perl -- Russ Allbery, Just Another Perl Hacker
$^=q;@!>~|{>krw>yn{u<$$<[~||<Juukn{=,<S~|}<Jwx}qn{<Yn{u<Qjltn{ > 0gFzD gD,
 00Fz, 0,,( 0hF 0g)F/=, 0> "L$/GEIFewe{,$/ 0C$~> "@=,m,|,(e 0.), 01,pnn,y{
rw} >;,$0=q,$,,($_=$^)=~y,$/ C-~><@=\n\r,-~$:-u/ #y,d,s,(\$.),$1,gee,print


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

Date: 27 May 1999 20:17:23 GMT
From: ilya@math.ohio-state.edu (Ilya Zakharevich)
Subject: Re: FAQ 4.16: Does Perl have a year 2000 problem? Is Perl Y2K compliant?
Message-Id: <7ik98j$a2g$1@mathserv.mps.ohio-state.edu>

[A complimentary Cc of this posting was sent to Sitaram Chamarty
<sitaram@diac.com>],
who wrote in article <slrn7ko97k.odc.sitaram@diac.com>:
> >> perl -wle '$a=shift; $b = shift; $d = substr $a,$a if shift;  $c = $a
> + $b; print $c' 5555555555 1
> >Name "main::d" used only once: possible typo at -e line 1.
> >5555555556
> >
> >> perl -wle '$a=shift; $b = shift; $d = substr $a,$a if shift; $c = $a
> + $b; print $c' 5555555555 1 1
> >Name "main::d" used only once: possible typo at -e line 1.
> >substr outside of string at -e line 1.
> >1260588260
> >
> >(differ only by the third ARGV term)
> 
> Wow!  I'm still reeling.  Anyway, wouldnt you call that a bug?

Of course it is (for a couple of days already: was!) a bug.  But what
I meant is that the amount of bugs/misfeatures in Perl makes it
*undocumentable* in any practical sense.  I'm going to fight this (but
not localtime(), of course - API *is* stupid, it gets in the way, but
it is pretty minor comparing to other problems, like an absense of ??
and 3-args open).

But the opposition on p5p (which basically says: Perl is perfect as it
is) is increadibly strong.

Ilya


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

Date: Thu, 27 May 1999 14:29:58 -0500
From: James Ludlow <ludlow@us.ibm.com>
Subject: Re: Hash question
Message-Id: <374D9D36.C4C6FB1B@us.ibm.com>

LorainCounty.com Webmaster wrote:

[snip - How do I look up a hash element by value?]

> Sorry if this is a little confusing I am new to hashes and haven't found
> the answer in the FAQ's.

It's in perlfaq4.

http://language.perl.com/newdocs/pod/perlfaq4.html#How_do_I_look_up_a_hash_element_

-- 
James Ludlow (ludlow@us.ibm.com)
(Any opinions expressed are my own, not necessarily those of IBM)


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

Date: Thu, 27 May 1999 20:14:06 GMT
From: alastair@calliope.demon.co.uk (Alastair)
Subject: Re: HTTP Upload using CGI.pm
Message-Id: <slrn7krdfo.5h.alastair@calliope.demon.co.uk>

Neal Barney <nbarney@csd.sdl.usu.edu> wrote:
>1.  Does CGI.pm have the capability to change the default filter from
>'*.html' to '*'?

Not as far as I know. No big deal, as far as I'm concerned. User education
required.

>2.  Is there anyway using CGI.pm (or any other perl module) to create a
>file upload progress box, similar to the browser download progress box? 
>Or must I use JavaScript to accomplish this?

Again, not as far as I know and again, no big deal here. I regularly use the CGI
module to upload files (anything to 500k) and have never been bothered by this.

HTH.

-- 

Alastair
work  : alastair@psoft.co.uk
home  : alastair@calliope.demon.co.uk


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

Date: Thu, 27 May 1999 20:08:26 GMT
From: alastair@calliope.demon.co.uk (Alastair)
Subject: Re: Ineed major help creating a CGI script with PERL
Message-Id: <slrn7krd53.5h.alastair@calliope.demon.co.uk>

dream69 <info@lucem.com> wrote:
>How do I make a script in the first place? Please help me. I have the Corel
>Script editor version 7.467 but I have no Idea on how to make a script to be
>able to create amailing robot for my Web page orderform. Please be gentle
>and tell me step by step. I need some guidance in this field. I also need a
>little dialogue box so that every member has a username and password to
>enter to my site. My Html form looks like this:
>
>Signed,
>Santiago Carmuega
>
>Your reply would be highly appreciated. Anybody out there know how to do
>this?

You make ascript using any text editor. The script can then be interpreted by
Perl. If you're interested in CGI, I suggest the 'CGI' module. For email, there
are also plenty of mail modules (check CPAN - http://www.cpan.org). I'd suggest
you try and learn Perl first though (buy a decent book).


-- 

Alastair
work  : alastair@psoft.co.uk
home  : alastair@calliope.demon.co.uk


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

Date: Thu, 27 May 1999 20:04:52 GMT
From: alastair@calliope.demon.co.uk (Alastair)
Subject: Re: is there a perl sdk?
Message-Id: <slrn7krcue.5h.alastair@calliope.demon.co.uk>

sbeaulieu@my-deja.com <sbeaulieu@my-deja.com> wrote:
>Is there a Perl SDK anywhere?

Hang on. Perl *is* a SDK!

-- 

Alastair
work  : alastair@psoft.co.uk
home  : alastair@calliope.demon.co.uk


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

Date: Thu, 27 May 1999 12:29:32 -0700
From: lr@hpl.hp.com (Larry Rosler)
Subject: Re: missing dates in ascii files
Message-Id: <MPG.11b73cf3b1a4d6c8989b11@nntp.hpl.hp.com>

[Posted and a courtesy copy mailed.]

In article <374D1E2E.1920AFB4@dnmi.no> on Thu, 27 May 1999 10:27:58 
+0000, John Bjornar Bremnes <j.b.bremnes@dnmi.no> says...
> I have a lot of ascii files with columns: year month day hour x1 x2 x3
> .... The problem is that some dates might be missing and I would like to
> add these to the file. An example:

<SNIP of data, reproduced below>

> New file:
> 1998 12 31 00  -1  -1  -1
> 1998 12 31 06  NA  NA  NA
> 1998 12 31 12  -1  -1  -1
> 1999 01 01 00  NA  NA  NA
> 1999 01 01 06  NA  NA  NA
> 1999 01 01 12  NA  NA  NA
> 1999 01 02 00  -1  -1  -1
> 1999 01 02 06  -1  -1  -1
> 1999 01 02 12  NA  NA  NA
> 
> Any suggestions? Useful modules? 

The only module you need is Time::Local, for the timegm() function.  
That module is included in the standard perl distribution (though I 
published a function recently that does this in a few lines of code 
without a module).

I implemented the following using UTC, to avoid Daylight-Savings-Time 
nightmares.  The program doesn't check for bad data, but what the 
hell...  It also doesn't produce that last NA line.

Why you want to skip the 1800-hour entries is beyond my ken, but the 
test is in there.


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

use Time::Local;
my $prev_time;

while (<DATA>) {
    my ($year, $month, $day, $hour) = split ' ', $_, 5;
    my $this_time = timegm 0, 0, $hour, $day, $month - 1, $year - 1900;
    $prev_time ||= $this_time; # Get started from the first datum.
    while (($prev_time += 6 * 60 * 60) < $this_time) {
        my ($hour, $day, $month, $year) = (gmtime $prev_time)[2 .. 5];
        printf "%.2d %.2d %.2d %.2d  NA  NA  NA\n",
            $year + 1900, $month + 1, $day, $hour unless $hour == 18;
    }
    $prev_time = $this_time;
    print;
}
__END__
1998 12 31 00  -1  -1  -1
1998 12 31 12  -1  -1  -1
1999 01 02 00  -1  -1  -1
1999 01 02 06  -1  -1  -1

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


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

Date: Thu, 27 May 1999 10:42:08 -0400
From: tadmc@metronet.com (Tad McClellan)
Subject: Re: My first working script; comments, hints?
Message-Id: <0klji7.hfo.ln@magna.metronet.com>

Remco Gerlich (scarblac-spamtrap@pino.selwerd.cx) wrote:
: After reading Learning Perl, a lot of messages in this group,
: and those parts of the docs I needed, I wrote my first "useful"
: script that was actually finished, and works. I thought I could
: post it here to see if someone has useful hints, because I'm sure
: there's going to be a lot wrong with it still, or at least there
: will be better ways to do some things.

: This is the script. Any comments on my style, or errors I've missed?

: #!/usr/bin/perl -w


   Warnings enabled. The first of the two first things is handled.

   Very good!


: # init RNG
: srand;

: $SIGCOM = $groups = $sigfile = undef;


   But you are missing the second of the first two things.

   Namely, the "use strict" pragma (compiler directive).

   If you "use strict;" then you must declare your variables
   before using them. So the above would become:


      my ($SIGCOM, $groups, $sigfile);  # they come set to undef already


: # for some reason I can't just use $ARGV[0] later on -
: # because of using <>?


   Yep. But then you can use $ARGV instead (maybe?).



: open (POST, ">$article");


   You have been reading articles here?

   It appears that you have somehow missed seeing one that says:

      *Always* check the return value from open() calls:

      open (POST, ">$article") || die "couldn't open '$article'  $!";



: # Read the sig index file
: open (SIGINDEX, "$ENV{'HOME'}/.sigindex") or die "No .sigindex: $!";


   So maybe you _have_ been reading articles here after all  :-)

   Why check the return value sometimes, but not other times?


: @sigindex = <SIGINDEX>;
: foreach $line (@sigindex) { chop $line; }


   chomp() is preferred over chop() for removing line endings.

   It even works on lists (so does chop).

   So you can replace the line above with:

      chomp(@sigindex);  # implicit loop



:   if ($SIGCOM =~ / ([^\"\']+)/) {


   double/single quotes are not metacharacters in a char class
   (there are only 4 such chars:   ]  \  ^  - ), so you do not
   need to backslash them:

      if ($SIGCOM =~ / ([^"']+)/) {


:   } elsif ($SIGCOM =~ / \"(.+)\"/) {


   double quotes are not metacharacters in regular expressions,
   so you don't need to backslash those either...


:     if ($try =~ /^\/(.*)\/ (.*)/) {


   if you chose an alternate delimiter, then you won't have to
   backslash the slashes either:

      if ($try =~ m!^/(.*)/ (.*)!) {



--
    Tad McClellan                          SGML Consulting
    tadmc@metronet.com                     Perl programming
    Fort Worth, Texas


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

Date: Thu, 27 May 1999 20:00:47 GMT
From: mmatz@my-deja.com
Subject: Re: Nested Data in MySQL.. getting at it with DBI..
Message-Id: <7ik89e$6qi$1@nnrp1.deja.com>

In article <Pine.LNX.4.05.9905261438380.12109-100000@aura.title14.com>,
  Pat Trainor <ptrainor@title14.com> wrote:
> (forgive the cross-post, but it applies to both)
>
> Here's an interesting(to me) problem:
>
> situation: perl & mysql (there's another way?)
>
> 	I have lots and lots of rows in a table. Each row has an id.
Each
> row also has a 'parent' id. These are web pages, but that isn't
important.
> 	Desired is to produce a query in mysql (sub-queries are not
> possible yet with mysql) that will populate a complex perl array such
that
> the 'tree' can be printed to represent the way the arrays are actually
> connected. Sounds weird, but it's easy:
>
> id
> id
> |------>id
> id
> |------>id
> 	|------>id
> 	|------>id
> id
> [...]
>
> 	Where the parent of a child is one less tab space(in the example
> above). Each parent can have many children, but each child can only
have
> one parent.
>
> 	After a structure is in memory, it will be used to pull out the
> names of the rows for each page, and a link to it with the graphical
> representation.. hopefully better than what I drew above!
>
> 	I'm not looking for hand-holding, so flame-off, please. I can
get
> at the db no sweat, just puzzled as to how to approach building a
large
> array with the values of each child and it's parent, then be able to
> output it in a way that will be logical.
>
> TIA!
>
> pat
> :)
>
> ptrainor@title14.com (key: www.title14.com/pgp/pat.key)
> Programming Rates: I do it: $20 You watch: $40 You help: $80
>
> Pat, I worked on a data warehouse system that used a structure just
like you mention to build a tree of reports.  2 Ways you can do it.  We
had a rank on each row as well as a node_id and parent_node_id.  The
rank was maintained as a fully opened tree traversing downward.  Then
the query is simply selecting all nodes in order.  More difficult is
inserting the rows in order and maintaining the tree.  Another way to
select the rows - providing you have a static amount of 'levels' is to
join the table to itself (using aliases) n level times where a.node_id
= b.parent_node_id and b.node_id = c.parent_node_id etc.  We used C++
as the programming language so it was easy to have a node class that
had an array of children that when retrieved were casted as nodes also
with an array of children.  I have just started using perl so I don't
know how easy it would be to emulate this.  I hope this helps.

Mike


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


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

Date: Thu, 27 May 1999 16:28:41 -0400
From: Scott Kramer <deeto@yahoo.com>
Subject: Passing arguments in SSI
Message-Id: <374DAAF9.B12B2C01@yahoo.com>

I'd like to have the following:
<!-- #exec cgi="cgi-bin/script.pl?myName=hello&yourName=goodbye"-->

Is this possible.  The script goes through the input data as normal, as
if it was a link being click on, but this way the script runs as soon as
the page is accessed.


Thanks.

--


Scott Kramer
http://www.makeyoulaugh.com




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

Date: Thu, 27 May 1999 19:04:06 GMT
From: emarkert@my-deja.com
Subject: Re: Perl and FUD [was: Safe.pm necessary for secure CGI?]
Message-Id: <7ik4v4$4d1$1@nnrp1.deja.com>

One use for Safe.pm would be to restore serialized objects.  Modules
like Data::Dumper, etc. basically take data structures and serialize
them in such a manner that you can save them to an ascii file.  The
easiest way to restore these objects would be to use eval.
Unfortunately, if someone tampered with one of these files eval'ing it
could, at the very least, corrupt your programs namespace - at worst do
some really vicious stuff to your system.  Safe.pm attempts to prevent
this by eval'ing stuff in segregated portions of your applications
namespace thus preventing any corruption, etc.

> And I still don't understand why or when I would want to use Safe.pm.
 I read in
> the documentation that "The Safe extensions module allows the creation
of
> compartments in which Perl code can be evaluated."  But I don't
understand why I
> would want to do that, particularly as it applies to CGI programming.
 Should I
> "use Safe" in everything, just to be uh... safe?
>
> Greg
>
> --
>
> ======================
> Gregory McCann
> http://www.calypteanna.com
>
> "Be kind, for everyone you meet is fighting a great battle."  Saint
Philo of
> Alexandria
>


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


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

Date: 27 May 1999 20:23:44 GMT
From: ilya@math.ohio-state.edu (Ilya Zakharevich)
Subject: Re: Perl compiler...If or when
Message-Id: <7ik9kg$aa7$1@mathserv.mps.ohio-state.edu>

[A complimentary Cc of this posting was sent to Eli the Bearded 
<*@qz.to>],
who wrote in article <eli$9905271318@qz.little-neck.ny.us>:
> > If you want example how to download a tarball from Makefile.PL, see
> > Math::Pari.  But you may also plug into CPAN.pm, which has 'get'
> > command already.  Hmm, maybe this is a better solution: write an
> > extension to CPAN.pm which calls CPAN's 'get', then calls harness.
> 
> How does the CPAN module handle extracting tar.gz files? <dig><dig>
> System tools or modules it seems. Bootstrapping into Archive::Tar
> and Compress::Zlib seems like it would be tricky on a PC.

It is not tricky on mine (OS/2).  Moreover:

You do not need this module if you build from the source.  If you have
a binary distribution, somebody did already bootstrap it.

Ilya


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

Date: Thu, 27 May 1999 10:25:31 -0400
From: tadmc@metronet.com (Tad McClellan)
Subject: Re: Reading text file
Message-Id: <rkkji7.hfo.ln@magna.metronet.com>

Tom Christiansen (tchrist@mox.perl.com) wrote:
:      [courtesy cc of this posting mailed to cited author]

: In comp.lang.perl.misc, "Robert" <ducott@geocities.com> writes:
: :Does anyone know how I can tell the code to read the text file and print
: :it's contents in the same format as it's written in the text file.
:  ^^^^                                ^^^^

: Sir, I'm afraid your genitives are missing.


   He must be using that Eunuchs operating system then...


--
    Tad McClellan                          SGML Consulting
    tadmc@metronet.com                     Perl programming
    Fort Worth, Texas


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

Date: Thu, 27 May 1999 20:27:38 GMT
From: Jared Hecker <jhecker@iago.nac.net>
Subject: Really dumb problem
Message-Id: <_Uh33.152$m4.1060@nntp1>

I think I'm just a little tired today.  Is there any reason I can't run
perl scripts in background in a Korn shell on a Sparc?  E.g. shell script:
 
perlscrip1 &
wait
perlscript2 &
wait
perlscript3


When I run the shell script it appears to ignore the 'wait' commands and
races through to the last perl script.  ?? Whazzup wit dat ??  I need to
run the scripts serially; I suppose I could issue a system call from one
script to the next or demodularize and make them all subroutines called
from a master a la C, but I don't understand why this shouldn't work!

TIA -

Regards,
jh
-- 
Jared Hecker	| HWA Inc. - Oracle architecture and Administration
jared@hwai.com	|  ** serving NYC and New Jersey **


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

Date: Thu, 27 May 1999 14:01:25 -0500
From: "AEF" <aef@pangea.ca>
Subject: Re: Sorting Problem
Message-Id: <7ik4p0$i4r$1@pumpkin.pangea.ca>


RABM@prodigy.net wrote in message ...

>use strict;
>use diagnostics; # for >= 5.004
>while ( <DATA> ) {
>    chomp;
>    create_index(split /,/, $_);
>}
>my %category_idx;
>sub create_index {
>    my($job_category, $equip_type, $position, $wages) = @_;
>    #create an array for all of these use a reference
>    my $rdata = [$job_category, $equip_type, $position, $wages];
>    push (@{$category_idx{"$job_category"}}, $rdata);
>}
># sort by the job categories first
>foreach my $k ( keys %category_idx ) {
>    print $k, "\n";
>    # now sort by the wages field
>    foreach my $cat (sort { $a->[3] <=> $b->[3] }  @{$category_idx{$k}} ) {
> print "\t", map { "$cat->[$_]  " } 0,1,2,3;
> print "\n";
>    }
>}
>


Vinny:
Thanks, I appreciate the time for your reply.

This still gives the same output as my hash creation previously, with the
same
problem that the categories are not in order ie THE category with the
highest salary
would be #1, (Major)  the next in rating would be (Charter), the next
(Executive).

Output

Executive
        HS125Captain82000
        Lear30Captain75000
        CitationFirst60000
        KingAir100/200Captain55000
Government
        P3OrionCaptain75000
        CitationCaptain65000
Tier_3
        BE1900Captain38000
Major
        A320Captain183000
        A320Captain173700
        A340First138109
        B737Captain130000
        A320First90000
        A320First85000
        B747Second71113
        A320First43000
Charter
        B757Captain86000
        A320Captain80000
        B757First54200
        A330First50000
        CitationCaptain50000
        L1011First45000
Discount
        B737First40000
Freight
        Falcon20Captain72000
Commuter




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

Date: 27 May 1999 20:21:37 GMT
From: ilya@math.ohio-state.edu (Ilya Zakharevich)
Subject: Re: unexponentialize field from text file
Message-Id: <7ik9gh$a7h$1@mathserv.mps.ohio-state.edu>

[A complimentary Cc of this posting was sent to Larry Rosler
<lr@hpl.hp.com>],
who wrote in article <MPG.11b68f3248e53768989b0e@nntp.hpl.hp.com>:
> + > #!usr/bin/perl -w
> + > use strict;
> + > 
> + > while (<DATA>) {
> + >     s/((?:\d+(?:\.\d*)?|\.\d+)[Ee][+-]?\d+)/$1 + 0/eg;
> + >     print;
> + > }
> + > __END__
> + > 0.20161E-01 1e0 -.5e+1
> + > 0.49279E-02
> + 
> + Prints
> + 
> + 	2.0161e-02 1 -5
> + 	4.9279e-03
> + 
> + here.
> + 
> + Hope this helps,
> 
> Well, not really.  Where is 'here'?

EMX perl.

> 
> I checked this code on perl 5.002, 5.003, 5.004_03 and 5.005_03

It has nothing to do with the Perl version.  Num->str conversion is
done by C RTL, so Perl will do the same C does.  AFAIK, vendors are
free to use 'e'-format for values below 0.1 (I got one message to the
contrary, so maybe the previous statement is not *that* correct ;-).

Ilya


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

Date: Thu, 27 May 1999 14:14:59 -0500
From: James Ludlow <ludlow@us.ibm.com>
Subject: Re: Use of parenthesis : General question
Message-Id: <374D99B3.9F0B9C08@us.ibm.com>

Thierry METOUDI wrote:

> it's noticeable that Perl let us make up our own programming style, but
> I would like to know if there were specific reasons when it comes to the
> use of parenthesis, they seem so optionnal.

In many cases, they are optional.  You're free to use any reasonable
style you want.

> Maybe considerations of backward compatibility (unless it's a forward
> one :-)
> For instance what are the differences between:
> 
> open IN, $filename ;
> 
>     and
> 
> open (IN, $filename);

For the example that you gave, one benefit of using ()'s would be
avoiding the common mistake of using:

open IN, $file || die "Error opening $file: $!";   # wrong

when you really mean

open IN, $file or die "Error opening $file: $!";

And then, maybe you think it's more clear to use:

open (IN, $file) or die "Error opening $file: $!"; 

It really comes down to style.  I try to use ()'s whenever it makes the
code easier to read.  If they're just clutter, then I'll leave them out.

-- 
James Ludlow (ludlow@us.ibm.com)
(Any opinions expressed are my own, not necessarily those of IBM)


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

Date: Thu, 27 May 1999 13:58:39 -0700
From: David Cassell <cassell@mail.cor.epa.gov>
Subject: Re: why doesn't my first program work?? (ok , third or something)
Message-Id: <374DB1FF.D6FAB558@mail.cor.epa.gov>

Scratchie wrote:
> 
> Tom Christiansen <tchrist@mox.perl.com> wrote:
> : In comp.lang.perl.misc, therzog@knotech.com (Tim Herzog) writes:
> : :The volume of perl documentation doesn't mean that
> : :the language is accessible.  Quite the contrary.
> 
> : I guess you'd say the same thing about the Oxford English Dictionary,
> : the Encyclopaedia Britannnica, Tolstoy's War and Peace, Thoreau's
> : Walden, Bach's Bm Mass, Mendelssohn's Midsummer Night's Dream, or
> : Mozart's Requiem.
> 
> Exactly. English is not an easy language to learn (so I'm told), in spite
> of the documentation. Neither is music.
> 
> If a foreigner is having trouble learning English, do you say "Idiot! Why
> don't you just go read the dictionary?"

I think that here people say, "Hey retardo, go to the right
newsgroup first, and *then* RTF Dictionary!"  :-)

David
-- 
David Cassell, OAO                     cassell@mail.cor.epa.gov
Senior computing specialist
mathematical statistician


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

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

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