|
|
Comments and Discussions
|
|
 |

|
It crashes deep down in perl!!
|
|
|
|

|
Please all the user of perl please help me.
I have paroject on perl. The project is about introduction and features of perl and its use in the Industry.
i know about AJAX usin .NET but is it possible using perl. if yes then pls. know me how. I want some examples and are run properly because I have to show the demo.
So please its my request to all. Help me. if you have example then plese give me.
I want to know that is it possible to run on windows? or just for the unix system?
Thanking you,
Jesal Rana
OK
|
|
|
|
|

|
Hi there,
A new version is available!
You can download binaries for using in your freeware applications or for evaulation purposes.
18 Feb 2005: v2.031:
* Interpreter will be always persistent, choice no longer available. Here are the reasons:
o calling die and exit within a script would exit your program, purely and simply.
o Perl was not made for perl_run 'ing a script several times (in perl.exe, perl_parse and perl_run are always performed conjointly).
o although it works, it raises some issues such as the fact that Perl forgets dynamically imported modules and functions.
o no performance gain, no interest.
o the persistent interpreter is more safe, it sets up a frontier between your program and your script, allowing a tight but safe integration.
* Bytecode support removed. People must be aware that it is declared as "experimental" in perldoc.
* A big effort has been made towards function names consistency, and product extensibility.
* Error report widely improved.
* Redirection much improved, more safe and reliable.
* Several other bug fixed.
http://pixigreg.com/?products[^]
Pixi
|
|
|
|

|
Hello!
I'm proud to announce you the release of PXPerlWrap, the successor of
"The PXPerl Namespace", the Perl embedding solution. After more than a
year of development, it is finally here, with tons of features
PXPerlWrap comes with PXPerl, which is a Perl distribution, loaded
with a bunch of modules, and among them is GraphicsMagick, a powerful
image manipulation library.
This Perl distribution was compiled for maximum performance, with an
average speed gain of 16% over ActivePerl. It was designed to ease the
developer task: with syntax highlighted HTML documentation, and
Explorer integration.
PXPerlWrap is a set of classes, intended for easing to the maximum the
embedding of Perl. It enables you to take advantage of the scripting
language within your applications in seconds.
"Embed Perl easily in your MFC application, through an intuitive set
of Object Oriented classes, and thanks to an automated installation
script. The PXPerlWrap advanced class architecture allows you to
create several Perl interpreters at a time, or only one and access it
from several threads, without variable and script objects existence
and conflict problems. Manipulate scalar objects, arrays, and hashes
objects the easy way; execute scripts, execute bytecode, convert to
bytecode, reformat scripts, fetch scripts from the internet. Evaluate
quickly a perl statement. It's so easy
Redirect the standard output to your windows, as if Perl were not a
console language (this is not a basic redirection as seen in Visual
Studio and others with process spawning and so on, but a dynamic
handles redirection).
Work with Unicode strings transparently between the two languages.
Call functions of your application from within your scripts, and vice versa."
Please note that PXPerlWrap documentation is not released yet, but is
going to be released soon (along with CodeProject.com article update).
However I believe its classes are very intuitive to use. Give it a
try, and have a look at the test application code to see how easy it
is to use.
Find out more about PXPerl and PXPerlWrap, download it now:
http://pixigreg.com/?pxperl
You can also reach Perl and modules documentation at any time:
http://pixigreg.com/perldoc
Feedback appreciated!
Grégoire Péan aka PixiGreg
www.pixigreg.com
|
|
|
|

|
Pixi
|
|
|
|

|
Um....First off, congrats on releasing this work as a 'real product'......But, I wonder: has this event/rethinking reduced this article to a 'promotional piece' aka 'an advertisement' and therefore no longer appropriate for this site?
I don't have an axe to grind about this, rather I'm just wondering out loud.....
Just trying to keep the forces of entropy at bay
|
|
|
|

|
Hi,
Not appropriate for this site, I don't agree with you.
Perhaps more appropriate for the free tools section, that's true. Article is going to be moved.
Having an article published on CodeProject surely promote any piece of code/product related to it. But as a product free for non commercial use (aka freeware) many people can use it without paying.
Regards,
Pixi
|
|
|
|

|
I stand corrected. Moved to free tools is the appropriate action. Even so, thank you for replying and BEST OF LUCK with your new product!!!!
Sincerely,
RedZenBird
Just trying to keep the forces of entropy at bay
|
|
|
|

|
Thank you very much!
Pixi
|
|
|
|

|
Hello all
Here is the latest development news:
- PXPerl's new name is PXPerlWrap, therefore the upcoming version is PXPerlWrap 2;
- PXPerl is now a Perl distribution, compatible with ActivePerl, and compiled with IC 8. It will include PXPerlWrap;
- I've nearly finished everything in PXPerlWrap (3000 lines of code) REDIRECTION WORKS PERFECTLY (erm, only in release mode actually, but I consider it working :P). Now I'm currently deeply testing and debugging every feature (lots :P).
- Biggest new features in PXPerlWrap 2:
=> CPerlScalar, CPerlArray, CPerlHash, CPerlInterpreter, CScript.
=> MT-safe,
=> UNICODE support, through C++ AND Perl (UTF8)
=> Perl Bytecode interpreter support (save scripts as bytecode, run as bytecode)
=> Advanced intern interpreter and variables management with an interpreter pool...
=> Use persistent interpreters or classic ones,
=> Test your script (perl -c)
=> Load scripts from a file, inline, or from internet, either text or bytecode...
- call C++ functions from your Perl scripts, thanks to SWIG (included, set up);
- PXPerlWrapSetup will setup everything for you in your project
stay tuned;)
Grégoire aka PixiGreg
(who loves smilies as you noticed)
|
|
|
|
|

|
Hi PixiGreg, hi all!
First thank you for your work! And yes, Perl can be a 'love'!
In my actual project, I want to integrate a perlintetrpreter as a embedded scripting language in my c++ Application. ( like vb in office )
I need interaction between c++ and Perl, that is my Application receives data ( from the outside ) , witch then must be send to the perl-script, if it is running.
And on the other side, the perlscript must be able to send data to the application. ( Send a command to the outside, reaction )
( something like callbacks, sendMessage ?? )
Is that possible?
Thank for any suggestions and sorry for my bad english.
Hardy.
|
|
|
|

|
Greetings!
Hardy_Smith wrote:
First thank you for your work! And yes, Perl can be a 'love'!
;D thx
Well, I must say I haven't thought about this yet. This would require running the script in a separate thread, and, shame on me, I haven't tried yet, I can't predict if getting/setting variables dynamically during script execution will work. To be tested :p However the code should be multithreaded-safe.
Another problem is that retrieving script output (STDOUT, STDERR) during script execution isn't possible. But i should be in version 2 !!! So, what I suggest you is to wait a bit for version 2
bye
Pixi
|
|
|
|
|

|
Hello all,
First, thanks all for your feedback.
I'm preparing PXPerl 2, which is more object oriented. Here is the CPerlScalar class so you get an idea on the great potential of the thing:
class PXPERL_API CPerlScalar : public CPerlObject
{
public:
~CPerlScalar();
// copies content, does NOT clone/duplicate the Perl scalar!
// Thus `this' must be a valid scalar returned by CPerlScript
const CPerlScalar& operator= (const CPerlScalar &scalar);
operator int() const;
const int Int() const;
int operator*= (int value);
int operator/= (int value);
int operator+= (int value);
int operator-= (int value);
int operator= (int value);
operator double() const;
const double Double() const;
double operator*= (double value);
double operator/= (double value);
double operator+= (double value);
double operator-= (double value);
double operator= (double value);
operator LPCSTR() const;
const CString& String() const;
const CString& operator= (const CString& value);
LPCSTR operator= (LPCSTR value);
LPCSTR operator+= (LPCSTR value);
////
// Perl-like functions :
int chomp(void);
//const CString& chomp(void) const;
int chop(void);
//const CString& chop(void) const;
void crypt(LPCSTR salt);
const CString& crypt(LPCSTR salt) const;
void lc(void);
const CString& lc(void) const;
void lcfirst(void);
const CString& lcfirst(void) const;
void uc(void);
const CString& uc(void) const;
void ucfirst(void);
const CString& ucfirst(void) const;
int length(void) const;
int hex(void) const;
int oct(void) const;
void reverse(void);
const CString& reverse(void) const;
int index(LPCSTR substr, int start_at_left=PARAM_OMITTED) const;
int rindex(LPCSTR substr, int start_at_right=PARAM_OMITTED) const;
void substr(int offset, int length=PARAM_OMITTED, LPCSTR replacement=(LPCSTR)PARAM_OMITTED);
const CString& substr(int offset, int length=PARAM_OMITTED,
LPCSTR replacement=(LPCSTR)PARAM_OMITTED) const;
void quotemeta(void);
const CString& quotemeta(void) const;
void split(LPCSTR pattern, CStringArray& array, bool bAppend=false) const;
// this won't create the CPerlArray object !
void split(LPCSTR pattern, CPerlArray* pArray, bool bAppend=false) const;
int tr(LPCSTR search_list, LPCSTR replacement_list, LPCSTR options);
int y(LPCSTR search_list, LPCSTR replacement_list, LPCSTR options); // synonymous for tr
int s(LPCSTR pattern, LPCSTR replacement, LPCSTR options);
bool m(LPCSTR pattern, LPCSTR options) const;
int pos(void) const; // when calling m/.../g
void undef(void);
void clear(void);
}
I will try to implement dynamic std streams redirection, as proposed by Vladimir (vladsch).
If I find time, I will get into std C++ conversion, thus it can be embedded in much more projects.
I'm trying to use as much funtions from the perl C api as possible, to make the thing as efficient as possible.
Keep in touch,
PixiGreg
|
|
|
|

|
Hello all,
well, you'd better have been patient up to now... I've still a problem with redirection. Redirecting standard output streams (stdout/stderr) from Perl DLL is not so easy; I'm working on it
PixiGreg
|
|
|
|

|
Hi in my prog i want to exec a precompiled perl script and pass some params that are obtained from boxes that the user fills in. Any Help on how to do that? Thanks
|
|
|
|

|
Hello,
Well, sorry for the late reply.
This can be simply achieved by fetching, as usual, values from your input boxes, and calling SetInt/Float/String/Array ?
Regards,
PixiGreg
|
|
|
|

|
Trying to keep the differences between a stand alone version, a web server version and the embedded version of a perl progam at minimum, I ran into trouble with the @ARGV variable (and I guess there are lots of other variables that show similar problems - what about $0 ?).
I can use other names to feed data into an array before the perl program is executed, however I am not able to do this with an array named @ARGV.
I think this behaviour has fooled me before with @INC. I was able to fix this for the moment using a statement like:
use lib 'mypath/for/the/packages';
Anyone out there, who found s good solution for that class of problem? I have done some modifications to the perlsistent.pl and I was able to fake @ARGV using a real bizar construct. But I am absolutely unhappy with that 'solution'.
Thank you PixiGreg and all the other who share there findings.
Qibono
Qibono
|
|
|
|

|
HELP!!!!
I've downloaded and built the project
pointed @ENC with
push @INC, 'c:/perl/lib', 'c:/perl/site/lib';
in persistent.pl
Then run the program and obtain the error
Error while running persistent interpreter
Can't locate strict.pm in @INC(@INC contains: .)
I've got the same problem with CPerlWrap - this is driving me nuts.
There's obviously something wrong with my environment - I'm running perl58
on WinXP and compiling with V6 (sp4)
DougSMiller
|
|
|
|

|
Hi,
Excuse me for the late reply!
Well, that's quite annoying indeed.
I've tried to remove the lib dir embedded with the demo project, and, indeed, even if you specify a push @INC in perlsistent.pl, perlsistent won't parse anyway.
Perl obviously needs a couple of files to run its interpreter, you should then let the basic "lib" dir provided (copying it to your project output dir as necessary).
You'll be able to use modules from 'c:/perl/lib' and 'c:/perl/site/lib' with your custom push this way.
Excuse me again,
Best luck,
Regards,
Pixi
|
|
|
|

|
Hi Pixigreg, nice...real nice, but (always a but), I am trying to run Perl scripts in the scanner I wrote. Instead of re-writing the scripts in C++, I just wanted to be lazy by using this PXPerl in my app. The scanners uses Thread Pooling from here at CP. The below code is executed in a sep. thread. My code looks like this:
if (m_perl.Load())
{
CScript script = m_perl.CompileFile("CHP", "D:\\XPoC\\Exploits\\MS03-046.pl");
CStringArray array;
array.Add(m_csHost);
array.Add("CHECK");
m_perl.SetArray(script, "ARGV", array);
m_perl.Exec(script);
CString csStdErr, csStdOut;
if (m_perl.GetSTDERR(csStdErr))
MessageBox(NULL,csStdErr,"StdErr",MB_OK);
if (m_perl.GetSTDOUT(csStdOut))
MessageBox(NULL,csStdOut,"StdOut",MB_OK);
}
Ofcourse depending on the STDOUT would show the system being scanned as VULNERABLE ot PATHCED. I am unable to get output from this to determine the status of the system?? Am I doing something wrong?? I can say that the script does use "IO::Socket::INet" ... does this have anything to do with it??
When this is ran from Active Perl, it gives output...
Regards,
Dan
|
|
|
|

|
Hi,
Well, embedding Perl is surely facetious... I have no immediate solution to your problem; if you have embedded the right modules your script needs (IO::Socket::INet) this should be ok. Consider checking you have indeed correctly embedded this module (with all the files required by module, even the *.dll files).
Sorry.
Best regards,
PixiGreg
|
|
|
|

|
Thanks for your reply...I have actually tried to put the .exe into the bin directory of perl with no success ... Should I even be doing it this way (in the earlier message) or do you have a better way to achieve what I am trying to do??
Regards,
Dan
|
|
|
|

|
You may consider using another way to run your script, if PXPerl is deficient : using Perl2Exe at
http://www.indigostar.com/perl2exe.htm[^]
This will produce a nice executable of your script with no module problem.
Good luck,
Best regards,
PixiGreg
|
|
|
|

|
Funny, it runs fine as Release, but nothing happens when "Execute" is clicked when compiled as Debug.
I copied the lib directory and the DLL over to the Debug directory, but no joy.
Great job! This could be easily converted in a portable version using std c++.
A.
|
|
|
|

|
Sorry, I forgot to mention my setup: VC++ 6 on Win2k.
A.
|
|
|
|

|
yep sorry for the late answer.
Indeed, it is possible for the project not to compile under VC6 since I think to remember I've updated VS .NET project file and not VC6 one.
I'm sorry for that. You can however consider using the project version converter (VSNET -> VC6) available on this site.
Regarding STD port, this should be indeed possible, and even worthwile.
But in the meantime I'm busy, so if someone wants to inspire from my code, no problem
Regards.
p i x i g r e g
|
|
|
|

|
The function
bool CPerl::Exec(const CScript& script)
contains the lines
char *args[] = { m_strAPackages.GetAt(script.m_nIndex).GetBuffer(0),
m_bAutoEmpty ? "1" : NULL, NULL };
The GetAt() returns a CString. In debug mode this class is destructed immediately and memory is filled up with FEEE...
quick workaround:
CString cs = m_strAPackages.GetAt(script.m_nIndex);
char *args[] = { cs.GetBuffer(0),
m_bAutoEmpty ? "1" : NULL, NULL };
SET_CONTEXT;
call_argv("execute", G_EVAL | G_DISCARD, args);
cs.ReleaseBuffer ();
|
|
|
|

|
Same patch in CPerl::Clean(CScript& script)
->
#if 1 // new
CString cs = m_strAPackages.GetAt(script.m_nIndex);
char *args[] = { cs.GetBuffer(0), NULL };
SET_CONTEXT;
call_argv("execute", G_EVAL | G_DISCARD, args);
cs.ReleaseBuffer ();
m_strAPackages.GetAt(script.m_nIndex).ReleaseBuffer();
#else
char *args[] = { m_strAPackages.GetAt(script.m_nIndex).GetBuffer(0), NULL };
m_strAPackages.GetAt(script.m_nIndex).ReleaseBuffer();
SET_CONTEXT;
call_argv("clean", G_EVAL | G_DISCARD, args);
#endif
thx for this great job
|
|
|
|

|
Sorry it's
#if 1 // new
CString cs = m_strAPackages.GetAt(script.m_nIndex);
char *args[] = { cs.GetBuffer(0), NULL };
SET_CONTEXT;
call_argv("clean", G_EVAL | G_DISCARD, args);
cs.ReleaseBuffer ();
m_strAPackages.GetAt(script.m_nIndex).ReleaseBuffer();
#else
char *args[] = { m_strAPackages.GetAt(script.m_nIndex).GetBuffer(0), NULL };
m_strAPackages.GetAt(script.m_nIndex).ReleaseBuffer();
SET_CONTEXT;
call_argv("clean", G_EVAL | G_DISCARD, args);
#endif
|
|
|
|

|
I know very little about perl scripting, but we have functionality implemented in perl script that I would like to expose through a GUI. Problem is that the perl script I had in mind use console arguments to decide what to do, such as:
"perl myscript.pl -all -u PKT"
What I would like is to run the perl script without having to change it (cause I can't) by generating the arguments from the GUI and feeding it to the perl engine. Is there a way to do this?
|
|
|
|

|
Try this but no warranty :p
CPerl perl;
...
CScript script = perl.CompileFile("myscript", "myscript.pl");
CStringArray array;
array.Add("all");
array.Add("u PKT");
perl.SetArray(script, "ARGV", array);
perl.Exec(script);
p i x i g r e g
|
|
|
|

|
This is simply an excellent article with a huge hack value!
However, like any good piece of reading, it raises some thoughts.
Would it be possible to attach perl file descriptors to C++ streams (or C file descriptors)? I mean, instead of accessing the script STDOUT as CString, you could attach a C++ stream to it. And the same with STDIN, STDERR and other file descriptors. Something like:
bool CPerl::AttachFileHandle(const CScript& script, LPCSTR szHandleName, ostream& stream);
// ...
ofstream ofile("C:\\foo.txt", std::ios::out);
ifstream ifile("C:\\autoexec.bat", std::ios::in);
CPerl perl;
perl.Load();
CScript script =
perl.Compile("TestScript", "$a = <>;"
"$b = ;"
"print \"foo: $a, $b\\n\";");
AttachFileHandle(script, "STDOUT", ofile);
AttachFileHandle(script, "STDIN", cin);
AttachFileHandle(script, "MYHANDLE", ifile);
|
|
|
|

|
Excellent idea ! That should be possible.
I will think about it
p i x i g r e g
|
|
|
|

|
You can do that for your whole windows app since it does not get stdout, stdin or stderr. I create two pipes, one for stdout and the other for stderr. I spawn two threads to suckup the data from the pipes and funnel them to a window. You can modify the code to use a file handle instead instead of a pipe. You may have do add other include headers, I pulled this code from a larger function in one of my projects, I did not try to compile this code. During initialization: #include <io.h> #include <fcntl.h> #include <ostream.h> #include <process.h> int handlesStdOut[2] = { -1, -1}; int handlesStdErr[2] = { -1, -1}; // Create a pipe for the child process's STDOUT. if (_pipe(handlesStdOut, 4096, _O_TEXT | _O_NOINHERIT) == -1) goto fail; if (_pipe(handlesStdErr, 4096, _O_TEXT | _O_NOINHERIT) == -1) goto fail; // change the stdout to be the pipe _close(1); // stdout _close(2); // stderr _dup2(handlesStdOut[1], 1); _dup2(handlesStdErr[1], 2); _close(handlesStdOut[1]); _close(handlesStdErr[1]); // set Windows std handles so that everything is redirected HANDLE h; h = (HANDLE)_get_osfhandle(1); SetStdHandle(STD_OUTPUT_HANDLE, h); h = (HANDLE)_get_osfhandle(2); SetStdHandle(STD_ERROR_HANDLE, h); // now set the c library stdout and stder // the stdout/stderr were already created // so we set them here. stdout->_file = 1; stderr->_file = 2; // make sure stdout is not buffered setvbuf(stdout, NULL, _IONBF, 0); setvbuf(stderr, NULL, _IONBF, 0);
You can get data from the pipe via: _read(handlesStdOut[0], &ch, sizeof(ch)), you should put this in a separate thread otherwise you get deadlocks when the buffer fills up. Now your application will have stdout and stderr redirected to a pipe under your control. Vladimir. vladimir@winpte.com
|
|
|
|

|
I must admit that I have also been aggravated by the namespace pollution of CPerlWrap, particularly the annoying #defines that keep getting in the way! I have been thinking about reimplementing CPerlWrap to use void * pointers and casting them as needed in the implementation, but you beat me to it.
I will probably still make those changes to CPerlWrap, but I will definitely put pointers to your PXPerl in the code and article.
Very nice! You got a 5 from me. Keep up the good work!
|
|
|
|
|

|
You get a five for that alone - anyone who cna work that into a sentence about/describing programming languages deserves a 5!
"What about a threesome"...I'll be chuckling all the way home tonight on the subway! Thanks
¡El diablo está en mis pantalones! ¡Mire, mire!
Real Mentats use only 100% pure, unfooled around with Sapho Juice(tm)!
|
|
|
|

|
You got my attention by the title.
John
|
|
|
|
|
|

|
Uwe Keim wrote:
To me, the biggest drawback is that you have to ship a separate Perl installation to your customers (I doubt that you can e.g. ship ActiveState for free).
In the demo app (whose link is now fixed), I shipped only the .dll and some required libs. Nothing more is needed. You can run the demo app on any machine, with no Perl installed. It will normally work.
There's no need to ship the complete ActivePerl dist, unless you parse script from user input (like in the demo) and want to provide documentation and all available modules.
And, if you really want to ship a Perl distribution, ActivePerl is not the only one. It is good, but SiePerl is also good ; larger, but under the artistic/GPL license so, you can do almost what you want with it :
"The build [SiePerl] is a compile of free software; you can redistribute it and/or
modify it under the terms of either the GNU General Public License or
the Artistic License."
Download here : http://www.cpan.org/authors/id/G/GR/GRAHAMC/SiePerl-5.8.0-bin-1.0-Win32.INSTALL.exe
Anyway, that's a good point to add in the article. Thanks for this question.
Regards.
p i x i g r e g
|
|
|
|
|
|

|
ooops, my mistake.
This is now repaired.
p i x i g r e g
|
|
|
|
 |
|
|
General News Suggestion Question Bug Answer Joke Rant Admin
|
A comprehensive Perl embedding solution.
| Type | Article |
| Licence | |
| First Posted | 12 Jul 2003 |
| Views | 145,591 |
| Bookmarked | 42 times |
|
|