Re: How to obtain filesize?

2004-11-05 Thread Tony Cheung
If I want to use $CGI::POST_MAX ,how to wirte in my program,thanks.$Bill Luebkert [EMAIL PROTECTED] wrote:
Tony Cheung wrote: Thanks for your help. I got a program yesterday,and add in it,but program is not word! #!e:\perl\bin\perl #CGI use CGI;  $upfilecount = 1; $maxuploadcount = 2; # $basedir = "e:/English"; # $allowall = "no"; # @theext =(".zip",".exe",".gif",".rm",".doc",".xls"); # $filesize = 220842; #216K print "Content-type: text/html\n\n"; while ($upfilecount = $maxuploadcount) { my $req = new CGI;  my $file = $req-param("FILE$upfilecount");  if ($file ne "") { my $fileName = $file;You can't check the file size until it's been uploaded. I thinkCGI would have stored the fi!
 le in a
 temporary file at this pointin time and you can use :my $tmpfile = $cgi-tmpFileName($file);my $file_size = -s $tmpfile;CGI can be configured to reject files greater than a given size :$CGI::POST_MAX = $filesize; # prior to the while loop my $file_size = -s $file; print $file_size."\n"; if ($file_size  $filesize) {  $fileName =~ s/^.*(\\|\/)// ;  # my $newmain = $fileName; my $filenotgood; if ($allowall ne "yes") { $extname =  lc(substr($newmain,length($newmain) - 4,4)); # for(my $i = 0; $i  @theext; $i++){  # if ($extname eq $theext[$i]){ $filenotgood = "yes"; last; } } }  if ($filenotgood ne "yes") { #You may be able to just move the temp file rather than copying
 it. open (OUTFILE, "$basedir/$fileName"); binmode(OUTFILE);  # while (my $bytesread = read($file, my  $buffer, 1024)) {  print OUTFILE! $buffer; } close (OUTFILE); $message.=$file . " !\n"; } else{ $message.=$filenb! sp; . "  !\n"; }  }else{ $message.=$file . "  !\n"; } } $upfilecount++;  } print $message; #*/Beckett Richard-qswi266 <[EMAIL PROTECTED]>/* wrote:  All you need to get the file size is -s.  I.e. $file_size = -s $file  Save the following script as size.pl, and run like this:  perl size.pl
 size.pl  use strict; use warnings; my $file = $ARGV[0]; my $file_size = -s $file; print "$file is $file_size bytes\n";   -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Tony Cheung Sent: 03 November 2004 06:54 To: perl-win32-users Subject: How to obtain filesize?   I have a perl program about update file from pc to mysql,but I want to limit filesize,how to obtain filesize and file type?-- ,-/- __ _ _ $Bill Luebkert Mailto:[EMAIL PROTECTED](_/ / ) // // DBE Collectibles Mailto:[EMAIL PROTECTED]/ ) /-- o // // Castle of Medieval Myth  Magic http://www.todbe.com/-/-' /___/__Do You
 Yahoo!?
150MP3
1G1000___
Perl-Win32-Users mailing list
[EMAIL PROTECTED]
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs


regex in

2004-11-05 Thread Jutu Subramanian, Srinivasan (Cognizant)

Hi,
pattern: abcdefghijklmnopqrstuvwxyz

From the above pattern, How to find the parameter $1=efgh and $2=qrst within . What 
is the regex to written in perl?

regards
Srinivas

This e-mail and any files transmitted with it are for the sole use of the intended 
recipient(s) and may contain confidential and privileged information.
If you are not the intended recipient, please contact the sender by reply e-mail and 
destroy all copies of the original message.
Any unauthorized review, use, disclosure, dissemination, forwarding, printing or 
copying of this email or any action taken in reliance on this e-mail is strictly
prohibited and may be unlawful.

  Visit us at http://www.cognizant.com

___
Perl-Win32-Users mailing list
[EMAIL PROTECTED]
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs


RE: regex in

2004-11-05 Thread Beckett Richard-qswi266
use strict;
use warnings;
my $pat = abcdefghijklmnopqrstuvwxyz;
print \$pat is $pat\n;
$pat =~ /(.*).*(.*)/;
my ($one, $two) = ($1, $2);
print \$one is $one\n\$two is $two\n;

R.
 -Original Message-
 From: [EMAIL PROTECTED] 
 [mailto:[EMAIL PROTECTED] On 
 Behalf Of Jutu Subramanian, Srinivasan (Cognizant)
 Sent: 05 November 2004 09:34
 To: [EMAIL PROTECTED]
 Subject: regex in 
 
 
 
 Hi,
 pattern: abcdefghijklmnopqrstuvwxyz
 
 From the above pattern, How to find the parameter $1=efgh 
 and $2=qrst within . What is the regex to written in perl?
 
 regards
 Srinivas
 
 This e-mail and any files transmitted with it are for the 
 sole use of the intended recipient(s) and may contain 
 confidential and privileged information.
 If you are not the intended recipient, please contact the 
 sender by reply e-mail and destroy all copies of the original message.
 Any unauthorized review, use, disclosure, dissemination, 
 forwarding, printing or copying of this email or any action 
 taken in reliance on this e-mail is strictly
 prohibited and may be unlawful.
 
   Visit us at http://www.cognizant.com
 
 ___
 Perl-Win32-Users mailing list
 [EMAIL PROTECTED]
 To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs
 
___
Perl-Win32-Users mailing list
[EMAIL PROTECTED]
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs


Re: regex in

2004-11-05 Thread $Bill Luebkert
Beckett Richard-qswi266 wrote:

 use strict;
 use warnings;
 my $pat = abcdefghijklmnopqrstuvwxyz;
 print \$pat is $pat\n;
 $pat =~ /(.*).*(.*)/;

You probably want to either make that non-greedy or use a different
expression in case there are more  in the string :

/(.*?).*(.*?)/;
or
/([^]+).*([^]+)/;

 my ($one, $two) = ($1, $2);
 print \$one is $one\n\$two is $two\n;
 
 R.
 
-Original Message-
From: [EMAIL PROTECTED] 
[mailto:[EMAIL PROTECTED] On 
Behalf Of Jutu Subramanian, Srinivasan (Cognizant)
Sent: 05 November 2004 09:34
To: [EMAIL PROTECTED]
Subject: regex in 



Hi,
pattern: abcdefghijklmnopqrstuvwxyz

From the above pattern, How to find the parameter $1=efgh 
and $2=qrst within . What is the regex to written in perl?


-- 
  ,-/-  __  _  _ $Bill LuebkertMailto:[EMAIL PROTECTED]
 (_/   /  )// //   DBE CollectiblesMailto:[EMAIL PROTECTED]
  / ) /--  o // //  Castle of Medieval Myth  Magic http://www.todbe.com/
-/-' /___/__/_/_http://dbecoll.tripod.com/ (My Perl/Lakers stuff)
___
Perl-Win32-Users mailing list
[EMAIL PROTECTED]
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs


Re: How to obtain filesize?

2004-11-05 Thread $Bill Luebkert
Tony Cheung wrote:

 If I want to use $CGI::POST_MAX ,how to wirte in my program,thanks.

Try reading the docs :

=item B$CGI::POST_MAX

If set to a non-negative integer, this variable puts a ceiling
on the size of POSTings, in bytes.  If CGI.pm detects a POST
that is greater than the ceiling, it will immediately exit with an error
message.  This value will affect both ordinary POSTs and
multipart POSTs, meaning that it limits the maximum size of file
uploads as well.  You should set this to a reasonably high
value, such as 1 megabyte.

=item B$CGI::DISABLE_UPLOADS

If set to a non-zero value, this will disable file uploads
completely.  Other fill-out form values will work as usual.

=back

You can use these variables in either of two ways.

=over 4

=item B1. On a script-by-script basis

Set the variable at the top of the script, right after the use statement:

use CGI qw/:standard/;
use CGI::Carp 'fatalsToBrowser';
$CGI::POST_MAX=1024 * 100;  # max 100K posts
$CGI::DISABLE_UPLOADS = 1;  # no uploads

=item B2. Globally for all scripts

Open up CGI.pm, find the definitions for $POST_MAX and
$DISABLE_UPLOADS, and set them to the desired values.  You'll
find them towards the top of the file in a subroutine named
initialize_globals().

=back

An attempt to send a POST larger than $POST_MAX bytes will cause
Iparam() to return an empty CGI parameter list.  You can test for
this event by checking Icgi_error(), either after you create the CGI
object or, if you are using the function-oriented interface, call
param() for the first time.  If the POST was intercepted, then
cgi_error() will return the message 413 POST too large.

This error message is actually defined by the HTTP protocol, and is
designed to be returned to the browser as the CGI script's status
 code.  For example:

   $uploaded_file = param('upload');
   if (!$uploaded_file  cgi_error()) {
  print header(-status=cgi_error());
  exit 0;
   }

However it isn't clear that any browser currently knows what to do
with this status code.  It might be better just to create an
HTML page that warns the user of the problem.



-- 
  ,-/-  __  _  _ $Bill LuebkertMailto:[EMAIL PROTECTED]
 (_/   /  )// //   DBE CollectiblesMailto:[EMAIL PROTECTED]
  / ) /--  o // //  Castle of Medieval Myth  Magic http://www.todbe.com/
-/-' /___/__/_/_http://dbecoll.tripod.com/ (My Perl/Lakers stuff)
___
Perl-Win32-Users mailing list
[EMAIL PROTECTED]
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs


Easy way of using module Env, platform independent?

2004-11-05 Thread zeray . abraha




# Hi,
# Question. Easy way of using module Env, platform independent.
# Want to do the following: (example)
# 1. get the PATH environment variable
# 2. change it to add an additional search path
# 3. put back the modified PATH
# 4. execute a program/script using the system command.
# Example below works but I don't like it. There must be an easy way,
similar to setenv(env_varName=value)
# that also takes care of the platform independence.
# Your help is appreciated.

use strict;
my @PATH=();
use Env; # Env qw(PATH);
my $mswin=0;
my $home=;
$mswin=1 if ($^O =~ /MSWin/);

@PATH=split(/;/,$ENV{'PATH'}) if $mswin; # for windows
@PATH=split(/:/,$ENV{'PATH'}) if !$mswin;# for unix

$home=$ENV{'HOMEPATH'} if $mswin;# for windows
$home=$ENV{'HOME'} . '/' if !$mswin; # for unix

print home=$home\n;

my $toolpath=${home}tmp/bin;   # in this path is my
executable
$toolpath =~ s/\//\\/g if $mswin;# adjust for windows
print toolpath=$toolpath\n;

push(@PATH, $toolpath);  # add to the PATH
environment variable
$ENV{'PATH'}=join(($mswin)? ';':':', @PATH); # set the PATH env.
thus
print PATH=,$ENV{'PATH'}, \n;# see if toolpath is
added

# execute your program now using system command.
# For this example, for unix, 'chmod +x ztest.bat'; ztest.bat prints 'some
message'
system(ztest.bat);
print Unknown command\n if $?;

# Thanks
# zeray


___
Perl-Win32-Users mailing list
[EMAIL PROTECTED]
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs


Re: How to obtain filesize?

2004-11-05 Thread Tony Cheung
Hi!
I used POST_MAX,and it's succeed,but the browser has not any result,why?
-
#!c:\perl\bin\perl#CGIuse CGI; $upfilecount = 1;$maxuploadcount = 2; #$basedir = "c:/English"; #$allowall = "no"; #@theext =(".zip",".exe",".gif",".rm",".doc",".xls",".mp3"); #$filesize = 220842; #216K
$CGI::POST_MAX=$filesize;

print "Content-type: text/html\n\n";while ($upfilecount = $maxuploadcount) { my $req = new CGI;  my $file = $req-param("FILE$upfilecount");  if ($file ne "") { my $fileName = $file; my $file_size = -s $file; print $file_size."\n"; if ($file_size  $filesize) {
  $fileName =~ s/^.*(\\|\/)//; # my $newmain = $fileName; my $filenotgood; if ($allowall ne "yes") { $extname = lc(substr($newmain,length($newmain) - 4,4));
 # for(my $i = 0; $i  @theext; $i++){ # if ($extname eq $theext[$i]){ $filenotgood =
 "yes"; last; } } }  if ($filenotgood ne "yes") {
 # open (OUTFILE, "$basedir/$fileName"); binmode(OUTFILE); # while (my $bytesread = read($file, my $buffer, 1024)) {  print OUTFILE!
 
 $buffer; } close (OUTFILE); $message.=$file . " !br\n"; } else{ $message.=$file!
 sp;
 . " !br\n"; }  }else{ $message.=$file . " !br\n";  } } $upfilecount++; }print status=cgi_error();print $message;!
 
 #
-$Bill Luebkert [EMAIL PROTECTED] wrote:
Tony Cheung wrote: If I want to use $CGI::POST_MAX ,how to wirte in my program,thanks.Try reading the docs :=item B$CGI::POST_MAXIf set to a non-negative integer, this variable puts a ceilingon the size of POSTings, in bytes. If CGI.pm detects a POSTthat is greater than the ceiling, it will immediately exit with an errormessage. This value will affect both ordinary POSTs andmultipart POSTs, meaning that it limits the maximum size of fileuploads as well. You should set this to a reasonably highvalue, such as 1 megabyte.=item B$CGI::DISABLE_UPLOADSIf set to a non-zero value, this will disable file uploadscompletely. Other fill-out form values will work as usual.=backYou can use these variables in either of two ways.=over 4=item B1. On a script-by-s!
 cript
 basisSet the variable at the top of the script, right after the "use" statement:use CGI qw/:standard/;use CGI::Carp 'fatalsToBrowser';$CGI::POST_MAX=1024 * 100; # max 100K posts$CGI::DISABLE_UPLOADS = 1; # no uploads=item B2. Globally for all scriptsOpen up CGI.pm, find the definitions for $POST_MAX and$DISABLE_UPLOADS, and set them to the desired values. You'llfind them towards the top of the file in a subroutine namedinitialize_globals().=backAn attempt to send a POST larger than $POST_MAX bytes will causeI to return an empty CGI parameter list. You can test forthis event by checking I, either after you create the CGIobject or, if you are using the function-oriented interface, callfor the first time. If the POST was intercepted, thencgi_error() will return the message "413 POST too large".This error message is actually defined by t!
 he HTTP
 protocol, and isdesigned to be returned to the browser as the CGI script's statuscode. For example:$uploaded_file = param('upload');if (!$uploaded_file  cgi_error()) {print header(-status=cgi_error());exit 0;}However it isn't clear that any browser currently knows what to dowith this status code. It might be better just to create anHTML page that warns the user of the problem.-- ,-/- __ _ _ $Bill Luebkert Mailto:[EMAIL PROTECTED](_/ / ) // // DBE Collectibles Mailto:[EMAIL PROTECTED]/ ) /-- o // // Castle of Medieval Myth  Magic http://www.todbe.com/-/-' /___/__Do You Yahoo!?
150MP3
1G1000___
Perl-Win32-Users mailing list
[EMAIL PROTECTED]
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs


Re: Easy way of using module Env, platform independent?

2004-11-05 Thread $Bill Luebkert
[EMAIL PROTECTED] wrote:

 
 
 
 # Hi,
 # Question. Easy way of using module Env, platform independent.
 # Want to do the following: (example)
 # 1. get the PATH environment variable
 # 2. change it to add an additional search path
 # 3. put back the modified PATH
 # 4. execute a program/script using the system command.
 # Example below works but I don't like it. There must be an easy way,
 similar to setenv(env_varName=value)
 # that also takes care of the platform independence.
 # Your help is appreciated.

Have you tried just setting the new vrbl and doing the system command ?

$ENV{NEW_ITEM} = 'New_value';
system ...

 use strict;
 my @PATH=();
 use Env; # Env qw(PATH);
 my $mswin=0;
 my $home=;
 $mswin=1 if ($^O =~ /MSWin/);
 
 @PATH=split(/;/,$ENV{'PATH'}) if $mswin; # for windows
 @PATH=split(/:/,$ENV{'PATH'}) if !$mswin;# for unix
 
 $home=$ENV{'HOMEPATH'} if $mswin;# for windows
 $home=$ENV{'HOME'} . '/' if !$mswin; # for unix
 
 print home=$home\n;
 
 my $toolpath=${home}tmp/bin;   # in this path is my
 executable
 $toolpath =~ s/\//\\/g if $mswin;# adjust for windows
 print toolpath=$toolpath\n;
 
 push(@PATH, $toolpath);  # add to the PATH
 environment variable
 $ENV{'PATH'}=join(($mswin)? ';':':', @PATH); # set the PATH env.
 thus
 print PATH=,$ENV{'PATH'}, \n;# see if toolpath is
 added
 
 # execute your program now using system command.
 # For this example, for unix, 'chmod +x ztest.bat'; ztest.bat prints 'some
 message'
 system(ztest.bat);
 print Unknown command\n if $?;
 



-- 
  ,-/-  __  _  _ $Bill LuebkertMailto:[EMAIL PROTECTED]
 (_/   /  )// //   DBE CollectiblesMailto:[EMAIL PROTECTED]
  / ) /--  o // //  Castle of Medieval Myth  Magic http://www.todbe.com/
-/-' /___/__/_/_http://dbecoll.tripod.com/ (My Perl/Lakers stuff)
___
Perl-Win32-Users mailing list
[EMAIL PROTECTED]
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs


Re: How to obtain filesize?

2004-11-05 Thread $Bill Luebkert
Tony Cheung wrote:

 Hi!
 I used POST_MAX,and it's succeed,but the browser has not any result,why?

Who knows.  1) I'm not going to play with a script that doesn't have a use strict
to start it off.  2) You should remove the code you added to test the file size
now that CGI is handling it.  I'm sure there are other errors in the script that
will show up with use strict in force.

 -
 #!c:\perl\bin\perl
 #Èç¹ûÓÃCGI·½Ê½À´Ðж¯Õâ¸öÎļþ£¬Çë°Ñ϶η¾¶¸Ä³ÉÄãµÄ»úÆ÷ÅäÖÃ
 use  CGI; 
 $upfilecount  =  1;
 $maxuploadcount  =  2;  #ÏÞÖÆÉÏ´«ÎļþµÄ×î´óÊý
 $basedir  =  c:/English;  #ÉÏ´«µÄÎļþ´æ·ÅµØÖ·
 $allowall  =  no;  #ÊÇ·ñ²»ÏÞÖÆÎļþºó׺ÉÏ´«
 @theext  =(.zip,.exe,.gif,.rm,.doc,.xls,.mp3); 
 #ÒªÏÞÖƵÄÎļþºó׺Ãû
 $filesize = 220842;  #ÏÞÖÆÎļþ´óСÔÚ216K
 
 $CGI::POST_MAX=$filesize;
  
 print  Content-type:  text/html\n\n;
 while  ($upfilecount  =  $maxuploadcount)  {
 my  $req  =  new  CGI; 
 my  $file  =  $req-param(FILE$upfilecount); 
 if  ($file  ne  )  {
 my  $fileName  =  $file;
 my $file_size = -s $file;
 print $file_size.\n;
 if ($file_size  $filesize) {

$fileName  =~  s/^.*(\\|\/)// file://\\|\/)//; 
 #ÓÃÕýÔò±í´ïʽȥ³ýÎÞÓõÄ·¾¶Ãû£¬µÃµ½ÎļþÃû
my  $newmain  =  $fileName;
my  $filenotgood;
if  ($allowall  ne  yes)  {
$extname  = 
 lc(substr($newmain,length($newmain)  -  4,4));  #È¡ºó׺Ãû
for(my  $i  =  0;  $i@theext;  $i++){ 
 #Õâ¶Î½øÐкó׺Ãû¼ì²â
if  ($extname  eq  $theext[$i]){
$filenotgood  =  yes;
last;
}
}
 }
if  ($filenotgood  ne  yes)  {  #Õâ¶Î¿ªÊ¼ÉÏ´«
open  (OUTFILE,  $basedir/$fileName);
binmode(OUTFILE); 
 #Îñ±ØÈ«Óöþ½øÖÆ·½Ê½£¬ÕâÑù¾Í¿ÉÒÔ·ÅÐÄÉÏ´«¶þ½øÖÆÎļþÁË¡£¶øÇÒÎı¾ÎļþÒ²²»»áÊܸÉÈÅ
while  (my  $bytesread  =  read($file,  my 
 $buffer,  1024))  { 
print  OUTFILE  $buffer;
}
close  (OUTFILE);
$message.=$file  .Òѳɹ¦ÉÏ´«!br\n;
}
else{
$message.=$file  .   
 Îļþºó׺²»·ûºÏÒªÇó£¬ÉÏ´«Ê§°Ü!br\n;
}
   
  }else{
  $message.=$file  .   
 Îļþ´óС²»·ûºÏÒªÇó£¬ÉÏ´«Ê§°Ü!br\n;
  }
  }
$upfilecount++;
   
 }
 print status=cgi_error();
 print  $message;  #×îºóÊä³öÉÏ´«ÐÅÏ¢


-- 
  ,-/-  __  _  _ $Bill LuebkertMailto:[EMAIL PROTECTED]
 (_/   /  )// //   DBE CollectiblesMailto:[EMAIL PROTECTED]
  / ) /--  o // //  Castle of Medieval Myth  Magic http://www.todbe.com/
-/-' /___/__/_/_http://dbecoll.tripod.com/ (My Perl/Lakers stuff)


___
Perl-Win32-Users mailing list
[EMAIL PROTECTED]
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs


Re: How to obtain filesize?

2004-11-05 Thread Tony Cheung
Please help me test this program,thanks!
Thank you very much!
---
upload.html
---
htmlbodyform method="POST" action=""http://localhost/cgi-bin/upload.pl">http://localhost/cgi-bin/upload.pl" ENCTYPE="multipart/form-data"File 1: input type="file" name="FILE1"brFile 2: input type="file" name="FILE2"brinput type="submit" value="Upload!"/form/body/html
===
--
upload.pl
--
#!c:\perl\bin\perl
use CGI; $upfilecount = 1;$maxuploadcount = 2; $basedir = "c:/English"; $allowall = "no"; @theext =(".zip",".exe",".gif",".rm",".doc",".xls",".mp3"); $filesize = 220842; #216K$CGI::POST_MAX=$filesize;
print "Content-type: text/html\n\n";while ($upfilecount = $maxuploadcount) { my $req = new CGI;  my $file = $req-param("FILE$upfilecount");  if ($file ne "") { my $fileName = $file; my $file_size = -s $file; print $file_size."\n"; if ($file_size  $filesize) {
  $fileName =~ s/^.*(\\|\/)//;  my $newmain = $fileName; my $filenotgood; if ($allowall ne "yes") { $extname = lc(substr($newmain,length($newmain) - 4,4));
  for(my $i = 0; $i  @theext; $i++){  if ($extname eq $theext[$i]){ $filenotgood =
 "yes"; last; } } }  if ($filenotgood ne "yes") {
  open (OUTFILE, "$basedir/$fileName"); binmode(OUTFILE);  while (my $bytesread = read($file, my $buffer, 1024)) {  print OUTFILE
 $buffer; } close (OUTFILE); $message.=$file . " upload ok!br\n"; } else{ $message.=$file!
 p;
 . " file postfix error!br\n"; }  }else{ $message.=$file . " file too large!br\n";  } } $upfilecount++; }print status=cgi_error();print $message; 
=
I use apache1.2.36 in my pc.$Bill Luebkert [EMAIL PROTECTED] wrote:
Tony Cheung wrote: Hi! I used POST_MAX,and it's succeed,but the browser has not any result,why?Who knows. 1) I'm not going to play with a script that doesn't have a use strictto start it off. 2) You should remove the code you added to test the file sizenow that CGI is handling it. I'm sure there are other errors in the script thatwill show up with use strict in force. - #!c:\perl\bin\perl #CGI use CGI;  $upfilecount = 1; $maxuploadcount = 2; # $basedir = "c:/English"; # $allowall = "no"; # @theext =(".zip",".exe",".gif",".rm",".doc",".xls",".mp3");  # $files!
 ize =
 220842; #216K  $CGI::POST_MAX=$filesize;  print "Content-type: text/html\n\n"; while ($upfilecount = $maxuploadcount) { my $req = new CGI;  my $file = $req-param("FILE$upfilecount");  if ($file ne "") { my $fileName = $file; my $file_size = -s $file; print $file_size."\n"; if ($file_size  $filesize) {  $fileName =~ s/^.*(\\|\/)// ;  # my $newmain = $fileName; my $filenotgood; if ($allowall ne "yes") { $extname =  lc(substr($newmain,length($newmain) - 4,4)); # for(my $i = 0; $i  @theext; $i++){  # if ($extname eq $theext[$i]){ $filenotgood = "yes"; last; } } } if ($filenotgood ne "yes") { # open (OUTFILE,
 "$basedir/$fileName"); binmode(OUTFILE);  # while (my $bytesread = read($file, my  $buffer, 1024)) {  print OUTFILE $buffer; } close (OUTFILE); $message.=$file . " !\n"; } else{ $message.=$file . "  !\n"; }  }else{ $message.=$file . "  !\n"; } } $upfilecount++;  } print status=cgi_error(); print $message; #-- ,-/- __ _ _ $Bill Luebkert Mailto:[EMAIL PROTECTED](_/ / ) // // DBE Collectibles Mailto:[EMAIL PROTECTED]/ ) /-- o // // Castle of Medieval Myth  Magic http://www.todbe.com/-/-' /___/__Do You Yahoo!?
150MP3
1G1000___
Perl-Win32-Users mailing list
[EMAIL PROTECTED]
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs


RE: regex in

2004-11-05 Thread Tom Pollard
On Fri, 5 Nov 2004, Beckett Richard-qswi266 wrote:
 use strict;
 use warnings;
 my $pat = abcdefghijklmnopqrstuvwxyz;
 print \$pat is $pat\n;
 $pat =~ /(.*).*(.*)/;
 my ($one, $two) = ($1, $2);
 print \$one is $one\n\$two is $two\n;

That does work in this case, but it's not terribly robust. If there were a
third angle-bracketed substring, for instance, (or only one) this would no
longer match them correctly.

I'd always use one of the following:

1) $pat = /([^]*).*([^]*)/;

   This always matches the first two angle-bracketed substrings, ignoring
   any others there might follow.

2) my @matches = ($pat =~ /([^]*)/g);

   This matches any number of angle-bracketed substrings, returning them
   in a list.


TomP

  -Original Message-
  pattern: abcdefghijklmnopqrstuvwxyz
  
  From the above pattern, How to find the parameter $1=efgh 
  and $2=qrst within . What is the regex to written in perl?

-
Tom Pollard   [EMAIL PROTECTED]
Schrodinger, Inc.646-366-9555 x102
-




___
Perl-Win32-Users mailing list
[EMAIL PROTECTED]
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs


Re: Easy way of using module Env, platform independent?

2004-11-05 Thread Roger Keane
[EMAIL PROTECTED] wrote:

# Hi,
# Question. Easy way of using module Env, platform independent.
# Want to do the following: (example)
# 1. get the PATH environment variable
# 2. change it to add an additional search path
# 3. put back the modified PATH
# 4. execute a program/script using the system command.
# Example below works but I don't like it. There must be an easy way,
similar to setenv(env_varName=value)
# that also takes care of the platform independence.
# Your help is appreciated.
use strict;
my @PATH=();
use Env; # Env qw(PATH);
my $mswin=0;
my $home=;
$mswin=1 if ($^O =~ /MSWin/);
@PATH=split(/;/,$ENV{'PATH'}) if $mswin; # for windows
@PATH=split(/:/,$ENV{'PATH'}) if !$mswin;# for unix
$home=$ENV{'HOMEPATH'} if $mswin;# for windows
$home=$ENV{'HOME'} . '/' if !$mswin; # for unix
print home=$home\n;
my $toolpath=${home}tmp/bin;   # in this path is my
executable
$toolpath =~ s/\//\\/g if $mswin;# adjust for windows
print toolpath=$toolpath\n;
push(@PATH, $toolpath);  # add to the PATH
environment variable
$ENV{'PATH'}=join(($mswin)? ';':':', @PATH); # set the PATH env.
thus
print PATH=,$ENV{'PATH'}, \n;# see if toolpath is
added
# execute your program now using system command.
# For this example, for unix, 'chmod +x ztest.bat'; ztest.bat prints 'some
message'
system(ztest.bat);
print Unknown command\n if $?;
# Thanks
# zeray
If you version of Perl is recent enough (5.6.0 or better, I think) the
array support for the path-like variables is already built-in to the Env
module, and is platform independent (uses the $Config{path_sep} variable).
You still need to be wary of path directory separators.  There are platform
independent modules for constructing the pathnames (see File::Spec), but
here's a qnd approach that works for windoze XP and *nix:
testedcode
#!perl -w
use strict;
require v5.6.0;
use Env qw( @PATH $HOME $HOMEDRIVE $HOMEPATH );
sub isWindoze() { return $^O =~ /Win32/; }
sub getHome() { return isWindoze() ? $HOMEDRIVE . $HOMEPATH : $HOME; }
sub add_paths(@)
{
my @paths = @_;
my $dir_sep = isWindoze() ? \\ : /;
push @PATH, map{ s/[\/\\]+/${dir_sep}/go; $_ } @paths;
}
my $home = getHome() || die( you are homeless!\n );
print( Before add_paths:\n   , join(\n   , @PATH), \n );
add_paths( $home/tmp/bin, temp, $home/temp, ///temp );
print( After add paths:\n   , join(\n   , @PATH), \n );
/testedcode
Several things to think about (left as an exercise for the reader):
 - what happens if home environment variable is not set?
 - what happens if added directories do not exist?
 - what happens if added directories are already in the path?
 - what happens if path string is longer than what is allowed on OS?
 - what happens if your executable exists in an earlier path component?
 - what happens if your os is not *nix or windoze XP?
 - what should happen for all of the above?
hth,
rgr
--
use strict; use warnings; print unpack'u',join'',map{chr}grep{$_}split/(\d{2})/,
q(5750715383613433655970938458385382403733696070806458383767588653824396969610);
__END__
___
Perl-Win32-Users mailing list
[EMAIL PROTECTED]
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs


How can I translate PERL module to C source code ?

2004-11-05 Thread Allen\(哲民\)



Hi,

Ineed to translate a PERL module to C 
source code , but I got the follow message :

[PERL under Linux]# perl -MO=C,-owin32.c 
win32_exec.pm 
Base class package 
"Msf::PayloadComponent::Win32Execute" is empty. 
(Perhaps you need to 'use' the module which 
defines that package first.) 
at win32_exec.pm line 12 BEGIN 
failed--compilation aborted at win32_exec.pm line 12.

Could someone let me know how can I 
solve this problem ?

Thank you,

Allen
___
Perl-Win32-Users mailing list
[EMAIL PROTECTED]
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs


How remove newlines?

2004-11-05 Thread Martin Leese
Hi,

A nice easy one for a Friday afternoon.

I have a variable containing text in which I wish to
convert embedded newlines to spaces.  And, I wish to
do this in a way which is portable.

I have come up with:

$tempValue =~ s/\r\n/ /g;
$tempValue =~ s/\n/ /g;

I believe this pair of statements will work on both
Windows and UNIX, and with text originating on both
Windows and UNIX.  I welcome improvements.

Also, how do I accommodate Macs?

Many thanks,
Martin

___
Perl-Win32-Users mailing list
[EMAIL PROTECTED]
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs


RE: How remove newlines?

2004-11-05 Thread vega, james
 -Original Message-
 From: [EMAIL PROTECTED] 
 [mailto:[EMAIL PROTECTED] On 
 Behalf Of Glenn Linderman
 Sent: Friday, November 05, 2004 1:48 PM
 To: Martin Leese
 Cc: [EMAIL PROTECTED]
 Subject: Re: How remove newlines?
 
 
 On approximately 11/5/2004 10:38 AM, came the following 
 characters from 
 the keyboard of Martin Leese:
  Hi,
  
  A nice easy one for a Friday afternoon.
  
  I have a variable containing text in which I wish to
  convert embedded newlines to spaces.  And, I wish to
  do this in a way which is portable.
  
  I have come up with:
  
  $tempValue =~ s/\r\n/ /g;
  $tempValue =~ s/\n/ /g;
  
  I believe this pair of statements will work on both
  Windows and UNIX, and with text originating on both
  Windows and UNIX.  I welcome improvements.
  
  Also, how do I accommodate Macs?
 
 If a sequence of newlines can be converted to a single space, then
 
 $tempValue =~ s/[\r\n]*/ /g;

That should be:

$tempValue =~ s/[\r\n]+/ /g;

Otherwise you'll end up putting spaces in more places than you like.

 will do it.  Otherwise, add
 
 $tempVale =~ s/\r/ /g;
 
 to your existing commands. (AFAIK -- I've never owned a Mac)
 
 -- 
 Glenn -- http://nevcal.com/
 ===
 Having identified a vast realm of ignorance, Wolfram is 
 saying that much of this realm lies forever outside the light 
 cone of human knowledge.
-- Michael Swaine, Dr Dobbs 
 Journal, Sept 2002 ___
 Perl-Win32-Users mailing list 
 [EMAIL PROTECTED]
 To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs
 
___
Perl-Win32-Users mailing list
[EMAIL PROTECTED]
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs


RE: How remove newlines?

2004-11-05 Thread A B
$tempVale =~ s/\r?\n/br/g;

 --- vega, james [EMAIL PROTECTED] wrote: 
  -Original Message-
  From: [EMAIL PROTECTED] 
  [mailto:[EMAIL PROTECTED] On 
  Behalf Of Glenn Linderman
  Sent: Friday, November 05, 2004 1:48 PM
  To: Martin Leese
  Cc: [EMAIL PROTECTED]
  Subject: Re: How remove newlines?
  
  
  On approximately 11/5/2004 10:38 AM, came the following 
  characters from 
  the keyboard of Martin Leese:
   Hi,
   
   A nice easy one for a Friday afternoon.
   
   I have a variable containing text in which I wish to
   convert embedded newlines to spaces.  And, I wish to
   do this in a way which is portable.
   
   I have come up with:
   
   $tempValue =~ s/\r\n/ /g;
   $tempValue =~ s/\n/ /g;
   
   I believe this pair of statements will work on both
   Windows and UNIX, and with text originating on both
   Windows and UNIX.  I welcome improvements.
   
   Also, how do I accommodate Macs?
  
  If a sequence of newlines can be converted to a single space, then
  
  $tempValue =~ s/[\r\n]*/ /g;
 
 That should be:
 
 $tempValue =~ s/[\r\n]+/ /g;
 
 Otherwise you'll end up putting spaces in more places than you like.
 
  will do it.  Otherwise, add
  
  $tempVale =~ s/\r/ /g;
  
  to your existing commands. (AFAIK -- I've never owned a Mac)
  
  -- 
  Glenn -- http://nevcal.com/
  ===
  Having identified a vast realm of ignorance, Wolfram is 
  saying that much of this realm lies forever outside the light 
  cone of human knowledge.
 -- Michael Swaine, Dr Dobbs 
  Journal, Sept 2002 ___
  Perl-Win32-Users mailing list 
  [EMAIL PROTECTED]
  To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs
  
 ___
 Perl-Win32-Users mailing list
 [EMAIL PROTECTED]
 To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs
  

__ 
Post your free ad now! http://personals.yahoo.ca
___
Perl-Win32-Users mailing list
[EMAIL PROTECTED]
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs


RE: How remove newlines?

2004-11-05 Thread vega, james
 -Original Message-
 From: A B [mailto:[EMAIL PROTECTED] 
 Sent: Friday, November 05, 2004 2:10 PM
 To: vega, james; Martin Leese
 Cc: 'Glenn Linderman'; [EMAIL PROTECTED]
 Subject: RE: How remove newlines?
 
 
 $tempVale =~ s/\r?\n/br/g;

What about Mac-formatted files which use just \r?

  --- vega, james [EMAIL PROTECTED] wrote: 
   -Original Message-
   From: [EMAIL PROTECTED]
   [mailto:[EMAIL PROTECTED] On 
   Behalf Of Glenn Linderman
   Sent: Friday, November 05, 2004 1:48 PM
   To: Martin Leese
   Cc: [EMAIL PROTECTED]
   Subject: Re: How remove newlines?
   
   
   On approximately 11/5/2004 10:38 AM, came the following
   characters from 
   the keyboard of Martin Leese:
Hi,

A nice easy one for a Friday afternoon.

I have a variable containing text in which I wish to convert 
embedded newlines to spaces.  And, I wish to do this in a way 
which is portable.

I have come up with:

$tempValue =~ s/\r\n/ /g;
$tempValue =~ s/\n/ /g;

I believe this pair of statements will work on both Windows and 
UNIX, and with text originating on both Windows and UNIX.  I 
welcome improvements.

Also, how do I accommodate Macs?
   
   If a sequence of newlines can be converted to a single space, then
   
   $tempValue =~ s/[\r\n]*/ /g;
  
  That should be:
  
  $tempValue =~ s/[\r\n]+/ /g;
  
  Otherwise you'll end up putting spaces in more places than you like.
  
   will do it.  Otherwise, add
   
   $tempVale =~ s/\r/ /g;
   
   to your existing commands. (AFAIK -- I've never owned a Mac)
   
   --
   Glenn -- http://nevcal.com/
   ===
   Having identified a vast realm of ignorance, Wolfram is 
   saying that much of this realm lies forever outside the light 
   cone of human knowledge.
  -- Michael Swaine, Dr Dobbs 
   Journal, Sept 2002 ___
   Perl-Win32-Users mailing list 
   [EMAIL PROTECTED]
   To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs
   
  ___
  Perl-Win32-Users mailing list 
  [EMAIL PROTECTED]
  To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs
   
 
 __
  
 Post your free ad now! http://personals.yahoo.ca
 
___
Perl-Win32-Users mailing list
[EMAIL PROTECTED]
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs


RE: How remove newlines?

2004-11-05 Thread Sui Ming Louie
Try this:

use strict;
use warnings;
my $tempstr = abcdefghijklmnopqrstuvwxyz\r\n\r\n\r0123456789\n\n\r;
$tempstr =~ s/(\r?\n)|(\r[^\n])|(\r$)/br/g;
print [$tempstr]\n;

Output:
[abcdefghijklmnopqrstuvwxyzbrbrbr123456789brbrbr]


-Original Message-
From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED] On Behalf Of
Martin Leese
Sent: Friday, November 05, 2004 1:38 PM
To: [EMAIL PROTECTED]
Subject: How remove newlines?

Hi,

A nice easy one for a Friday afternoon.

I have a variable containing text in which I wish to
convert embedded newlines to spaces.  And, I wish to
do this in a way which is portable.

I have come up with:

$tempValue =~ s/\r\n/ /g;
$tempValue =~ s/\n/ /g;

I believe this pair of statements will work on both
Windows and UNIX, and with text originating on both
Windows and UNIX.  I welcome improvements.

Also, how do I accommodate Macs?

Many thanks,
Martin

___
Perl-Win32-Users mailing list
[EMAIL PROTECTED]
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs


___
Perl-Win32-Users mailing list
[EMAIL PROTECTED]
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs


RE: How remove newlines?

2004-11-05 Thread Sui Ming Louie
Previous reply had some bugs.  This one might be better.

use strict;
use warnings;

my $tempstr =
abcdefghijklmnopqrstuvwxyz\r\n\r\n\r0123456789\n\n\rABCDEFGHIJKLMNOPQRSTUVW
XYZ\n\n\r\n\r;
$tempstr =~ s/(\r?\n)|(\r)/br/g;
print [$tempstr]\n;

Output:

[abcdefghijklmnopqrstuvwxyzbrbrbr0123456789brbrbrABCDEFGHIJKLMNO
PQRSTUVWXYZbrbrbrbr]

Sui


-Original Message-
From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED] On Behalf Of
Martin Leese
Sent: Friday, November 05, 2004 1:38 PM
To: [EMAIL PROTECTED]
Subject: How remove newlines?

Hi,

A nice easy one for a Friday afternoon.

I have a variable containing text in which I wish to
convert embedded newlines to spaces.  And, I wish to
do this in a way which is portable.

I have come up with:

$tempValue =~ s/\r\n/ /g;
$tempValue =~ s/\n/ /g;

I believe this pair of statements will work on both
Windows and UNIX, and with text originating on both
Windows and UNIX.  I welcome improvements.

Also, how do I accommodate Macs?

Many thanks,
Martin

___
Perl-Win32-Users mailing list
[EMAIL PROTECTED]
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs



___
Perl-Win32-Users mailing list
[EMAIL PROTECTED]
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs


Convert Python Com Code to Win32::OLE

2004-11-05 Thread Celeste Suliin Burris
I'm a Unix systems administrator who is making the transition to 
Windows. I am trying to access some COM objects, but the only examples 
I have are written in Python, using import win32com.client.

Here's the Python Script (which works). I copied it from the manual, 
then tested it.

import win32com.client
gp = win32com.client.Dispatch(esriGeoprocessing.GpDispatch.1)
testtext = gp.Usage(Buffer_analysis)
print testtest
Here's my perl script - which doesn't work.
use Win32::OLE;
# Set some variables
my $Class = esriGeoprocessing.GpDispatch.1;
my $gp =  Win32::OLE-new($Class)
|| die Could not create a COM '$Class' object;
$testtext = $gp-{Usage}-(Buffer_analysis);
print $testtest;
There error message I get is Undefined subroutine main:: called at 
sample.pl line 7.
darned if I can figure out what it should be.

If someone could point out where I've gone wrong, I'd sure appreciate 
it.  I'm sure the Win32:OLE module is correctly installed, since the 
test scripts work, and so do the ones from the Roth book.

Celeste Suliin Burris
Systems Administrator
Tacoma Economic Development Department
Phone - 253-591-5093
Email - [EMAIL PROTECTED]
___
Perl-Win32-Users mailing list
[EMAIL PROTECTED]
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs


RE: Convert Python Com Code to Win32::OLE

2004-11-05 Thread Jan Dubois
On Fri, 05 Nov 2004, Celeste Suliin Burris wrote:

 testtext = gp.Usage(Buffer_analysis)
...
 $testtext = $gp-{Usage}-(Buffer_analysis);

Try:

  $testtext = $gp-Usage(Buffer_analysis);

Cheers,
-Jan


___
Perl-Win32-Users mailing list
[EMAIL PROTECTED]
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs


Re: Convert Python Com Code to Win32::OLE

2004-11-05 Thread Celeste Suliin Burris
Unfortunately, that doesn't work either.  I think I tried it before in 
my thrashing around.

Thanks for the help, anyway
On Nov 5, 2004, at 13:02, Jan Dubois wrote:
On Fri, 05 Nov 2004, Celeste Suliin Burris wrote:
testtext = gp.Usage(Buffer_analysis)
...
$testtext = $gp-{Usage}-(Buffer_analysis);
Try:
  $testtext = $gp-Usage(Buffer_analysis);
Cheers,
-Jan
___
Perl-Win32-Users mailing list
[EMAIL PROTECTED]
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs


Re: Convert Python Com Code to Win32::OLE

2004-11-05 Thread Celeste Suliin Burris
Well, it doesn't blow up, but it creates an 'undef' variable. I'm not 
sure if that is progress.

On Nov 5, 2004, at 14:34, Chris wrote:
I don't know much about OLE, but it looks like a simple hash.
Maybe $gp{'Usage'}{'Buffer_analysis'} is what your looking for?
- Chris
-Original Message-
From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED] On Behalf Of
Celeste Suliin Burris
Sent: Friday, November 05, 2004 3:57 PM
To: [EMAIL PROTECTED]
Subject: Convert Python Com Code to Win32::OLE
I'm a Unix systems administrator who is making the transition to
Windows. I am trying to access some COM objects, but the only examples
I have are written in Python, using import win32com.client.
Here's the Python Script (which works). I copied it from the manual,
then tested it.
import win32com.client
gp = win32com.client.Dispatch(esriGeoprocessing.GpDispatch.1)
testtext = gp.Usage(Buffer_analysis)
print testtest
Here's my perl script - which doesn't work.
use Win32::OLE;
# Set some variables
my $Class = esriGeoprocessing.GpDispatch.1;
my $gp =  Win32::OLE-new($Class)
 || die Could not create a COM '$Class' object;
$testtext = $gp-{Usage}-(Buffer_analysis);
print $testtest;
There error message I get is Undefined subroutine main:: called at
sample.pl line 7.
darned if I can figure out what it should be.
If someone could point out where I've gone wrong, I'd sure appreciate
it.  I'm sure the Win32:OLE module is correctly installed, since the
test scripts work, and so do the ones from the Roth book.
Celeste Suliin Burris
Systems Administrator
Tacoma Economic Development Department
Phone - 253-591-5093
Email - [EMAIL PROTECTED]
___
Perl-Win32-Users mailing list [EMAIL PROTECTED]
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs
___
Perl-Win32-Users mailing list
[EMAIL PROTECTED]
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs


Convert Python Com Code to Win32::OLE - The answer

2004-11-05 Thread Celeste Suliin Burris
Okay - thanks to a couple of suggestions and much reading of books, 
pods and help files - here is some sample code that works. I'm posting 
it because I've googled and searched and there doesn't seem to be any 
sample perl code for geoprocessing dispatch on the entire 'Net. Of 
course, this is the simplest sample in the book...

use Win32::OLE;
my $Class = esriGeoprocessing.GpDispatch.1;
my $gp =  Win32::OLE-new($Class)
|| die Could not create a COM '$Class' object;
my $testtext = $gp-Usage('Buffer_analysis');
print $testtext;
On Nov 5, 2004, at 15:15, Celeste Suliin Burris wrote:
-Original Message-
From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED] On Behalf 
Of
Celeste Suliin Burris
Sent: Friday, November 05, 2004 3:57 PM
To: [EMAIL PROTECTED]
Subject: Convert Python Com Code to Win32::OLE

I'm a Unix systems administrator who is making the transition to
Windows. I am trying to access some COM objects, but the only examples
I have are written in Python, using import win32com.client.
Here's the Python Script (which works). I copied it from the manual,
then tested it.
import win32com.client
gp = win32com.client.Dispatch(esriGeoprocessing.GpDispatch.1)
testtext = gp.Usage(Buffer_analysis)
print testtest
Here's my perl script - which doesn't work.
use Win32::OLE;
# Set some variables
my $Class = esriGeoprocessing.GpDispatch.1;
my $gp =  Win32::OLE-new($Class)
 || die Could not create a COM '$Class' object;
$testtext = $gp-{Usage}-(Buffer_analysis);
print $testtest;
There error message I get is Undefined subroutine main:: called at
sample.pl line 7.
darned if I can figure out what it should be.
If someone could point out where I've gone wrong, I'd sure appreciate
it.  I'm sure the Win32:OLE module is correctly installed, since the
test scripts work, and so do the ones from the Roth book.
Celeste Suliin Burris
Systems Administrator
Tacoma Economic Development Department
Phone - 253-591-5093
Email - [EMAIL PROTECTED]
___
Perl-Win32-Users mailing list 
[EMAIL PROTECTED]
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs
___
Perl-Win32-Users mailing list
[EMAIL PROTECTED]
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs
___
Perl-Win32-Users mailing list
[EMAIL PROTECTED]
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs


Re: How remove newlines?

2004-11-05 Thread $Bill Luebkert
Sui Ming Louie wrote:

 Try this:
 
 use strict;
 use warnings;
 my $tempstr = abcdefghijklmnopqrstuvwxyz\r\n\r\n\r0123456789\n\n\r;
 $tempstr =~ s/(\r?\n)|(\r[^\n])|(\r$)/br/g;
 print [$tempstr]\n;
 
 Output:
 [abcdefghijklmnopqrstuvwxyzbrbrbr123456789brbrbr]

Your RE is overly complicated (this has already been posted as a solution) :
s/[\r\n]+/ /g;

use strict;
use warnings;

$_ = 
abcdefghijklmnopqrstuvwxyz\r\n\r\n\r0123456789\n\n\rABCDEFGHIJKLMNOPQRSTUVWXYZ\n\n\r\n\r;
s/[\r\n]+/ /g;
print [$_]\n;

__END__


-- 
  ,-/-  __  _  _ $Bill LuebkertMailto:[EMAIL PROTECTED]
 (_/   /  )// //   DBE CollectiblesMailto:[EMAIL PROTECTED]
  / ) /--  o // //  Castle of Medieval Myth  Magic http://www.todbe.com/
-/-' /___/__/_/_http://dbecoll.tripod.com/ (My Perl/Lakers stuff)
___
Perl-Win32-Users mailing list
[EMAIL PROTECTED]
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs


Extracting Images Question

2004-11-05 Thread barons
I know there has to be an easy Perl way to do this. Our HR
dept. scans in thousands of documents and has them up on a
intranet site with thumbnail views. Then another department
clicks on the thumbnail to get the large version of that
doc to save to their desktop. How can I use Perl to enter
in the site name http://myintranet.com and say this hour
there are 40 new scan images up there it will parse through
that page and follow the thumbnail nail paths and download
all the actual size images.

I can use LWP but this seems a bit daunting. Then I would
need to pattern match and so on.

Any ideas?

Thank you
Allan
___
Perl-Win32-Users mailing list
[EMAIL PROTECTED]
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs


Re: Extracting Images Question

2004-11-05 Thread Mike G.
check out saime or mechanize.  Both have the ability to follow links in a page and 
then return to the original window.  How well they work depends upon how the web page 
is constructed.

Mike

On Fri, Nov 05, 2004 at 10:36:27PM -0500, [EMAIL PROTECTED] wrote:
 I know there has to be an easy Perl way to do this. Our HR
 dept. scans in thousands of documents and has them up on a
 intranet site with thumbnail views. Then another department
 clicks on the thumbnail to get the large version of that
 doc to save to their desktop. How can I use Perl to enter
 in the site name http://myintranet.com and say this hour
 there are 40 new scan images up there it will parse through
 that page and follow the thumbnail nail paths and download
 all the actual size images.
 
 I can use LWP but this seems a bit daunting. Then I would
 need to pattern match and so on.
 
 Any ideas?
 
 Thank you
 Allan
 ___
 Perl-Win32-Users mailing list
 [EMAIL PROTECTED]
 To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs
___
Perl-Win32-Users mailing list
[EMAIL PROTECTED]
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs


Re: How to insert picture(.jpe) into mysql database?

2004-11-05 Thread Tony Cheung
Thanks for your help.
I got a program about this subjust,but this program writein PHP with mysql.:

mysql database:
"CREATE TABLE binary_data ( id INT(4) NOT NULL AUTO_INCREMENT PRIMARY KEY,description CHAR(50), bin_data LONGBLOB, filename CHAR(50), filesize CHAR(50), filetype CHAR(50));"
-
store.php3 ? 
if ($submit) { MYSQL_CONNECT( "localhost", "root", "password"); mysql_select_db( "binary_data"); $data = "" "r"), filesize($form_data))); $result=MYSQL_QUERY( "INSERT INTO binary_data (description,bin_data,filename,filesize,filetype) VALUES ('$form_description','$data','$form_data_name','$form_data_size','$form_data_type')"); $id= mysql_insert_id();  print "This file has the following Database ID: $id"; MYSQL_CLOSE(); } else { ? 
File Description:File to upload/store in database:} ? -
What is description,bin_data,filename,filesize,filetype?and how to get these imformaton from perl?
Thank you very much.
Ed Chester [EMAIL PROTECTED] wrote:
In my opinion you have two choices: i) store the image in a binary BLOB fieldii) store a reference to a filename in a sensible text field, and actually store the image in your normal filesystemOf these, I absolutely recommend (ii) and think that (i) is a disastrous thing to do. It will lead to large server load, much slower DB performance, more interface problems, and very large data tables. I cannot think of a single good reason to actually store an image in a mysql database, but if you have one please do post it :) ed cDo You Yahoo!?
150MP3
1G1000___
Perl-Win32-Users mailing list
[EMAIL PROTECTED]
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs


Re: Extracting Images Question

2004-11-05 Thread $Bill Luebkert
[EMAIL PROTECTED] wrote:

 I know there has to be an easy Perl way to do this. Our HR
 dept. scans in thousands of documents and has them up on a
 intranet site with thumbnail views. Then another department
 clicks on the thumbnail to get the large version of that
 doc to save to their desktop. How can I use Perl to enter
 in the site name http://myintranet.com and say this hour
 there are 40 new scan images up there it will parse through
 that page and follow the thumbnail nail paths and download
 all the actual size images.
 
 I can use LWP but this seems a bit daunting. Then I would
 need to pattern match and so on.
 
 Any ideas?

If you have FTP access, you could handle it a lot more easily
(by checking file times etc.) and then just download files
that are of different dates or possibly sizes than previous
versions of files.

You would need to be more exact in how the files differ and
are added to be more specific in a solution.  Can you keep
a local mirror ?  That would make it even easier since you
can just compare what you have locally to what's new on the
site.

-- 
  ,-/-  __  _  _ $Bill LuebkertMailto:[EMAIL PROTECTED]
 (_/   /  )// //   DBE CollectiblesMailto:[EMAIL PROTECTED]
  / ) /--  o // //  Castle of Medieval Myth  Magic http://www.todbe.com/
-/-' /___/__/_/_http://dbecoll.tripod.com/ (My Perl/Lakers stuff)
___
Perl-Win32-Users mailing list
[EMAIL PROTECTED]
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs