[12145] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 5745 Volume: 8

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Fri May 21 15:07:12 1999

Date: Fri, 21 May 99 12:00:21 -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           Fri, 21 May 1999     Volume: 8 Number: 5745

Today's topics:
        Accessing Files Thru Network <venugopalvv@hotmail.com>
        creating system command at runtime (Eric Smith)
    Re: DB2 SDK required to use DBD::DB2? (C superior?) <technik@auburger.de>
    Re: DBD/MySQL (brian d foy)
        DBI Error Handling <wwest@ucsd.edu>
    Re: DBI::DBD trough the net... <pm@univie.ac.at>
    Re: Dereferencing a filehandle. (Tad McClellan)
    Re: FAQ 8.14: How do I modify the shadow password file  (Alan Curry)
        Getting Column headers from DB <adityauma@hotmail.com>
    Re: How do I use a regular expression to ignore Java st (Andrew Johnson)
    Re: Need Perl interpreter <cassell@mail.cor.epa.gov>
    Re: Need Perl interpreter (Tad McClellan)
    Re: Perl "constructors" <jdporter@min.net>
    Re: Perl Unicode/Multibyte Support (Tad McClellan)
    Re: Sorting arrays using values from two arrays <jdporter@min.net>
    Re: Sorting is too slow for finding top N keys... - UPD (Marko R. Riedel)
    Re: stripping text with regex (Tad McClellan)
        timelocal huichai@my-dejanews.com
    Re: TROLL ALERT (Re: Perl "constructors") <jdporter@min.net>
    Re: TROLL ALERT (Re: Perl "constructors") <jdporter@min.net>
    Re: Utterly poor perl!! (using index) <jdporter@min.net>
    Re: variable = current URL (Matthew Bafford)
    Re: variable = current URL <jdporter@min.net>
        Web page redirect - Not working ?perl problem?  Plse he <kirasa@oz.net>
    Re: What is the meaning of '.' in @INC? (Matthew Bafford)
    Re: Writing a HTML page with perl (Tad McClellan)
        Special: Digest Administrivia (Last modified: 12 Dec 98 (Perl-Users-Digest Admin)

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

Date: 21 May 1999 14:04:12 -0500
From: "Venu Gopal" <venugopalvv@hotmail.com>
Subject: Accessing Files Thru Network
Message-Id: <3745a01c@discussions>


Hi,

How do i access files in another computer
connected thru LAN and update it. Do i have
to use File::Copy module? If so tell me where
it is available.I'm using Perl under Windows

Any help is appreciated

thanks in advance

Venu



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

Date: 21 May 1999 18:55:58 GMT
From: eric@fruitcom.com (Eric Smith)
Subject: creating system command at runtime
Message-Id: <slrn7kbb5o.ahl.eric@plum.fruitcom.com>


Hi

I have scripts that automatically send mail with all sorts of prepared
parameters.  The core of the script is a call to the MUA mutt viz:

system "mutt -s '$subject' -a $file $address <<EOF
Now I am embarrassingly being reduced to the following in order to include
all the attachments.

system "mutt -s '$subject' -a $file -a\
/d/e/distribution/doc/advancereports.jpeg\
 -a /d/e/distribution/doc/bluelevel.jpeg -a\
/d/e/distribution/doc/consreport.jpeg \
-a /d/e/distribution/doc/elecscreen.jpeg -a\
/d/e/distribution/doc/greenlevel.jpeg \
-a /d/e/distribution/doc/intransitalarm.jpeg -a\
/d/e/distribution/doc/invoice.jpeg \
etc etc

Can I supply a globbing reference on the command line which will be passed
to in my @ARGV and have perl do all this dirty work for me? 

Thanx a lot

--
Eric Smith
<eric@fruitcom.com>
Tel. 021 236 111


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

Date: Fri, 21 May 1999 20:48:44 +0200
From: Andreas Vierengel <technik@auburger.de>
Subject: Re: DB2 SDK required to use DBD::DB2? (C superior?)
Message-Id: <1C444EF02304C91A.C3D0E4556AD10AC5.7D1BFE48AC0550CA@library-proxy.airnews.net>



tzadikv@my-dejanews.com wrote:
> 
> Is there any way I can distribute my Perl script that uses DBD::DB2 to
> machines that do not have the DB2 SDK installed?
> 
> I know that the DB2 SDK is necessary to *build* DBD::DB2 but question why it
> should be necessary for simply *running* a script that *uses* DBD::DB2.
> 
> One irritating aspect of this problem is that apparently a C program that
> uses DB2 does not suffer from this problem.  You just "bind" the C program
> with the DB2 database (on a machine that has the DB2 SDK) and then you can
> distribute the compiled and "bound" C program to a machine that does *not*
> have the SDK. Thus if this is true, programming DB2 apps in C has a distinct
> advantage over programming them in Perl, which rubs me the wrong way.
> 
> One problem with this issue is how to copy a DBD::DB2 module from one machine
> to the other (without building it on the second machine).  I tried doing such
> a copy recently by simply using "tar" to package up the relavant directorys
> in /usr/local/lib/perl5, but I could not run my script on the second machine.
>  I would get:
> 
> Can't load '/usr/local/lib/perl5/site_perl/5.005/aix/auto/DBD/DB2/DB2.so' for
> mo dule DBD::DB2: dlopen:
> /usr/local/lib/perl5/site_perl/5.005/aix/auto/DBD/DB2/DB2 .so: A file or
> directory in the path name does not exist. at /usr/local/lib/perl
> 5/5.00502/aix/DynaLoader.pm line 168.
> 
> (I posted about this problem at the time but got no response.  The "DB2.so"
> file it claims does not exist actually does exist...the problem seems to be
> something that is called from "DB2.so".  The only way I could come up with to
> solve this problem was to install the DB2 SDK on the second machine and
> rebuild DBD::DB2 there.)
> 

Did you do an 'ldd DB2.so'
check these dependencies and copy those libraries to the other system,
too.

Tell me, if you succeed. I will probably have the same problem in a few
weeks. Now I'm to busy to test it myself.

--Andy


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

Date: Fri, 21 May 1999 14:49:16 -0400
From: brian@pm.org (brian d foy)
Subject: Re: DBD/MySQL
Message-Id: <brian-ya02408000R2105991449160001@news.panix.com>

In article <37458446.534089460@internal.news.shellnet.co.uk>, flec@flec.co.uk (Steven Fletcher) posted:

> I've stumbled across a weird problem that I don't know the answer for
> when using DBI. I have 2 variables, $subject and $o_tech, in a line like
> this:
> 
> my $sth = $dbh->prepare( q{ INSERT INTO slips (o_tech, problem)
> VALUES($o_tech, $subject) });

you want a double-quotish context to interpolate those variables.

   qq{  yadda yadda yadda  };

good luck. ;)

-- 
brian d foy                    
CGI Meta FAQ <URL:http://www.smithrenaud.com/public/CGI_MetaFAQ.html>
Perl Monger Hats! <URL:http://www.pm.org/clothing.shtml>


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

Date: Fri, 21 May 1999 11:40:35 -0700
From: "Bill West" <wwest@ucsd.edu>
Subject: DBI Error Handling
Message-Id: <7i49ag$ie5@rosebud.sdsc.edu>

I am looking for the best method to handle database trhown errors in a CGI
environment. For instance if a user passes an insert command that violates a
unique key constraint I would like to capture that error number, interpret
it and send the user a meaningful message possibly in a Javascript alert.

The DBI documentation make a reference to a module called CGI::ErrorWrap but
I can't find it anywhere. Can someone point me in the right direction for a
strategy on this.

Thanks in advance,

Bill West
San Diego Supercomputer Center




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

Date: 21 May 1999 18:02:34 GMT
From: Peter Marksteiner <pm@univie.ac.at>
Subject: Re: DBI::DBD trough the net...
Message-Id: <7i473q$13k0$1@www.univie.ac.at>

In comp.lang.perl.misc Fridiric Ruffet <fruffet@kaptech.com> wrote:

: Here is a little problem I encounter :
: I was programming an application in perl wich access Oracle 7.3.4
: through DBI::DBD. No (big) problem. When, suddently, DBA decided to get
: the new Oracle 8.0.5. It could have been no problem for me, except that
: the new Database, is no more on the server I used to work with. I mean
: that till then perl scripts and Oracle database were on the same
: machine. Now, I have perl script on my old machine, and the new DB is on
: a distant server I can access through our Intranet. What configuration
: must I set up to access this distant database. For now, all I needed to
: do, was to set my environment variables, and to connect with the connect
: instruction of the DBI package.

The following works fine for me:

(1) On the local machine, configure tnsnames.ora (I suppose you have at
    least a rudimentary Oracle there, otherwise the DBD package would not
    compile). tnsnames.ora should contain something like 

MYSID =
  (DESCRIPTION =
    (ADDRESS = (PROTOCOL= TCP)(Host= remote.db.host.com)(Port= 1521))
    (CONNECT_DATA = (SID = MYSID))
  )

If you have a correct tnsnames.ora entry, you don't need the
TWO_TASK environment variable.

(2) Go ahead: $dbh = DBI->connect("dbi:Oracle:MYSID", "user", "pass")

   Peter

-- 
Peter Marksteiner
Vienna University Computer Center


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

Date: Fri, 21 May 1999 09:20:53 -0400
From: tadmc@metronet.com (Tad McClellan)
Subject: Re: Dereferencing a filehandle.
Message-Id: <ljm3i7.iuf.ln@magna.metronet.com>

Larry Rosler (lr@hpl.hp.com) wrote:
: [Posted and a courtesy copy mailed.]

: In article <7i3q8b$ccp$1@bmerhc5e.ca.nortel.com> on Fri, 21 May 1999 
: 10:24:24 -0400, Keith <keithp@comnet.ca> says...
: > Can anyone tell me how to show the value of a filehandle in my output?
: > I have something like this:
: > print "FILE: $_\n";
: > 
: > Where FILE is the filehandle defined earlier in the program.
: > I want FILE to show up as the real file name.

: That can't be done.

: In general, there is no way of recovering the name under which a file 
: was opened from the filehandle.  The file may even have been renamed or 
: unlinked in the meantime (under some thirty-year-old operating systems).


   Or it may even be that the filehandle is not associated with
   any file (pipe open).


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


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

Date: Fri, 21 May 1999 18:25:05 GMT
From: pacman@defiant.cqc.com (Alan Curry)
Subject: Re: FAQ 8.14: How do I modify the shadow password file on a Unix system?  
Message-Id: <5yh13.8714$M3.210993@news7.ispnews.com>

In article <374599dc@cs.colorado.edu>,
Tom Christiansen  <perlfaq-suggestions@perl.com> wrote:
>(This excerpt from perlfaq8 - System Interaction 
>    passwd(5) manpage for specifics) and use pwd_mkdb(8) to install it
                                                       ^
>    (see the pwd_mkdb(5) manpage for more details).
                       ^
-- 
Alan Curry    |Declaration of   | _../\. ./\.._     ____.    ____.
pacman@cqc.com|bigotries (should| [    | |    ]    /    _>  /    _>
--------------+save some time): |  \__/   \__/     \___:    \___:
 Linux,vim,trn,GPL,zsh,qmail,^H | "Screw you guys, I'm going home" -- Cartman


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

Date: Fri, 21 May 1999 14:26:43 -0400
From: Umashankar Kotturu <adityauma@hotmail.com>
Subject: Getting Column headers from DB
Message-Id: <3745A563.E68D6043@hotmail.com>

hi,

I am accessing MS-access from Perl using dbi drivers.

When I make a query to the database I get the data. How can I get the
header also into the program variables ?

Please reply to adityauma@hotmail.com

TIA,
Uma.



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

Date: Fri, 21 May 1999 18:15:42 GMT
From: andrew-johnson@home.com (Andrew Johnson)
Subject: Re: How do I use a regular expression to ignore Java style comments in a file? 
Message-Id: <iph13.1702$Q_5.37896@news2.rdc1.on.home.com>

In article <374597b2@news1.us.ibm.net>,
 Jacob Yackenovich <jyacken@ibm.net> wrote:
! I have close to 30,000 Java files that need to be checked for certain bits
! of information. If a line of code is commented out (by using // to comment
! the line), I would like to ignore that line completely, and move onto the
! next.
! 
! Example:
! public class myclass extends ListResourceBundle
!  ....
! { "a_key","the value"},
! // { "b_key","the other value},
! ....
! 
! In this example the line that contains a_key would be used (so would any
! other that does not have a commented line), and the line that contains b_key
! needs to be ignored. I have tried to use regular expressions to pattern
! match //, but seeing as how the contents of the pattern to be matched are
! bounded by / and /, I have ran into somewhat of a brick wall. The Perl books
! that I have referenced (Cookbook, Programming, Learning, Nutshell, 21 days,
! etc...) all turn up empty to a solution. Any ideas on how to overcome this
! one?

You could escape the slashes with backslashes 

next if m/\/\//; # Ugly (TM)

or just use different delimiters with  your match op:

#!/usr/bin/perl -w
use strict;
while(<DATA>){
    next if m<^//>;
    print;
}
__DATA__
{ "a_key","the value"},
// { "b_key","the other value},

the above only ignores lines beginning with //, you'll need to
take more care if your requirements differ.

regards
andrew


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

Date: Fri, 21 May 1999 11:02:33 -0700
From: David Cassell <cassell@mail.cor.epa.gov>
Subject: Re: Need Perl interpreter
Message-Id: <37459FB9.A719B23E@mail.cor.epa.gov>

anonymous wrote:
> 
> Where's the best place to get a Perl interpreter for Windows 98?  Can
> I download one for free from anywhere?

Yes.  If you had read the FAQ, you would have already known
that you can get Perl from www.activestate.com for free.  All
Perl stuff is free, unless you're paying someone to write code
for you.  Perl is like that.

When you download it, it will install itself with minor
intervention on your part.  Tell it where on your Start menu
you want it to put the HTML docs.  Then use your Start menu
and read the docs.  Start with the ActivePerl Docs, and read
the FAQ too.  Then you'll know (1) how to run your Perl
programs from the command line and from your webserver; (2)
how to find the answers you need, without leaving the comfort
of your computer desk.  Every time you let PPM install new
Perl modules, it will also insert the docs into your HTML
doc tree, so you'll have easy access to them as well.
 
HTH,
David
-- 
David Cassell, OAO                     cassell@mail.cor.epa.gov
Senior computing specialist
mathematical statistician


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

Date: Fri, 21 May 1999 09:24:36 -0400
From: tadmc@metronet.com (Tad McClellan)
Subject: Re: Need Perl interpreter
Message-Id: <kqm3i7.iuf.ln@magna.metronet.com>

anonymous (quikscor@ix.netcom.com) wrote:
: Where's the best place to get a Perl interpreter for Windows 98?  Can
: I download one for free from anywhere?


   http://www.perl.com


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


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

Date: Fri, 21 May 1999 17:52:47 GMT
From: John Porter <jdporter@min.net>
Subject: Re: Perl "constructors"
Message-Id: <7i46he$5cc$1@nnrp1.deja.com>

In article <7hu1qs$o54$1@nnrp1.deja.com>,
  armchair@my-dejanews.com wrote:
> > > Or perhaps I have done something that most Perl programmers
> > > have not:
> > > had to modify other people's code.

Perhaps.  Or more likely, you need to get out more, and take
a look around.

Last project I was on, I had to maintain/enhance a 10,000-line
system, on which at least five people had worked before me.
100% Perl.

--
Put it on a plate, son.  You'll enjoy it more.


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


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

Date: Fri, 21 May 1999 09:12:59 -0400
From: tadmc@metronet.com (Tad McClellan)
Subject: Re: Perl Unicode/Multibyte Support
Message-Id: <r4m3i7.iuf.ln@magna.metronet.com>

Ilya Zakharevich (ilya@math.ohio-state.edu) wrote:
: [A complimentary Cc of this posting was sent to Matt Sergeant 
: <matt-news@sergeant.org>],
: who wrote in article <37452248.272384F9@sergeant.org>:
: > > Keep in mind that apparently *nobody* did ever tried to use it
: > > (judging by the obvious bugs I see in the implementation, and a
: > > complete absense of bug reports).
: > 
: > Probably due to the fact that it's not in the perl people use yet. For
: > example, judging by the TPI survey, almost 40% of perl users are on NT,
: > for which there is no Beta-perl binary build available. I'm sure in
: > reality very few people are using 5.005_[5..9]\d
: > 
: > Once it becomes the standard perl, expect lots of bug reports from the
: > XML people... :)

: It is going to be too little too late.  I have seen reports that XML
: people shy from Perl now.


   If you build it, they will come.

   :-)


   Some (maybe even most) won't, but many others will.


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


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

Date: Fri, 21 May 1999 18:41:56 GMT
From: John Porter <jdporter@min.net>
Subject: Re: Sorting arrays using values from two arrays
Message-Id: <7i49dj$7gs$1@nnrp1.deja.com>

In article <7i3otg$6cj$1@the-fly.zip.com.au>,
  "News" <andrew_long@andrews-models.com.au> wrote:
> I am trying to sort an array by using values from another array and
then
> doing the second ordering of the sorted list.  The arrays are
> one-dimensional and always have the same number of elements.
>
> The code I have written is:
>
> sub byrank {
>  $out_rank[$a] <=> $out_rank[$b]
>  or
>  $a <=> $b;
> }
> @out_sort = sort byrank @out;
>
> which does some sort of sorting, but I can't quite work out exactly
what.
>
> As an example if we have
> @out_rank={2,2,1,1,2} and
> @out={10,20,30,40,50}
>
> I am hoping to get back from @out_sort the following
> @out_sort={30,40,10,20,50}
>
> I would be ever grateful for any help

The code you have is very close, but not quite. I'll explain
what you need to do differently.

Since you are working with two "parallel" arrays, where A[i]
corresponds to B[i], you need to sort the indices.  You use
the one array (@out_rank) to sort the indices, then use that result
to index into @out.

Long-hand:
@indices = ( 0 .. $#outrank );
@sorted_indices = sort { $out_rank[$a] <=> $out_rank[$b] } @indices;
@sorted_out = @out[ @sorted_indices ];

Putting it all together:
@sorted_out = @out[
  sort { $out_rank[$a] <=> $out_rank[$b] } ( 0 .. $#out_rank )
];

--
Put it on a plate, son.  You'll enjoy it more.


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


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

Date: 21 May 1999 20:04:20 +0200
From: mriedel@neuearbeit.de (Marko R. Riedel)
Subject: Re: Sorting is too slow for finding top N keys... - UPDATE
Message-Id: <lzvhdmwb8b.fsf@linux_sexi.neuearbeit.de>

michel.dalle@usa.net (Michel Dalle) writes:

[SNIP]
> 
> I'm not up to fully understanding the different algorithms used, but could 
> Marko's quick select implementation be improved in the same way as 
> you described for quicksort ?
> 
[SNIP]

The code included below might be a step in the right direction.

(Randomization of inputs that are expected to contain large numbers of
duplicate keys is no longer necessary.)

[SNIP] > qselect4.pl 30980 31011 < lrosler.dat 
31012
27 27 27 27 28 28 28 28 28 28 29 29 30 30 30 31 31 31 31 32 32 33 37 37 37 41 41 50 52 56 59 79
[SNIP] > sort -n lrosler.dat | tail -14
27      4
28      6
29      2
30      3
31      4
32      2
33      1
37      3
41      2
50      1
52      1
56      1
59      1
79      1


#! /usr/bin/perl -w
#

sub qsel {
  local ($aref, $min, $max, $lower, $upper) = @_;
  local ($temp, $pivot, $i, $j, $upshift);

  return $aref if($lower>=$upper);

  if($upper-$lower<=6){
    my $maxpos;

    for($i=$upper; $i>$lower; $i--){
      for($maxpos=$lower, $j=$lower+1; $j<=$i; $j++){
	$maxpos=$j if $$aref[$j]>$$aref[$maxpos];
      }
	
      if($maxpos!=$i){
	$temp=$$aref[$i];
	$$aref[$i]=$$aref[$maxpos];
	$$aref[$maxpos]=$temp;
      }
    }

    return $aref;
  }

  my $c01=$$aref[$lower] <=> $$aref[$lower+1];
  my $c02=$$aref[$lower] <=> $$aref[$lower+2];
  my $c12=$$aref[$lower+1] <=> $$aref[$lower+2];
  my $median=0;

  if(($c01!=1 && $c12!=1) ||
     ($c01!=-1 && $c12!=-1)){
    $median=1;
  }
  if(($c02!=1 && $c12!=-1) ||
     ($c02!=-1 && $c12!=1)){
    $median=2;
  }

  if($median){
    $temp=$$aref[$lower];
    $$aref[$lower]=$$aref[$lower+$median];
    $$aref[$lower+$median]=$temp;
  }


  $pivot=$$aref[$lower];

  $upshift=0;

  $i=$lower+1; $j=$upper;
  while($i<=$j){
    while($i<=$j && $$aref[$i]<$pivot){
      $$aref[$i-1]=$$aref[$i];
      $i++;
    };

    if(!$upshift){
      while($i<=$j && $$aref[$j]>$pivot){ 
	$j--;
      }
    }
    while($i<=$j){
      $c01=$$aref[$j] <=> $pivot;
      last if $c01==-1;
      
      $$aref[$j+$upshift]=$$aref[$j] if $c01==1;
      $j--;

      $upshift++ if !$c01;
    }


    if($i<=$j-1){
      $temp=$$aref[$i];
      $$aref[$i]=$$aref[$j];
      $$aref[$j]=$temp;
    }
  }

  &qsel($aref, $min, $max, $lower, $i-2) 
    if($i>$lower+1 && $min<$i-1);

  &qsel($aref, $min, $max, $i+$upshift, $upper)
    if($i<$upper && $max>=$i+$upshift);

  $$aref[$i+$upshift]=$pivot while $upshift-->=0;

  return $aref;
}


MAIN: {
  local ($min, $max)=@ARGV;
  local ($size, @perm);
    
  $|=1; $,=' ';

  for ($size=0; <STDIN>; ) {
    my ($value, $number) = /(\d+)\s+(\d+)/;
    $perm[$size++] = $value while $number--;
  }
  print "$size\n";
  print "@perm\n" if $size<=256;

  &qsel(\@perm, $min, $max, 0, $size-1);

  print "@perm[$min..$max]\n";
}


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

Date: Fri, 21 May 1999 09:17:01 -0400
From: tadmc@metronet.com (Tad McClellan)
Subject: Re: stripping text with regex
Message-Id: <dcm3i7.iuf.ln@magna.metronet.com>

Anand (anand@my-dejanews.com) wrote:
: In article <fd42i7.0je.ln@magna.metronet.com>,
:   tadmc@metronet.com (Tad McClellan) wrote:
: > ainsoph@propaganda-arts.org wrote:
: > : Is it possible to use regex to stip the text off of a string, say a
: > : first name, and turn it into an initial?
: >
: > : example: chris = c
: >
: >    No, you need an operator to do that.
: >    A regex is not enough.

: Why? This regex will do it.

: $str="chris";
: if ($str =~ /^\W*(.)/) {
               ^^^^^^^
               ^^^^^^^

   The underlined part is the regex.

   the m// is the match _operator_


:   print $1;
: }

: It prints "c" for me like the original poster wanted.


   And it uses an operator, not a regex alone, like I said.


   But, as other followups have pointed out, operators that
   use regexen are not needed for the original poster's problem.
   The substr() _operator_ will do the job without using regexen.


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


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

Date: Fri, 21 May 1999 18:05:01 GMT
From: huichai@my-dejanews.com
Subject: timelocal
Message-Id: <7i478b$614$1@nnrp1.deja.com>



Hi,

I'm noticing some strange behavior with the timelocal() function.
I have a script which takes the output from the unix 'date' command
and translates it into unix time.  When I run the program in
debug mode, it returns the right unix time, but when it is run
not in debug mode, it returns a -1.

according to the man page, the routine returns -1 if the integer
limit is hit. I.e. for dates after the 1st of January, 2038 on
most machines, which is not my case.
but why would it behave differently in debug mode?

thanks,





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


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

Date: Fri, 21 May 1999 18:01:11 GMT
From: John Porter <jdporter@min.net>
Subject: Re: TROLL ALERT (Re: Perl "constructors")
Message-Id: <7i4717$5pj$1@nnrp1.deja.com>

In article <7hmc3t$jrb$1@nnrp1.deja.com>,
  armchair@my-dejanews.com wrote:
>
> If you are saying that the normal way to construct an object is on the
> heap via:
>
> MyClass *pClass = new MyClass();
>
> I don't think that I would agree with that.

Maybe I'm just being dense, but what other way is there to construct an
object on the heap?


> C++, as I mentioned before, actually
> gives you more ways to make a class than Perl does.

Well, making a class and making an instance of a class are two
entirely separate things, of course.  I think we were talking about
the latter...  Can you show an example that illustrates your point?
What are these different ways of constructing an object that C++
gives you?

--
John Porter
Put it on a plate, son.  You'll enjoy it more.


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


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

Date: Fri, 21 May 1999 18:22:09 GMT
From: John Porter <jdporter@min.net>
Subject: Re: TROLL ALERT (Re: Perl "constructors")
Message-Id: <7i488e$6li$1@nnrp1.deja.com>

In article <374403d3@newsread3.dircon.co.uk>,
  Jonathan Stowe <gellyfish@gellyfish.com> wrote:
> armchair@my-dejanews.com wrote:
> > Well, you may not believe me on this, but I cut and paste my text
from
> > an entry in the "online manual" that you can get to via
www.perl.com.
>
> Look Nigel it doesnt even say 'record' in the *Perl 4* manpage so I
very
> much doubt that you saw it in any documentation pertaining to the
> current release.
>
> What you quoted there doesnt even like Perl documentation at all.

Sorry, gel, it very much does.

http://www.perl.com/CPAN-local/doc/manual/html/pod/perlfunc/localtime.html

--
John Porter
Put it on a plate, son.  You'll enjoy it more.


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


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

Date: Fri, 21 May 1999 18:30:23 GMT
From: John Porter <jdporter@min.net>
Subject: Re: Utterly poor perl!! (using index)
Message-Id: <7i48o0$728$1@nnrp1.deja.com>

In article <7i4097$pp$1@nnrp1.deja.com>,
  Richard Lawrence <ralawrence@my-dejanews.com> wrote:
> Here is some utterly poor code to take each line from a file txt.txt
> and see if that line contains the words on the command line ie.
>
> prog.pl fish          -- will list all lines with fish in it
> prog.pl fish chips    -- will list all lines with fish AND chips in it
>
> Two problems:
>
> 1. Its case sensitive - the only way I can think of making it case
> insensitive is by copying both bits of text to temp variables,
> lowercasing them and then compairing but that is HORRIBLE. Can anyone
> suggest a better solution?
>
> 2. Is there any better way to do this code? In the end there won't be
> the input from the command line, just an array of words (like
> @requests).
>
> #!/usr/bin/perl -w
>
> use strict;
>
> my @requests;
> my $len;
> my $flag;
> my $i;
> my $line;
>
> @requests = split(/ /, $ARGV[0]);
> $len = @requests;
>
> open (DATA, "txt.txt") || die "can't open txt.txt: $!";
> while (<DATA>) {
>   $line = $_;  # do i need to do this or will $_ stay the same?
>   $flag = 1;
>   $i = 0;
>   while ($i < $len && $flag == 1) {
>     if ((index $line, $requests[$i]) == -1) {
>       $flag = 0;
>     }
>     $i++;
>   }
>
>   if ($flag == 1) {
>     print "***** $line";
>   }
> }

If you really don't want (for whatever misguided reasons) to use
lc, then you can use m//i.

I notice that you don't really care about word boundaries.  Right?

while (<>) {
  my $match = 0;
  for my $w ( @requests ) {
    /\Q$w\E/i and $match++;
  }
  $match and print "$.: $_";
}

If you want to care about word boundaries:

while (<>) {
  my $match = 0;
  for my $w ( @requests ) {
    /\b\Q$w\E\b/i and $match++;
  }
  $match and print "$.: $_";
}

--
John Porter
Put it on a plate, son.  You'll enjoy it more.


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


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

Date: Fri, 21 May 1999 18:06:55 GMT
From: dragons@dragons.duesouth.net (Matthew Bafford)
Subject: Re: variable = current URL
Message-Id: <slrn7kb6k1.4av.dragons@dragons.duesouth.net>

On Fri, 21 May 1999 09:47:30 -0700, LEB <airman@inreach.com>
held some poor sysadmin at gun point while typing in the following:
: Does anyone know how to get the value of the current url for a window?
: 
: i.e. $url = $ENV(CURRENT_URL) or something?

Your code doesn't compile.

You don't explain what you mean by window.

All environment variables will be set by the program calling your script,
so if it is in an environment variable, it has nothing to do with Perl.

: Thanks

HTH,

--Matthew


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

Date: Fri, 21 May 1999 18:44:47 GMT
From: John Porter <jdporter@min.net>
Subject: Re: variable = current URL
Message-Id: <7i49iv$7hm$1@nnrp1.deja.com>

In article <37458E22.42198164@inreach.com>,
  LEB <airman@inreach.com> wrote:
> Does anyone know how to get the value of the current url for a window?
>
> i.e. $url = $ENV(CURRENT_URL) or something?

Since you are using CGI.pm (right? right!):

my $q = new CGI;
my $url = $q->url;

--
John Porter
Put it on a plate, son.  You'll enjoy it more.


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


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

Date: Fri, 21 May 1999 11:15:57 -0700
From: "Kira S. Anastasia" <kirasa@oz.net>
Subject: Web page redirect - Not working ?perl problem?  Plse help!
Message-Id: <3745A2DD.3623A7C1@oz.net>

Hi All & TIA,

  I've beaten my head bloody and my eyes bleary trying to
figure out where I am going wrong here.  I'm sure it is
probably ignorance on my part somehow, but I have been
unable to resolve it.

  What I am *trying* to do:  Take input from an HTML form,
process the data and generate a new page and THEN go to it
when the script finishes.  Everything works, but the
re-direct doesn't.

  I got the code from:
http://language.perl.com/newdocs/pod/perlfaq9.html#How_do_I_redirect_to_another_pag

After everything is done I do the following:
-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
#!/usr/bin/perl -w
# vgb.cgi
# Tue May 18 10:25:33 PDT 1999

# Do housekeeping.

use CGI::Request;
[ ... ]
    close VGB;
# ---- New data now in dataset -----------
[ ... ]
# --- End generate new guest book --------
$url = "http://vikki.oz.net/~kira/kgb.html";
print "Location: $url\n\n";

exit;
}
-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-

What I get is a page (from netscape view source):
-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
Location: http://vikki.oz.net/~kira/kgb.html
-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
(yes, that is the entirity of what is returned.)

I would very much appreciate any thoughts, suggestions or
pointers to help in resolving this.  

Sigh, *what* have I missed here?

Thanks MUCH & take care, Kira.
--
Respectfully, Kira Anastasia,  kirasa@oz.net
Without adventure, civilization is in full decay. Alfred
Whitehead


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

Date: Fri, 21 May 1999 18:06:54 GMT
From: dragons@dragons.duesouth.net (Matthew Bafford)
Subject: Re: What is the meaning of '.' in @INC?
Message-Id: <slrn7kb6dl.4av.dragons@dragons.duesouth.net>

On Fri, 21 May 1999 18:07:14 +0200, Vincent Vanbiervliet <vincent_vanbiervliet@be.ibm.com>
held some poor sysadmin at gun point while typing in the following:
: I was expecting that the '.' (dot) was refering to the current directory
: (I'm on a Winxx system), and thus a require would work with any files in the
: directory of my current script.
: This works on the command line, but not with my webserver. For example, if I
: use a require in /cgi-bin/asubdir/ascript.pl, and I have that 'required'
: file in /cgi-bin/asubdir/, it doesn't work.
: Why not?

Because you can assume very little about the environment a program
following the CGI is executed in.

The current directory could be /tmp, with the program being called like:

/home/vincent_vanbiervliet/www/cgi-bin/asubdir/ascript.pl

Use absolute paths:

use lib qw(/home/vincent_vanbiervliet/www/cgi-bin/asubdir);

--Matthew


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

Date: Fri, 21 May 1999 09:07:45 -0400
From: tadmc@metronet.com (Tad McClellan)
Subject: Re: Writing a HTML page with perl
Message-Id: <1rl3i7.iuf.ln@magna.metronet.com>

Eng. Edilson Francioni Coelho (efcoelho@123_rio.com) wrote:

: I'm a newbie and I'd like to write a HTML page from perl.

: I have once once done it starting with

: 	print "Content-type: text/html\n\n";

: and then printing everything else line by line, making the special
: characters preceded by the backslash.

: It worked fine, but it gave me a lot of work preparing everything. I
: have once seen such a script doing things differently, reprinting a
: whole block of HTML without regards to special characters in about the
: same way that the tags <pre></pre> works in HTML. I have not been able
: to find it in my hard disk and in the lots of perl tutorials I've been
: searching today.

: Can anyone tell me how it's done?


   A "here doc" makes it easy to output a whole bunch of lines.

   It is documented in the 'perldata.pod' man page:

---------------------
A line-oriented form of quoting is based on the shell "here-doc"
syntax.  Following a C<E<lt>E<lt>> you specify a string to terminate
the quoted material, and all lines following the current line down to
the terminating string are the value of the item.  The terminating
string may be either an identifier (a word), or some quoted text.
 ...
---------------------


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


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

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

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