[16082] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 3494 Volume: 9

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Tue Jun 27 18:11:25 2000

Date: Tue, 27 Jun 2000 15:10:44 -0700 (PDT)
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)
Message-Id: <962143843-v9-i3494@ruby.oce.orst.edu>
Content-Type: text

Perl-Users Digest           Tue, 27 Jun 2000     Volume: 9 Number: 3494

Today's topics:
    Re: Number of Unique Values (Tad McClellan)
    Re: Oracle minimum install for perl DBI on Linux <rereidy@indra.com>
    Re: Perl and Sockets (Bart Lateur)
    Re: Perl/cgi newbie questions <stephen.kloder@gtri.gatech.edu>
    Re: Perl/cgi newbie questions <news@webneeds.com>
    Re: Perl/cgi newbie questions <red_orc@my-deja.com>
    Re: Perl/cgi newbie questions <sariq@texas.net>
    Re: Perl/cgi newbie questions <care227@attglobal.net>
        problem with substr <dem@achilles.net>
    Re: problem with substr (M.J.T. Guy)
    Re: problem with substr <sariq@texas.net>
        Problem writing a binary file to another location <adams1015@worldnet.att.net>
        Ranking numbers <cghansen@micron.com>
    Re: Ranking numbers <cghansen@micron.com>
    Re: regex - slurp file and extract email addresses (Bart Lateur)
    Re: regex - slurp file and extract email addresses <care227@attglobal.net>
    Re: regex - slurp file and extract email addresses (Abigail)
    Re: Script cron problems <care227@attglobal.net>
    Re: Such an easy task, open and write to a file, here i <care227@attglobal.net>
        Such an easy task, open and write to a file, here is my (Ariel Lia)
    Re: Syntax Question Not Found in Camel (Andrew Johnson)
        Sys::Syslog - Not working timwalker1000101@my-deja.com
        system call for /usr/bin/find without spawning shell backtick@my-deja.com
    Re: system call for /usr/bin/find without spawning shel <care227@attglobal.net>
    Re: Unable to access an array from within a class <abe@ztreet.demon.nl>
    Re: Win-95, perl, & almost any database <methabol@hem.passagen.se>
    Re: Write to file problem <aranick@home.com>
        Digest Administrivia (Last modified: 16 Sep 99) (Perl-Users-Digest Admin)

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

Date: Tue, 27 Jun 2000 14:17:06 -0400
From: tadmc@metronet.com (Tad McClellan)
Subject: Re: Number of Unique Values
Message-Id: <slrn8lhrt2.ag8.tadmc@magna.metronet.com>

On Tue, 27 Jun 2000 11:22:52 -0500, Russ Jones <russ_jones@rac.ray.com> wrote:
                                    ^^
>Abigail wrote:
>> 
>> Gwyn Judd (tjla@guvfybir.qlaqaf.bet) wrote on MMCDXCII September MCMXCIII
>> [] >%% What is the significance of this number? It (2492 September 1993)
>> [] >%% doesn't make much sense to me.
>> [] >
>> [] >
>> [] >You aren't the first to ask in this group. Nor the second or third.
>> [] >Not even the tenth.
>> []
>> [] you mean it is in the FAQ?
>> 
>> No. But it's on dejanews.
>> 
>
>Now I get it! 


I don't think so.


> It's (yet another) excuse for Abigail to be rude to
>people! 


Refusing to look up something for others is not rude.

Expecting others to look things up for you is rude.



>Abby, if you don't want people to ask you why you're wearing clown
 ^^^^
>shoes, just don't wear them.


Ru, if you don't want to see people wearing clown shoes, don't
buy tickets for the clp.misc "circus", or make a killfile entry as
appropriate.


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


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

Date: Tue, 27 Jun 2000 15:59:17 -0600
From: Ron Reidy <rereidy@indra.com>
Subject: Re: Oracle minimum install for perl DBI on Linux
Message-Id: <395923B5.D62D3140@indra.com>

Kathryn Cassidy wrote:
> 
> Hi all,
> 
> I'm trying to set up a linux machine so that I can access a remote
> Oracle 8.0.5 server using DBD::Oracle.  I don't want to have to install
> all of oracle on my machine, but I can't seem to find any reliable
> information about what files I need to copy over in order to get
> DBD::Oracle to compile.  Any info I could find was about Oracle 7 and
> doesn't seem to apply.  I've copied over just about all the files from
> the machine
> with Oracle installed on it, but I still can't get it to work.
> 
> I just get the following when I run perl Makefile.PL
> 
>   The ORACLE_HOME environment variable must be set.
>   It must be set to hold the path to an Oracle installation directory
>   on this machine (or a compatible archtecture).
>   See the README.clients file for more information.
> 
> $ORACLE_HOME is set.
> 
> Has anyone done this before?  Can you let me know what files you
> required?  Alternatively, does anyone know of a good website where I can
> find this info?
> 
> Thanks,
> Kathryn.
Kathryn,

You need to install the **complete** Oracle client.  You could guess at
what libraries need to be copied over, but you would spend more time
doing this than just doing the client install.

Good luck.
-- 

Ron Reidy
Oracle DBA
Reidy Consulting, L.L.C.


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

Date: Tue, 27 Jun 2000 20:37:10 GMT
From: bart.lateur@skynet.be (Bart Lateur)
Subject: Re: Perl and Sockets
Message-Id: <395a0fe5.803662@news.skynet.be>

valarkin@my-deja.com wrote:

> $realNumber = int (unpack("S", $len));

>I have tried most of the values for "S", V, v, I, i, M, m and the
>others. How would I check to see if I got the 4 bytes?

I think you need 'N', for "Network order". It sounds reasonable to me
that data sent though sockets would use that convention.

-- 
	Bart.


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

Date: Tue, 27 Jun 2000 14:17:14 -0400
From: Stephen Kloder <stephen.kloder@gtri.gatech.edu>
Subject: Re: Perl/cgi newbie questions
Message-Id: <3958EFA9.ED681A5B@gtri.gatech.edu>

rickh wrote:

> #!/usr/bin/perl -w
> print <<HTML;
> Content-type: text /html\n\n
> <HTML><HEAD><TITLE></title><head><BODY>
> <p> Environment Variables
> <p>
> HTML
>
> foreach (keys %ENV) {print "$_: $ENV{$_}<br>\n";}
>
> Print <<HTML;
> </body></html>
> HTML
>

Try using print <<'HTML';




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

Date: Tue, 27 Jun 2000 12:18:34 -0600
From: "Dan Manion" <news@webneeds.com>
Subject: Re: Perl/cgi newbie questions
Message-Id: <Hi665.42$%%5.1693@news.uswest.net>

Did you run this from the command line?  If so did it spit out any errors.

First problem:
When a browser connects to a web server it asks for a document then waits
for the reply.  The reply has 2 parts in most cases.  A header and a body.

The only required header object that *has* to be send from the server to the
browsers is the "Content-type:".  This simple lets the browser know what's
coming so it can treat the file accordingly.  After The header one blank
line is sent followed by the content of the page (in most cases).  In your
case you are sending a reply header telling the server that you are gonna
send an HTML file.  After which you proceed printing out the html.

With this in mind one problem with the code come from the very first part of
your code.  \n is a new line character.  Meaning every time it is printed
out a new line is inserted.  So print "Content-type: text/html\n\n";  prints
your one line header followed by a blank line.  After which you can starting
printing out text and or html to the screen.

but this:
print <<HTML;
Content-type: text/html\n\n

<HTML>
 ...
HTML

actually prints out 3 blank lines instead of the one you actually want.  Try
taking off the new line characters in your header for starters.

Second Problem:
I am pretty sure the reason your program is failing is *not* coming from the
problem above though.  That is why I asked if you ran the program from the
command line.  The first line may be the incorrect path to perl.  Maybe you
don't have executable permission on the file.  Running the program from the
command line will spit out these types of error message to you.  Also, the
web servers log files are great great tools for debugging code if you get
server errors when connecting from the web.

Hope this helps!

"rickh" <rickh@burgoyne.com> wrote in message
news:3958E801.AE4569BD@burgoyne.com...
> I am trying to learn Perl/cgi on a caldera linux box.  I have a sample
> program that was copied from the MySQL & mSQL O'REILLY book.  the sample
> program is shown below.
>
> #!/usr/bin/perl -w
> print <<HTML;
> Content-type: text /html\n\n
> <HTML><HEAD><TITLE></title><head><BODY>
> <p> Environment Variables
> <p>
> HTML
>
> foreach (keys %ENV) {print "$_: $ENV{$_}<br>\n";}
>
> Print <<HTML;
> </body></html>
> HTML
>
> When I access this program through my web browser, I get an "internal
> error.  Looking at the error_log it would appear that the Print <<HTML
> lines are the problem.  the error message indicates that they are not
> numeric and appearently the << is the numeric left shift operator.
> Question is What was the Print <<HTML line supposed to do?
>
> Regards
> Rick
>




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

Date: Tue, 27 Jun 2000 18:16:39 GMT
From: Rodney Engdahl <red_orc@my-deja.com>
Subject: Re: Perl/cgi newbie questions
Message-Id: <8jar1k$ml4$1@nnrp1.deja.com>

In article <3958E801.AE4569BD@burgoyne.com>,
  rickh <rickh@burgoyne.com> wrote:
> I am trying to learn Perl/cgi on a caldera linux box.  I have a sample
> program that was copied from the MySQL & mSQL O'REILLY book.  the
> sample program is shown below.
>
> #!/usr/bin/perl -w
> print <<HTML;

I thought it was supposed to be:

print <<"HTML";

> Content-type: text /html\n\n

looks like you have whtespace between the 'text' and the '/html'.

> <HTML><HEAD><TITLE></title><head><BODY>
> <p> Environment Variables
> <p>
> HTML
>

<SNIP>

>
> When I access this program through my web browser, I get an "internal
> error.  Looking at the error_log it would appear that the Print <<HTML
> lines are the problem.  the error message indicates that they are not
> numeric and appearently the << is the numeric left shift operator.
> Question is What was the Print <<HTML line supposed to do?
>

where possible, you should include the exact wording of the error
message.

> Regards
> Rick
>
>


Sent via Deja.com http://www.deja.com/
Before you buy.


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

Date: Tue, 27 Jun 2000 13:34:02 -0500
From: Tom Briles <sariq@texas.net>
Subject: Re: Perl/cgi newbie questions
Message-Id: <3958F39A.61EA1733@texas.net>

rickh wrote:
> 
> I am trying to learn Perl/cgi on a caldera linux box.

You do know that 'Perl' ne 'CGI', don't you?

> I have a sample
> program that was copied from the MySQL & mSQL O'REILLY book.  the sample
> program is shown below.

<snip>

> Print <<HTML;

Perl doesn't have a Print function.

- Tom


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

Date: Tue, 27 Jun 2000 14:51:17 -0400
From: Drew Simonis <care227@attglobal.net>
Subject: Re: Perl/cgi newbie questions
Message-Id: <3958F7A5.2889DEA5@attglobal.net>

Rodney Engdahl wrote:
> 
> 
> I thought it was supposed to be:
> 
> print <<"HTML";
> 


it can be print <<('|"|`)MARKER('|"|`);

All lines before MARKER appears on a line all alone will be 
interpreted with the quoting specifified.


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

Date: Tue, 27 Jun 2000 16:08:42 -0400
From: "Dave McIntyre" <dem@achilles.net>
Subject: problem with substr
Message-Id: <8jb1ju$e9$1@bcarh8ab.ca.nortel.com>

Hi. This code:

    #!/bin/perl
    $blah = "def";
    substr($blah, 0, 0, "abc");
    print $blah;

prints "abcdef" as expected, but only on Win32.
On Solaris I get "Too many arguments for substr at blah.pl line 4 near
""abc")".
I switched to:

    substr($blah, 0, 0)= "abc";
which works fine on both, but I'm still wondering why the trouble with the
original.
Using 5.22 Win32; 5.004_04 for Sun4-Solaris.

Dave






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

Date: 27 Jun 2000 20:22:10 GMT
From: mjtg@cus.cam.ac.uk (M.J.T. Guy)
Subject: Re: problem with substr
Message-Id: <8jb2di$jig$1@pegasus.csx.cam.ac.uk>

Dave McIntyre <dem@achilles.net> wrote:
>    #!/bin/perl
>    $blah = "def";
>    substr($blah, 0, 0, "abc");
>    print $blah;
>
>prints "abcdef" as expected, but only on Win32.
>On Solaris I get "Too many arguments for substr at blah.pl line 4 near
>""abc")".
>I switched to:
>
>    substr($blah, 0, 0)= "abc";
>which works fine on both, but I'm still wondering why the trouble with the
>original.
>Using 5.22 Win32; 5.004_04 for Sun4-Solaris.

The 4 argument form of substr() was only introduced in perl5.005 IIRC.


Mike Guy


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

Date: Tue, 27 Jun 2000 15:24:30 -0500
From: Tom Briles <sariq@texas.net>
Subject: Re: problem with substr
Message-Id: <39590D7E.3F4C6934@texas.net>

Dave McIntyre wrote:
> 
> Hi. This code:
> 
>     #!/bin/perl
>     $blah = "def";
>     substr($blah, 0, 0, "abc");
>     print $blah;
> 
> prints "abcdef" as expected, but only on Win32.
> On Solaris I get "Too many arguments for substr at blah.pl line 4 near
> ""abc")".

It has nothing to do with the OS (using that term loosely).

Did you bother to read the documentation for substr() on the Solaris
box?

HTH.  HAND.

- Tom


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

Date: Tue, 27 Jun 2000 18:15:05 GMT
From: "Jeremiah Adams" <adams1015@worldnet.att.net>
Subject: Problem writing a binary file to another location
Message-Id: <Ja665.4296$AM4.269022@bgtnsc04-news.ops.worldnet.att.net>

hi,

I am trying to get a file which is uploaded with a browser and write it to
another directory. I am using cgi.mod to do the uploads. The upload works
fine as well as saving it but the data is corrupted when saved and you
cannot view the images.

There is no strict pragma because according to Stien (the mod's author) this
creates problems.

Here is the source. Most of it comes straight from stein's web site.:
#!/usr/bin/perl -w

# test for file upload
use diagnostics;

use CGI::Carp qw(carpout fatalsToBrowser);

use CGI qw(:standard);
$save_path = "/httpd/cgi-bin/tests/_temp";


print header,
    start_html('file upload'),
    h1('file upload');
print_form()    unless param;
print_results() if param;
print end_html;

sub print_form {
    print start_multipart_form(),
       filefield(-name=>'upload',-size=>60),br,
       submit(-label=>'Upload File'),
       end_form;
}

sub print_results {
    my $length;

    my $file = param('upload');
     my $m_save_path = "$save_path/file1.gif";
    if (!$file) {
        print "No file uploaded.";
        return;
    }
   # print h2('File name'),$file;
   # print h2('File MIME type'),
   # uploadInfo($file)->{'Content-Type'};
    while (<$file>) {
        $length += length($_);
   }
   # print h2('File length'),$length;

    $file_type = uploadInfo($file)->{'Content-Type'};

    if ( $file_type eq 'image/gif' ) {
        print h2('Correct File');


        # Copy a binary file to somewhere safe
        open (OUTFILE,">> $m_save_path");
        while ($bytesread=read($file,$buffer,$length)) {
           print OUTFILE $buffer;
        }
    }
    else {
         print_bad_file();
    }
}
sub print_bad_file {
    print h2('Bad file type');
    print p('Only select .gif or .jpg files.')
}





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

Date: Tue, 27 Jun 2000 14:07:48 -0600
From: "Colby Hansen" <cghansen@micron.com>
Subject: Ranking numbers
Message-Id: <8jb1il$ans$1@admin-srv3.micron.com>

I need some help ranking some numbers.  Here's my list of numbers:

@list = (0,1,3,4,6,8,9,9,9,9,10,14,22,28,31,31,36)

I want to be able to change the list to:

@list = (1,2,3,4,5,6,8.5,8.5,8.5,8.5,11,12,13,14,15.5,15.5,17)

This doesn't seem that hard, but I'm having trouble with it.  Any help would
be greatly appreciated!  Thanks.




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

Date: Tue, 27 Jun 2000 14:10:30 -0600
From: "Colby Hansen" <cghansen@micron.com>
Subject: Re: Ranking numbers
Message-Id: <8jb1nn$aob$1@admin-srv3.micron.com>

Actually, I my changed list should look like this:

@list = (1,2,3,4,5,6,7.5,7.5,7.5,7.5,11,12,13,14,15.5,15.5,17)




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

Date: Tue, 27 Jun 2000 20:37:05 GMT
From: bart.lateur@skynet.be (Bart Lateur)
Subject: Re: regex - slurp file and extract email addresses
Message-Id: <39590ec3.514152@news.skynet.be>

Drew Simonis wrote:

>Mastering Regular Expressions.  Its the Owl book (the Hip Owl?  heh)
>
>In fact, the book ends with an example regualr expression to match 
>an email address.  Its a 16,000+ byte regular expression.  Just shows
>the scope of such a match when you want to get an email address "from 
>the wild". 

Actually, it's only between 6000 and 7000 characters.

And thereason why it's so big, is because it allows (and matches) nested
comments, i.e. stuff between "(" and ")".

You don't need nested comments. They add nothing to the deliverability
of an email address. So if you get rid of any comments in email
addresses, and store the simpler form you get, extracting it again will
be so much easier. For example, Tom Phoenix' example

    "fred and barney" (yes, this works!)@(believe me!) redcat.com

is actually equivalent to

	"fred and barney"@redcat.com

-- 
	Bart.


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

Date: Tue, 27 Jun 2000 16:51:59 -0400
From: Drew Simonis <care227@attglobal.net>
Subject: Re: regex - slurp file and extract email addresses
Message-Id: <395913EF.9DE6338A@attglobal.net>

Bart Lateur wrote:
> 
> Actually, it's only between 6000 and 7000 characters.
> 
> And thereason why it's so big, is because it allows (and matches) nested
> comments, i.e. stuff between "(" and ")".
> 

Right.  Thats why I specified "in the wild".  I think everyone would
agree that the task gets close to trivial when you have knowlege of 
a constrained format.  Without that format, however, it is a different
matter all together.


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

Date: 27 Jun 2000 17:29:32 EDT
From: abigail@delanet.com (Abigail)
Subject: Re: regex - slurp file and extract email addresses
Message-Id: <slrn8li87p.ka1.abigail@alexandra.delanet.com>

Bart Lateur (bart.lateur@skynet.be) wrote on MMCDXCII September MCMXCIII
in <URL:news:39590ec3.514152@news.skynet.be>:
 .. Drew Simonis wrote:
 .. 
 .. >Mastering Regular Expressions.  Its the Owl book (the Hip Owl?  heh)
 .. >
 .. >In fact, the book ends with an example regualr expression to match 
 .. >an email address.  Its a 16,000+ byte regular expression.  Just shows
 .. >the scope of such a match when you want to get an email address "from 
 .. >the wild". 
 .. 
 .. Actually, it's only between 6000 and 7000 characters.
 .. 
 .. And thereason why it's so big, is because it allows (and matches) nested
 .. comments, i.e. stuff between "(" and ")".

But only to a certain level of nested. (2 IIRC).



Abigail
-- 
sub f{sprintf$_[0],$_[1],$_[2]}print f('%c%s',74,f('%c%s',117,f('%c%s',115,f(
'%c%s',116,f('%c%s',32,f('%c%s',97,f('%c%s',0x6e,f('%c%s',111,f('%c%s',116,f(
'%c%s',104,f('%c%s',0x65,f('%c%s',114,f('%c%s',32,f('%c%s',80,f('%c%s',101,f(
'%c%s',114,f('%c%s',0x6c,f('%c%s',32,f('%c%s',0x48,f('%c%s',97,f('%c%s',99,f(
'%c%s',107,f('%c%s',101,f('%c%s',114,f('%c%s',10,)))))))))))))))))))))))))


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

Date: Tue, 27 Jun 2000 14:34:48 -0400
From: Drew Simonis <care227@attglobal.net>
Subject: Re: Script cron problems
Message-Id: <3958F3C8.58B15C19@attglobal.net>

gulgan@my-deja.com wrote:
> 
> I have croned a script as root (let's not get into the discussion as to
> why it's a long sotry) and it doesn't seem to be running with root
> permissions.  It runs fine at command line but it fails when trying to
> run via cron.  Any ideas?

What does this have to do with Per?

try comp.unix.misc, this is way off topic here.


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

Date: Tue, 27 Jun 2000 16:31:21 -0400
From: Drew Simonis <care227@attglobal.net>
Subject: Re: Such an easy task, open and write to a file, here is my code, but no  worky
Message-Id: <39590F19.4BF66C4F@attglobal.net>

Ariel Lia wrote:
> 
> 
> #!/usr/local/bin/perl

#!/usr/local/bin/perl -Tw
use strict;
> 
> 
>    open NEWFILE, ">>afraid" or die $!;
                    ^

This will now append to the file instead of overwriting it.  Not sure
if thats your problem, since you never bother to trap any errors (I 
fixed that too) and you didn't specify what was actually happening.

And please do read the FAQ's.  Filehandles are covered in Perlfaq5


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

Date: Tue, 27 Jun 2000 16:19:41 -0400
From: Ariellia@garden.com (Ariel Lia)
Subject: Such an easy task, open and write to a file, here is my code, but no worky
Message-Id: <451DC15540C98F9A.1BB4CD83C2385489.1B2F4DB91B34A3C0@lp.airnews.net>

Hello,

I try to invoke this simple script by inserting: 
http://www.mydomain.com/cgi-bin/wwwboard/test_a.pl

into a browser and then clicking reload.  I have tried a number of 
variations.  I use lots of other scripts on this Unix webserver and have 
the latest perl installed.  I am very familiar with getting other 
people's scripts to run:  wwwboard, voting software scripts, etc...

And now I am trying to write my own simple stuff...  I just want to be 
able to create a file and write content to it.  Then concatenate content 
later on.

Any advice?  What is wrong with my code below?  It's a cut and paste 
froma working script.  Am i just executing the script incorrectly?

Thanks!

A



#!/usr/local/bin/perl


&new_file;

sub new_file {

   open(NEWFILE,">afraid") || print "<html><head><title>You 
Idiot</title></head><body>You Idiot</body></html>\n";

   print NEWFILE "<html>\n";
   print NEWFILE "  <head>\n";
   print NEWFILE "    <title>Hello</title>\n";
   print NEWFILE "  </head>\n";
   print NEWFILE "  <body>\n";
   print NEWFILE "    <center>\n";
   print NEWFILE "      <h1>hi</h1>\n";
   print NEWFILE "    </center>\n";
   print NEWFILE "<hr size=7 width=75%>\n";
   
   print NEWFILE "</body></html>\n";
   close(NEWFILE);
}


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

Date: Tue, 27 Jun 2000 19:38:43 GMT
From: andrew-johnson@home.com (Andrew Johnson)
Subject: Re: Syntax Question Not Found in Camel
Message-Id: <7p765.1908$k5.35140@news1.rdc1.mb.home.com>

In article <3958aca8$0$6022@wodc7nh1.news.uu.net>,
 spurcell <skpurcell@hotmail.com> wrote:
> Hello,
> I was reading Andrew Johnstons book "Effective Perl Programming" last night,
> and ran into the following snippet of code.

I think you are a wee bit confused:

    %possibly = (
            this => {
                book   => 'Elements of Programming with Perl',
                author => 'Andrew L Johnson',
                },
            that => {
                book   => 'Effective Perl Programming',
                author => 'Joseph N Hall',
                },
            );
    
I suspect you are referring to $possibly{this}{book} written by
$possibly{this}{author}, as the code you refer to does, in fact,
occur on pages 209 and 210 of $possibly{this}{book}:
 
> $dir ||= './';
> 

Page 66 (of $possibly{this}{book}) gives a couple examples to
illustrate the concept of combined assignment operators, but not the
||= construct specifically, and mentions the perlop manpage for the
full list of combined assignment operators. They are all interpreted
in a similar fashion:

    $a OP= $b  --->  $a = $a OP $b

where OP is the operator in question, therefore:

    $a ||= $b  --->  $a = $a || $b

If the '$a = $a || $b' construct is puzzling you, please refer to
sect. 5.3 of $possibly{this}{book}, or the perlop manpage, for
information on how the || operator operates.

regards,
$possibly{this}{author}

-- 
Andrew L. Johnson   http://members.home.net/perl-epwp/
      Some days you are the bug, 
      some days you are the windshield.


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

Date: Tue, 27 Jun 2000 21:06:08 GMT
From: timwalker1000101@my-deja.com
Subject: Sys::Syslog - Not working
Message-Id: <8jb500$9ol$1@nnrp2.deja.com>

I am trying to use Sys::Syslog, but am not having much luck. I'm not
receiving any error messages, however when it tries to openlog it fails.
Here's my code if anyone can help point out what I am doing wrong...  Thanks.

Tim Walker

#!/usr/bin/perl

use Sys::Syslog qw(:DEFAULT setlogsock);
# I have also tried:  use Sys::Syslog qw(openlog syslog setlogsock closelog);
use strict;

   my $level = "info";
   my $message = "Test message";

   setlogsock('unix');
# I have also tried  Sys::Syslog::setlogsock('unix') ;

   if (openlog($0, 'cons,pid', 'local1')) {
	syslog($level, $message);
	closelog;
   }
   else {
      # Log failed. Send error to stdout
	print STDERR "Cannot open syslog($error, $message): $!\n";
   }



Sent via Deja.com http://www.deja.com/
Before you buy.


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

Date: Tue, 27 Jun 2000 18:31:13 GMT
From: backtick@my-deja.com
Subject: system call for /usr/bin/find without spawning shell
Message-Id: <8jarth$nhn$1@nnrp1.deja.com>

I'm new to CGI scripting, and am working on a script that needs to
call /usr/bin/find with -exec.  I've read in the WWW security faq that
if I call system with my arguments in a list, instead of one long
string, it won't spawn a shell, so it won't expand metachars, which is
obviously good.

So I'm trying to call system with something like this:

system "/usr/bin/find",$currentloc,$archiveloc,'-name','*.html','-
exec',"egrep -li \"$querystr\" {} \;";

$currentloc and $archiveloc are set in the code, but $querystr is taken
from user input in a form.  Before calling system, I'm stripping out
any ;'s or \;'s from $querystr in an attempt to keep someone from
subverting the find call with an rm, etc.

With the above call, and $querystr set to "asdf", I get the following
error:

/usr/bin/find: missing argument to `-exec'

I've tried other ways of doing this...combining stuff into things
like "-exec egrep -li....etc", instead of seperating it out...this
gives me unknown predicate.  I've tried seperating each individual
word, or just parts of the egrep (making \; a different argument in the
list).

Anyways, I can't seem to get this to run the way I'd like it to.  Does
anyone have any pointers on dealing with find in this case?  Or am I
better off doing this by hand in my perl program with a glob of some
sort, or some other option?

Any pointers appreciated.

Thanks


Sent via Deja.com http://www.deja.com/
Before you buy.


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

Date: Tue, 27 Jun 2000 14:56:27 -0400
From: Drew Simonis <care227@attglobal.net>
Subject: Re: system call for /usr/bin/find without spawning shell
Message-Id: <3958F8DB.2434ADDB@attglobal.net>

backtick@my-deja.com wrote:
> 
> I'm new to CGI scripting, and am working on a script that needs to
> call /usr/bin/find with -exec.  I've read in the WWW security faq that
> if I call system with my arguments in a list, instead of one long
> string, it won't spawn a shell, so it won't expand metachars, which is
> obviously good.
> 

From `perldoc -f system`:

"If there is more than one argument in LIST, or if LIST is
an array with more than one value, starts the program given by the
first element of the list with arguments given by the rest of the list.
If there is only one scalar argument, the argument is
checked for shell metacharacters, and if there are any, the entire
argument is passed to the system's command shell for parsing (this is
/bin/sh on Unix platforms, but varies on other platforms).  If
there are no shell metacharacters in the argument, it is split into
words and passed directly to execvp(), which is more efficient."

> 
> Anyways, I can't seem to get this to run the way I'd like it to.  Does
> anyone have any pointers on dealing with find in this case?  Or am I
> better off doing this by hand in my perl program with a glob of some
> sort, or some other option?

Check out CPAN for the File::find module.  It couldn't be easier.


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

Date: Tue, 27 Jun 2000 22:54:26 +0200
From: Abe Timmerman <abe@ztreet.demon.nl>
Subject: Re: Unable to access an array from within a class
Message-Id: <m94ilsgmq82480al0ed3erjsaf0buvaglc@4ax.com>

On Tue, 27 Jun 2000 16:24:50 GMT, bart.lateur@skynet.be (Bart Lateur)
wrote:

> Abe Timmerman wrote:
> 
> >> :     bless {
> >> :         "arrayRef" => @array
> 
> >Nope, an array in scalar context will return it's length. So
> >$obj->{arrayRef} will only hold the length of the array it was supposed
> >to be a reference to.
> 
> This isn't scalar context.
> 
> 	@array = (1, 2, 3);
> 	%hash = ( item => @array );
> 	print join(", ", %hash), "\n";
> -->
> 	2, 3, item, 1

Oops, you're _so_ right. I can understand this, but wouldn't have
thought it. [bad me for not testing]

Although warnings are raised with an even number of elements in @array.

Oh well, not the sort of idiom you should use, I guess (unless you know
what you are doing).

-- 
Good luck,
Abe


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

Date: Tue, 27 Jun 2000 21:08:43 +0200
From: Dan Zetterstrom <methabol@hem.passagen.se>
Subject: Re: Win-95, perl, & almost any database
Message-Id: <nfuhls0g4jgkmtfndls93b55okhel0eq1h@4ax.com>

On 27 Jun 2000 17:53:50 GMT, "Joel Fentin" <joel@cts.com> wrotc:

>Windoz-95 is installed and working.
>Perl 5.6.0 is installed and working.
>MySQL is installed and working.
>I have several mysql files.
>I have several comma delimited files.
>I have several Access files.
>
>I have not been able to connect to any driver.
>I can't get DBD-mysql to install.
>I can't get ODBC to install.

Have you tried the DBD modules available with PPM? I believe both the
mysql and the ODBC driver is there. DBD::Ram handles CSV files and
doesn't require any database engine so it's perfect for tiny databases
or prototyping.


-- 
Tell me your dreams and I will crush them.


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

Date: Tue, 27 Jun 2000 20:16:40 GMT
From: Tim <aranick@home.com>
Subject: Re: Write to file problem
Message-Id: <39590A34.BFFA0C8A@home.com>

Hello,


I'd like to thank all of you that gave me some suggestions. The chomp()
worked perfectly. I aprecaite the help very much :o)


Tim


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

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


Administrivia:

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.  

| NOTE: The mail to news gateway, and thus the ability to submit articles
| through this service to the newsgroup, has been removed. I do not have
| time to individually vet each article to make sure that someone isn't
| abusing the service, and I no longer have any desire to waste my time
| dealing with the campus admins when some fool complains to them about an
| article that has come through the gateway instead of complaining
| to the source.

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.

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 V9 Issue 3494
**************************************


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