Re: Php perl?

2003-04-06 Thread Scott R. Godin
George Schlossnagle wrote:

 
 On Friday, April 4, 2003, at 01:56  PM, Scott R. Godin wrote:
 The question I have is with the current Apache (2.x)
 
 First off, Apache 2.x is highly beta software.  Almost no-one is
 running it in production.  The questionable thread-safety of many third
 party libraries makes anything but the pre-fork MPM largely unusable
 for most people (php and perl).

Right. The place that I mention below was using 1.3.x .. Whether or not 
Apache 2.x is still not widely regarded as stable, this does not invalidate 
the question. 

 and mod_perl (1.27?)
 involved, when a perl program is incorporated into the httpd process in
 this manner, how much more *memory* overhead does each httpd process
 require over related circumstances in php?
 
 Probably more relevant to that is to look at so-called realistic
 performance benchmarks.  When the Yahoo! folks were deciding to swicth
 from their hown-grown scripting language to something more mainstream,
 they did an internal performance bakeoff between a mod_perl solution
 and a mod_php solution.  Properly tuned they delivered almost identical
 performance numbers.  Look up Michael Radwin's 'Making The Case for PHP
 at Yahoo!' talk from PHPCON 2002 for the details.  (It was an
 interesting talk no matter outside of this as well.  An interesting
 take on the differences between language solutions.)

performance speed wise and performance in terms of how much extra memory 
each httpd child requires are different animals. I'll look up the article 
though. should be interesting reading. 

 for example if I use CGI.pm to create a form (using its functional
 interface to produce the actual HTML seen) and also respond to said 
 form, how much more RAM will each httpd process require if this is 
 run under mod_perl?
 
 Comparing mod_php to CGI.pm is really apples and oranges.  CGI.pm pages
 result in a high level of intermingling between Perl code and html
 code.The resultant soup looks neither like HTML or Perl.  PHP on

I don't know how you code personally, or what sort of code you encounter, 
but when I code CGI.pm applications the processing sections look like perl 
and the output sections look like html (very much so thanks to CGI.pm's 
function-oriented interface. This also has the VERY nice side-effect that 
all the html closures are provided for and wrapped properly... i.e. it's 
easier to produce well-formed html via this method.) To *me*, the 
intermingling of html and php looks more like soup. 

 the other hand is designed for embedding of code fragments within HTML,
 producing code that still largely looks like HTML.  This allows (but
 doesn't force you) to have as much separation of display logic from
 application logic as you would like.  This isn't PHP FUD, there are
 solutions in almost every language that emulate this behavior:
 
 Perl: Apache::ASP, embperl (both mod_perl)
 Python: mod_python, mod_snake, mod_psp
 VB: ASP
 PHP: PHP
 ?: ?

true true.

 They've chosen this model because for a huge number of people it's the
 Right Way (tm) to solve the web problem.
 

 One argument I've been handed by the php camp is that in a mod_perl
 situation, this will cause apache processes to become much larger,
 thereby taking up more of the precious memory resources.
 
 In my experience that statement is pretty vacuous.  The PHP and
 mod_perl footprints both largely depend on the size of the source code
 base you are running and the number of extensions/packages you use.
 It's hard to get a side-by-side comparison.  And why bother.
 Performance numbers and code maintainability/extensibility are what
 really matter.

Also true. Considering an un-mod_perl cgi accessing a database via DBI will 
run considerably slower than one that is run under mod_perl, and also 
considerably slower than its php counterpart. 

This is one of the things I ran into where the people involved outright 
refused to even consider testing with mod_perl and instead waved specious 
benchmarks around comparing the perl vs the php in completely unrelated 
contexts. It was quite frustrating to nice well-formed scripts thrown out 
because of the lack of support hooks in the httpd process that the 
'opposing' scripts were given. 

 (consider a large gaming website like planetunreal (which IIRC uses
 .asp),
 or quakeworld, which garner huge volumes of hits on a daily basis)
 
 I've run PHP on a website doing 130 million page requests/day.  I've
 also run Apache::ASP on a site doing 10 million hits per day.  They
 both run fine.  Performance wise, the language-intrinsic differences
 are small in comparison to user code performance issues (sub optimal
 database queries, suboptimal code implementation, poor architectural
 choices, etc.).

I totally agree with this, which is why the situation was so frustrating. 

 This issue needs to be addressed firmly to the php camp, because the
 FUD being spread was enough to cost me one of the most fun hobby 
 projects I was involved with,
 
 

'Soft' link 'real; filename

2003-04-06 Thread beau
Hi -

A little OT, but, with Perl runing under Linux,
is there any way to get the 'target' file name
of a 'soft' link? Or even determine a filename
is a 'soft' link? (By 'soft' I mean a link
created so: ln -s target link).

Aloha = Beau;


-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



accessing the string from system(ls -al) / browse dir script

2003-04-06 Thread Motherofperls
I'm trying to put the string from the system(ls -al) into a variable.  It 
simply prints to the page and puts 1 in the variable.

I wan't to use this variable to determine the permissions for the files on a 
linux machine.  Is there an easier way?

Tricia


Re: accessing the string from system(ls -al) / browse dir script

2003-04-06 Thread Li Ngok Lam


 I'm trying to put the string from the system(ls -al) into a variable.  

@list = `ls -al`;

 It simply prints to the page and puts 1 in the variable.

What's that mean '1' anyway ?




-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



RE: accessing the string from system(ls -al) / browse dir scri pt

2003-04-06 Thread Halkyard, Jim


@ls = `la -al`;


will do it.

$ls = system(ls -al);

will save the exit status of the command, rather than the output.

Jim

-Original Message-
From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]
Sent: 06 April 2003 12:01
To: [EMAIL PROTECTED]
Subject: accessing the string from system(ls -al) / browse dir script


I'm trying to put the string from the system(ls -al) into a variable.  It 
simply prints to the page and puts 1 in the variable.

I wan't to use this variable to determine the permissions for the files on a

linux machine.  Is there an easier way?

Tricia

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Re: 'Soft' link 'real; filename

2003-04-06 Thread John W. Krahn
[EMAIL PROTECTED] wrote:
 
 Hi -

Hello,

 A little OT, but, with Perl runing under Linux,
 is there any way to get the 'target' file name
 of a 'soft' link?

my $actual_file = readlink $soft_link;

 Or even determine a filename
 is a 'soft' link?

print $file_name is a 'soft' link.\n if -l $file_name;

 (By 'soft' I mean a link
 created so: ln -s target link).

Or with perl:

symlink OLDFILE,NEWFILE
Creates a new filename symbolically linked to the old
filename.
Returns `1' for success, `0' otherwise. On systems that
don't
support symbolic links, produces a fatal error at run time.


perldoc -f readlink
perldoc -f -l
perldoc -f symlink
perldoc -f link
perldoc -f stat
perldoc -f lstat



John
-- 
use Perl;
program
fulfillment

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Re: accessing the string from system(ls -al) / browse dir script

2003-04-06 Thread Paul Johnson
On Sun, Apr 06, 2003 at 07:01:02AM -0400, [EMAIL PROTECTED] wrote:

 I wan't to use this variable to determine the permissions for the files on a 
 linux machine.  Is there an easier way?

opendir
readdir
stat
closedir

perldoc -f each of those for the docs.

-- 
Paul Johnson - [EMAIL PROTECTED]
http://www.pjcj.net

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Re: accessing the string from system(ls -al) / browse dir script

2003-04-06 Thread John W. Krahn
[EMAIL PROTECTED] wrote:
 
 I'm trying to put the string from the system(ls -al) into a variable.  It
 simply prints to the page and puts 1 in the variable.

perldoc -f system

 I wan't to use this variable to determine the permissions for the files on a
 linux machine.  Is there an easier way?

The third field returned from the stat (or lstat) function contains all
the permission bits for a file.

perldoc -f stat
perldoc -f lstat
man 2 stat


John
-- 
use Perl;
program
fulfillment

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Re: accessing the string from system(ls -al) / browse dir script

2003-04-06 Thread Rob Dixon
[EMAIL PROTECTED] wrote:
 I'm trying to put the string from the system(ls -al) into a variable.  It
 simply prints to the page and puts 1 in the variable.

 I wan't to use this variable to determine the permissions for the files on a
 linux machine.  Is there an easier way?

Hi Tricia.

There's nothing new herem just boiling down the answers that others have
posted:

- system() returns the exit status code of the external program it ran,
  not the output. A value of 1 generally indicates success.

- to get the output of an external program, use backticks: `ls -al` rather
  than system().

- get into the habit of doing things within Perl if you can. This
  increases the chances of your program working on another
  system. opendir/readdir/closedir calls will let you build a directory

- use stat() to get extended information about an existing file ( lstat()
  will do the same for a link )

HTH,

Rob





-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



what's the mode number represent with stat()[2]?

2003-04-06 Thread Motherofperls
I've learned alot from all this.  Thanks for the info!
This is what I pulled from the learning  perl book.
($dev,$ino,$mode,$nlink,$uid,$gid,$rdev,$size,$atime,$mtime,$ctime,$blksize,$b

locks) = stat(...)

I tried this to access the mode but it puts out a number  16877 that I don't 
konw how to decipher.

my($mode) = (stat($base/$dir_path))[2];

and is this code platform independant?





why 2 r's in Owner permission: drwxr-xr-x

2003-04-06 Thread Motherofperls
I've read about 10 pages on unix permissions.   

So far I've learned that a directory is a file with a listing of 
subdirectories and files.  And the d in drwxr-xr-x indicates the file is a 
directory.  And if it begins with -, it's a file -rwxr-xr-x.Also the - 
separates permissions of the Owner - Group - World.
r = read w=write x=execute.   Pretty simple.

What I don't understand is the r listed twice in the Owner section.  None of 
the pages I've read explain this or I missed it somewhere.


Re: what's the mode number represent with stat()[2]?

2003-04-06 Thread John W. Krahn
[EMAIL PROTECTED] wrote:
 
 I've learned alot from all this.  Thanks for the info!
 This is what I pulled from the learning  perl book.
 ($dev,$ino,$mode,$nlink,$uid,$gid,$rdev,$size,$atime,$mtime,$ctime,$blksize,$b
 
 locks) = stat(...)
 
 I tried this to access the mode but it puts out a number  16877 that I don't
 konw how to decipher.

If you are on a unix-like system the STAT(2) man page describes in some
detail what the different bits in $mode mean.  Perl's POSIX module
contains the constants and macros described in STAT(2).  For a complete
description of files and file I/O in Unix get _Advanced Programming in
the UNIX Environment_ by W. Richard Stevens, ISBN: 0-201-56317-7.


 my($mode) = (stat($base/$dir_path))[2];
 
 and is this code platform independant?

If the platform is POSIX compliant it should be.  YMMV


John
-- 
use Perl;
program
fulfillment

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Re: why 2 r's in Owner permission: drwxr-xr-x

2003-04-06 Thread John W. Krahn
[EMAIL PROTECTED] wrote:
 
 I've read about 10 pages on unix permissions.
 
 So far I've learned that a directory is a file with a listing of
 subdirectories and files.  And the d in drwxr-xr-x indicates the file is a
 directory.  And if it begins with -, it's a file -rwxr-xr-x.Also the -
 separates permissions of the Owner - Group - World.

The - indicates that that permission is turned off, an r, w or x means
it is turned on.

 r = read w=write x=execute.   Pretty simple.
 
 What I don't understand is the r listed twice in the Owner section.  None of
 the pages I've read explain this or I missed it somewhere.

You must have misread something.  Each owner, group and world field has
only one each of r, w and x.


John
-- 
use Perl;
program
fulfillment

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Re: why 2 r's in Owner permission: drwxr-xr-x

2003-04-06 Thread Peter Scott
In article [EMAIL PROTECTED],
 [EMAIL PROTECTED] writes:
I've read about 10 pages on unix permissions.   

So far I've learned that a directory is a file with a listing of 
subdirectories and files.  And the d in drwxr-xr-x indicates the file is a 
directory.  And if it begins with -, it's a file -rwxr-xr-x.Also the - 
separates permissions

Wrong.  It indicates the absence of permission.

 of the Owner - Group - World.
r = read w=write x=execute.   Pretty simple.

What I don't understand is the r listed twice in the Owner section.  None of 
the pages I've read explain this or I missed it somewhere.

You're reading the wrong pages.  Here's one that has all the explanation
you'll need:
http://www.sinc.sunysb.edu/cgi-bin/cgiwrap/helpdesk/knowledge/getArticle?filename=unix_permissions.html

-- 
Peter Scott
http://www.perldebugged.com

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Re: 'Soft' link 'real; filename

2003-04-06 Thread beau
On 6 Apr 2003 at 5:27, John W. Krahn wrote:

 [EMAIL PROTECTED] wrote:
  
  Hi -
 
 Hello,
 
  A little OT, but, with Perl runing under Linux,
  is there any way to get the 'target' file name
  of a 'soft' link?
 
 my $actual_file = readlink $soft_link;
 ...

Thanks John - I don't know how I missed that!

Aloha = Beau; 



-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Getting Image data

2003-04-06 Thread Mike Blezien
Hello.

hoping to find someone fimilar with using ImageMagick. I haven't used this too 
much and need to get the image that's uploaded, it's pixel size(width x heigth)

I can do this using the Image::Size module, but I assume, somehow I do the same 
the same using the ImageMagick too. In the docs it says to use the Get() 
method,.. but I'm not real clear on how to get the image width and height from that.

thanks for any help ;)

--
MikemickaloBlezien
=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
Thunder Rain Internet Publishing
Providing Internet Solutions that work!
http://www.thunder-rain.com
Web Hosting
http://www.justlightening.net
Tel:  1(985)902-8484
MSN: [EMAIL PROTECTED]
=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]


Re: Getting Image data

2003-04-06 Thread beau
On 6 Apr 2003 at 10:13, Mike Blezien wrote:

 Hello.

Hello, Mike

 
 hoping to find someone fimilar with using ImageMagick. I haven't used this too 
 much and need to get the image that's uploaded, it's pixel size(width x heigth)
 
 I can do this using the Image::Size module, but I assume, somehow I do the same 
 the same using the ImageMagick too. In the docs it says to use the Get() 
 method,.. but I'm not real clear on how to get the image width and height from that.
 
 thanks for any help ;)
 
 -- 

I do exactly what you want to do in some of
my web sites; here's the code I use (works
fine). The code is set up for Mason, but you
can adjust it for general use:

%perl
my $in = shift; # image file name
my ($image, $warn);
$image = Image::Magick-new;
$warn = $image-Read ($in);
if ($warn) {
$m-comp ('/shared/_error' =
error getting size for image $in: $warn);
return (0, 0);
}
my ($w, $h) = ($image-Get ('width'),
 $image-Get ('height'));
$image = undef;
return ($w, $h);
/%perl

Aloha = Beau;



-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Re: why 2 r's in Owner permission: drwxr-xr-x

2003-04-06 Thread Rob Dixon
[EMAIL PROTECTED] wrote:
 I've read about 10 pages on unix permissions.

 So far I've learned that a directory is a file with a listing of
 subdirectories and files.  And the d in drwxr-xr-x indicates the file is a
 directory.  And if it begins with -, it's a file -rwxr-xr-x.Also the -
 separates permissions of the Owner - Group - World.
 r = read w=write x=execute.   Pretty simple.

 What I don't understand is the r listed twice in the Owner section.  None of
 the pages I've read explain this or I missed it somewhere.

Hi.

What the others have said is correct: a hyphen indicates that permission
is disabled. This means that you permission string above '-rwxr-xr-x'
unpacks as

-  rwx  r-x  r-x

with the groups for directory, owner, group, world in that order:

directory   -   (is not a directory)
owner   rwx (read, write, execute)
group   r-x (read, execute)
world   r-x (read, execute)

note that each value is a bit, and three bit groups allows the
complete set to be represented conveniently in octal. In this
case 755. Remember that value - you'll see it a lot!

HTH,

Rob




-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Re: unix windows permissions

2003-04-06 Thread Jenda Krynicky
From: [EMAIL PROTECTED]
 Does windows use the chmod command in the same manner as unix

No.
There is no chmod in the system itself. And the builtin chmod() 
function is almost a NOOP under windows. The ony thing chmod() does 
under Windows is that it sets the READONLY attribute on the file 
according to the user-writeable bit of the permissions. AFAIK.

The permissions model used by Unix and Windows is too different for 
chmod() to do anything better.

From ActivePerl-faq5 - Implementation Quirks:

--
How does the chmod function work on Win32 platforms?
chmod() is supported in ActivePerl. However, it can only be used for 
setting owner read/write access. (The group and other bits are 
ignored.)

UNIX-style security for files is not applicable to files on Win32 
systems. Win32 systems inherit from DOS four possible file 
attributes: archived (A), read-only (R), hidden (H), and system (S). 
These can be checked and set with the 
Win32::File::Get/SetAttributes().

Windows NT/2000 systems using NTFS can also have more specific 
permissions granted on individual files to users and groups. For 
builds 300 and above, and the Perl Resource Kit for Win32, you can 
use the Win32::FileSecurity module to maintain file permissions.
--


HTH, Jenda
= [EMAIL PROTECTED] === http://Jenda.Krynicky.cz =
When it comes to wine, women and song, wizards are allowed 
to get drunk and croon as much as they like.
-- Terry Pratchett in Sourcery


-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Re: maching end of a line with $

2003-04-06 Thread Jose Malacara
Thanks for the help! You are correct, a string equality test is easier.
My main problem was that I realized that I wasn't splitting my line of
input (containing the IP addresses and other values) before I was trying
to match, so I had:

if ($array[0] eq $value) {
@array = split(/,/, $line);


instead of:

@array = split(/,/, $line);
if ($array[0] eq $value) {


This was causing my match to fail because it was trying to match against
the entire line of input instead of just the IP.

Thanks to all that helped.

Jose


On Fri, 2003-04-04 at 17:54, Wiggins d'Anconia wrote:
 Jose Malacara wrote:
  Can someone help me out here, please.
  
  I have an if statement that is looping over a list of IP addresses:
  
  192.168.1.1
  192.168.1.2
  192.168.1.3 ...192.168.1.10
  
  $value=192.168.1.1
  
  if ($line =~ /($value)/) ...
  
  I only want to match the value exactly (192.168.1.1). My problem is that I am 
  matching all addresses containing that string (192.168.1.10, 192.168.1.11, 
  192.168.1.100, etc...)
  
 
 In the case of an exact match why not just use string equality test? 
 (don't forget to 'chomp' the line if you are getting it from a filehandle)
 
 if ($line eq $value) 
 
  I know the trailing '$' anchors the match to the end of the line only, but I 
  cannot seem to get it to work as I think my syntax is incorrect.
  
 
 What trailing '$' you don't have one in the code you posted above...if 
 you insist on the regex, it would go something like:
 
 if ($line =~ /^($value)$/) 
 
 Which says match $value (and set it to $1) starting at the beginning of 
 the string '^' and going until the end of the string '$'.
 
 http://danconia.org
 
 
 -- 
 To unsubscribe, e-mail: [EMAIL PROTECTED]
 For additional commands, e-mail: [EMAIL PROTECTED]
 
 



-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



File::Stat vers system('ls -al')

2003-04-06 Thread Motherofperls
http://www.rubycentral.com/book/ref_c_file__stat.html

Ive read the above page which explains File::Stat methods.  I'm just not sure 
how this translates to the various unix forms of drwxrwxrwx.

Another thing I'm not clear on is the real user and the effective user.


Re: accessing the string from system(ls -al) / browse dir script

2003-04-06 Thread simran
Stat::lsMode would probably be of interest as well. 

http://search.cpan.org/author/MJD/Stat-lsMode-0.50/lsMode.pm

On Mon, 2003-04-07 at 10:41, R. Joseph Newton wrote:
 [EMAIL PROTECTED] wrote:
 
 
  Hello Mother,
 
  While not knowing exactly what you want to do,
  in general you can use the backtick operators
  to return the output of an external script or
  program; for example, to get a 10 byte string
  of permissions on 'some.file' you could:
 
  $perm = substr (`ls -al some.file`, 0, 10);
 
 I like it!  I'm not much of a 'nix user, and I'd forgotten that you could ls -al for
 a single filename.  This certainly pulls the wanted information in quite elegantly.
 
 Joseph


-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Re: unix windows permissions

2003-04-06 Thread Motherofperls
I'm afraid to use `ls -al` now because unix sytems may vary.

I'm going to try the module suggested:
http://search.cpan.org/author/MJD/Stat-lsMode-0.50

and insert the $^O to test for windows or unix.  

Then to test for windows permissions I can just use -r and -w, right?

Somehow I would have to pack Stat-lsMode into my software. I'm hoping that 
will be as easy as putting the pm file in the same cgi directory.

I have alot more to read about user permissions for unix.  But I'm going give 
what I've learned so far time to sink in.

Thanks again,  
Tricia 


POSIX 'strftime'

2003-04-06 Thread David Gilden
Hello,

How can get the date formatted to include the day of the week (plus one)
'04-07-2003-1013'

Thanks,
Dave
( kora musician / audiophile / web master @ cora connection /  Ft. Worth, TX, USA)

The following misses the day of week!!

#!/usr/bin/perl -w

use POSIX 'strftime';

print strftime('%m-%W-%Y-%I%M',localtime),\n;


==
 Cora Connection: Your West African Music Source
  Resources, Recordings, Instruments  More!
   http://www.coraconnection.com/ 
==

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Re: POSIX 'strftime'

2003-04-06 Thread John W. Krahn
David Gilden wrote:
 
 Hello,

Hello,

 How can get the date formatted to include the day of the week (plus one)

man 3 strftime
[snip]
   %a The abbreviated weekday name according to the  curĀ­
  rent locale.

   %A The  full  weekday  name  according  to the current
  locale.
[snip]
   %u The day of the week as a decimal,  range  1  to  7,
  Monday being 1.  See also %w. (SU)

   %w The day of the week as a decimal,  range  0  to  6,
  Sunday being 0.  See also %u.


John
-- 
use Perl;
program
fulfillment

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]