checking if a file exists

2001-11-22 Thread Greg . Froese

How would I check if a certain file exists in a certain directory?

I'm already using File::Find to process a bunch of mp3's, and before I 
move/copy them to a different folder, I want to check if the file already 
exists.

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




directories

2001-11-21 Thread Greg . Froese

what is the best way to check for the existence of a directory? 
(windows/Linux)

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




RE: Off-Topic (200%) - Where are you from?

2001-11-09 Thread Greg . Froese

Winnipeg, MB, Canada

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




Re: Faking form variables

2001-10-26 Thread Greg . Froese

Curtis,

What is the syntax for passing these values through the url?
Greg





Curtis Poe [EMAIL PROTECTED]
10/25/2001 01:44 PM
Please respond to poec

 
To: [EMAIL PROTECTED], [EMAIL PROTECTED]
cc: 
Subject:Re: Faking form variables


--- [EMAIL PROTECTED] wrote:
 I'm using the following snippet of code to put all form data passed into 
a 
 hash table.
 
 $form_data_size = $ENV{'CONTENT_LENGTH'};
 read (STDIN, $form_data, $form_data_size);
 @info_returned = split (//,$form_data);
 
 foreach $keyvalue (@info_returned)
 {
 ($key, $value) = split(/=/, $keyvalue);
 $value =~ tr/+/ /;
 $value =~ s/%([\dA-Fa-f][\dA-Fa-f])/pack(C,hex($1))/eg;
 $pairs{$key} = $value;
 }
 
 is there a way to build a url that will pass data that is then parsed 
out 
 into a hash table.
 
 what I want to do is be able to have a regular link on a webpage that 
 points to this one and also passes a parameter to it.
 this code sample works fine if I use a form on the referring page to 
pass 
 my info, but that's not what I want.

The reason your code doesn't handle your request is because parameters 
embedded in the URL are in
$ENV{QUERY_STRING} and are considered a GET request.  Your snippet reads 
the parameters from
STDIN, which is how POST requests are handled.

The simple way to deal with both (and to eliminate your code):

use CGI qw/:cgi-lib/;
use strict;
my %pairs = Vars;

That snippet deals with either GET or POST requests.

Cheers,
Curtis Ovid Poe

=
Senior Programmer
Onsite! Technology (http://www.onsitetech.com/)
Ovid on http://www.perlmonks.org/

__
Do You Yahoo!?
Make a great connection at Yahoo! Personals.
http://personals.yahoo.com

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






Faking form variables

2001-10-25 Thread Greg . Froese

I'm using the following snippet of code to put all form data passed into a 
hash table.

$form_data_size = $ENV{'CONTENT_LENGTH'};
read (STDIN, $form_data, $form_data_size);
@info_returned = split (//,$form_data);

foreach $keyvalue (@info_returned)
{
($key, $value) = split(/=/, $keyvalue);
$value =~ tr/+/ /;
$value =~ s/%([\dA-Fa-f][\dA-Fa-f])/pack(C,hex($1))/eg;
$pairs{$key} = $value;
}

is there a way to build a url that will pass data that is then parsed out 
into a hash table.

what I want to do is be able to have a regular link on a webpage that 
points to this one and also passes a parameter to it.
this code sample works fine if I use a form on the referring page to pass 
my info, but that's not what I want.


Re: No such file or directory exists

2001-10-24 Thread Greg . Froese

That was not the problem.  The problem was the ^M at the end of each line




walter valenti [EMAIL PROTECTED]
Sent by: [EMAIL PROTECTED]
10/24/2001 09:11 AM

 
To: [EMAIL PROTECTED]
cc: [EMAIL PROTECTED], [EMAIL PROTECTED]
Subject:Re: No such file or directory exists


Hi,
look the first line of the script: contains the location of perl's
interpreter
Most common are:
#!/usr/bin/perl

#!/usr/local/bin/perl

Walter

 I'm working with my perl scripts in Linux and Windows.  my scripts were
 running fine when I ran them as perl myscript.pl

 but when I tried to execute the perl script using only its name
 (./myscript.pl) then I would get the message No such file exists
 I searched and searched until I found that there were ^M chars at the 
end
 of each line of my source.  These could not be seen with the text editor 
I
 was using, but could be seen using cat -v myscript.pl

 I also found a one line perl command that removes all of these 
characters,
 and then my script worked fine to run as ./myscript.pl.
 I don't have that command on this machine, but if anybody is having the
 same trouble, I could email them later with the command.

 What is the cause of these chars? Is it using a Windows editor to code
 these scripts, and then running them in Linux?
 I'm curious to know the cause of this because I spent a good part of 2
 hours getting that problem sorted out.

 Thanks,
 Greg


_
Do You Yahoo!?
Get your free @yahoo.com address at http://mail.yahoo.com






No such file or directory exists

2001-10-24 Thread Greg . Froese

I'm working with my perl scripts in Linux and Windows.  my scripts were 
running fine when I ran them as perl myscript.pl

but when I tried to execute the perl script using only its name 
(./myscript.pl) then I would get the message No such file exists
I searched and searched until I found that there were ^M chars at the end 
of each line of my source.  These could not be seen with the text editor I 
was using, but could be seen using cat -v myscript.pl

I also found a one line perl command that removes all of these characters, 
and then my script worked fine to run as ./myscript.pl.
I don't have that command on this machine, but if anybody is having the 
same trouble, I could email them later with the command.

What is the cause of these chars? Is it using a Windows editor to code 
these scripts, and then running them in Linux?
I'm curious to know the cause of this because I spent a good part of 2 
hours getting that problem sorted out.

Thanks,
Greg


Re: No such file or directory exists

2001-10-24 Thread Greg . Froese

elementary? oooh, that hurts =)
but you are right, I should have been using -w




Peter Scott [EMAIL PROTECTED]
10/24/2001 10:03 AM

 
To: [EMAIL PROTECTED], [EMAIL PROTECTED]
cc: 
Subject:Re: No such file or directory exists


At 09:01 AM 10/24/2001 -0500, [EMAIL PROTECTED] wrote:
I'm working with my perl scripts in Linux and Windows.  my scripts were
running fine when I ran them as perl myscript.pl

but when I tried to execute the perl script using only its name
(./myscript.pl) then I would get the message No such file exists
I searched and searched until I found that there were ^M chars at the end
of each line of my source.  These could not be seen with the text editor 
I
was using, but could be seen using cat -v myscript.pl

I also found a one line perl command that removes all of these 
characters,
and then my script worked fine to run as ./myscript.pl.
I don't have that command on this machine, but if anybody is having the
same trouble, I could email them later with the command.

What is the cause of these chars? Is it using a Windows editor to code
these scripts, and then running them in Linux?

Bingo.  And I'll bet you're being naughty and not using the -w flag 
(unless 
you're being modern and using 'use warnings', in which case I take it back 

and then some).  Because the ^M at the end of the #! line is being taken 
as 
part of the invocation, and in order for you to get that error message, it 

would have to be taken as part of the path to perl, which means that you 
don't have any options following it.

I'm curious to know the cause of this because I spent a good part of 2
hours getting that problem sorted out.

Often the silliest things do have this effect.  That's why I mentioned 
this 
one (which can cause other errors) and other 'elementary' errors in my 
book.
Peter Scott
[EMAIL PROTECTED]
http://www.perldebugged.com






accessing environment variables

2001-10-19 Thread Greg . Froese

How do I access Windows environment vars?

I want to be able to test whether I'm in Windows or Linux, and this seems 
like a good way to do it.

If there is an easier/better way, I'm all ears.

Thanks 
Greg


Re: accessing environment variables

2001-10-19 Thread Greg . Froese

Thanks Brian and Marcus. 
$^O is exactly what I needed.





_brian_d_foy [EMAIL PROTECTED]
10/19/2001 08:44 AM

 
To: [EMAIL PROTECTED]
cc: 
Subject:Re: accessing environment variables


In article [EMAIL PROTECTED], 
[EMAIL PROTECTED] (Greg Froese) wrote:


 I want to be able to test whether I'm in Windows or Linux, and this 
seems 
 like a good way to do it.

you want $^O, not an environment variable.  take a look inside
CGI.pm for some example code. :)
-- 
brian d foy [EMAIL PROTECTED] - Perl services for hire
CGI Meta FAQ - http://www.perl.org/CGI_MetaFAQ.html
Troubleshooting CGI scripts - http://www.perl.org/troubleshooting_CGI.html

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






Using Win32::ODBC

2001-10-09 Thread Greg . Froese

I'm successfully connecting to a Pervasive 7 database with my PERL program 
when running from the command line.

I try to run the program in my webbrowser and I get the following error.

Error connecting to MO Error: [802] [] [Pervasive Software][ODBC 
Interface][Pervasive Software SQL Engine]General error. 

(MO is the name of my system DSN)


any ideas how to fix this so it runs on the web server properly



RE: Using Win32::ODBC

2001-10-09 Thread Greg . Froese

Yes, I am using IIS as my webserver.

-Original Message-
What is your web-server? IIS??
- Rex

-Original Message-
From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]]
Subject: Using Win32::ODBC

I'm successfully connecting to a Pervasive 7 database with my PERL program 

when running from the command line.

I try to run the program in my webbrowser and I get the following error.

Error connecting to MO Error: [802] [] [Pervasive Software][ODBC 
Interface][Pervasive Software SQL Engine]General error. 

(MO is the name of my system DSN)


any ideas how to fix this so it runs on the web server properly


Inserting records into database

2001-10-05 Thread Greg . Froese

I'm using Win32::ODBC and trying to insert a record into an access 
database.

This is the error I'm getting.
SQL failed. Error: [-3035] [1] [0] [Microsoft][ODBC Microsoft Access 
Driver] Operation must use an updateable query. 

and this is the code I'm using

 #Opening database
if (!($db = new Win32::ODBC($DSN))){
print Error connecting to $DSN\n;
print Error:  . Win32::ODBC::Error() . \n;
exit;
}
 
$SqlStatement = INSERT INTO project (projectid,name,startdate,status) 
values ($projnum,'$fields{prjname}',$fields{startdate},$status);
if ($db-Sql($SqlStatement)){
print SQL failed.\n;
print Error:  . $db-Error() . \n;
$db-Close();
exit;
}

#Closing database
$db-Close();

what is wrong with this code, it works great for doing queries.


Connecting to an Access/MySQL database

2001-10-03 Thread Greg . Froese

what module(s) would I need to connect to an access database?

and if I code an app that uses an access database, can that be easily 
changed to MySQL or whatever just by changing the connect string?

TIA
Greg


Reusing same output line

2001-09-26 Thread Greg . Froese

Is it possible when writing to the console with print to continue using 
the same line rather than have each message appear after the previous one?

Anyone is familiar with ncftp knows that the program shows the up/download 
status updating on the same line.  I'm curious if the same thing is 
possible with perl.

Thanks
Greg


arrays

2001-09-25 Thread Greg . Froese

are there multi-dimensional arrays in perl?