|
|
Comments and Discussions
|
|
 |

|
Hello All,
I wish to execute a perl module and redirect the ouput to variable / array with redirect operator '>' instead of a file.
Can any one please let me know how to do this if it's possible ?
Thankyou very much.
Best Regards.
Amar.
|
|
|
|

|
How to write a Regular Expression I want To First Letter is Must be 9 Word After 0-9 Words. Total Maxmium Words is 9 words only.
please help me asap.
regards
venkat
-- modified at 7:08 Friday 5th October, 2007
|
|
|
|

|
Has anyone tried using pop-up menus or sliding menus in PHP, preferably in table driven format menus...
|
|
|
|

|
Hi all,
I have written a stored procedure in Firebird that receives the field name
(field1) and the condition-cond1 (where clause of the select statement) as parameters and
returns the required field as output.
Here are those 2 lines of statement.
i.e.
str_sql = 'Select ' || :field1 || ' from my_table where ' || :cond1;
execute statement :str_sql into :outstring;
The procedure does not return any values. Can any body help me?
|
|
|
|

|
Here is the asp.net version with c sharp, sql server and jav script
clickety[^]
|
|
|
|

|
hello everybody,,
i m tanmoy panja doing a project on online Adwords system using perl.now i m facing a problem with how to check that flash must support clicktag.because i have to show flash ads on publisher websites.exactly i mean to say that how to check if there is any clicktag in .swf file using perl.
plzzz help me out as early as possible from this.
Tanmoy Panja
Software Developer
mob:-9434661484
Intrasoft Technologies Pvt. Ltd.
5,Lake Temple road.
Kolkata-29.
|
|
|
|
|

|
Now that the Oracle database has been updated to 9i.
Some of the perl and CGI scripts no longuer work.
Cannot connect to oracle error ORA-3113
So far it looks like oraperl is not compatible with oracle 9i
|
|
|
|

|
Can somebody help me on this, I created a perl script to search for a certain records from a mySQL DB, uploading the script to our remote web server, calling the script, I received error 500.
Is this an permission error or the script is buggy?
500 /cgi-bin/bizsearch.pl ==> this is the page I received..
Any help?
Thanks.
|
|
|
|

|
Hi,
I am new to OO perl. I try to develop a perl program which used a few self defined module. I put all my .pm files in my project development directory. Here is a simply example:
aaa.pl
#!/usr/bin/perl -w
use lib '/my_project_package';
use ttt ();
ttt.pm
package ttt;
use Switch;
However when I run aaa.pl, I got the error message as:
ttt.pm did not return a true value at ./aaa.pl line 4.
BEGIN failed--compilation aborted at ./aaa.pl line 4.
Can anyone give me a help in solving this problem? Thanks in advance.
|
|
|
|

|
Hi all.
I wrote some code that will check if a message has been posted in the forum. It will check the data.txt file every 30 minutes to see if the number has changed. The code is based on this cp article [^]
Note that this code is a very quick hack so expect bugs! It works for me though...
// FCheck.cpp : Defines the entry point for the application.
//
#include
#include
#include
#include
typedef BOOL (__stdcall * LPFN_INETAUTODIAL)(DWORD, HWND);
typedef BOOL (__stdcall * LPFN_INETREADFILE)(LPVOID, LPVOID, DWORD, LPDWORD);
typedef BOOL (__stdcall * LPFN_INETAUTOHANGUP)(DWORD);
typedef BOOL (__stdcall * LPFN_INETCLOSEHANDLE)(LPVOID);
typedef BOOL (__stdcall * LPFN_INETGETCONNSTATE)(LPDWORD, DWORD);
typedef LPVOID (__stdcall * LPFN_INETOPEN)(LPCSTR, DWORD, LPCSTR, LPCSTR, DWORD);
typedef LPVOID (__stdcall * LPFN_INETOPENURL)(LPVOID, LPCSTR, LPCSTR, DWORD, DWORD, DWORD);
HINSTANCE hWinInet;
bool bDLLFailure;
HINTERNET hInternetSession;
HINTERNET hURL;
char szTempName[MAX_PATH];
DWORD m_LastKnownAmount;
// APIs.
LPFN_INETGETCONNSTATE Inet_GetConnectedState;
LPFN_INETAUTODIAL Inet_AutoDial;
LPFN_INETOPEN Inet_Open;
LPFN_INETCLOSEHANDLE Inet_CloseHandle;
LPFN_INETOPENURL Inet_OpenUrl;
LPFN_INETREADFILE Inet_ReadFile;
LPFN_INETAUTOHANGUP Inet_AutoHangup;
int RegReadDWord( HKEY hkey, LPTSTR name, DWORD *pval);
DWORD RegReadDWord(LPCTSTR key, LPCTSTR name, DWORD defaultVal, HKEY hParent = HKEY_LOCAL_MACHINE);
int RegWriteDWord(HKEY hkey, LPTSTR name, DWORD val);
BOOL RegWriteDWord(LPCTSTR hKey, LPCTSTR name, DWORD value, HKEY hKeyParent = HKEY_LOCAL_MACHINE);
void ErrorHandler (char * szMessage)
{
// Display a message box to alert the user to the failure.
::MessageBox (NULL, szMessage, "Checking Forum", MB_OK | MB_ICONINFORMATION);
}
bool ConnectToWeb (char * szAgent)
{
DWORD dwFlags;
// First we see if the user is already connected...
if (!Inet_GetConnectedState (&dwFlags, 0)) {
// Prompt the user to connect to the internet.
if (!Inet_AutoDial (0, NULL)) {
ErrorHandler ("This application must connect to the Internet to check the forum.");
return false;
}
}
// Ok first connect to the internet.
hInternetSession = Inet_Open (szAgent, INTERNET_OPEN_TYPE_PRECONFIG, NULL, NULL, 0);
if (hInternetSession == NULL) {
ErrorHandler ("Cannot connect to the Internet.");
return false;
}
return true;
}
bool DisconnectFromWeb ()
{
// Close down connections.
Inet_CloseHandle (hInternetSession);
// Disconnect from the Internet.
Inet_AutoHangup (0);
return true;
}
bool RetrieveFileFromWeb (char * szUrl, char * szFileName)
{
DWORD dwBytesRead, dwBytesWritten;
char szFileBuffer[4096];
HANDLE hTempFile;
char * szBuffer;
// Make the complete URL from the filename and URL given.
szBuffer = new char [strlen (szUrl) + strlen (szFileName) + 2];
if (szBuffer == NULL) {
ErrorHandler ("Cannot allocate memory to buffer!");
return false;
}
// Concatinate the URL and filename
sprintf (szBuffer, "%s/%s", szUrl, szFileName);
// Open the URL.
hURL = Inet_OpenUrl (hInternetSession, szBuffer, NULL, INTERNET_FLAG_NO_CACHE_WRITE, 0, 0);
if (hURL == NULL) {
ErrorHandler ("Cannot connect to forum URL.");
delete[] szBuffer;
return false;
}
// Create a temporary file.
char* pBuf = new char[MAX_PATH];
GetTempPath(MAX_PATH, pBuf);
GetTempFileName (pBuf, "WU_", 0, szTempName);
delete[] pBuf;
hTempFile = CreateFile ((LPTSTR) szTempName, GENERIC_READ | GENERIC_WRITE, 0, NULL, CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL,NULL);
// Check to see if the file was created successfully.
if (hTempFile == INVALID_HANDLE_VALUE) {
ErrorHandler ("Cannot create a temporary forum check file.");
delete[] szBuffer;
return false;
}
// TODO: show progress bar!
do {
// Keep reading until we have the entire file.
Inet_ReadFile (hURL, (LPSTR) szFileBuffer, (DWORD) 1024, &dwBytesRead);
// If we retrieved some data - write it to the output file.
if (dwBytesRead > 0) WriteFile (hTempFile, (PVOID) szFileBuffer, dwBytesRead, &dwBytesWritten, NULL);
} while (dwBytesRead > 0);
// Close the handle to the file.
CloseHandle (hTempFile);
// Close the handle to the URL.
Inet_CloseHandle (hURL);
return true;
}
bool ParseVersionFile (char * szVersionFile)
{
DWORD dwBytesRead, dwSize;
int nCounter = 0;
char * szBuffer;
HANDLE hVersionFile;
// Open the file for reading.
hVersionFile = CreateFile (szVersionFile, GENERIC_READ, FILE_SHARE_READ, NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL);
if (hVersionFile == INVALID_HANDLE_VALUE) {
ErrorHandler ("Cannot open downloaded version file.");
return false;
}
// Try to obtain the version file size.
dwSize = GetFileSize (hVersionFile, NULL);
// Read the file into a buffer.
szBuffer = new char [dwSize];
if (szBuffer == NULL) {
ErrorHandler ("Cannot allocate memory for buffer.");
return false;
}
memset(szBuffer, 0, dwSize);
// Actually read from the file.
if (!ReadFile (hVersionFile, szBuffer, dwSize, &dwBytesRead, NULL)) {
ErrorHandler ("Cannot read from downloaded version file.");
return false;
}
// Close the handle to the file.
CloseHandle (hVersionFile);
// Parse the file
if (atol(szBuffer) != m_LastKnownAmount)
{
// A new message!
m_LastKnownAmount = atol(szBuffer);
char msg[MAX_PATH];
memset(&msg, 0, MAX_PATH);
sprintf((char *)&msg, "New message! Total messages: %d.", m_LastKnownAmount);
ErrorHandler(msg);
HKEY hKey;
DWORD disp = REG_OPENED_EXISTING_KEY;
if ( RegCreateKeyEx( HKEY_LOCAL_MACHINE,
"SOFTWARE\\YOURKEY\\FCheck",
0,
"",
REG_OPTION_NON_VOLATILE,
KEY_ALL_ACCESS,
NULL,
&hKey,
&disp) != ERROR_SUCCESS)
{
return FALSE;
}
::RegWriteDWord(hKey, "Forum Check", m_LastKnownAmount);
}
// Clean up the memory allocations.
delete [] szBuffer;
return true;
}
int APIENTRY WinMain(HINSTANCE hInstance,
HINSTANCE hPrevInstance,
LPSTR lpCmdLine,
int nCmdShow)
{
// TODO: Place code here.
HKEY hKey;
RegOpenKey(HKEY_LOCAL_MACHINE, "SOFTWARE\\YOURKEY\\FCheck", &hKey);
if (RegReadDWord(hKey, "Forum Check", &m_LastKnownAmount)<0)
{
m_LastKnownAmount = 60000;
}
RegCloseKey(hKey);
bDLLFailure = false;
// Dynamically load the WinInet.Dll file.
hWinInet = LoadLibrary ("WinInet.Dll");
if (hWinInet == NULL) {
ErrorHandler ("Cannot load WinInet.Dll. Please make sure IE 4.0 or greater is installed!");
return TRUE;
}
// Attempt to dynamically load the APIs
Inet_GetConnectedState = (LPFN_INETGETCONNSTATE) GetProcAddress (hWinInet, "InternetGetConnectedState");
Inet_AutoDial = (LPFN_INETAUTODIAL) GetProcAddress (hWinInet, "InternetAutodial");
Inet_Open = (LPFN_INETOPEN) GetProcAddress (hWinInet, "InternetOpenA");
Inet_CloseHandle = (LPFN_INETCLOSEHANDLE) GetProcAddress (hWinInet, "InternetCloseHandle");
Inet_OpenUrl = (LPFN_INETOPENURL) GetProcAddress (hWinInet, "InternetOpenUrlA");
Inet_ReadFile = (LPFN_INETREADFILE) GetProcAddress (hWinInet, "InternetReadFile");
Inet_AutoHangup = (LPFN_INETAUTOHANGUP) GetProcAddress (hWinInet, "InternetAutodialHangup");
// Check to see if all the APIs have been successful and we have a v4.0 WinInet.Dll...
if (Inet_GetConnectedState == NULL) bDLLFailure = true;
if (Inet_AutoDial == NULL) bDLLFailure = true;
if (Inet_Open == NULL) bDLLFailure = true;
if (Inet_CloseHandle == NULL) bDLLFailure = true;
if (Inet_OpenUrl == NULL) bDLLFailure = true;
if (Inet_ReadFile == NULL) bDLLFailure = true;
if (Inet_AutoHangup == NULL) bDLLFailure = true;
// If we have a failure report it to the user and force the upgrade to stop.
if (bDLLFailure == true) {
ErrorHandler ("Cannot load WinInet.Dll. Please make sure IE 4.0 or greater is installed!");
return TRUE;
}
// If we have a failure report it to the user and force the upgrade to stop.
if (bDLLFailure == true) {
ErrorHandler ("IE 4.0 or greater has to be installed to use forum check!");
return -1;
}
while (1)
{
// Connect to the Internet.
if (!ConnectToWeb (forum checker"))
{
Sleep(5 * 60 * 1000);
continue;
}
if (!RetrieveFileFromWeb ("http://www.YOURSITE.com", "data.txt"))
{
DisconnectFromWeb();
Sleep(5 * 60 * 1000);
continue;
}
if (!ParseVersionFile (szTempName))
{
DisconnectFromWeb();
Sleep(5 * 60 * 1000);
continue;
}
if (!DisconnectFromWeb ())
{
Sleep(5 * 60 * 1000);
continue;
}
DeleteFile(szTempName);
Sleep(30 * 60 * 1000);
}
return 0;
}
/***************************************************************************
* RegReadDWord()
*
* Function reads a DWORD entry from the registry
*
* hkey: handle of key to query
* name: address of name of value to query
* pval: address of the variable to fill in upon return
*
* Returns: -1 when the entry does not exist or is not a DWORD
* >=0 when the entry is read
*
*/
int RegReadDWord( HKEY hkey, LPTSTR name, DWORD *pval)
{
DWORD var = 0;
DWORD type = REG_DWORD;
DWORD size = sizeof( DWORD);
// Query the value, check if it exists and really is a DWORD
LONG retv = RegQueryValueEx( hkey,
name,
NULL,
&type,
(BYTE*)&var,
&size);
if ( retv == ERROR_SUCCESS && type == REG_DWORD)
{
*pval = var;
return 0;
}
return -1;
}
/***************************************************************************
* RegReadDWord()
*
* Description : Reads a value from the registry
*
* Return value : the value if succeeded, or the default value otherwise
*
* Parameters :
* - key : the key in which to read (e.g. SOFTWARE\\dZine\\SomeKey)
* - name : the name of the value to read
* - defaultVal : the value to return if the read fails
* - hKeyParent : the key from which to start
* (default : HKEY_LOCAL_MACHINE)
*
*/
DWORD RegReadDWord(LPCTSTR key, LPCTSTR name, DWORD defaultVal, HKEY hKeyParent)
{
HKEY hKey = NULL;
DWORD result = defaultVal;
if (RegOpenKeyEx(hKeyParent,
(LPCTSTR)key,
0,
KEY_QUERY_VALUE,
&hKey) == ERROR_SUCCESS)
{
DWORD type = REG_SZ;
DWORD size = sizeof(DWORD);
DWORD valueRead;
// Query the value, check if it exists and really is a DWORD
if (RegQueryValueEx(hKey,
name,
NULL,
&type,
(BYTE *)&valueRead,
&size) == ERROR_SUCCESS)
{
result = valueRead;
}
RegCloseKey(hKey);
}
return result;
}
/***************************************************************************
* RegWriteDWord()
*
* Function writes a DWORD entry to the registry
*
* hkey: handle of key to query
* name: address of name of value to write
* val: value to write
*
* Returns: -1 failed to write the entry (invalid key, no rights ???)
* >=0 when the entry is written
*
*/
int RegWriteDWord( HKEY hkey, LPTSTR name, DWORD val)
{
if ( RegSetValueEx( hkey, name, 0, REG_DWORD,
(BYTE*)&val, sizeof( DWORD)) != ERROR_SUCCESS)
return -1;
return 0;
}
/***************************************************************************
* RegWriteDWord()
*
* Description : Writes a DWORD value to the registry
*
* Return value : TRUE == success, FALSE == error
*
* Parameters :
* - key : the name of the key (e.g. SOFTWARE\\dZine\\SomeKey)
* - name : the name of the registry value
* - value : the value to write
* - hKeyParent : the key from which to start
* (default : HKEY_LOCAL_MACHINE)
*
*/
BOOL RegWriteDWord(LPCTSTR key, LPCTSTR name, DWORD value, HKEY hKeyParent)
{
HKEY hKey;
DWORD disposition;
if ( RegCreateKeyEx(hKeyParent,
key,
0,
"",
REG_OPTION_NON_VOLATILE,
KEY_SET_VALUE,
NULL,
&hKey,
&disposition) != ERROR_SUCCESS)
{
return FALSE;
}
if (RegSetValueEx(hKey,
name,
0,
REG_DWORD,
(const BYTE *)&value,
sizeof(DWORD)) != ERROR_SUCCESS)
{
RegCloseKey(hKey);
return FALSE;
}
RegCloseKey(hKey);
return TRUE;
}
-----------------------
New and improved: kwakkelflap.com
My second CP article: MAP files[^]
while (!:bob:.IsDrunk())
{
:bob:.Drink( :beer: );
}
|
|
|
|

|
I love your work! Thanks to this article, I have my message board running on my site without using any database. This is a plus for me since I would need to upgrade my hosting if I wanted a MySQL database or something.
I have one problem though. When using the forum with Opera, none of the messages appear when clicking them. Do you have any idea what this could be? No problem in IE though. Haven't tested in any other browsers...
-----------------------
New and improved: kwakkelflap.com
My second CP article: MAP files[^]
while (!:bob:.IsDrunk())
{
:bob:.Drink( :beer: );
}
|
|
|
|

|
Hi There, I have a very peculiar problem. I am using Cygwin perl Version 5.6.1 on win2k system. I am trying to FTP Windows ASCII/Text files to unix. I am getting windows line endings at the end of each line in the files that have been ftp'd using Net::Ftp module. These are CR/LF. I dont want them to appear in the files that have been ftp'd onto unix. I want to remove them. I know there are some tools out there that would remove this for me. But i want to use them as the last resort. And i am approaching this forum to get any inputs on this. If anyone could throw some light as to how i could convert a windows file with windows line ending to windows file with unix line endings before fpt'ing it accross to unix. Or to remove the windows line endings in general. I know of another way using "tr". But i dont want to use this either. As this is on a file by file basis. I wanted to know if there is any environment variable or any other way out with which i make minimal changes to my perl script and achieve the objective. Reason i am saying this is, my perl script has 100's of such files(ascii) being ftp'd and i have to add tr ahead of each one of them as it doesnt work for a bunch of files or using a wild character. Any further info, please dont hesitate to post your responses. Thanks in advance for your time. K
|
|
|
|

|
Well, I am not sure about doing anything automatically, but you could alter the perl script to have the files go through these scripts:
dos->unix (remover.pl):
$infile = $ARGV[0];
$outfile = $ARGV[1];
open (IN, "<$infile") or die ("Cannot open file.");
open (OUT, ">$outfile") or die ("Cannot open file.");
binmode IN, ":crlf";
binmod OUT. ":raw";
while (defined($line = )) {
print OUT $line;
}
close IN;
close OUT;
You could have perl load an array with the file names and pass them to ^ the script.
If you need to go back...:
unix->dos:
$inf = $ARV[0];
$outf = $ARGV[1];
open (IN, "<$inf") or die("Cannot open file");
open (OUT, ">$outf") or die ("Cannot open file");
binmod OUT;
while (defined($line = )) {
$line =~ s/\n/\r\n/g;
print OUT $line;
}
close IN;
close OUT;
Have perl run the script as something like (a seperate perl script)
@files = #load something here
and do a foreach loop in the @files, putting them in $ARGV[0] (or something else)
with the same name in the $ARGV[1].
I really hope this helps!
Hey, Bill!
It compiles! Lets ship it!
|
|
|
|

|
I always get a fault in line 176 of my forum.pl file
This is the fault:
No such file or directory at forum.pl line 176.
I don't know how to solve it.
Please help me
David Liebens
|
|
|
|
|
|

|
i am starting progamming with perl.
please give me some refrences about perl on internet.
or a best book of the perl .
thank you ..
|
|
|
|

|
One of the better books I've used is the Perl How to Program by Deitel Deitel Nieto and McPhie. It has a lot of good Perl info, and also sections on CGI and Python... Kinda expensive, but worth it so far.
John Ribar
|
|
|
|

|
Also try "Learning Perl" from O'Reilly. Great intro to Perl, though the section on CGIs is pretty sparse. After you get your feet wet, then by a more advance book like "Programming Perl."
Jon Sagara
"Ninety percent of baseball is mental, the other half is physical." -- Yogi Bera
|
|
|
|

|
Can't believe I forgot the metion CPAN!
Jon Sagara
"There are lies, damned lies and statistics."
-- Mark Twain.
|
|
|
|
|
|

|
I'm looking for perl Excel and Ole examples , can anyone give me some hints, links....
I wrote some code in perl to access the spreatsheet which I'm willing to share if one askes for it. ( I'm not having a server on line ) If you mail me i'll send it to you.
Email : ArnoTeunisse@hetnet.nl
|
|
|
|

|
i think using www.google.com you 'll find out something (:
just enter approprate fraze (:
----------------
muaaa ..
i have no time to do something good ):
|
|
|
|
 |
|
|
General News Suggestion Question Bug Answer Joke Rant Admin
Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.
|
The Code Project discussion board in Perl. This is an open source project for the Code Project community.
| Type | Article |
| Licence | |
| First Posted | 29 Aug 2001 |
| Views | 102,922 |
| Bookmarked | 13 times |
|
|