RE: Copying A File From A Remote Location Through A Webpage

2002-09-02 Thread Morse, Richard E.

Have you looked at the CGI.pm docs?

There are two parts to uploading docs via a webpage.  First, you have supply the
correct type of form on the webpage:

form method=post action=url/to/your/script enctype=multipart/form-data
input type=file name=myfile size=40
input type=submit value=upload
/form

is probably the bare minimum that you need.

Then, the script needs to properly parse the sent file.  Below is a loop that I
use in a script I have.  You should probably customize this to fit your
needs

  foreach my $file_type ('resp', 'family', 'cancer') {
# first, we need to grab the uploaded file's file handle, and check
# to see if there was an error during the send
my $fh = $q-upload($file_type);
if (!$fh  $q-cgi_error) {
  die(File upload error for $file_type:  . $q-cgi_error);
} elsif (!$fh) {
  die(No file specified for $file_type);
}

# here, we make sure that the file name contains the $file_type string.
This
# is used as a simple stop-gap to try and make sure that the correct
file is being
# passed for each parameter...
my $in_file_name = $q-param($file_type);
$in_file_name =~ s/\\/\//g;
{
  # the uploaded file's name contains the entire remote path
  my $fname = pop @{[ split(/, $in_file_name) ]};
  unless ($fname =~ m/$file_type/i) {
die(File uploaded for file type '$file_type' was named
'$fname', which doesn't contain the string '$file_type');
  }
}

# at this point, we have a good file that has been uploaded
open(my $out, , $save_dir . $file_type . '.dat') or die(Could not
create '$save_dir$file_type.dat': $!);

# just in case, although on unix boxes it shouldn't matter, we make sure
that
# we have raw character discipline
binmode($fh, :raw);
binmode($out, :raw);

# now, read the data using buffered IO (rather than sysread)
my $bytesread;
my $buffer;
while($bytesread = read($fh, $buffer, 1024)) {
  print $out $buffer;
}

# read returns undef on an error.  I don't know where this error gets
stored...
if (!defined($bytesread)) {
  die(An error occured while trying to write '$save_dir$file_type.dat':
$!);
}

# now close the files...
close($fh);
close($out);
  }

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



Installing PDF-API2?

2002-08-26 Thread Morse, Richard E.

Hi!  I'm trying to install the PDF-API2 ppm (btw: will that be updated
soon?), but I get an error: no suitable installation target found for
package PDF-API2.  What does this mean?

Thanks,
Ricky

-
Richard MorseSystem Administrator 
MGH Biostatistics Center  50 Staniford St. Rm 560
[EMAIL PROTECTED] 617/724-9830
___
Perl-Win32-Users mailing list
[EMAIL PROTECTED]
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs



RE: FILEHANDLE Problem

2002-07-15 Thread Morse, Richard E.

steve silvers [mailto:[EMAIL PROTECTED]] wrote:

 open(FILE, d:\path_to\textfiles\test.txt) or die Can't open $!;

So, um, you do know that \t is a tab in double-quoted text?

Try:
open(my $file, d:/path/to/your/test.txt) or die(Can't open: $!)

or:
open(my $file, d:\\path\\to\\your\\text.txt) or die(Can't open:
$!)

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



RE: if statement does not work, help please

2002-07-12 Thread Morse, Richard E.

Malcolm Debono [mailto:[EMAIL PROTECTED]] wrote:

 #!C:\Perl\bin\perl
 
 use CGI; # Use the CGI.pm module
 use strict;
 use CGI qw/:standard/;
 
 my $q = new CGI;
 my $url = param('url');
 my ($html,$meta,$lockit,$lines,$path_to_input_file,@metas,@lines);
 
 use LWP::Simple;
 my $pagecontent  = get ($url);
 
 # Get rid of all the \r and \n
 $pagecontent =~ s/[\r\n]+//g;
 @metas = $pagecontent =~ /(meta[^]+)/gi;
 
 #THIS OPENS A FILE TO WRITE THE HTML TO
 open (RECORD, read.dat) || die Error - cannot open read.dat: $!;
  if($lockit){flock(RECORD,2);}
 foreach $meta(@metas)
 {
  chomp($meta);
 if ($meta ne )
 print  RECORD $meta\n;
 }else{
  no_tags;
 }
 }
  if($lockit){flock(RECORD,8);}
  close (RECORD);

You're missing the beginning of the first block in you if-statement.  Try
running with perl -w, use strict; use warnings; and see what you get...

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



RE: Reply: Win32 Sound Module install ???

2002-06-26 Thread Morse, Richard E.

Michael D. Smith [mailto:[EMAIL PROTECTED]] wrote:
 I saw this link:
 
 http://www.activestate.com/PPMPackages/zips/5xx-builds-only/?_x=1
 
 but when I click on a zip file on that page, I get the zip 
 file, on-screen, 
 in text (mostly garbage actually), instead of the expected 
 download dialog 
 box. I assumed that was happening because I didn't have the 
 right build. 
 The tile does say, 5xx-builds-only, and I have build 633.

Actually, this is because the mime-type of the file isn't set correctly by the
server, so that the browser doesn't know that it's a .zip file (whatever the
mime-type for that is), so it defaults to text/plain...

 I right clicked, used download target as, and managed to 
 get the zipped 
 file from the 5xx builds only page downloaded into my 
 files, but I'm 
 waiting for comments again before I proceed. It just does not 
 feel right.

I can't comment on whether this will work with your AS build, but the file you
downloaded is the file that you requested from the server...

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



RE: Send email in ActivePerl using SMTP

2002-06-06 Thread Morse, Richard E.

$Bill Luebkert [mailto:[EMAIL PROTECTED]] wrote:
 [EMAIL PROTECTED] wrote:
 
  I tried the following to use SMTP to send email:

 $smtp = Net::SMTP - new (luxn.com);
 $smtp - mail($optFrom);
  
  Can't call method mail on an undefined value at 
  mailtest.pl line 8
  
  line 8 is:$smtp - mail($optFrom);

Sorry to pull this through $Bill -- I didn't get the original...

According to the error messages, $smtp isn't properly being defined.  I have no
idea whether this affects things or not, but what happens if you get rid of the
extra whitespace (ie, write $smtp = Net::SMPT-new('luxn.com'))?

Also, read the docs for Net::SMTP -- there may be a way to get the error message
reported when it can't create the original $smtp...

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



RE: operator question

2002-06-05 Thread Morse, Richard E.

Charles Oppenheimer [mailto:[EMAIL PROTECTED]] wrote:

 Hi folks.  I have a question... I wanted to create a
 sub procedure that takes an operator as an argument,
 like so:
 
 compare(1,,2);
 
 sub compare {
   my ($value1,$operator,$value2) = @_;
 
   if ($value1 $operator $value2) {
   print statement is true!!\n;
   }
 
 }

I've never actually done this, so I'm somewhat guessing here, but you might be
looking for something like:

sub compare {
my ($a, $o, $b) = @_;
if (eval($a $o $b)) {
print True!\n;
}
}

Note that this is completely untested -- you may need to work a bit harder to
get the eval block to return the value correctly...

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



RE: Executable program from perl script

2002-05-07 Thread Morse, Richard E.

If you are certain that the acld.exe accepts input from stdin (as opposed to
actually reading directly from the console, or creating a GUI input stream,
etc), you might try looking at IPC::Open2.  This will allow you to read and
write from and to the stdout and stdin of the program.  Make sure you read the
docs, because there are some issues with this module that could cause deadlock.
There may also be an expect module on CPAN (at least, IPC::Open2 references
it)...

HTH,
Ricky

 -Original Message-
 From: Sushil Kumar Gupta [mailto:[EMAIL PROTECTED]]
 Sent: Tuesday 07 May 2002 6:17 AM
 To: '$Bill Luebkert'
 Cc: '[EMAIL PROTECTED]'
 Subject: RE: Executable program from perl script
 
 
 Thanks for suggesting this 
 but seems this is not working .. i tried 
 it still send start to the STDOUT and not to the application. 
 Actually i want sort of what EXPECT can do , in PERL
 
 Regards,
 Sushil
 
 -Original Message-
 From: $Bill Luebkert [mailto:[EMAIL PROTECTED]]
 Sent: Tuesday, May 07, 2002 3:23 AM
 To: Sushil Kumar Gupta
 Cc: '[EMAIL PROTECTED]'
 Subject: Re: Executable program from perl script
 
 
 Sushil Kumar Gupta wrote:
 
  No it's not the command line argument that we can provide to the
  application. 
  Okay let me give some details about the application.
  
  when i start acld.exe it starts one seperate GUI and then 
 wait for commands.
  when i say start on the command prompt, it will do something
  when i say stop on the command prompt, it will do something
  when i say version on the command prompt, it will give me 
 the version of
  the application.
  etc etc etc
  
  i hope now my intent is clear.
 
 
 Then you probably want a pipe:
 
 
   open PIPE | /path/acld.exe or die ...
 
   print PIPE start\n;
 
 
 Or similar.
 
 -- 
,-/-  __  _  _ $Bill Luebkert   ICQ=14439852
   (_/   /  )// //   DBE Collectibles   Mailto:[EMAIL PROTECTED]
/ ) /--  o // //  http://dbecoll.tripod.com/ (Free 
 site for Perl)
 -/-' /___/__/_/_ Castle of Medieval Myth  Magic 
 http://www.todbe.com/
 
___
Perl-Win32-Users mailing list
[EMAIL PROTECTED]
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs



RE: Using DBI::ODBC to get primary keys?

2002-05-07 Thread Morse, Richard E.

Simon Oliver [mailto:[EMAIL PROTECTED]] wrote:
 First of all, DBD::ODBC now has direct $dbh-primary_key() 
 support so use
 that instead.

Which version has this?  I'm running DBD::ODBC v0.28 -- I don't see a more
recent PPM in the ActiveState repositories, and I don't have the MSVC++ compiler
to be able to compile my own module...
 
 This probably means that the ODBC driver does not support the function
 (GetPrimaryKeys).

As you noted, a trace reveals that this function isn't supported.  If the driver
doesn't support SQLPrimaryKeys, would the DBD::ODBC driver's -primary_key that
you noted above work?

Running the script you provided (for which much thanks!), I note that I don't
have SQLPrimaryKeys, SQLForeignKeys, and a number of other things.  However, I
do have SQLSpecialColumns -- can I get primary key data from this call?

(The DB in question is an Access97 database, and I don't actually have Access97
on the computer, nor, for permissions reasons, can I convert it to Access2K)

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



RE: Simple Menu

2002-05-07 Thread Morse, Richard E.

Here's how I would write this -- I don't know if it will work, but you might try
it...

#!perl
use strict;
use warnings;

my $done = 0;
while(!done) {
display_menu();
print == ;
my $choice = ;
chomp $choice;
if ($choice eq '00') { $done++; }
elsif ($choice eq '01') { ; } # do stuff in these brackets
# and so on...
elsif ($choice eq '31') {
print Copying files...\n;
my $source = c:/webstaff3/aliases/;
my $dest = c:/last weeks updates/aliases/;
my $cmd = xcopy \$source\ \$dest\ /Y;
print (running '$cmd')\n;
my $result = system($cmd);  # yes, this isn't quite the same
# as the output from
backticks...
print returned: $result\n;
} else {
print Invalid choice: please select again\n;
}
}

__END__

Actually, though, I would probably bypass the system commands anyways.  If you
know that there are no subdirectories that you are copying, try this (adding in
error checking as needed):

my $source_dir_text = c:/webstaff3/aliases/;
my $dest_dir_text = c:/last weeks updates/aliases/;
opendir(my $source_dir, c:/webstaff3/aliases/);
my @files = grep { -f $source_dir_text$_ } readdir $source_dir;
closedir($source_dir);
foreach my $file (@files) {
rename $source_dir_text$file $dest_dir_text$file;
}

Or, if there are subdirectories, I think there are a bunch of modules on CPAN
that will do what you need...

HTH,
Ricky


-Original Message-
From: Mike Reilley [mailto:[EMAIL PROTECTED]]
Sent: Tuesday 07 May 2002 10:40 AM
To: $Bill Luebkert; Carl Jolley; Toby Stuart;
[EMAIL PROTECTED]
Subject: Simple Menu


Sorry I meant to include the fact that I am running
ActivePerl  5.6.0 Build 613
on Windows 98 SE

CODE:

$| = 1; # UNBUFFER THE CONSOLE
while () { 
scrprt();
my $result = STDIN;
chomp $result;
exit 0 if $result == 0;
if ($result == 31) {  
print Copying Files\n\n;
#$cmd = xcopy32.exe ;
$cmd = xcopy ;
$cmd = $cmd.\c:\\webstaff3\\aliases\ ;
$cmd = $cmd.\c:\\last weeks updates\\aliases\ /y  ;
print CMD == $cmd\n;
$output = `$cmd`;
print output == $output\n;
   }

 }


sub scrprt {
#system $ENV{COMSPEC} /C CLS\n;
print \n;
print \n;
print  00 .. Terminate Menu \n;
#print \n;
#print \n;
print  31 .. Copy Web files to Last Weeks\n;
print  \n;
print  \n;
print  ;
}


It has recently  come to my attention that some people consider my use of
uppercase letters in email as obnoxious, I would like to apologize but in light
of having lost 6 fingers and the use of a seventh that leaves me with just a
thumb and pinky on my left hand and only a thumb on my right hand. Therefore
nothing is meant or implied by my haphazard capitalization.


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



RE: fastest way to load text file data into a scalar variable

2002-04-13 Thread Morse, Richard E.

my $data;
{
open(my $file, , $file_name) or die (can't open $file_name: $!);
local $/ = undef;
$data = $file;
close($file);
}

That's one way...

HTH,
Ricky

 -Original Message-
 From: Pankaj Agarwal [mailto:[EMAIL PROTECTED]]
 Sent: Saturday 13 April 2002 7:35 PM
 To: perl-win32-users
 Subject: fastest way to load text file data into a scalar variable
 
 
 Hi All,
 
 while () print $_ ;  
 is fast but still reads data line by line any other
 way to load the whole file data in just one shot.
 
 Thanks
 Pankaj
 
 
 __
 Do You Yahoo!?
 Yahoo! Tax Center - online filing with TurboTax
 http://taxes.yahoo.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: Write to a file issue

2002-04-05 Thread Morse, Richard E.

Based on the program that you sent, and what I understand of what you're asking,
you need to read in the entire file, parse it, internally represent it, and then
write it back out...

HTH,
Ricky

 -Original Message-
 From: Jorge Goncalvez [mailto:[EMAIL PROTECTED]]
 Sent: Friday 05 April 2002 11:08 AM
 To: Morse, Richard E.
 Subject: RE: Write to a file issue
 
 
 I tried but it didn't work
 In fact I wanted to write only one time for exemple test 
 but with my code it 
 adds test always i run my program.
 Thanks if you could help me.
 I would be very grateful.
 
___
Perl-Win32-Users mailing list
[EMAIL PROTECTED]
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs



RE: Perl's exec and system functions

2002-04-02 Thread Morse, Richard E.

Try this:

my @results = `ping $ip`;

HTH,
Ricky




-Original Message-
From: nicole [mailto:[EMAIL PROTECTED]]
Sent: Tuesday 02 April 2002 10:28 AM
To: [EMAIL PROTECTED]
Subject: Perl's exec and system functions




Hello. I am new to the mailing list. I come from a PHP background with
little Perl experience.
My question pertains to the exec and system functions.

In PHP, I am familiar with these 2 functions. I am trying to use them the same
way in Perl. However, I am not sure if I am using them correctly.

I want to be able to execute the ping command to verify a web server is
reachable.

In PHP, I do this:

snip

exec( ping $ip, $results );  ## where $results is an array of each line of
results returned from the ping

## Then I can loop through $results and print out each line.

/snip

Now, in Perl, I want to do the same thing. Since I don't have access to PHP on
the particular server that I want to use to do the pinging, I have to use Perl
(which is available).

Here is my interpretation of the above code in Perl:

snip

exec( ping $ip );

/snip

*Note, in both code examples, $ip will be passed or set somewhere. So pretend
$ip is set to some IP or domain, such as www.domain.com. In this case, however,
I will be pinging an actual IP.

Now, I read that exec doesn't return results and never returns. So, it suggests
using system. So, how can I implement this in Perl so that I get the same
results as with my version in PHP? I have gone through the docs on these two
functions and I can't figure out if I even can get back the results. I don't
want to actually have them printed out. I want to search through the results to
verify if the ping was successful or if I got back an unknown host or
something other type of message.

Any ideas? Any suggestions? Any better way to do this? Any better documentation
on these two functions? I am still searching and thought I'd try here.

Thanks in advance!

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



RE: MSAccess file format question...

2002-02-28 Thread Morse, Richard E.

H... however, I don't need to just create a blank database -- the idea
is to be able to have a cgi extract data from an Oracle database and create
an Access database with the data in it, and then return that via HTTP
download...  In order to do that, I need to be able to write out to the
Access file format...

Thanks for any help,
Ricky

-Original Message-
From: Mike DeWolfe [mailto:[EMAIL PROTECTED]]
Sent: Thursday 28 February 2002 11:22 AM
To: [EMAIL PROTECTED]
Subject: Re: MSAccess file format question...


What I've done in the past is make a blank database and then copy that file
and rename it as required. As it's only a file (and a small one when it's
empty), that makes it easy to throw around.

- Mike DeWolfe

- Original Message -
From: Morse, Richard E. [EMAIL PROTECTED]
To: [EMAIL PROTECTED]
Sent: Thursday, February 28, 2002 7:42 AM
Subject: MSAccess file format question...


 Hi!  For a particular application (actually, a CGI) I am writing, I want
to
 be able to create a .mdb (access 2000 version) file.  However, if
possible,
 I want to avoid actually opening access.  Is there some reference that
would
 tell me what the Access2000 file format is?  Or, better yet, is there a
 module somewhere that will do this?

 Thanks,
 Ricky

 -
 Richard MorseSystem Administrator
 MGH Biostatistics Center  50 Staniford St. Rm 560
 [EMAIL PROTECTED] 617/724-9830
 ___
 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: pack

2002-02-20 Thread Morse, Richard E.

Hah!  I know what the problem is!

ASCII character 10 happens to be either \n -- so when you print this number to
the file, you get a newline character for one of the bytes, so your
while(READ) loop finds three lines in the file instead of two.

I think that in order to read this number back out of the file, you'll have to
use sysread, instead of READ...

HTH,
Ricky

-Original Message-
From: Sisyphus [mailto:[EMAIL PROTECTED]]
Sent: Wednesday 20 February 2002 9:11 AM
To: [EMAIL PROTECTED]
Subject: pack 


Hi,

Ok - so I'm running the code below and it's working as I want - unless
either of the 2 values being written to the file is 10. (ie unless $num = 8
or 10).

If the value is 10, then I get a couple of warnings about 'use of
uninitialised value'.
'10' is the only value I've found that exhibits this disgraceful behaviour.

U .. I'm a little hard pressed to make sense of that 
something to do with the newline characters or the chomping perhaps ?

use warnings;
my $file = try;
my $num = 2;
open (WRITEB, $file)
or die Can't open WRITEB: $!;
binmode WRITEB;
print WRITEB pack(I,$num,), \n;
print WRITEB pack(I,$num + 2), \n;
close (WRITEB)
 or die Can't close WRITEB: $!;

open (READ, $file)
or die Can't open READ: $!;
binmode READ;
while (READ) {
chomp;
$ret = unpack(I, $_);
print $ret, \n;
}
close (READ)
 or die Can't close READ: $!;

Cheers,
Rob


___
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: Hash Questions

2002-02-04 Thread Morse, Richard E.

I imagine that that was meant to be qw...

HTH,
Ricky

-Original Message-
From: Jeffrey [mailto:[EMAIL PROTECTED]]
Sent: Monday 04 February 2002 2:45 PM
To: Carl Jolley; [EMAIL PROTECTED]
Subject: Re: Hash Questions



--- Carl Jolley [EMAIL PROTECTED] wrote:
 Try this:
 
 for $key (wq(first_name last_name address
 transportation)) {
   print $reqfields{$key\n;
 }

Closing } on $key in the print statement aside, what
exactly does this do?  I can't find reference to wq anywhere.

=

Jeffrey Hottle
nkuvu at yahoo dot com

__
Do You Yahoo!?
Great stuff seeking new owners in Yahoo! Auctions! 
http://auctions.yahoo.com
___
Perl-Win32-Users mailing list
[EMAIL PROTECTED]
To unsubscribe:
http://listserv.ActiveState.com/mailman/listinfo/perl-win32-users
___
Perl-Win32-Users mailing list
[EMAIL PROTECTED]
To unsubscribe: http://listserv.ActiveState.com/mailman/listinfo/perl-win32-users



RE: How to sort Array of Hashes

2002-01-29 Thread Morse, Richard E.

Probably something like

sort { $::a-{'SIZE'} = $::b-{'SIZE'} } @A_of_H;

I haven't tested this, though, so I could be wrong.

Ricky

-Original Message-
From: John Draper [mailto:[EMAIL PROTECTED]]
Sent: Tuesday 29 January 2002 9:23 AM
To: [EMAIL PROTECTED]
Subject: Q: How to sort Array of Hashes


Hi,

I would like to know how to sort an array of hashes based on one of the
values from one of it's keys.

Specifially, I have a structure like this:

my @A_of_H;
my $i = 0;

some looping mechanism starts here which populates $file, $size and $date:
   $A_of_H[$i]{'FILE'} = $file;
   $A_of_H[$i]{'SIZE'} = $size;;
   $A_of_H[$i]{'DATE'} = $date;
   $i++;
end of loop..

I would like to sort @A_of_H based on 'SIZE', i.e., A_of_H[$i]{'SIZE'} from
largest to smallest.

How does one do this in Perl. I know how to do it for 'pure' arrays or
hashes, but not an array of hashes. Any help would be appreciated.

Thanks,

John

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



RE: Q: How to sort Array of Hashes

2002-01-29 Thread Morse, Richard E.

Okay, I'll bite.

Orcish manouver?

Ricky

-Original Message-
From: Thomas R Wyant_III [mailto:[EMAIL PROTECTED]]
Sent: Tuesday 29 January 2002 2:07 PM
To: [EMAIL PROTECTED]
Subject: RE: Q: How to sort Array of Hashes



[EMAIL PROTECTED] wrote



snip!

 Do you think we can impose upon our Original Poster to run some
 benchmarking on his live data?

Honestly, no. We could try, but since we're just mailing addresses to each
other, I doubt we have anything to impose _with_. But if he wishes to do it
and publish, I for one would welcome the information.

My personal approach to just about any code is to do it the dumb way first,
and tweak it if it isn't up to snuff. There are people who, no matter how
many cycles they have at their disposal, grudge every one. But I figure
that these days wetware cycles are generally more expensive than hardware
cycles. Some benchmark data would tell us where spending a few wetware
cycles is worthwhile.

I have yet to use the Schwartzian transform, I merely pulled it in for
completeness in my answer. The REALLY short answer to the Original Poster's
question was RTFM. But I wanted to couch this in the more humane terms of
Here's how you get started, and here's where you go for more information,
and the Schwartzian transform was my hook for the second half.

If only I could have found a way to bring in the Orcish maneuver, which I
_do_ use, and which has a _much_ cooler name.

Tom Wyant

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



RE: Another Question - hashes please ..

2002-01-21 Thread Morse, Richard E.



In your "update", you are actually resetting the entire value of 
$the_data[1] to point to a new hash reference, which has only y 
defined.

Try this instead:

$the_data[1] = { x = 'A', y = 'B' };
print $the_data[1]-{x}, "\n";
$the_data[1]-{y} = 'C';
print $the_data[1]-{y}, "\n";

HTH,
Ricky

  -Original Message-From: Andrew Wax 
  [mailto:[EMAIL PROTECTED]]Sent: Monday 21 January 2002 4:05 
  PMTo: [EMAIL PROTECTED]Subject: 
  Another Question - hashes please ..
  Good Afternoon - I have a hash that I define 
  as:
  
  $the_data[1] ={ 
  x= "A",y = "B",};print 
  $the_data[1] - {x};
  
  works and prints A
  
  
  if I want to update the value of 'y' to C 
  like:
  $the_data[1] 
  ={y = "C"};print 
  $the_data[1] - {x};
  
  this does not work because it prints out a 
  blank. Obviously I am not updating my value of part of the hash. 
  Is there an easy way to just update the value of $the_data - {y} to be C 
  without having to remember $the_data - {x}
  
  Thank you for your help -everyone has been very 
  helpful with these basic but annoying 'bumps'
  
  Andrew
  


RE: Format number

2002-01-10 Thread Morse, Richard E.

In the camel book they discuss this -- so it should be somewhere in the
documentation?

Ricky

-Original Message-
From: Cristian Carvajal [mailto:[EMAIL PROTECTED]]
Sent: Thursday 10 January 2002 1:57 PM
To: [EMAIL PROTECTED]
Subject: Format number


Desire to take a variable to scale and to give format him of numerico
 example 3145 == 3.145,00

and used sprintf but does not give this format anybody me knows since I can
do this


thanks

___
Perl-Win32-Users mailing list
[EMAIL PROTECTED]
http://listserv.ActiveState.com/mailman/listinfo/perl-win32-users
___
Perl-Win32-Users mailing list
[EMAIL PROTECTED]
http://listserv.ActiveState.com/mailman/listinfo/perl-win32-users



RE: Show perl source on web page

2002-01-07 Thread Morse, Richard E.

Sorry for the lack of security -- I was basing my file selection mechanism
on the one that the original poster had been using.

I agree with you that it is rather unsafe.  In fact, I would create a
hard-coded (or read from a secure location on the local FS) list of all
allowed files, and if the requested one doesn't match an item in the list, I
would log the request and email the scriptadmin.

Ricky

-Original Message-
From: Tillman, James [mailto:[EMAIL PROTECTED]]
Sent: Monday 07 January 2002 11:20 AM
To: Morse, Richard E.; 'Robert Davis';
[EMAIL PROTECTED]
Subject: RE: Show perl source on web page


 A slightly more trivial example would be this:
 
 #!/usr/bin/perl -w
 use strict;
 
 print Content-type: text/plain\n\n;
 my $fn = $ENV{'QUERY_STRING'};
 
 my $opened = 1;
 
 open(my $in, , $fn) || ($opened = 0);
 
 if ($opened) {
   while ($in) {
   print $_;
   }
 } else {
   print Could not open requested script: $!\n;
 }
 
 __END__

I assume by trivial, you mean hack me, PLEEZ!  ;-)

Please never, ever, on any server install a script that takes a full path to
a file name and prints the source.  It makes perl cgi coders look very, very
bad.  Please don't do that.  Define a document root as a constant in your
CGI code, accept only the filename (preferably only the basename, as you can
append the .pl yourself) as the parameter, check for .. and other hacker
tricks, and run in taint mode.

jpt
___
Perl-Win32-Users mailing list
[EMAIL PROTECTED]
http://listserv.ActiveState.com/mailman/listinfo/perl-win32-users
___
Perl-Win32-Users mailing list
[EMAIL PROTECTED]
http://listserv.ActiveState.com/mailman/listinfo/perl-win32-users



RE: OLE and Outlook

2001-12-18 Thread Morse, Richard E.

My guess is that you are getting epoch dates -- that is, offset in seconds from
the computer's epoch.  You can test this by getting the date, then printing the
value of 
scalar(localtime($date_val))
which will attempt to figure out the date from the epoch.  Note that Access may
use a different epoch than the computer (I don't see why it should, but just in
case...), in which case you may need to do some arithmitic on the initial value
to get it to the computer's epoch...

HTH,
Ricky

-Original Message-
From: Wells, Doug [mailto:[EMAIL PROTECTED]]
Sent: Tuesday 18 December 2001 3:04 PM
To: '[EMAIL PROTECTED]'
Subject: OLE and Outlook


Hi-
I am using OLE to access information in my Contacts folder in my Outlook PST
file. All is fine, but I need the last modification information and I am having
trouble with it. When I access that data, it is a long integer (possibly a
Julian date?). I am not sure how to interpret it into a useable date. Can anyone
help? Here is my code:

use strict; 
use Win32::OLE; 
use Win32::OLE::Const 'Microsoft Outlook'; 
 
my $Outlook = Win32::OLE-new('Outlook.Application', 'Quit');
my $ol = Win32::OLE::Const-Load($Outlook);

my $namespace = $Outlook-GetNamespace(MAPI);
my $Folder = $namespace-GetDefaultFolder(olFolderContacts); 

my $contacts = $Folder-{Items}; 
my $ncon = $contacts-{Count}; 
  print number of contacts - $ncon\n\n;

my $con; 
for my $ii (1 .. $ncon) { 
  $con = $contacts-Item($ii); 
  print $ii - $con-{FullName}\n;
  print Phone is $con-{HomeTelephoneNumber}\n;
  print Last Modified ${$con-{LastModificationTime}}\n;
}

Thanks
Doug
___
Perl-Win32-Users mailing list
[EMAIL PROTECTED]
http://listserv.ActiveState.com/mailman/listinfo/perl-win32-users
___
Perl-Win32-Users mailing list
[EMAIL PROTECTED]
http://listserv.ActiveState.com/mailman/listinfo/perl-win32-users



RE: global setting wrecking setuid CGI script

2001-12-09 Thread Morse, Richard E.

Hi!  I'm not sure why adding the 1; makes it work (that really is only needed at
the end of a package definition to return a true value).  However, I think I can
tell you another way to solve the problem, and what the problem actually is

It looks to me that the script is being run with taint checking on.  If your
script is suid'd, it will always do this.  Taint checking makes sure that you
can't accidentally pass bad data off to the OS, possibly causing it to crash.
What you need to do is make sure that you detaint the $country parameter.  Read
up in the Camel book or in perldoc about taint checking to see how you want to
do this...

HTH,
Ricky

-Original Message-
From: Bennett Haselton [mailto:[EMAIL PROTECTED]]
Sent: Friday 07 December 2001 7:42 AM
To: [EMAIL PROTECTED]
Subject: global setting wrecking setuid CGI script


(Sorry if this is more of a Perl for UNIX question.)

I get the following error:
Insecure dependency in piped open while running setuid at
/usr/lib/perl5/5.00503/i386-linux/IO/File.pm line 164.

whenever I try loading the URL
http://[hostname]/test-signup.cgi?country=Wales

whose contents are the perl script at the bottom of this message, with the
setuid bit on the script set.  (Don't worry, I am not asking anyone to debug
code for me :)  This is a general question.)

What I can't figure out is that if I add the line:

1;

right after the line RunQuery($querystring);, then the script does NOT give me
the error!  (The line 0; also works.)

So, this anomaly is apparently due to the exactly the kind of programming
language quirk that I absolutely hate: global settings that can be changed
invisibly by seemingly innocuous lines like 1; which apparently don't do
anything.

What kind of mysterious flag is set by the RunQuery() function call that causes
the script not to work (if I comment out that function, the script runs fine) --
and how does the statement 1; cause that flag to be set back to normal?

I thought at first that maybe tainted variables had to be untainted before
they could be used in a MySQL query executed from a setuid perl script -- but if
you put the line 'print STDERR $querystring\n;' at the end of the function
body of RunQuery() below, it does get printed to the error log -- suggesting
that the actual execution of the MySQL query does get run, and isn't the
problem.

Also, the script runs fine if you comment out the lines that send mail.

-Bennett

Here is the script -- it won't work on other systems though since I import
tlglobal:



#!/usr/local/bin/perl

# lines that must appear at the top of all code files
use strict;
use lib '/home/bhaselto/web/html/';
use tlglobal;

use CGI;
use IO::File;
use DBI;

my $q = new CGI;

my $country = $q-param('country');

my $querystring = select \$country\;;

RunQuery($querystring);

my $mh = IO::File-new(|$mailprog bennett\@tracerlock.com);
print $mh From: nothing\@tracerlock.com\n;
print $mh To: bennett\@tracerlock.com\n;
print $mh Subject: nothing\n;
print $mh \n;
close($mh);

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

sub RunQuery
{
my($querystring) = @_;

my $dbh = DBI-connect(DBI:mysql:host=localhost,
'guest', # username
'', # password
{'RaiseError' = 1 }
);
my $sth = $dbh-prepare($querystring);
$sth-execute;
$sth-finish();
$dbh-disconnect();
}

___
Perl-Win32-Users mailing list
[EMAIL PROTECTED]
http://listserv.ActiveState.com/mailman/listinfo/perl-win32-users
___
Perl-Win32-Users mailing list
[EMAIL PROTECTED]
http://listserv.ActiveState.com/mailman/listinfo/perl-win32-users



RE: [Fwd: Re: null pointer OLE]

2001-11-29 Thread Morse, Richard E.

Ummm... have you tried to pass a 0 in to the function?

Ricky

 -Original Message-
 From: Doug Claar [SMTP:[EMAIL PROTECTED]]
 Sent: Thursday, November 29, 2001 5:08 PM
 To:   [EMAIL PROTECTED]
 Subject:  [Fwd: Re: null pointer  OLE]
 
 Thanks for the suggestions! Still no joy, though...
 
 If I use undef, I get:
 
my $result=$control-Play(phEventClose, undef, phDialogSilent);
 
Win32::OLE(0.1401) error 0x8002000f: Parameter not optional
   in METHOD/PROPERTYGET Play
 
 Pack gives a different error:
 
my $nothing=pack h8, ;
my $result=$control-Play(phEventClose, $nothing, phDialogSilent);
 
Win32::OLE(0.1401) error 0x80020005: Type mismatch
   in METHOD/PROPERTYGET Play argument 2

 
 my \$nothing is a syntax error, but trying to do something in the spirit
 of that gets me back to Parameter not optional:
 
my $nothing=undef;
my $result=$control-Play(phEventClose, \$nothing, phDialogSilent);
 
Win32::OLE(0.1401) error 0x8002000f: Parameter not optional
   in METHOD/PROPERTYGET Play
 
 I don't know if it is OLE telling me that the parameter is not optional,
 or if OLE is just relaying a message from the Play function...
 
 ==Doug Claar
 ___
 Perl-Win32-Users mailing list
 [EMAIL PROTECTED]
 http://listserv.ActiveState.com/mailman/listinfo/perl-win32-users
___
Perl-Win32-Users mailing list
[EMAIL PROTECTED]
http://listserv.ActiveState.com/mailman/listinfo/perl-win32-users



RE: calling an Internet url

2001-11-27 Thread Morse, Richard E.

Look into the lwp modules.  There is some sample code with them that should
help...

HTH,
Ricky

 -Original Message-
 From: Rafala, Michael [SMTP:[EMAIL PROTECTED]]
 Sent: Tuesday, November 27, 2001 4:06 PM
 To:   [EMAIL PROTECTED]
 Subject:  calling an Internet url
 
 I've got an http url that returns an xml file (that is, if I type the url in
 the address line of a web browser, I get xml-tagged data).
 
 Can I make this call from a perl script and then store the xml directly into
 a scalar.
 
 I've looked at http::request and others, but I just don't know if I'm
 barking up the wrong tree.
 
 mike rafala
 rafalam at cadmus com
 ___
 Perl-Win32-Users mailing list
 [EMAIL PROTECTED]
 http://listserv.ActiveState.com/mailman/listinfo/perl-win32-users
___
Perl-Win32-Users mailing list
[EMAIL PROTECTED]
http://listserv.ActiveState.com/mailman/listinfo/perl-win32-users



RE: using current date to make a filename

2001-11-15 Thread Morse, Richard E.

Actually, the format can vary from platform to platform, and might also
depend on the user's regional settings.

So, instead of trying to interpret that, use the array output.

something like:

my $trans_hash = ( 1='Jan', 2='Feb', 3='Mar', ...);
my ($month, $day) = (localtime(time))[4,3];
$month++;
my $filename = $day . $trans_hash{$month};

For more info, and to see why I did what I did, look at the perldocs for the
'localtime' function...

HTH,
Ricky

 -Original Message-
 From: Raj Subedi [SMTP:[EMAIL PROTECTED]]
 Sent: Thursday, November 15, 2001 11:24 AM
 To:   [EMAIL PROTECTED]
 Subject:  using current date to make a filename 
 
 Hi,
  I would like to create a new file with a name that
 combines third and second column of scalar localtime.
 For e.g.
 printf scalar localtime; produces
 
 Thu Nov 15 10:26:15 2001
 
 I actually want to create a file named 15Nov in
 differnt directory.
 
 Any help will be highly appreciated.
 
 Thanx
 
 Raj
  
 
 
 __
 Do You Yahoo!?
 Find the one for you at Yahoo! Personals
 http://personals.yahoo.com
 ___
 Perl-Win32-Users mailing list
 [EMAIL PROTECTED]
 http://listserv.ActiveState.com/mailman/listinfo/perl-win32-users
___
Perl-Win32-Users mailing list
[EMAIL PROTECTED]
http://listserv.ActiveState.com/mailman/listinfo/perl-win32-users



RE: Question regarding printing from IE via OLE (followup to previous question?)

2001-10-10 Thread Morse, Richard E

Hi!  Thanks for the suggestion, but I still don't get prompted to print, nor
does it print on its own -- although I no longer get the errors

I'm running this on Win95, with IE 5.5 -- does that require different constants?

Thanks,
Ricky

 -Original Message-
 From: Sisyphus [SMTP:[EMAIL PROTECTED]]
 Sent: Wednesday, October 10, 2001 4:55 AM
 To:   [EMAIL PROTECTED]
 Subject:  Re: Question regarding printing from IE via OLE (followup to
 previous question?)
 
 
 - Original Message -
 From: Morse, Richard E [EMAIL PROTECTED]
 
  $ieApp = Win32::OLE-new(
   'InternetExplorer.Application',
   sub {$_[0]-Quit;} );
  $ieApp-Navigate('http://www.activestate.com/');
 sleep 10; # eliminates Trying to revoke error, for me.
  $ieApp-ExecWB(6, 2);
 
 
 That change may be all that is required. I don't have a printer attached to
 this machine, but when I run the script with the above change I get a popup
 asking me whether I want to fax or print - and telling me to install the
 printer if I wish to print.
 
 Hope there's something helpful in that.
 
 Cheers,
 Rob
 
 ___
 Perl-Win32-Users mailing list
 [EMAIL PROTECTED]
 http://listserv.ActiveState.com/mailman/listinfo/perl-win32-users
___
Perl-Win32-Users mailing list
[EMAIL PROTECTED]
http://listserv.ActiveState.com/mailman/listinfo/perl-win32-users