[10786] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 4387 Volume: 8

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Wed Dec 9 10:07:21 1998

Date: Wed, 9 Dec 98 07:00:27 -0800
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)

Perl-Users Digest           Wed, 9 Dec 1998     Volume: 8 Number: 4387

Today's topics:
    Re: 80 column conversion (I.J. Garlick)
        Accessing MS SQL db from unix <jjn@sanger.ac.uk>
    Re: Accessing MS SQL db from unix <hendrik.woerdehoff@sdm.de>
        Assignment to same variable <dward@pla.net.au>
    Re: Assignment to same variable (Tad McClellan)
        Checking if a Dir exists <r2-d2@REMOVEbigfoot.com>
    Re: Checking if a Dir exists <Allan@due.net>
    Re: Checking if a Dir exists <dennis.kowalski@daytonoh.ncr.com>
    Re: How to disallow fields to input puncuations excepts (Tad McClellan)
    Re: HTML Embedded in Perl (Tad McClellan)
        Installing Perl5.004 Solaris 2.6 <msmith@stokecoll.ac.uk>
    Re: Interpreting Multipart encoding <fty@utk.edu>
    Re: Oraperl and stored procedures (David Cantrell)
        perl on psion series 5 <23_skidoo@geocities.com>
        Perl-to-C convertor <wapst7@pitt.edu>
    Re: please help.. <Allan@due.net>
    Re: Problem running Perl CGI's on NT in SuiteSpot <bwduggan@DONTSPAMbear.com>
    Re: Redirecting STDIN <wallenborn@phys.chem.ethz.ch>
    Re: simple regular expression problem esiyuri@my-dejanews.com
        Strange Module missing problem (Michael Schmidt-Maier)
        sub routines. om7@cyberdude.com
    Re: test for a directory (terry hinds)
    Re: test for a directory (Tad McClellan)
        This is a test please ignore. Sorry. <anthony.thompson@dalgety.co.uk>
        using system() command in perl/cgi script running under <lfs97@tm.net.my>
        using the command  system() in perl cgi <lfs97@tm.net.my>
        win32 messages <MatharuN@Logica.com>
    Re: Y2K potential problem in localtime() (Andrew M. Langmead)
        Special: Digest Administrivia (Last modified: 12 Mar 98 (Perl-Users-Digest Admin)

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

Date: Wed, 9 Dec 1998 08:55:55 GMT
From: ijg@csc.liv.ac.uk (I.J. Garlick)
Subject: Re: 80 column conversion
Message-Id: <F3owt8.LA8@csc.liv.ac.uk>

In article <1djpudu.xiwfwa1nnbjusN@roxboro0-060.dyn.interpath.net>,
phenix@interpath.com (John Moreno) writes:
> 
> A easy way to do it with regex in case you don't like Text::Format (I
> recently wanted to wrap while maintaining a prefix so I've written my
> own) is to do it recursively -- loop and use a regular expression like:
> 
>    $preferred_length=72;
>    $max_length=80;
>    $min2wrap=$max_length-$preferred_length;
>    $rest_of_line =~ s/(.{1,$preferred_length})(\s.{$min2wrap,})/$1/ if (length $rest_of_line > $max_length);
> 
>    # but what if the line doesn't have any 
>    if (length $rest_of_line  > $max_length) {
>       $rest_of_line =~ s/(.{1,$preferred_length})(.+)/$1/;
>    }
> 
>   # and get ready to send it, while saving the leftover
>   $send_line_text = $rest_of_line;
>   $text_wrapped_from_last_line = $2;
> 

Thanks for this John, filed away in my useful snipits of Perl dir. (also
filed the code Tim Gim Yee posted, thanks Tim).
I was getting their, the regexp I was using did the same as the $1 part of
yours but I didn't have the second bit. Maybe that was the problem, I'll
never know.

After struggling to try and get Text::Format to do what I wanted, mainly,
preserve all lines blank or otherwise and just format continous single lines,
I gave up. I then rolled my own which basically meant passing any line
shorter than the col width straight through, breaking up continous long and
finally wrapping those pesky long lines.

I used the split the line up into an array of words and then add them back
together again method. It works it's not very pretty and it needs optimizing
badly (it was 2am when I finished it). I'll post it in the hope that some of
those with more Perl time can find ways of shaving down the code, running
time and quatity.
> 
>> I knew if I lurked long enough something good would come of reading this
>> group, but this is the first time what I am currently trying to do has come
>> up as a specific topic just in time.
>> 
>> Anyway thanks to all of the Perl gurus who have been helping me without
>> knowing it.
> 
> The above is part of a function to wrap while keeping a prefix (testing
> some stuff for doing wrapping and rewrapping of usenet articles), if
> you'd to see the whole thing just ask.
> 

-- 
--
Ian J. Garlick
<ijg@csc.liv.ac.uk>

New systems generate new problems.

The code (those not interested need read no further.)
as you will see the wrap function is a direct replacement for Text::Wrap
also it's part of an object class (I think better in objects and I am finding
harder to use the traditional sub method, I get fidgety if the first thing in
a sub isn't my $self = shift; :-) )

sub wrap {
   my $self  = shift;

   $self->first_indent(shift);
   $self->body_indent(shift);

   @{$self->{LINES}} = map { $_ } @_;

   my $fcol = $self->{COLS} - length $self->{FINDENT};
   my $bcol = $self->{COLS} - length $self->{BINDENT};
   my @lines; 
   foreach (@{$self->{LINES}}) {
#     deal with blank line
      push @lines, $self->{FINDENT} and next unless $_;

#     deal with a short line
      push @lines, $self->{FINDENT}.$_ and next
         if length($_) <= $bcol;

#     lines longer than COLS with no spaces
      if (length($self->{FINDENT}.$_) > $fcol && !/[ \t]/) { 
         my $fst = 1;
         while ($_) {
            my $col = $fst ? $fcol : $bcol;
            s/^(.{0,$col})//;
            $fst ? push @lines, $self->{FINDENT}.$1
                 : push @lines, $self->{BINDENT}.$1;
            $fst = 0;
         }
         next;
      }
      my $fst = 1;
      my @words = split /\s+/,$_;
      while (@words) {
         my $col = $fst ? $fcol : $bcol;
         my $line = $fst ? $self->{FINDENT} : $self->{BINDENT};
         while (@words && length($line) < $col) { 
            $line .= (shift @words);
            $line .= ' '; 
         }
         $line =~ s/ $//; 
         if (length($line) > $col) { 
            $line =~ s/ (\S+)$//;
            unshift @words, $1 if $1;
         }
         push @lines, $line;
         $fst = 0;
      }
   }

   return wantarray ? @lines : join("\n", @lines)."\n";
}

Well that's what I get for doing this at 2am, I can see one optimization
already.

BTW this isn't meant as a replacement for anything it's just my attempt to
solve a problem I have with my current project, and is therefore tailored to
suit that specifically. I will make it more general if and when I ever need
to.

Thanks for taking the trouble to read this far. :-)


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

Date: Wed, 9 Dec 1998 12:03:17 +0000
From: Jonathan Nicholson <jjn@sanger.ac.uk>
Subject: Accessing MS SQL db from unix
Message-Id: <Pine.OSF.4.00.9812091152220.13496-100000@byron>


Is there a perl module out there that will allow me to access a NT MS SQL
database from UNIX. 

Regards,

Jonathan

 ----------------------------------------------------------------------------
= Jonathan Nicholson - System Administrator  +44 1223 494987 (internal 4987) =
= The Sanger Centre, Wellcome Trust Genome Campus, Hinxton, Cambs, CB10 1SA  =
= Email: jjn@sanger.ac.uk (Work) (finger jjn@byron.sanger.ac.uk for PGP Key) =
 ----------------------------------------------------------------------------



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

Date: Wed, 09 Dec 1998 15:20:16 +0100
From: Hendrik Woerdehoff <hendrik.woerdehoff@sdm.de>
Subject: Re: Accessing MS SQL db from unix
Message-Id: <366E871F.51E@sdm.de>

Jonathan Nicholson wrote:
> 
> Is there a perl module out there that will allow me to access a NT MS SQL
> database from UNIX.

Yes. At least there was one last week when we had this discussion the
last time.

Searching for "comp.lang.perl.misc SQLServer" with DejaNews shows:

> David Cantrell wrote:
> > 
> > On Tue, 01 Dec 1998 17:39:22 +0100, Hendrik Woerdehoff
> > <hendrik.woerdehoff@sdm.de> enlightened us thusly:
> > 
> > >Jens Hilgers wrote:
> > >
> > >> is there a perl module to connect to a MS SQL Server ?
> > >
> > >Yes! DBI and DBD::Sybase :-)
> > 
> > I know MS-SQL is really a tarted up old version of Sybase, but would
> > DBD::Sybase _really_ work?
> 
> If it wouldn't I wonder how our system got data from our Linux machine
> into the NT database and back for the last three months ;-)
> 
> It works really well for MS SQLServer 6.5 and the Linux ctlib version
> 10. I also tried version 11 successfully but that was just a quick test.
> The most important difference is that MS SQLServer listens to a
different socket than Sybase SQLServer.
> 
> A nice description by Brian Jepson is in
> http://www.localnet.com.au/lg/issue18/sybase.html. For answers about how
> to get DBI/DBD::Sybase working on Linux see
> http://www.brodeur.com/~pjacob/dbdsybase/.
> 
> I have read some statements that suggested that MS SQLServer 7 doesn't
> work with Sybase libraries any longer. But I have no knowledge whether
> this is really the case and wich actions are not working (all or just
> new features).
> 
> Yours
>   Hendrik


Pursuant to US Code, Title 47, Chapter 5, Subchapter II, Sec. 227,
any and all unsolicited commercial E-mail sent to this address
is subject to a download and archival fee in the amount of $500
US (per infraction).  E-mailing denotes acceptance of these terms.

--
Hendrik W"ordehoff         |s  |d &|m  |  software design & management
                           |   |   |   |  GmbH & Co. KG                :
woerdehoff@sdm.de          |   |   |   |  Thomas-Dehler-Str. 27      >B)
Tel/Fax (089) 63812-337/515               81737 M"unchen               :


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

Date: Wed, 09 Dec 1998 13:10:23 +1100
From: Darren Ward <dward@pla.net.au>
Subject: Assignment to same variable
Message-Id: <366DDC0F.94C4B59C@pla.net.au>

Hello all,

How can we grow a join in a loop?

I'm trying to use:

while ($loop ge 1) {
    $domain = join '.' @dns[$loop], $domain;
    $loop = $loop + 1;
}

What's wrong with the join assignment?

TIA
Darren

Please reply via email


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

Date: Wed, 9 Dec 1998 07:45:53 -0600
From: tadmc@metronet.com (Tad McClellan)
Subject: Re: Assignment to same variable
Message-Id: <huul47.5c4.ln@magna.metronet.com>

Darren Ward (dward@pla.net.au) wrote:

: How can we grow a join in a loop?

: I'm trying to use:

: while ($loop ge 1) {
               ^^
               ^^  ge tests *strings*.  >= tests numbers

    Looks like that loop will run for a really really long time...


:     $domain = join '.' @dns[$loop], $domain;
                        ^^
                        ^^ missing comma
                        ^^ using array slice instead of scalar
:     $loop = $loop + 1;
: }

: What's wrong with the join assignment?

   1) you should use -w on *every* Perl program

       #!/usr/bin/perl -w

   2) you have something wrong with nearly every line...

   3) maybe this will do what you want:

         $domain = join '.', reverse @dns;



: Please reply via email

   Yuk, yuk.


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


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

Date: Wed, 9 Dec 1998 10:20:35 -0000
From: "Artoo" <r2-d2@REMOVEbigfoot.com>
Subject: Checking if a Dir exists
Message-Id: <74lium$6ep$1@plug.news.pipex.net>

Hi All

How can you check to see if a directory already exists before trying to
create one?

Many thanks
Artoo




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

Date: Wed, 9 Dec 1998 09:14:59 -0500
From: "Allan M. Due" <Allan@due.net>
Subject: Re: Checking if a Dir exists
Message-Id: <74m0bg$ekg$1@camel19.mindspring.com>

Artoo wrote in message <74lium$6ep$1@plug.news.pipex.net>...
>Hi All
>How can you check to see if a directory already exists before trying to
>create one?


Well, TIMTOWTDI.  You might use -d:


my $dirname = 'd:/temp';
(-d $dirname) ? print "Exists" : print "Not a directory, could still be a
file name though";
(-e $dirname) ? print "It is a file" : print "Not a file either, do we need
to check anything else?";

HTH

AmD




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

Date: Wed, 09 Dec 1998 09:34:53 -0500
From: Dennis Kowalski <dennis.kowalski@daytonoh.ncr.com>
Subject: Re: Checking if a Dir exists
Message-Id: <366E8A8D.49F0@daytonoh.ncr.com>

Artoo wrote:
> 
> Hi All
> 
> How can you check to see if a directory already exists before trying to
> create one?
> 
> Many thanks
> Artoo

Try this

$dir = "some-value";
if (! -d $dir)
{
  mkdir($dir);
}


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

Date: Wed, 9 Dec 1998 07:29:42 -0600
From: tadmc@metronet.com (Tad McClellan)
Subject: Re: How to disallow fields to input puncuations excepts
Message-Id: <60ul47.5c4.ln@magna.metronet.com>

GiLLY (hklife@soback.kornet21.net) wrote:
: On Tue, 8 Dec 1998 07:43:24 -0600, tadmc@metronet.com (Tad McClellan)
: wrote:

: >davidmaher@my-dejanews.com wrote:
: >
: >: > How to enable the hypens , a-z , 0-9 but disable blank space and other
: >: > puncuations at the company??
: >
: >: Try something like this:
: >
: >
: >   And then try something else...   ;-)
: >
: >
: >:     if ($form{'company'} !~ /^[-A-z0-9]+$/) {

: A-z -> A-Z

: >:         print "Bad\n";
: >:     }
: >:     else {
: >:         print "Good\n";
: >:     }
: >
: >
: >   $form{'company'} = 'ac[\]^_`xyz';  # above code prints 'Good' !!!

: it'll work now.


  Not yet:

      $form{'company'} = 'ac';  # above code prints 'Bad' !!!


   you meant

      A-Z -> A-Za-z   ;-)

   or 

      /^[-A-Z0-9]+$/i
                    ^


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


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

Date: Wed, 9 Dec 1998 07:48:43 -0600
From: tadmc@metronet.com (Tad McClellan)
Subject: Re: HTML Embedded in Perl
Message-Id: <r3vl47.5c4.ln@magna.metronet.com>

backslashxt@yahoo.com wrote:

: Basically, what I would like to do is open an external
: HTML file and in the HTML page have the variable names (ie: $name, $url,
: $email) in the HTML code. When Perl reads the HTML file, it should populate
: the data, but the scipt rather takes all variable names as literal
: characters.

: Any suggestions?


   I suggest checking the Perl FAQ before posting.

   Perl FAQ, part 4:

      "How can I expand variables in text strings?"


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


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

Date: Wed, 09 Dec 1998 11:43:26 +0000
From: Mick Smith <msmith@stokecoll.ac.uk>
Subject: Installing Perl5.004 Solaris 2.6
Message-Id: <366E625E.3D08F2D8@stokecoll.ac.uk>

I have recently downloaded and installed Perl 5.004 for Solaris 2.6
(Sparc) from www.sunfreeware.com - a site that provides pre-compiled
software for Solaris platforms.

It was installed using the pkgadd function into the default directory
/usr/local/bin.

There were no error messages and everything seemed OK,  although our web
developer informs me that Perl is not working on our system.  An email
to sunfreeware reports that the precompiled version should work straight
after the pkgadd program.  Is there any configuration settings that I am
missing?  I was under the impression that all that is required it to
point the first line of a perl script to the location of the perl
binaries (/usr/local/bin).

ANY help would be greatly appreciated as I have no knowledge of perl.

Kind regards,

Mike Smith.



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

Date: Wed, 09 Dec 1998 09:21:13 -0500
From: Jay Flaherty <fty@utk.edu>
Subject: Re: Interpreting Multipart encoding
Message-Id: <366E8759.BC724A37@utk.edu>

Artoo wrote:
> 
> Hi all
> 
> How can you have a CGI script Interpret the Multipart Encoding type?  I have
> a form that has both normal text fields and a file upload field and need to
> be able to interpret the encoded text fields.

Use CGI.pm. It will handle it for you. i.e.

$file = param('filename');
open (FILE,">./savedfile.txt") or die $!;
while (<$file>) {
    print FILE $_;
}
close FILE;
__END__

jay


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

Date: Wed, 09 Dec 1998 13:22:30 GMT
From: NukeEmUp@ThePentagon.com (David Cantrell)
Subject: Re: Oraperl and stored procedures
Message-Id: <366e7947.182797719@thunder>

On Tue, 08 Dec 1998 13:11:29 GMT, NukeEmUp@ThePentagon.com (David
Cantrell) enlightened us thusly:

>Does anyone know how to call Oracle stored procedures from Oraperl?

The solution is to wrap the stored procedure in a BEGIN ... END pair,
thus:

&ora_do($lda, "BEGIN myStoreProc('$param1', '$param2'); END;");

[Copying newsgroup posts to me by mail is considered rude]

-- 
David Cantrell, part-time Unix/perl/SQL/java techie
                full-time chef/musician/homebrewer
                http://www.ThePentagon.com/NukeEmUp


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

Date: Wed, 09 Dec 1998 12:23:13 +0000
From: 23_skidoo <23_skidoo@geocities.com>
Subject: perl on psion series 5
Message-Id: <366E6BA8.68C0@geocities.com>

hi,

does anyone know if it's possible to run perl on a psion series 5? i'm
not sure what the psion OS is comparable to as i havn't bought one yet.
i looked through the faq, it mentioned a number of platforms but not
psion.

thanks

-23


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

Date: Wed, 09 Dec 1998 07:47:19 -0500
From: Wasan Pattara-atikom <wapst7@pitt.edu>
Subject: Perl-to-C convertor
Message-Id: <366E7157.36932576@pitt.edu>

Hi all,

	Does anyone know if there is a utility to convert perl source code or.
If anybody has any clue, please pleas please let me know. I seriously
need it.

Thank you,
-Wasan


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

Date: Wed, 9 Dec 1998 08:15:58 -0500
From: "Allan M. Due" <Allan@due.net>
Subject: Re: please help..
Message-Id: <74lsss$g7v$1@camel19.mindspring.com>


Enrico Ng wrote in message <74knqa$r8o$1@info3.fnal.gov>...
>I cant get to that either.
>I have tried http://www.vejrum.dk/WWW-Mail/, but I cant get it to work.
>also, I have tried emumail, but it does not work, way ... too slow.
>I tried http://www.canvasis.com/scripts/pop/, but its just a web form,  I
>cant get to the perl code.
>does any one have a perl code that can do it, I dont know too much about
>perl so I would know how to use a pop3client.pm module either.
>--
>--
Not tested, not a recommendation but I know it exists and is used at a
number of Universities.  Mailman at:

http://www.endymion.com/

AmD

[oddly, both posted and mailed]




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

Date: Wed, 09 Dec 1998 12:18:21 GMT
From: Bryan Duggan <bwduggan@DONTSPAMbear.com>
Subject: Re: Problem running Perl CGI's on NT in SuiteSpot
Message-Id: <366E6ABD.832F9005@DONTSPAMbear.com>

Thanks, but I discovered this to be the solution, which was mailed to me by Kevin
R Falcone:

For perl, you need to create a cgi-shell directory.
You can create this from the admin page, just select the Program tab,
then click on the ShellCGI Directory and it will allow you to alias
something like http://www.mydomain.com/shell to
c:\netscape\suitespot\cgi-shell .

Bryan



dturley@pobox.com wrote:

> In article <366D667A.720981EA@DONTSPAMbear.com>,
>   Bryan Duggan <bwduggan@DONTSPAMbear.com> wrote:
>
> > I am running SuiteSpot on a NT machine and I want to evaluate some perl
> > scripts for a web site.
>
> Have you made sure you have added a handler for .pl in the Netscape admin
> function? I can't remember exactly where it is, but it in the "wonderful"
> (I'm being sarcastic here) Administrative setup screen for SuiteSpot. I don't
> recall that the mime-type was set by default. -- David Turley
> dturley@pobox.com http://www.binary.net/dturley/
>
> -----------== Posted via Deja News, The Discussion Network ==----------
> http://www.dejanews.com/       Search, Read, Discuss, or Start Your Own

--
Remove the DONTSPAM to get my email address
Unite For Java! - http://www.javalobby.org




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

Date: 09 Dec 1998 12:56:28 +0100
From: Ernst-Udo Wallenborn <wallenborn@phys.chem.ethz.ch>
Subject: Re: Redirecting STDIN
Message-Id: <uipv9t7clv.fsf@bacon.ethz.ch>

aml@world.std.com (Andrew M. Langmead) writes:

> Jon Rifkin <jrifkin@mail.ims.uconn.edu> writes:
> #!/usr/bin/perl -w
> 
> my @files = @ARGV;
> 
> # put STDIN in a random spot in the array
> splice @files, rand @files, 0, '-'; 
> 
> print "printing @files\n";
> for $file (@files) {
>   open FILE, $file or warn "Can't open $file: $!\n";
>   while(<FILE>) {
>     print;
>   }
> }



another way would be using IO

use IO::Handle;
use IO::File;

and then


my ($in,$out);
if ($infile eq '-') {
  $in = new IO::Handle;
  die "$!: Can't pipe from STDIN" unless ($in->fdopen(fileno(STDIN),"r"));  
} else {
  die "$!: Can't open $infile" unless ($in = new IO::File "<$infile");

}

if ($outfile) {
  die "$!: Can't open $outfile" unless ($out = new IO::File ">$outfile");
} else {
  $out = new IO::Handle;
  die "$!: Can't pipe to STDOUT" unless ($out->fdopen(fileno(STDOUT),"w"));  
}


-- 
Ernst-Udo Wallenborn
Laboratorium fuer Physikalische Chemie
ETH Zuerich


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

Date: Wed, 09 Dec 1998 11:03:13 GMT
From: esiyuri@my-dejanews.com
Subject: Re: simple regular expression problem
Message-Id: <74lldg$pof$1@nnrp1.dejanews.com>

In article <74jm6g$3oi$1@nnrp1.dejanews.com>,
  esiyuri@my-dejanews.com wrote:

> can anybody help me with the following regular expression problem...
> I have a string variable that contains some text with embedded newline
> characters and I want to extract just some of the text.  I'm very new
> to perl, so please forgive me if this is a stupid question...  [snip]

Thanks for all the replies.  I have combined them below in the hope that they
may be useful to somebody else...

--------------------8<---------------------8<---------------------
my $text = "Name: Fred Jones\nTel: 12345 6789\nFax: 34343 3434\n";
print "=== before ===\n";
print $text;
print "=== My poor attempt at a solution ===\n";
(my $tel = $text) =~ s/^(?!Tel:).*//gm;
$tel =~ s/\n//gm;
$tel =~ s/^Tel: //s;
print "($tel)\n";
print "=== Patrick Timmins' solution ===\n";
(my $tel = $text) =~ s/.*Tel: (.*?)\n.*/$1/s;
print "($tel)\n";
print "=== Brand Hilton's solution ===\n";
my ($tel) = $text =~ /^Tel: (.*)$/m;
print "($tel)\n";
print "=== Sean McAfee's solution ===\n";
(my $tel) = $text =~ /^Tel: (.*)/m;
print "($tel)\n";
--------------------8<---------------------8<---------------------

This produces:

=== before ===
Name: Fred Jones
Tel: 12345 6789
Fax: 34343 3434
=== My poor attempt at a solution ===
(12345 6789)
=== Patrick Timmins' solution ===
(12345 6789)
=== Brand Hilton's solution ===
(12345 6789)
=== Sean McAfee's solution ===
(12345 6789)

As you can see, all the solutions gave the correct answer, though mine was by
far the lest elegant, needing three lines of code.

Thanks.

--
Regards
Yuri McPhedran

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


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

Date: 7 Dec 1998 20:33:06 GMT
From: M.S.M@t-online.de (Michael Schmidt-Maier)
Subject: Strange Module missing problem
Message-Id: <74he22$5sl$1@news01.btx.dtag.de>

Hi,
I wrote a small script that just queries a simple database and displays the
output.
Since this script is supposed to run on a server without the modules
installed (perl 5.002 with all the modules taken off ;(
I compiled it using perl2exe.
Everything works fine on my machine running NT4 Server with SP3 and Active
State 5.006.
Another Machine running Win95 and PWS2 with Perl 5.002 installed also
performs just fine.
Only the the Target server (NT4, SP3, Perl5.002 without modules) display the
old message "Can`t locate loadable object for module Win32::ODBC" even
though perl2exe compiled just fine.
The code is appended below.
Any hints?
Thanks a million in advance

Michael


________________CODE________________


#!C:/perl/bin/perl.exe -w

#use lib "C:\\inetpub\\wwwroot\\info-b\\msm\\lib";
use Win32::ODBC;
use CGI;
$query = CGI->new();
print $query->header( 'text/html');
#$| = 1;
#print "Content-type: text/html\n\n";


my $db = new Win32::ODBC("PLZOPTA");

$wert = $query->param('wert');
$postlz = $query->param('plz');
if ($query->param('plz') ne 'alle')  {
 $plzstring = " AND Plz like '$postlz%'";
 }
 else {
 $plzstring = "";
 }

if ($query->param('wert') eq 'F')  {
 $bundesweit = "OR Bundesweit = 'j'";
 }
 else {
 $bundesweit = "";
 }



$db->Sql("SELECT DISTINCT
Name1,Name2,Name3,Strasse,Plz,Ort,Telefon1,Telefax,Bundesweit FROM T_PLZOPTA
WHERE WVGrund like '%$wert%' $plzstring $bundesweit ORDER BY Plz");
print "<font face=arial size=2>\n";
print "<ul>\n";
while ($db->FetchRow()) {
 @values = $db->Data();

  $name1 = $values[0];
  $break1 = ($name1 eq "") ? "" : '<br>';
  $name2 = $values[1];
  $break2 = ($name1 eq "") ? "" : '<br>';
  $name3 = $values[2];
  $strasse = $values[3];
  $plz = $values[4];
  $ort = $values[5];
  $telefon1 = $values[6];
  $telefax = $values[7];
  $bundesmark = $values[8];
  if ($bundesmark ne '' && $wert eq 'F') {
  print "<b><font color=red>BUNDESWEIT</font></b><br>\n";
   }
  print "<b>$name1\n";
  print "$name2\n";
  print "$name3</b><br>\n";
  print "<b>$plz</b>\n";
  print "$ort,\n";
  print "$strasse<br>\n";
  print "Tel: $telefon1,\n";
  print "Fax: $telefax<br>\n";
        print "<hr size=0 width=400 align=left>\n";

 }
print "</ul>\n";
print "</font>";




$db->Close();





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

Date: Wed, 09 Dec 1998 11:44:42 GMT
From: om7@cyberdude.com
Subject: sub routines.
Message-Id: <74lnra$rnn$1@nnrp1.dejanews.com>

I've got another question I was hoping someone could PLEASE answer.

I've got some code, which goes something like the following


use Otherfilename;

name_of_sub_routine
{
 .........
 .........
 .........
}


Now, in the file 'Otherfilename', there is a sub routine with the same name,
'name_of_sub_routine' and it's decared as a sub routine.

Why are things done this way?
What is the significance of using the same name here?
Does this make 'name_of_sub_routine' the main function that's executed or
something?

I've read the intro to Perl book by O'Reilly and don't remember coming across
this convention.


Any help would be much appreciated.


THANKS.

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


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

Date: Wed, 09 Dec 1998 19:17:53 +0900
From: terry577@aol.com (terry hinds)
Subject: Re: test for a directory
Message-Id: <terry577-0912981917540001@cs11k42.ppp.infoweb.ne.jp>


try this (tested):

#!usr/local/bin/perl -w    
use diagnostics -verbose;  
$pathname= "/your/path/name/here/"; #<== fill in the directory path of
your choice

chdir("$pathname"); #changes to the directory of you chose

while (defined ($contents = <*>)) { #globs the entire contents of the directory
   if (-d $contents) { #filters for sub directories & loads the name into
an array
   @directory = sort (@directory, $contents); #sorts the names into ascii order
   }#end of if 
}#end of 1st while loop


print "hey look what I found in $pathname: \n";

while (@directory) { #prints out the contents of the array
   $directory = shift (@directory);
   print "$directory\n";
} #end of 2nd while loop

   

> Nick Franken (franken@cistron.nl) wrote:
> 
> : How do I test if a subdir with any name exists?


++ > (Tad McClellan) wrote:
++ > # UNTESTED
++ > opendir(DIR, '/firstdir') || die "could not open '/firstdir'  $!";
++ > @dirs = grep -d, readdir(DIR);
++ > closedir(DIR);
++ > 
++ > print "subdirs exist\n" if @dirs;
++ > 
++ > 
++ > --
++ >     Tad McClellan                          SGML Consulting
++ >     tadmc@metronet.com                     Perl programming
++ >     Fort Worth, Texas


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

Date: Wed, 9 Dec 1998 07:32:59 -0600
From: tadmc@metronet.com (Tad McClellan)
Subject: Re: test for a directory
Message-Id: <b6ul47.5c4.ln@magna.metronet.com>

terry hinds (terry577@aol.com) wrote:

: chdir("$pathname"); #changes to the directory of you chose


   It might change the current directory, but then again it might not.

   You won't know unless you check the return value:

      chdir($pathname) || die "could not change to '$pathname' dir  $!";


   The double quotes serve no purpose either.


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


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

Date: 9 Dec 1998 13:18:46 GMT
From: "Anthony Thompson" <anthony.thompson@dalgety.co.uk>
Subject: This is a test please ignore. Sorry.
Message-Id: <01be236d$94120950$380a10ac@aztp99>

As above


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

Date: 9 Dec 1998 22:00:25 +0800
From: "Liew Fook Sin" <lfs97@tm.net.my>
Subject: using system() command in perl/cgi script running under Linux
Message-Id: <01be2402$c08aa9c0$LocalHost@tm.net.my>

Hi,

I am suppose to decrypt a series of files in a particular directory
automatically using a perl/cgi script.
By the way the files are all encrypted using pgp.

I have use the system() command to perform this task in
a perl/cgi script as pgp commands need to be embed inside
my script.

My problem is when the script is run manually, it works fine but
when it is called via a URL from a HTML form., the script runs
without error but the commands in the system() simply is not
executed.

Can somebody please tell what is wrong and how can this be
done. Thank you.

liew
malaysia


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

Date: 9 Dec 1998 21:39:08 +0800
From: "Liew Fook Sin" <lfs97@tm.net.my>
Subject: using the command  system() in perl cgi
Message-Id: <01be23ff$a0088c60$LocalHost@tm.net.my>

Hi,

I am running a cgi script that is suppose to automate the process of
decrypting a series
of files in a particular directory.
To decrypt the files use pgp commands. Since perl command system() allows
other
programs to be executed within the perl script, this approach was
attempted.
My problem is when I execute the Perl cgi script manually it works nicely.
However, when I execute the same script via a  URL in a HTML form, the
script runs but command
embed inside the system() command simply does not respond.

Can anybody please tell me what is wrong, and how can this be solved.
Thank you.


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

Date: Wed, 9 Dec 1998 14:40:21 -0000
From: "Navtej S Matharu" <MatharuN@Logica.com>
Subject: win32 messages
Message-Id: <74m24n$c0g@romeo.logica.co.uk>

Dear All,

Can anyone tell me how to check for incoming SMTP messages through running a
Perl script?? It has to run on Windows NT4.

Thanks in advance.

BIM




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

Date: Wed, 9 Dec 1998 14:55:42 GMT
From: aml@world.std.com (Andrew M. Langmead)
Subject: Re: Y2K potential problem in localtime()
Message-Id: <F3pDGu.AKo@world.std.com>

phenix@interpath.com (John Moreno) writes:

>It should have been this (which is useful now).

>$year = $year % 100;
>$year = "0$year" if ($year < 10);

Or

$year = sprintf '%02d', $year % 100;

-- 
Andrew Langmead


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

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

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