31 Jul, 2007
Posted by: vinny In: perl
Passing inputs to a POST form in a cgi from the command line (to DProf scripts, etc):
echo “attribute=value1+value2…” | perl -d:DProf scriptname.cgi
Alternately, “attribute=value1+value2…” (no quotes) can be in a file, testfile.txt. Then you just:
perl -d:DProf scriptname.cgi < testfile.txt
Perl 1.0 was released on this day in 1987.
The safest way to do perl one-liners is to wrap the parameters within “” (double-quotes) then use q() and qq() inside the parameters. q() and qq() will put whatever is inside them between single-quotes or double-quotes, respectively.
Taken from the ActiveState Perl winfaq4, but edited so it’s real, actual, readable english (with->will in the second sentence).
Well, sometimes it is. Just not this time. My Symbolic References post has another problem. Deep Recursion. I’m calling my ldapsearch sub, which generates warnings in perl like this:
Deep recursion on subroutine “Net::LDAP::sync” at C:/Perl/site/lib/Net/LDAP/Message.pm line 121, line 283.
Deep recursion on subroutine “Net::LDAP::_recvresp” at C:/Perl/site/lib/Net/LDAP.pm line 695, line 283.
Deep recursion on subroutine “Net::LDAP::Search::decode” [...]
So I’m working on a program to pull some data from a server and I’m trying to save myself some work. I’m recycling code that I wrote a year(ish) ago, I have a good idea (and a diagram) of what I need to accomplish, and I finally have chunks of free time to work on [...]
Still a work in progress, but it works for simple cases
#!/usr/bin/perl -w
use strict;
use Net::LDAP::LDIF;
use Text::ParseWords;
my %omsyntaxmap = (
# items with no mapping in the next hash are not listed here
‘1.3.6.1.4.1.1466.115.121.1.2′ => ‘64′,
‘1.3.6.1.4.1.1466.115.121.1.3′ => ‘64′,
‘1.3.6.1.4.1.1466.115.121.1.4′ => ‘4′,
‘1.3.6.1.4.1.1466.115.121.1.5′ => ‘4′,
[...]
Using the Devel::DProf module, a profile of a perl program can be assembled. Usage is simple:
perl -d:DProf program.pl -arg1 -arg2…
This generates a file called tmon.out in the directory with your perl code. This file can be viewed with ‘dprofpp tmon.out‘. Outout looks like this:
Total Elapsed Time = 36.84173 Seconds
User+System Time = 27.61574 Seconds
Exclusive [...]