Re: using perl in a c code

2003-12-03 Thread R. Joseph Newton
Dan Muey wrote:

> > On Dec 1, 2003, at 6:22 AM, Ramprasad A Padmanabhan wrote:
> > [..]
> > > Instead Can I just embed this perl code  in my c program
> > > I will be happy if someone can give some links to examples
> > on the net
> >
> > 
>
> That is very very sexxy! I was reading the part at:
> http://www.perldoc.com/perl5.6/pod/perlembed.html#Adding-a-Perl-interpreter-to-your-C-program
>
> Which will let you run perl code/file containing perl code supplied as an argument.
> Very cool.
>
> What I was wondering about was how to execute some perl code *inside* the c program 
> instead of takign it via ARGV.
> I  think eval_pv and eval_sv have somethgin to do with it but I'm a bit cloudy there.

HI Dan,

This is probably where you want to focus more, then, because it is [probably] 
critical.  Just taking a sorta wild guess here, I'm going to guess that these are
casts to numerical and string types.  Certainly that distinction underlies the biggest 
difference between Perl and C.  Where Perl abstracts the difference between
number and string, C strictly enforces type differences.  Strings are seen as arrays.  
Anytime you are passing information between perl and C, you have to keep this
distinction in mind.  So if my stab in the dark is on the mark, these two functions 
you cite should be interfaces to that type-specific syntax and declaration
protocol..  Don't know the details, as I haven't ventured into that territory, but 
these may be worthwhile leads to follow up.

Joseph



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



Re: Help access SQL Data using Hashes

2003-12-03 Thread Casey West
Hi.

I'm in the employ of Casey West, a list admin, to assist you with your
question. I've taken the liberty to search Google using the Subject line
you provided in your email to the list. I hope one of the links below
will be of service to you.

Sadly Google hasn't given us a nice, legal API for searching newsgroups,
so you may also want to try these searches.

 http://groups.google.com/groups?q=Perl+Help+access+SQL+Data+using+Hashes
 
http://groups.google.com/groups?q=Help+access+SQL+Data+using+Hashes+group%3Acomp.lang.perl.*

If you didn't get any useful results below, there's a chance your
Subject line was not specific enough, or not detailed enough. For
example, the following subject lines are not very good choices.

  Subject: Doubt
  Subject: HELP!
  Subject: Problem

On the other hand, it's possible that your question is unique, or the
search needs a human touch to get just the right results.

Enjoy!

Perl.org Beginners' Lists, 0 results.
  Searched: site:nntp.x.perl.org inurl:perl.beginners -inurl:show_headers Help access 
SQL Data using Hashes

Perl.org Lists, 1 results.
  Searched: site:nntp.x.perl.org -inurl:show_headers Help access SQL Data using Hashes

  [1] nntp.perl.org - perl.perl6.language.subs (326)
   http://nntp.x.perl.org/group/perl.perl6.language.subs/326
 ... calls all over the place (CGI, tk, SQL wrapper functions ...
 in this realm, the current proto-types are of no help. ... hash is
 really an array with hash-like-access). ...

search.cpan.org, 10 results.
  Searched: site:search.cpan.org Help access SQL Data using Hashes

  [1] NAME DBD::ADO - A DBI driver for Microsoft ADO (Active Data ...
   http://search.cpan.org/src/SGOELDNER/DBD-ADO-2.79/README
 ... arguments, 'function name') You may access the following ...
 Microsoft OLE DB Provider for SQL Server SQLState ... Wiedmann for
 additions, debuggery and general help. ...

  [2] search.cpan.org: DB::Objects - Perl extension to ease creation of ...
   http://search.cpan.org/search%3Fmodule=DB::Objects
 ... were very similar: they all had access methods for ... The
 Help menu with Help topics, an optional upgrade ... the DB }
 $sth->finish; # Finished with SQL return $self ...

  [3] WebTool Help
   http://search.cpan.org/src/JLISHEV/WebTools-1.27/docs/HELP.html
 ... User name used to connect SQL server $webtools ... Note: If
 your visitors use proxy toaccess your scripts ... functions and
 WebTools itself are released to help and to ...

  [4] NAME DBD::ADO - A DBI driver for Microsoft ADO (Active Data ...
   http://search.cpan.org/src/SGOELDNER/DBD-ADO-2.81/README
 ... func_name ) or die ...; You may access the following ...
 Microsoft OLE DB Provider forSQL Server SQLState ... Wiedmann for
 additions, debuggery and general help. ...

  [5] search.cpan.org: DBIx::FileSystem - Manage tables like a ...
   http://search.cpan.org/search%3Fmodule=DBIx::FileSystem
 ... Then start your favourite SQL editor and manually change the
 database layout according to %vdirs. ... Requires write access to
 the directory. ... Usage: 'help [command ...

  [6]   NAME DBIx::TableHash - Tie a hash ...
   http://search.cpan.org/src/CHTHORMAN/DBIx-TableHash-1.04/README
 ... >create_copy($Params) or die "Help!"; my ...
 store into the tied hash!) Toaccess only a ... retrieval of data
 results in corresponding SQL queries being ...

  [7] NAME DBD::CSV - DBI driver for CSV files SYNOPSIS use DBI; $dbh = ...
   http://search.cpan.org/src/JWIED/DBD-CSV-0.1030/README
 ... and column number from the programmer: For example MS Access
 doesn't ... 3) manpage, the Text::CSV_XS(3) manpage, the
 SQL::Statement(3) manpage For help on the ...

  [8] search.cpan.org: PApp::SQL - absolutely easy yet fast and ...
   http://search.cpan.org/search%3Fmodule=PApp::SQL
 ... a lot more gimmicks to play around with to help you create ...
 The PApp::SQL::Database class does that, in a ... is currently a
 single method call per access (you can ...

  [9] search.cpan.org: DBD::CSV - DBI driver for CSV files
   http://search.cpan.org/search%3Fmodule=DBD::CSV
 ... and column number from the programmer: For example MS Access
 doesn't ... DBI(3), Text::CSV_XS(3),SQL::Statement(3). For help on
 the use of DBD::CSV, see the DBI ...

  [10]   NAME DBD::CSV - DBI driver for ...
   http://search.cpan.org/src/JZUCKER/DBD-CSV-0.2002/README
 ... and column number from the programmer: For example MS Access
 doesn' ... 3) manpage, the Text::CSV_XS(3) manpage, the
 SQL::Statement(3) manpage For help on the ...

Google Search, 10 results.
  Searched: Perl Help access SQL Data using Hashes

  [1] Arlene's Homepage
   http://www.cse.msu.edu/~zenglinf/htmlfiles/resume.htm
 ... Da

Help access SQL Data using Hashes

2003-12-03 Thread Patrick Shoaf
I am retrieving the following data from MySQL.  I need to access the data 
via some sort of Hash or Array.  I need to take this data and create a web 
page using some some of the data to create Java Script Arrays, while the 
rest is simply display on the web page.  Any all help is appreciated...

DATA:
Itm1,Red,S,1.00
Itm1,Red,M,1.00
Itm1,Red,L,1.50
Itm1,Grn,S,1.00
Itm1,Grn,M,1.00
Itm1,Grn,L,1.25
Itm1,Grn,XL,1.50
Itm2,Red,S,2.00
Itm2,Red,M,2.00
Itm2,Red,L,2.50
Itm2,Brn,S,2.00
Itm2,Brn,M,2.00
Itm2,Brn,L,2.25
Itm2,Brn,XL,2.50
I would need from the above sample the following outputs:

Itm1 - (Color Drop Down) - (Size Drop Down) - Price
I have Java scripts that auto change Size Drop Down and Price using Java 
Script Arrays.

I need in perl a way to create a hash/array/etc so that I can access get
 - All Unique colors for Itm1 individually through a loop (for color drop 
down)
 - All Sizes for Itm1,Color1 individually for a Java Script Array for each 
item
 - All Prices for Itm1,Color1 individually for a Java Script Array for 
each item

Patrick Shoaf
[EMAIL PROTECTED]

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


Re: Timing several processes

2003-12-03 Thread drieux
On Dec 3, 2003, at 5:01 PM, Wiggins d'Anconia wrote:
[..]
it might be a framework you could rip off
and use:

Have we come back to POE?  POE.

;-)
who knows, after a bit of work the OP may decide that
the 400m of downloadable free software framework from
source forge will help him over more things than he
would want to Shake a Stick At.
But first things first, show them some chunky code
that they can futz around with. Keep pointing them
back into the other stuff, and raising flags as to
why that might be simpler...
There are always going to be trade offs, as you noticed
over on the cgi-beginner's with whether the 'thunking'
of Autoloadables et al is worth the time it takes, or
should one just buy all of that overhead in one bang
at start up and  and and...
So FribNark, I Tried to invoke

	&POE::Pipe::_stop_blocking($my_back_side);

but I am still constipated

what did I do wrong?

8-)

ciao
drieux
---

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


Re: Timing several processes

2003-12-03 Thread Wiggins d'Anconia
drieux wrote:


So while you are in the process of learning
fork() and exec() why not think a bit more
agressively and go with say a pipe to pass
back the information so as not to buy
the IO overhead of writing to files?
While the following was written for a command
line 'let us get interactive' type of solution,
it might be a framework you could rip off
and use:


Have we come back to POE?  POE.

;-)

http://danconia.org

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


Re: Bio::MAGE

2003-12-03 Thread Wiggins d'Anconia
Sebastian Jünemann wrote:
Hi List!

Im new in Perl and just starting with a big Mission...
I have to use teh Bio::MAGE Modul to Parse Mage-ML Files ( these ar 
eXML-Files) and put them in a SQL DB!
But this Modul is really huge and  besides i must modify they due to we 
use 02DBI instead of the included SQL.pm!
So my question: Do anyone of you ever get near with on eof this Classes 
and know how the work and how to use them?
I've already gooled and searched at cpan and perl org ...but whithout a 
Conclusion!

thx a lot
I suspect though don't guarantee that you might get better or at least 
more help on: [EMAIL PROTECTED]

Haven't been given the opportunity to properly explore the Bio:: space 
yet, damn finicky recruiters seem to only want PhDs. Just because I only 
had one bio class in college and have an econ degree, geez... ;-)

http://danconia.org

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


Re: Crypt::CBC

2003-12-03 Thread Wiggins d'Anconia


Phil Schaechter wrote:
What am I doing wrong?   I encrypt a tar file and immediatly decrypt it (in a 
different function, however) and it is a totally borked file upon decryption.  
I've basically copy-pasted the example from Crypt:CBC.  The only clue I have 
is this warning:

Use of uninitialized value in pack at 
/usr/local/lib/perl5/site_perl/5.8.0/Crypt/CBC.pm line 213,  line 3.

using this:

--- encryption 
 $cipher = Crypt::CBC->new( {'key' => $password,
  'cipher'  => 'Blowfish',
  'padding' => 'standard',
   });
open(in, "$ws/$$.new/$$.tar") || die;
open(out, ">$newname") || die;
$cipher->start('encrypting');

   while (read(in, $buf, 1024 ) )
  {
  print out $cipher->crypt($buf);
  }
print out $cipher->finish;

close(in);
close(out);
-- decryption 

$cipher = Crypt::CBC->new( {'key' => $password,
   'cipher'  => 'Blowfish',
   'padding' => 'standard',
  });
open (in, $cryptfile) || die;
open (out, ">$workspace/$$") || die;
$cipher->start('decrypting');

while (read(in, $buf, 1024 ) )
  {
  print out $cipher->decrypt($buf);
  }
print out $cipher->finish;
close(in);
close(out);
The warning that is given comes from the "finish" call while decrypting in the 
Crypt:CBC module:

sub finish (\$) {
my $self = shift;
my $bs = $self->{'blocksize'};
my $block = $self->{'buffer'};
$self->{civ} ||= '';

my $result;
if ($self->{'decrypt'}) { #decrypting
$block = pack("a$bs",$block); # pad and truncate to block size
*snip*

I just don't see what (if anything) I'm doing wrong.  Since the comment 
appears to be talking about padding, I've tried a few different padding 
options with crypt:cbc, all with the same result.
I agree that seems baffling, code looks right. I am curious how the 
'read' and in particular the size of the tar might be affecting things. 
It appears that 'read' will buffer whatever is being read (at least that 
is my understanding of the perldoc for it), if that buffer were then 
encrypted/decrypted and tacked back onto the tar file it seems that it 
might be corrupted by the padding??  So some tests (if you haven't 
already), try to just encrypt/decrypt a string of text, then a plain 
text file, then try without doing the 1024 buffered read, slurp the file 
or a smaller version tar file into a single scalar and see if that 
works.  The only thing odd to me is the warning message you provided, 
which would indicate that something still thinks there is data to 
decrypt/encrypt when there really isn't since we know the $bs is set 
otherwise it would have croak'd earlier.  The way CBC uses pack to build 
its block list has me curious how it would interact with any padding 
'read' does.

HTH, suppose its good *and* bad that I couldn't point out something 
obvious, sorry

http://danconia.org

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


Re: Timing several processes

2003-12-03 Thread drieux
On Dec 3, 2003, at 10:49 AM, Akens, Anthony wrote:
[..]
print "Running vmstat\n";
defined(my $vmstat_pid = fork) or die "Cannot fork: $!";
unless ($vmstat_pid) {
  exec "vmstat 5 5 > /log/monitor/delta/vmstat.out";
  die "cannot exec vmstat: $!";
}
print "Running sar\n";
defined(my $sar_pid = fork) or die "Cannot fork: $!";
unless ($sar_pid) {
  exec "sar 5 5 > /log/monitor/delta/sar.out";
  die "cannot exec date: $!";
}
print "Waiting...\n";
waitpid($vmstat_pid, 0);
waitpid($sar_pid, 0);
print "done!\n";
[..]

I presume you are working on a solaris box?
have you thought about
timex sar 5 5
timex vmstat 5 5
and you will notice that the sar command will
take about 25 seconds and the vmstat about 20.
but then there is that minor nit about

exec "vmstat 5 5 > /log/monitor/delta/vmstat.out"
or  die "cannot exec vmstat: $!";
since in theory exec WILL not return, so if it failed
why not keep it in the proper context...
Then there is that Minor Nit about not controlling 'stderr'
which can lead to things like:
vladimir: 60:] ./st*.plx
Running vmstat
Running sar
sh: /log/monitor/delta/vmstat.out: cannot create
sh: /log/monitor/delta/sar.out: cannot create
Waiting...
done!
vladimir: 61:]
So while you are in the process of learning
fork() and exec() why not think a bit more
agressively and go with say a pipe to pass
back the information so as not to buy
the IO overhead of writing to files?
While the following was written for a command
line 'let us get interactive' type of solution,
it might be a framework you could rip off
and use:




ciao
drieux
---

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


Re: using perl in a c code

2003-12-03 Thread drieux
On Dec 3, 2003, at 3:17 PM, Dan Muey wrote:
[..]
Doh! I was on 5.5, 5.8 just worked for me to, 5.6.1 also!
just wait until you have to remember,

did this work with gcc2.X or only with gcc3.Y...
and how exactly did I get it to build for the DogBertOS???
Before you get too lost, you may want to start into
learning how 'make' works so that you can simply do
make
make test
make bug_fix
make the_right_way
make with_fewer_bugs
make again_and_again
It will help you with your project builds...

Great! Awesome! Perfect! One little catch now is
it'd be nice to just do ./test  or ./test name=value&name2=val2 
instead of
./test -e ''
Or ./test

Oh sure, now you need to learn how to

a. parse char **argv by hand
b. deal with tweeking char **env
You wanted to give up a Perfectly LOVELY

	Getopt::Long

cultural heritage to go throwing waka-waka
just to impress young women with your studly
cross coding, uh, "issues"???
I'll have to look into that, I know it has something to
do with perl_parse() and #include stdio I just don't know the 
details...yet :)
Think THERAPY!

ciao
drieux
---

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


RE: using perl in a c code

2003-12-03 Thread david
Dan Muey wrote:

[snip]

> Doh! I was on 5.5, 5.8 just worked for me to, 5.6.1 also!
> Great! Awesome! Perfect! One little catch now is
> it'd be nice to just do ./test  or ./test name=value&name2=val2 instead of
> ./test -e ''
> Or ./test
> 

this can easily be solve by adding:

char* nothing[] = {"","-e1"};

along the top of the program and then change:

>>perl_parse(my_perl, NULL, argc, argv, (char **)NULL);

to:

perl_parse(my_perl, NULL, 2, nothing, (char **)NULL);

david
-- 
s,.*,<<,e,y,\n,,d,y,.s,10,,s
.ss.s.s...s.sss.s.ss
s.s.s...s...s..s
...s.ss..s.sss..ss.sss.s
s.s.s...ss.sss.s
..s..sss.s.ss.sss...
..ssss.sss.sss.s

,{4},"|?{*=}_'y!'+0!$&;"
,ge,y,!#:$_(-*[./<[EMAIL PROTECTED],b-t,
.y...,$~=q~=?,;^_#+?{~,,$~=~
y.!-&*-/:[EMAIL PROTECTED] ().;s,;,
);,g,s,s,$~s,g,y,y,%,,g,eval

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



RE: using perl in a c code

2003-12-03 Thread Dan Muey

> Dan Muey wrote:
> 
> [snip]
> 
> > /* From David
> >printf("%s",SvPV_nolen(eval_pv(perlcode,0)));
> > at compile:
> > cc -o perlemb perlemb.c `perl -MExtUtils::Embed -e ccopts -e ldopts`
> > /tmp/ccTi5bTD.o: In function `main':
> > /tmp/ccTi5bTD.o(.text+0x77): undefined reference to `eval_pv'
> > /tmp/ccTi5bTD.o(.text+0x82): undefined reference to `SvPV_nolen' */
> >perl_destruct(my_perl);
> >perl_free(my_perl);
> > }
> 
> i don't have a version of xsubpp that matches your version. i have a 
> slightly better one and i don't have any problem compiling 
> the following:
> 
> #include 
> #include 
> 
> static PerlInterpreter *my_perl;
> static const char *perlcode =
> "use CGI 'header';print header();print 'hello World';";
> 
> main (int argc, char **argv, char **env)
> {
>SV* code;
> 
>my_perl = perl_alloc();
>perl_construct( my_perl );
> 
>perl_parse(my_perl, NULL, argc, argv, (char **)NULL);
> 
>perl_run(my_perl);
> 
>code = eval_pv(perlcode,0);
> 
>printf("%s", SvPV_nolen(code));
> 
>perl_destruct(my_perl);
>perl_free(my_perl);
> }
> 
> [panda]# cc test.c -o test `perl -MExtUtils::Embed -e ccopts 
> -e ldopts` [panda]#
> 
> your xsubpp came with Perl v5.6.0, yes? i will try to find a 
> machine with 
> 5.6.0 and see what happen.

Doh! I was on 5.5, 5.8 just worked for me to, 5.6.1 also!
Great! Awesome! Perfect! One little catch now is 
it'd be nice to just do ./test  or ./test name=value&name2=val2 instead of 
./test -e ''
Or ./test


I'll have to look into that, I know it has something to 
do with perl_parse() and #include stdio I just don't know the details...yet :)

Thanks for the help David very cool stuff, as I said to 
someone else about this it's kind of a Rube Goldburg experiment!


> 
> david

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



Re: Crypt::CBC

2003-12-03 Thread Casey West
Hi.

I'm in the employ of Casey West, a list admin, to assist you with your
question. I've taken the liberty to search Google using the Subject line
you provided in your email to the list. I hope one of the links below
will be of service to you.

Sadly Google hasn't given us a nice, legal API for searching newsgroups,
so you may also want to try these searches.

 http://groups.google.com/groups?q=Perl+Crypt%3A%3ACBC
 http://groups.google.com/groups?q=Crypt%3A%3ACBC+group%3Acomp.lang.perl.*

If you didn't get any useful results below, there's a chance your
Subject line was not specific enough, or not detailed enough. For
example, the following subject lines are not very good choices.

  Subject: Doubt
  Subject: HELP!
  Subject: Problem

On the other hand, it's possible that your question is unique, or the
search needs a human touch to get just the right results.

Enjoy!

Perl.org Beginners' Lists, 2 results.
  Searched: site:nntp.x.perl.org inurl:perl.beginners -inurl:show_headers Crypt::CBC

  [1] nntp.perl.org - perl.beginners (56119)
   http://nntp.x.perl.org/group/perl.beginners/56119
 ... Previous | Next | Toggle headers Newsgroups: perl.beginners
 Date: Thu, 27 Nov 2003 12:37 ... have a copy of Lincoln > Stein's
 (He wrote the Crypt::CBC module, among ...

  [2] nntp.perl.org - perl.beginners (56114)
   http://nntp.x.perl.org/group/perl.beginners/56114
 ... 0500 To: Philipp Traeder  Cc:
 perl beginners http://nntp.x.perl.org/group/perl.crypto/49
 ... 08:08:51 -0400 To: Toby Stuart
  CC: "'perl-crypto[at]perl.org'"
  Subject: Re: FW: Crypt::CBC w/Crypt ...

  [2] nntp.perl.org - perl.crypto (4)
   http://nntp.x.perl.org/group/perl.crypto/4
 ... pair.com> <[EMAIL PROTECTED]>
 <[EMAIL PROTECTED]> From:
 dparis[at]w3works.com (Dave Paris) Actually, Crypt::CBC uses a ...

  [3] nntp.perl.org - perl.crypto (5)
   http://nntp.x.perl.org/group/perl.crypto/5
 ... ID: <[EMAIL PROTECTED]> From:
 ben[at]rhumba.pair.com (Benjamin Trott) References:
 <[EMAIL PROTECTED]> > Actually, Crypt::CBC uses a ...

  [4] nntp.perl.org - perl.daily.news (681)
   http://nntp.x.perl.org/group/perl.daily.news/681
 ... Allopass-1.04 -- A class for micro-payment system from
 Allopass * [9]Config-IniFiles-Import-0.901 *
 [10]Crypt-Anubis-1.0.4 -- Crypt::CBC-compliant block cipher ...

  [5] nntp.perl.org - perl.crypto (48)
   http://nntp.x.perl.org/group/perl.crypto/48
 ... Message-ID:
 <[EMAIL PROTECTED]> To:
 "'perl-crypto[at]perl.org'"  Subject: FW:
 Crypt::CBC w/Crypt ...

  [6] nntp.perl.org - perl.crypto (3)
   http://nntp.x.perl.org/group/perl.crypto/3
 ... One > thing is that Crypt::CBC takes the last byte of the last
 block in the > decrypted data and treats it as an integer telling
 it how much of the last ...

  [7] nntp.perl.org - perl.crypto (46)
   http://nntp.x.perl.org/group/perl.crypto/46
 ... Erik #!/usr/bin/perl -w use IO::Socket; use Crypt::CBC; my
 $key = $ARGV[0]; $sock = new IO::Socket::INET (PeerAddr =>
 'localhost', PeerPort => 1200, Proto ...

  [8] nntp.perl.org - perl.crypto
   http://nntp.x.perl.org/group/perl.crypto
 ... 0800, 89. 49, Re: FW: Crypt::CBC w/Crypt-DES,
 dparis#w3works.com, Wed, 23 Oct 2002 08:08:51 -0400, 105. 48, FW:
 Crypt::CBC w/Crypt-DES, toby ...

  [9] nntp.perl.org - perl.crypto (25)
   http://nntp.x.perl.org/group/perl.crypto/25
 ... Previous | Next | Toggle headers Newsgroups: perl.crypto
 Subject: Crypt::CBC 2.02 not using supplied init vector To: Perl
 Asymmetric Cryptography List http://nntp.x.perl.org/group/perl.cpan.testers/32399
 ... effort. -- Crypt::CBC and some other Crypt modules (this is
 also the case with Crypt::DES) seem to be having problems
 inter-relating. ...

search.cpan.org, 10 results.
  Searched: site:search.cpan.org Crypt::CBC

  [1] search.cpan.org: Lincoln D. Stein / Crypt-CBC
   http://search.cpan.org/search?dist=Crypt-CBC
 Lincoln D. Stein > Crypt-CBC. Crypt-CBC. This Release,
 Crypt-CBC-2.08, ... Modules.Crypt::CBC, Encrypt Data with Cipher
 Block Chaining Mode, 2.08. 

  [2] search.cpan.org: Crypt::CBC - Encrypt Data with Cipher Block ...
   http://search.cpan.org/search%3Fmodule=Crypt::CBC
 Lincoln D. Stein > Crypt-CBC-2.08 > Crypt::CBC. Module Version:
 2.08 Source: ...

  [3] search.cpan.org: Crypt::Loki97 - Crypt::CBC compliant block ...
   http://search.cpan.org/search%3Fmodule=Crypt::Loki97
 ... NAME ^. Crypt::Loki97 - Crypt::CBC compliant block cipher.
 SYNOPSIS ^. ... This module supports the Crypt::CBC interface,
 with the following functions. Functions. ...

  [4] search.cpan.org: Crypt::Rainbow - Crypt::CBC-compliant block ...
   http://sea

Crypt::CBC

2003-12-03 Thread Phil Schaechter
What am I doing wrong?   I encrypt a tar file and immediatly decrypt it (in a 
different function, however) and it is a totally borked file upon decryption.  
I've basically copy-pasted the example from Crypt:CBC.  The only clue I have 
is this warning:

Use of uninitialized value in pack at 
/usr/local/lib/perl5/site_perl/5.8.0/Crypt/CBC.pm line 213,  line 3.

using this:

--- encryption 
 $cipher = Crypt::CBC->new( {'key' => $password,
  'cipher'  => 'Blowfish',
  'padding' => 'standard',
   });

open(in, "$ws/$$.new/$$.tar") || die;
open(out, ">$newname") || die;

$cipher->start('encrypting');

   while (read(in, $buf, 1024 ) )
  {
  print out $cipher->crypt($buf);
  }

print out $cipher->finish;

close(in);
close(out);

-- decryption 

$cipher = Crypt::CBC->new( {'key' => $password,
   'cipher'  => 'Blowfish',
   'padding' => 'standard',
  });

open (in, $cryptfile) || die;
open (out, ">$workspace/$$") || die;

$cipher->start('decrypting');

while (read(in, $buf, 1024 ) )
  {
  print out $cipher->decrypt($buf);
  }

print out $cipher->finish;
close(in);
close(out);


The warning that is given comes from the "finish" call while decrypting in the 
Crypt:CBC module:

sub finish (\$) {
my $self = shift;
my $bs = $self->{'blocksize'};
my $block = $self->{'buffer'};

$self->{civ} ||= '';

my $result;
if ($self->{'decrypt'}) { #decrypting
$block = pack("a$bs",$block); # pad and truncate to block size

*snip*

I just don't see what (if anything) I'm doing wrong.  Since the comment 
appears to be talking about padding, I've tried a few different padding 
options with crypt:cbc, all with the same result.

-Phil

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



RE: using perl in a c code

2003-12-03 Thread david
Dan Muey wrote:

[snip]

> /* From David
>printf("%s",SvPV_nolen(eval_pv(perlcode,0)));
> at compile:
> cc -o perlemb perlemb.c `perl -MExtUtils::Embed -e ccopts -e ldopts`
> /tmp/ccTi5bTD.o: In function `main':
> /tmp/ccTi5bTD.o(.text+0x77): undefined reference to `eval_pv'
> /tmp/ccTi5bTD.o(.text+0x82): undefined reference to `SvPV_nolen' */
>perl_destruct(my_perl);
>perl_free(my_perl);
> }

i don't have a version of xsubpp that matches your version. i have a 
slightly better one and i don't have any problem compiling the following:

#include 
#include 

static PerlInterpreter *my_perl;
static const char *perlcode =
"use CGI 'header';print header();print 'hello World';";

main (int argc, char **argv, char **env)
{
   SV* code;

   my_perl = perl_alloc();
   perl_construct( my_perl );

   perl_parse(my_perl, NULL, argc, argv, (char **)NULL);

   perl_run(my_perl);

   code = eval_pv(perlcode,0);

   printf("%s", SvPV_nolen(code));

   perl_destruct(my_perl);
   perl_free(my_perl);
}

[panda]# cc test.c -o test `perl -MExtUtils::Embed -e ccopts -e ldopts`
[panda]#

your xsubpp came with Perl v5.6.0, yes? i will try to find a machine with 
5.6.0 and see what happen.

david
-- 
s,.*,<<,e,y,\n,,d,y,.s,10,,s
.ss.s.s...s.sss.s.ss
s.s.s...s...s..s
...s.ss..s.sss..ss.sss.s
s.s.s...ss.sss.s
..s..sss.s.ss.sss...
..ssss.sss.sss.s

,{4},"|?{*=}_'y!'+0!$&;"
,ge,y,!#:$_(-*[./<[EMAIL PROTECTED],b-t,
.y...,$~=q~=?,;^_#+?{~,,$~=~
y.!-&*-/:[EMAIL PROTECTED] ().;s,;,
);,g,s,s,$~s,g,y,y,%,,g,eval

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



Re: Reading files

2003-12-03 Thread drieux
On Dec 3, 2003, at 7:44 AM, [EMAIL PROTECTED] wrote:

how can I dup file handles
do you mean:

   open(LOG, ">>/tmp/logfile");
   open(STDERR, ">&LOG");
hence you code is One $ over the line?

#!/usr/bin/perl -w
use strict; # this would help you with finding those
# nasty bits where you have variables not set...
$file="./text";
$|=1;
use Fcntl;
use IO::Handle;
	$D_LOG = $ENV{MHCONTEXTFD};

open(LOG, "< logfile");
open($D_LOG, "<&LOG");
$LOG->autoflush(1);
$D_LOG->autoflush(1);
$line1=<$LOG>;
$line2=<$D_LOG>;
	print "1:$line1 2:$line2";

HTH.

ciao
drieux
---

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


RE: using perl in a c code

2003-12-03 Thread Dan Muey
Thank yu Tassilo and David for your insights!!

>
> 
> Maybe I can also point you to [EMAIL PROTECTED] If you want
> to do the occasional XS or embedding, this mailing-list is 
> the right place to consult.

I may do that, thanks!


Ok heres what 


#include 
#include 

static PerlInterpreter *my_perl;

main (int argc, char **argv, char **env)
{
   const char *perlcode = "use CGI 'header'; print header();print 'hello World';";

   my_perl = perl_alloc();
   perl_construct( my_perl );

   perl_parse(my_perl, NULL, argc, argv, (char **)NULL);

   perl_run(my_perl); /* this line will execute cmd line perl  */

   printf(perlcode); /* this line successfully prints the Perl code above out */
/* Leave the comments below in place and it compiles fine, uncomment them and you get 
the results I've put below each one */
/* From Tassilo
   STRLEN n_a;
   SV *res = eval_pv(perlcode);
   printf("%s", SvPV(res, n_a));
at compile:
cc -o perlemb perlemb.c `perl -MExtUtils::Embed -e ccopts -e ldopts`  
perlemb.c: In function `main':
perlemb.c:19: syntax error before `n_a'
perlemb.c:21: `res' undeclared (first use in this function)
perlemb.c:21: (Each undeclared identifier is reported only once
perlemb.c:21: for each function it appears in.)
perlemb.c:21: `n_a' undeclared (first use in this function)
*/
/* From David
   printf("%s",SvPV_nolen(eval_pv(perlcode,0)));
at compile:
cc -o perlemb perlemb.c `perl -MExtUtils::Embed -e ccopts -e ldopts`  
/tmp/ccTi5bTD.o: In function `main':
/tmp/ccTi5bTD.o(.text+0x77): undefined reference to `eval_pv'
/tmp/ccTi5bTD.o(.text+0x82): undefined reference to `SvPV_nolen' */
   perl_destruct(my_perl);
   perl_free(my_perl);
}


Any ideas what I need to do to resolve those errors? (Besdies going elsewhere ;p )

TIA

Dan

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



RE: remove control chars

2003-12-03 Thread Kipp, James
THanks. worked fine as well !


> -Original Message-
> From: John W. Krahn [mailto:[EMAIL PROTECTED]
> Sent: Wednesday, December 03, 2003 4:24 PM
> To: [EMAIL PROTECTED]
> Subject: Re: remove control chars
> 

> 
> Including "\t" and "\n"?
> 
> 
> > Is the perl getc() function the best way to look at one 
> char at a time?
> 
> In any language doing it one character at a time is not the best way.
> 
> perl -i.bak -pe's/[[:cntrl:]]/ /g' file1 file2 file*
> 
> If you don't want to include "\t" and "\n" in that:
> 
> perl -i.bak -pe's/[^\t\n[:^cntrl:]]/ /g' file1 file2 file*
> 
> 
 


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



Re: first steps - read from files and make linklist

2003-12-03 Thread Stephan Hochhaus
Hello Bob,

thanks a lot for your help!

read the documentation and you'll see that the basename() function can
remove extensions as well.
Done that :-)

The final app looks like this:

#!/usr/bin/perl
use strict;
use diagnostics;
use File::Basename;
fileparse_set_fstype( 'Unix' );

#HTML blah blah
print "Content-type: text/html\n\n";
print "\n";
print "My Links\n";

print "My Links\n";

#reading filenames
my @filenames = glob "./data/*";
#sort filenames, I wonder if this is neccessary at all
@filenames = sort @filenames;
#create the links
my $name;
foreach my $filename (@filenames) {
   open(FILE, $filename) or die "cannot open $filename!\n";
   $name = fileparse($filename,'\..*');
   print "$name\n";
   while () {
  #read every line and format it properly
  chomp;
  my @hyperlink = split /\t/;
  print "$hyperlink[0] - ";
  print "$hyperlink[1]\n";
  }
   print "\n";
   close FILE ;
   }

print "";

Next thing on my todo list is to be able to sort the links inside the 
data files alphabetically, either in the static txt files or in the 
resulting cgi file on my webserver, but that's something for a new day, 
I feel this will be a little more complicated. But then again, 
eventually I will come back and ask if I'm stuck :-)

Thanks a lot for all people who cared to read my postings and helped me 
one way or the other.

Stephan - soon-to-be-Perl-Guru

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


Re: remove control chars

2003-12-03 Thread John W. Krahn
James Kipp wrote:
> 
> Hi

Hello,

> I have some C code that I need to convert to perl and I am pressed for time,
> which is why I am posting this.  All the code does is read each character
> from either STDIN or a file and replaces any ASCII control characters with a
> space.

Including "\t" and "\n"?


> Is the perl getc() function the best way to look at one char at a time?

In any language doing it one character at a time is not the best way.

perl -i.bak -pe's/[[:cntrl:]]/ /g' file1 file2 file*

If you don't want to include "\t" and "\n" in that:

perl -i.bak -pe's/[^\t\n[:^cntrl:]]/ /g' file1 file2 file*



John
-- 
use Perl;
program
fulfillment

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



RE: remove control chars

2003-12-03 Thread Kipp, James
> Thanks. For some reason, this is not working like the C code 
> is ( my desired result)
> 
> C:
> echo   | cvt 
> adc def
> hij
> 
> Perl:
> echo "abc^Hdef\nhij"  | perl -pe 'tr/\040-\176\n/ /c' 
> abc^Hdef
> hij


> perl -pi.bak -e 'tr/\040-\176\n/ /c' file

> That'll change all characters that are NON between 0040 and 0176 and \n
> into spaces.

woops, never mind. It works fine. I stuck a real backpsace char in there by
unsetting my stty setttings and it worked. 
echo "aaa\b^Hb\na" | test.pl
aaa  b
a

THANKS JEFF AND ALL WHO HELPED!!!

Jim


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



RE: remove control chars

2003-12-03 Thread Kipp, James
> >if ( (ch<=0176) && (ch>=040) || (ch=='\n') ) {
> >  putc( ch, stdout );
> >} else {
> >  putc( ' ', stdout );
> >}
> >  }
> 
>   perl -pi.bak -e 'tr/\040-\176\n/ /c' file
> 

Thanks. For some reason, this is not working like the C code is ( my desired
result)

C:
echo | cvt 
adc def
hij

Perl:
echo "abc^Hdef\nhij"  | perl -pe 'tr/\040-\176\n/ /c' 
abc^Hdef
hij





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



RE: Timing several processes

2003-12-03 Thread Akens, Anthony
It seems as if my example was doing what it was intended to do, the
"problem" was in the exec for sar...

It seems that using redirection with the sar command is a little
different then I expected... it does not write anything to the
output file until it is finished.

As for the "Waiting..." line not showing up, when I had done my
testing I had left out the /n  - which caused it not to print until
later.  Once I added the /n (as you see in the code below) it printed
when I expected it to.

Thanks for the help...

-Tony

-Original Message-
From: Akens, Anthony 
Sent: Wednesday, December 03, 2003 1:50 PM
To: Wiggins d Anconia; Tom Kinzer; [EMAIL PROTECTED]
Subject: RE: Timing several processes


Here's the sample code I'm trying...  In essence I would expect to see
The following output:

Running vmstat
Running sar
Waiting...  (at this point a long wait while sar and vmstat finish)
Done!


Instead I am seeing:
Running vmstat
Running sar  (The long wait is here)
Waiting...
Done!


In watching the file sizes, I can see both files are created at the Same
time, but sar does not produce any output in its file until Vmstat
finishes.

-Tony

#!/usr/bin/perl -w

use strict;

print "Running vmstat\n";
defined(my $vmstat_pid = fork) or die "Cannot fork: $!";
unless ($vmstat_pid) {
  exec "vmstat 5 5 > /log/monitor/delta/vmstat.out";
  die "cannot exec vmstat: $!";
}
print "Running sar\n";
defined(my $sar_pid = fork) or die "Cannot fork: $!";
unless ($sar_pid) {
  exec "sar 5 5 > /log/monitor/delta/sar.out";
  die "cannot exec date: $!";
}
print "Waiting...\n";
waitpid($vmstat_pid, 0);
waitpid($sar_pid, 0);
print "done!\n";

-Original Message-
From: Wiggins d Anconia [mailto:[EMAIL PROTECTED] 
Sent: Wednesday, December 03, 2003 1:31 PM
To: Akens, Anthony; Tom Kinzer; [EMAIL PROTECTED]
Subject: RE: Timing several processes


I was going to suggest POE as well, 'til I saw that little word 'simple'
:-)...

Have you read:

perldoc perlipc
perldoc -f fork
perldoc -f wait
perldoc -f waitpid

Of course POE is what makes keeping track of all those spun off
processes trivial, but learning it is I will admit not trivial...

http://danconia.org

> I already have some ideas for how I want to build the page, how to 
> parse the data I will generate, etc.
> 
> As I said, I've looked at some of the other tools out there, and want 
> to stick to some simple perl code to parse out the information and 
> return the results.
> 
> The only bit I'm not sure of is how to tell if all forked processes 
> have completed before moving on.
> 
> 
> -Tony
> 
> -Original Message-
> From: Tom Kinzer [mailto:[EMAIL PROTECTED]
> Sent: Wednesday, December 03, 2003 12:35 PM
> To: [EMAIL PROTECTED]
> Subject: RE: Timing several processes
> 
> 
>  http://poe.perl.org
> 
> Maybe this would be a good job for POE?
> 
> -Tom Kinzer
> 
> 
> -Original Message-
> From: Akens, Anthony [mailto:[EMAIL PROTECTED]
> Sent: Wednesday, December 03, 2003 7:49 AM
> To: [EMAIL PROTECTED]
> Subject: Timing several processes
> 
> 
> Hi all!
> 
> I'm wanting to write a simple web-based tool to see the status of
> several servers at a glance.  I know there are many solutions 
> existing, but I can't learn as much about perl by just using one of 
> those as I can by writing my own.  The first step I want to do is call

> a script from cron that runs several basic monitoring tools (sar,
> vmstat, df, iostat, etc) and saves the output of each to a file. Then 
> I'd parse those files up, and write a summary file.
> 
> Easy enough.  And I could certainly do it with by calling the tools
> one at a time.  However, I'd like to get roughly 1 minute of vmstat, 
> iostat, and sar output Simultaneously.  So I'm supposing I'd want 
> to fork off each process, and then when those are all done come back 
> and run a script that then parses those results out for the individual

> statistics I'm looking for.
> 
> I've never used fork before, and while it looks fairly straight
> forward what I am not sure of is how to make sure all of those forked 
> processes have completed before moving on and parsing the files.
> 
> Any pointers?
> 
> Thanks in advance
> 
> -Tony
> 


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


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


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



Re: remove control chars

2003-12-03 Thread Jeff 'japhy' Pinyan
On Dec 3, Kipp, James said:

>Is the perl getc() function the best way to look at one char at a time?

The C way is always never the Perl way.

>  while ( !feof(fin) ) {
>ch=getc(fin);
>
>if ( (ch<=0176) && (ch>=040) || (ch=='\n') ) {
>  putc( ch, stdout );
>} else {
>  putc( ' ', stdout );
>}
>  }

  perl -pi.bak -e 'tr/\040-\176\n/ /c' file

That'll change all characters that are NON between 0040 and 0176 and \n
into spaces.

-- 
Jeff "japhy" Pinyan  [EMAIL PROTECTED]  http://www.pobox.com/~japhy/
RPI Acacia brother #734   http://www.perlmonks.org/   http://www.cpan.org/
 what does y/// stand for?   why, yansliterate of course.
[  I'm looking for programming work.  If you like my work, let me know.  ]


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



RE: remove control chars

2003-12-03 Thread Kipp, James
> > 
> > Is the perl getc() function the best way to look at one char at a
> > time? 
> > 
> > The C code looks like below. I have some ideas but I am not sure of
> > the best way to represent these char ranges in perl
> > --
> >   while ( !feof(fin) ) {
> > ch=getc(fin);
> > 
> > if ( (ch<=0176) && (ch>=040) || (ch=='\n') ) {
> >   putc( ch, stdout );
> > } else {
> >   putc( ' ', stdout );
> > }
> > 
> >   }
> 
> The following one-liner will do the trick:
> 
>  perl -pe 'BEGIN {$/=\8192} tr/\040-\176/ /c' myfile
> 
> The /c on the tr/// operator complements the search range, so 
> everything
> *not* in the range 040 to 176 gets changed to a space.
> 
> The BEGIN block sets $/ so that input gets processed in 8kb chunks,
> regardless of the format of the input files. (Can that be done with a
> command-line option to perl?)

Thanks

Doesn't quite work. Notice I need to keep any newline ( "\n" ) chars. 
Here is an example:

echo "abc^Hdef\naa" | perl -pe 'BEGIN {$/=\8192} tr/\040-\176/ /c'

returns: abc^Hdef aa




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



RE: first steps - read from files and make linklist

2003-12-03 Thread Bob Showalter
Stephan Hochhaus wrote:
> > The while() reads a line into the $_ variable, but you're not
> > printing that; you're printing the filename itself. So you'll get
> > one line of (the same) output for each line in the file.
> Ah, I should have seen that in the first place
> 
> > Then to show just the 'perl.txt' part, use:
> > 
> >print basename($filename), "\n";
> Great, this looks a lot nicer. Now I'll figure out a way to chop the
> last 4 characters off if the filename has an extension, but I guess I
> can do this by myself :-) 

Now you need to learn how to use perldoc. Run 'perldoc File::Basename' to
read the documentation and you'll see that the basename() function can
remove extensions as well.

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



Re: first steps - read from files and make linklist

2003-12-03 Thread Stephan Hochhaus
The while() reads a line into the $_ variable, but you're not 
printing
that; you're printing the filename itself. So you'll get one line of 
(the
same) output for each line in the file.
Ah, I should have seen that in the first place

Then to show just the 'perl.txt' part, use:

   print basename($filename), "\n";
Great, this looks a lot nicer. Now I'll figure out a way to chop the 
last 4 characters off if the filename has an extension, but I guess I 
can do this by myself :-)

   my @f = split /\t/;# split into separate fields on tab char
Thanks for pointing that out to me, split seems very useful.

You're off to a good start!
As long as it takes me somewhere desirable ;-)

Stephan

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


Re: remove control chars

2003-12-03 Thread Casey West
It was Wednesday, December 03, 2003 when Bob Showalter took the soap box, saying:
: The following one-liner will do the trick:
: 
:  perl -pe 'BEGIN {$/=\8192} tr/\040-\176/ /c' myfile
: 
: The /c on the tr/// operator complements the search range, so everything
: *not* in the range 040 to 176 gets changed to a space.
: 
: The BEGIN block sets $/ so that input gets processed in 8kb chunks,
: regardless of the format of the input files. (Can that be done with a
: command-line option to perl?)

  -0[octal]   specify record separator (\0, if no argument)

  Casey West

-- 
Shooting yourself in the foot with COBOL 
USEing a COLT 45 HANDGUN, AIM gun at LEG.FOOT, THEN place
ARM.HAND.FINGER on HANDGUN.TRIGGER and SQUEEZE. THEN return HANDGUN to
HOLSTER. CHECK whether shoelace needs to be retied. 


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



First Steps Perl DB programming (was: Re: first steps - read from files and make linklist)

2003-12-03 Thread Wiggins d Anconia


> Hello list,
> I am as well a beginner to Perl and am currently working my way through 
> the LLama and I have also purchased the Camel and am looking through it.  
> My goal is to be able to do some programming for a MySQL database that I 
> am in charge of running.  Any help along with the previous message would 
> be great.
> 

Your question, other than context, is really completely different. In
general the canned response of,

"You will want to become familar with the DBI module available from
CPAN. It is a generic Perl interface that uses engine specific drivers
to control any of numerous types of engines, MySQL being one of those."

Should get you most of the way there, assuming you then go and read the
documentation for DBI. ORA also has a book "Programming the Perl DBI"
that is excellent coverage of the material if you are into the whole
book thing.

http://search.cpan.org/~timb/DBI-1.39/DBI.pm

http://danconia.org

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



RE: remove control chars

2003-12-03 Thread Bob Showalter
Kipp, James wrote:
> Hi
> I have some C code that I need to convert to perl and I am pressed
> for time, which is why I am posting this.  All the code does is read
> each character from either STDIN or a file and replaces any ASCII
> control characters with a space.
> 
> Is the perl getc() function the best way to look at one char at a
> time? 
> 
> The C code looks like below. I have some ideas but I am not sure of
> the best way to represent these char ranges in perl
> --
>   while ( !feof(fin) ) {
> ch=getc(fin);
> 
> if ( (ch<=0176) && (ch>=040) || (ch=='\n') ) {
>   putc( ch, stdout );
> } else {
>   putc( ' ', stdout );
> }
> 
>   }

The following one-liner will do the trick:

 perl -pe 'BEGIN {$/=\8192} tr/\040-\176/ /c' myfile

The /c on the tr/// operator complements the search range, so everything
*not* in the range 040 to 176 gets changed to a space.

The BEGIN block sets $/ so that input gets processed in 8kb chunks,
regardless of the format of the input files. (Can that be done with a
command-line option to perl?)

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



RE: first steps - read from files and make linklist

2003-12-03 Thread Bob Showalter
Stephan Hochhaus wrote:
> Hello list,
> 
> I am trying to write my very own first "useful" program and I am in
> need of some help. I do have a lot of ressources (a book by Andrew
> Johnson, the yellow book for dummies and lots of hypertexts) but I
> cannot seem to get things done the way they're supposed to work. I am
> completely new to Perl and programming as well.
> 
> So here's what I want to do:
> I want to write a little script that will read the files from a
> directory and make html links out of it. The data files look somewhat
> like this: 
> 
> Datafile:
> Linkname\tDescription\tURL\tLanguage

OK, looks good.

> 
> Here's what I have so far:
> #!/usr/bin/perl
> use strict;
> use diagnostics;
> 
> #read filenames
> my @filenames = glob"./data/*";
> print "filenames read...\n";
> #sort files
> @filenames = sort @filenames;
> print "@filenames\n";
> 
> #output link for every file
> foreach my $filename (@filenames) {
> open(FILE, $filename) or die "cannot open $filename!\n";
>while () { #read every single lines and output HTML
>print "$filename\n";

The while() reads a line into the $_ variable, but you're not printing
that; you're printing the filename itself. So you'll get one line of (the
same) output for each line in the file.

If you mean to print each filename as it's being processed, move the print
statement up above the while() line.

>}
> close FILE ;
> }
> 
> My questions so far (please don't give me a complete
> solution, I wanna
> work my way into Perl) is, why does the last print
> "$filename\n"; print
> every filename twice? 

See above.

> And how can I get rid of the directoy
> info up to
> the last / (./data/perl.txt)? Will that require knowledge of the
> mystical RegExp? 

You can use a regex, but the "preferred" way is to use the standard
File::Basename module. All you do is add the following line at the top of
your script:

   use File::Basename;

Then to show just the 'perl.txt' part, use:

   print basename($filename), "\n";

> How can I get the tab delimited strings in my
> datafile into 
> an array

Use the split() function. split() has a "default" mode that splits on
whitespace (like awk). If your fields contain spaces that's no good; you
want to split only on the tab char. In addition, since $_ contains the line
terminator when read by while(), you need to chomp() that off.

So you do something like this:

   while () {
   chomp; # remove line terminator
   my @f = split /\t/;# split into separate fields on tab char

   }

> so
> that I can access that array like this: print " href="$hyperlink[3]">"; and so on?
> 
> I hope this is not too trivial, but I've been trying to nail things
> down for the last two days, I am glad I found this diagnostics option
> but now I am stuck.. 
> 
> Any help is greatly appreciated!
> 
> Stephan - who has never written a programm before.

You're off to a good start!

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



Re: help with removing control chars

2003-12-03 Thread Casey West
Hi.

I'm in the employ of Casey West, a list admin, to assist you with your
question. I've taken the liberty to search Google using the Subject line
you provided in your email to the list. I hope one of the links below
will be of service to you. I know we all do research before posting
here, in some form or another, but things get past the best of us, and
that's okay.

Sadly Google hasn't given us a nice, legal API for searching newsgroups,
so you may also want to try these searches.

 http://groups.google.com/groups?q=Perl+help+removing+control+chars
 http://groups.google.com/groups?q=help+removing+control+chars+group%3Acomp.lang.perl.*

If you didn't get any useful results below, there's a chance your
Subject line was not specific enough, or not detailed enough. For
example, the following subject lines are not very good choices.

  Subject: Doubt
  Subject: HELP!
  Subject: Problem

Enjoy!

Perl.org Beginners' Lists, 0 results.
  Searched: site:nntp.x.perl.org inurl:perl.beginners -inurl:show_headers help 
removing control chars

Perl.org Lists, 1 results.
  Searched: site:nntp.x.perl.org -inurl:show_headers help removing control chars

  [1] nntp.perl.org - perl.mvs (1113)
   http://nntp.x.perl.org/group/perl.mvs/1113
 ... writing converted and unconverted strings by removing the call
 ... 1.2 system around > Feb 1. Any help is appreciated ... a web
 server that you have control and access ...

search.cpan.org, 10 results.
  Searched: site:search.cpan.org help removing control chars

  [1] search.cpan.org: DBIx::FileSystem - Manage tables like a ...
   http://search.cpan.org/search%3Fmodule=DBIx::FileSystem
 ... a one line help text for the help command. ... to check for
 references before removing a # file ... database layout FileSystem
 supports a simple version number control. ...

  [2] ReadMe for ICU
   http://search.cpan.org/src/LTOETSCH/parrot-0.0.13/icu/readme.html
 ... libraries can be made smaller by removing functionality ...
 application is externalized via Job Control Language (JCL ...
 asking the icu4c-support mailing list for help. ...

  [3]   0.59s: (MH) - - Added ' ...
   http://search.cpan.org/src/MLEHMANN/Audio-Play-MPG123-0.62/mpg123/CHANGES
 ... cleanup in Makefile for the initial help information - Added
 ... 0.59j: (MH)  added sajber jukebox control interface (it&
 ... Removing O_NDELAY fixed the problem ...

  [4] search.cpan.org: perlcall - Perl calling conventions from C
   http://search.cpan.org/~jhi/perl-5.8.0/pod/perlcall.pod
 ... that the stack is tidied up by removing the undef ... is the
 bottom line--if you are sure that control will revert ... To help
 understand why this can be a real problem ...

  [5] =head1 NAME perlcall - Perl calling conventions from C =head1 ...
   http://search.cpan.org/src/JHI/perl-5.8.1/pod/perlcall.pod
 ... essential that the stack is tidied up by removing the I ...
 bottom line--if you are sure that control will revert ... To help
 understand why this can be a real problem ...

  [6] search.cpan.org: Changes in DBD-Oracle 1.14 27th March 2003
   http://search.cpan.org/dist/DBD-Oracle/Changes
 ... Help HPUX configs by removing -l:libcl.a from ... AIX core
 dump on disconnect advice into README.help. ... v6/v7, v7)
 ora_parse_defer => 0 | 1 (control defered parsing ...

  [7] search.cpan.org: perlcall - Perl calling conventions from C
   http://search.cpan.org/~gbarr/perl5.005_03/pod/perlcall.pod
 ... that the stack is tidied up by removing the undef. ... the
 bottom line - if you are sure that control will revert ... To help
 understand why this can be a real problem ...

  [8] =head1 NAME perlcall - Perl calling conventions from C =head1 ...
   http://search.cpan.org/src/GBARR/perl5.005_03/pod/perlcall.pod
 ... essential that the stack is tidied up by removing the I ...
 bottom line - if you are sure that control will revert ... To help
 understand why this can be a real problem ...

  [9] search.cpan.org: perlguts - Introduction to the Perl API
   http://search.cpan.org/~jhi/perl-5.8.0/pod/perlguts.pod
 ... a little hack: instead of actually removing the characters ...
 as deferred SvREFCNT_dec should help to minimize ... argument
 consists of flags that control the context ...

  [10] ;;; cperl-mode.el --- Perl code editing commands for Emacs ;; ...
   http://search.cpan.org/src/NWCLARK/perl-5.8.2/emacs/cperl-mode.el
 ... New macro ;;; (`cperl-write-tags'): When removing old TAGS ...
 C-hv" ;;(concat (char-to-stringhelp-char) "v") ; does not work
 'cperl-get-help [(control h) v ...

Google Search, 10 results.
  Searched: Perl help removing control chars

  [1] Removing carriage returns from source code [110481 categorized ...
  

help with removing control chars

2003-12-03 Thread Kipp, James
Hi
I have some C code that I need to convert to perl and I am pressed for time,
which is why I am posting this.  All the code does is read each character
from either STDIN or a file and replaces any ASCII control characters with a
space.

Is the perl getc() function the best way to look at one char at a time?

The C code looks like below. I have some ideas but I am not sure of the best
way to represent these char ranges in perl
--
  while ( !feof(fin) ) {
ch=getc(fin);

if ( (ch<=0176) && (ch>=040) || (ch=='\n') ) {
  putc( ch, stdout );
} else {
  putc( ' ', stdout );
}

  }

-

Thanks for any suggestions
Jim


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



Beta Testing a Robot

2003-12-03 Thread Casey West
I'm beta-testing a robot that searches Google when new questions are
posed to the beginners' lists.  I have no idea if it will be useful.
:-)

I'm going to watch it closely and hope it is.  I'll remove it if I
find that it does a bad job.

  Casey West

-- 
Good Idea: Kissing a loved one.
Bad Idea:  Kissing a total stranger. 


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



RE: using perl in a c code

2003-12-03 Thread Dan Muey

> 
> [panda]# perl ${PATH}/xsubpp -v
> 

xsubpp version 1.9507

> finally, i am VERY surprise that your code:
> 
> >const char *perlcode = "use CGI 'header';print header();print 'hello
> World';";
> 
> will work at all. the reason being is that the Perl 
> interpreter you create 
> with:
> 
> > static PerlInterpreter *my_perl;
> 
> does NOT support dynamic loading. if the module that you are 
> trying to use 
> is written entirely in Perl, it usually works but 'CGI' is 
> not written 
> purely in Perl. any module that uses XS/C must be loaded up 
> during start up 
> and the Perl interpreter you created does not support that. 
> even if you can 
> compile your script, you will get a nasty error when you 
> actually try to 
> run it. the error (depends on what version of xsubpp you are 
> using) usually 
> tells you that CGI.pm can not found. the solution is to link 
> a special file 
> after you create your interpreter. Embed.pm has a function 
> for creating 
> this file:
> 

Good to know, I'll change that to a simple print statement and see how it goes

> [panda]# perl -MExtUtils::Embed -e xsinit
> 
> this will create a file perlxsi.c in the current directory. 
> once you have 
> that, you need to link it against your object file and change:
> 
> > perl_parse(my_perl, NULL, argc, argv, (char **)NULL);
> 
> to:
> 
> perl_parse(my_perl, xs_init, argc, argv, (char **)NULL);

I'll give that ashot after I get a super simple version to go.
This will be very very helpful!

> i omit a LOT of details but it's almost impossible to tell 
> you everything 
> you need to know to successfully embed Perl in C with a 
> single message.
> 

Absolutely, thanks for all of this!!

> david

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



Re: remove control chars

2003-12-03 Thread Casey West
Hi.

I'm in the employ of Casey West, a list admin, to assist you with your
question. I've taken the liberty to search Google using the Subject line
you provided in your email to the list. I hope one of the links below
will be of service to you. I know we all do research before posting
here, in some form or another, but things get past the best of us, and
that's okay.

Sadly Google hasn't given us a nice, legal API for searching newsgroups,
so you may also want to try these searches.

 http://groups.google.com/groups?q=Perl+remove+control+chars
 http://groups.google.com/groups?q=remove+control+chars+group%3Acomp.lang.perl.*

If you didn't get any useful results below, there's a chance your
Subject line was not specific enough, or not detailed enough. For
example, the following subject lines are not very good choices.

  Subject: Doubt
  Subject: HELP!
  Subject: Problem

Enjoy!

Perl.org Beginners' Lists, 0 results.
  Searched: site:nntp.x.perl.org inurl:perl.beginners -inurl:show_headers remove 
control chars

Perl.org Lists, 0 results.
  Searched: site:nntp.x.perl.org -inurl:show_headers remove control chars

search.cpan.org, 10 results.
  Searched: site:search.cpan.org remove control chars

  [1] search.cpan.org: CGI::Debug - module for CGI programs debugging
   http://search.cpan.org/search%3Fmodule=CGI::Debug
 ... At any time you can remove the "use CGI ... 2. environment
 control variables 3. the importcontrol parameters 4 ... cookies;
 environment variables (max 60 chars in value). ...

  [2] Package Win32::GUI::Textfield
   http://search.cpan.org/src/ACALPINI/Win32-GUI-0.0.558/docs/html/Textfield.html
 ... multiline => 0/1 (default 0) the control can have ... Limits
 the number of characters that the Textfield accept to CHARS, or
 returns the ... To remove the limit (eg. ...

  [3] /* File: freesubs.c * Author: Richard Durbin ([EMAIL PROTECTED] ...
   http://search.cpan.org/src/LDS/AcePerl-1.74/ace/freesubs.c
 ... continuation */ { ++line ; while (isspace (*in = getc(fil))) ;
 / remove whitespace */ } else ... isprint (*in) && *in != '\t') /*
 ignore control chars, eg \x0d ...

  [4]       

remove control chars

2003-12-03 Thread Kipp, James
Hi
I have some C code that I need to convert to perl and I am pressed for time,
which is why I am posting this.  All the code does is read each character
from either STDIN or a file and replaces any ASCII control characters with a
space.

Is the perl getc() function the best way to look at one char at a time?

The C code looks like below. I have some ideas but I am not sure of the best
way to represent these char ranges in perl
--
  while ( !feof(fin) ) {
ch=getc(fin);

if ( (ch<=0176) && (ch>=040) || (ch=='\n') ) {
  putc( ch, stdout );
} else {
  putc( ' ', stdout );
}

  }

-

Thanks for any suggestions
Jim


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



Re: first steps - read from files and make linklist

2003-12-03 Thread drowl

> Hello list,
>
> I am trying to write my very own first "useful" program and I am in
> need of some help. I do have a lot of ressources (a book by Andrew
> Johnson, the yellow book for dummies and lots of hypertexts) but I
> cannot seem to get things done the way they're supposed to work. I am
> completely new to Perl and programming as well.
>
> So here's what I want to do:
> I want to write a little script that will read the files from a
> directory and make html links out of it. The data files look somewhat
> like this:
>
> Datafile:
> Linkname\tDescription\tURL\tLanguage
>
> Here's what I have so far:
> #!/usr/bin/perl
> use strict;
> use diagnostics;
>
> #read filenames
> my @filenames = glob"./data/*";
> print "filenames read...\n";
> #sort files
> @filenames = sort @filenames;
> print "@filenames\n";
>
> #output link for every file
> foreach my $filename (@filenames) {
> open(FILE, $filename) or die "cannot open $filename!\n";
> while () {
>#read every single lines and output HTML
>print "$filename\n";
>}
> close FILE ;
> }
>
> My questions so far (please don't give me a complete solution, I wanna
> work my way into Perl) is, why does the last print "$filename\n"; print
> every filename twice? And how can I get rid of the directoy info up to
> the last / (./data/perl.txt)? Will that require knowledge of the
> mystical RegExp?
> How can I get the tab delimited strings in my datafile into an array so
> that I can access that array like this: print " href="$hyperlink[3]">"; and so on?
>

hello well i would use
while () {
my @hyperlink = split (/\//,$_,4);

but i am only a begener too

as for the
#read every single lines and output HTML
print "$filename\n";

why are you printing $filename ? do you not want the content of the file
in which case $_ would do as it would containe the text from the file you
just read.



sorry about my bad spelling
hope this helps

Ritchie

> I hope this is not too trivial, but I've been trying to nail things
> down for the last two days, I am glad I found this diagnostics option
> but now I am stuck..
>
> Any help is greatly appreciated!
>
> Stephan - who has never written a programm before.
>
>
> --
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]


-- 




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



Re: first steps - read from files and make linklist

2003-12-03 Thread Jonathan Jesse
Hello list,
I am as well a beginner to Perl and am currently working my way through 
the LLama and I have also purchased the Camel and am looking through it.  
My goal is to be able to do some programming for a MySQL database that I 
am in charge of running.  Any help along with the previous message would 
be great.

Thanks in adavance,

Jonathan Jesse

On Wed, 3 Dec 2003 19:55:11 +0100, Stephan Hochhaus <[EMAIL PROTECTED]> 
wrote:

Hello list,

I am trying to write my very own first "useful" program and I am in need 
of some help. I do have a lot of ressources (a book by Andrew Johnson, 
the yellow book for dummies and lots of hypertexts) but I cannot seem to 
get things done the way they're supposed to work. I am completely new to 
Perl and programming as well.

So here's what I want to do:
I want to write a little script that will read the files from a 
directory and make html links out of it. The data files look somewhat 
like this:

Datafile:
Linkname\tDescription\tURL\tLanguage
Here's what I have so far:
#!/usr/bin/perl
use strict;
use diagnostics;
#read filenames
my @filenames = glob"./data/*";
print "filenames read...\n";
#sort files
@filenames = sort @filenames;
print "@filenames\n";
#output link for every file
foreach my $filename (@filenames) {
open(FILE, $filename) or die "cannot open $filename!\n";
while () {
   #read every single lines and output HTML
   print "$filename\n";
   }
close FILE ;
}
My questions so far (please don't give me a complete solution, I wanna 
work my way into Perl) is, why does the last print "$filename\n"; print 
every filename twice? And how can I get rid of the directoy info up to 
the last / (./data/perl.txt)? Will that require knowledge of the 
mystical RegExp?
How can I get the tab delimited strings in my datafile into an array so 
that I can access that array like this: print ""; and so on?

I hope this is not too trivial, but I've been trying to nail things down 
for the last two days, I am glad I found this diagnostics option but now 
I am stuck..

Any help is greatly appreciated!

Stephan - who has never written a programm before.



--
Using M2, Opera's revolutionary e-mail client: http://www.opera.com/m2/
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]


first steps - read from files and make linklist

2003-12-03 Thread Stephan Hochhaus
Hello list,

I am trying to write my very own first "useful" program and I am in 
need of some help. I do have a lot of ressources (a book by Andrew 
Johnson, the yellow book for dummies and lots of hypertexts) but I 
cannot seem to get things done the way they're supposed to work. I am 
completely new to Perl and programming as well.

So here's what I want to do:
I want to write a little script that will read the files from a 
directory and make html links out of it. The data files look somewhat 
like this:

Datafile:
Linkname\tDescription\tURL\tLanguage
Here's what I have so far:
#!/usr/bin/perl
use strict;
use diagnostics;
#read filenames
my @filenames = glob"./data/*";
print "filenames read...\n";
#sort files
@filenames = sort @filenames;
print "@filenames\n";
#output link for every file
foreach my $filename (@filenames) {
   open(FILE, $filename) or die "cannot open $filename!\n";
   while () {
  #read every single lines and output HTML
  print "$filename\n";
  }
   close FILE ;
   }
My questions so far (please don't give me a complete solution, I wanna 
work my way into Perl) is, why does the last print "$filename\n"; print 
every filename twice? And how can I get rid of the directoy info up to 
the last / (./data/perl.txt)? Will that require knowledge of the 
mystical RegExp?
How can I get the tab delimited strings in my datafile into an array so 
that I can access that array like this: print ""; and so on?

I hope this is not too trivial, but I've been trying to nail things 
down for the last two days, I am glad I found this diagnostics option 
but now I am stuck..

Any help is greatly appreciated!

Stephan - who has never written a programm before.

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


RE: Timing several processes

2003-12-03 Thread Akens, Anthony
Here's the sample code I'm trying...  In essence I would expect to see
The following output:

Running vmstat
Running sar
Waiting...  (at this point a long wait while sar and vmstat finish)
Done!


Instead I am seeing:
Running vmstat
Running sar  (The long wait is here)
Waiting...
Done!


In watching the file sizes, I can see both files are created at the
Same time, but sar does not produce any output in its file until
Vmstat finishes.

-Tony

#!/usr/bin/perl -w

use strict;

print "Running vmstat\n";
defined(my $vmstat_pid = fork) or die "Cannot fork: $!";
unless ($vmstat_pid) {
  exec "vmstat 5 5 > /log/monitor/delta/vmstat.out";
  die "cannot exec vmstat: $!";
}
print "Running sar\n";
defined(my $sar_pid = fork) or die "Cannot fork: $!";
unless ($sar_pid) {
  exec "sar 5 5 > /log/monitor/delta/sar.out";
  die "cannot exec date: $!";
}
print "Waiting...\n";
waitpid($vmstat_pid, 0);
waitpid($sar_pid, 0);
print "done!\n";

-Original Message-
From: Wiggins d Anconia [mailto:[EMAIL PROTECTED] 
Sent: Wednesday, December 03, 2003 1:31 PM
To: Akens, Anthony; Tom Kinzer; [EMAIL PROTECTED]
Subject: RE: Timing several processes


I was going to suggest POE as well, 'til I saw that little word 'simple'
:-)...

Have you read:

perldoc perlipc
perldoc -f fork
perldoc -f wait
perldoc -f waitpid

Of course POE is what makes keeping track of all those spun off
processes trivial, but learning it is I will admit not trivial...

http://danconia.org

> I already have some ideas for how I want to build the page, how
> to parse the data I will generate, etc.
> 
> As I said, I've looked at some of the other tools out there,
> and want to stick to some simple perl code to parse out the 
> information and return the results.
> 
> The only bit I'm not sure of is how to tell if all forked processes
> have completed before moving on.
> 
> 
> -Tony
> 
> -Original Message-
> From: Tom Kinzer [mailto:[EMAIL PROTECTED]
> Sent: Wednesday, December 03, 2003 12:35 PM
> To: [EMAIL PROTECTED]
> Subject: RE: Timing several processes
> 
> 
>  http://poe.perl.org
> 
> Maybe this would be a good job for POE?
> 
> -Tom Kinzer
> 
> 
> -Original Message-
> From: Akens, Anthony [mailto:[EMAIL PROTECTED]
> Sent: Wednesday, December 03, 2003 7:49 AM
> To: [EMAIL PROTECTED]
> Subject: Timing several processes
> 
> 
> Hi all!
> 
> I'm wanting to write a simple web-based tool to see the status of 
> several servers at a glance.  I know there are many solutions 
> existing, but I can't learn as much about perl by just using one of 
> those as I can by writing my own.  The first step I want to do is call

> a script from cron that runs several basic monitoring tools (sar, 
> vmstat, df, iostat, etc) and saves the output of each to a file. Then 
> I'd parse those files up, and write a summary file.
> 
> Easy enough.  And I could certainly do it with by calling the tools 
> one at a time.  However, I'd like to get roughly 1 minute of vmstat, 
> iostat, and sar output Simultaneously.  So I'm supposing I'd want 
> to fork off each process, and then when those are all done come back 
> and run a script that then parses those results out for the individual

> statistics I'm looking for.
> 
> I've never used fork before, and while it looks fairly straight 
> forward what I am not sure of is how to make sure all of those forked 
> processes have completed before moving on and parsing the files.
> 
> Any pointers?
> 
> Thanks in advance
> 
> -Tony
> 


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


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



Re: Undefined subroutine

2003-12-03 Thread drieux
On Dec 3, 2003, at 7:55 AM, Jan Gruber wrote:
[..]
Where is Eris_Gate.pm, and what is its package declaration? From
what you say it should be in
  /usr/lib/perl5/site_perl/5.8.0/Modules
Right, its in there.

and should read
  package Modules::Eris_Gate
NO, it didn't.
It read "package Eris_gate" before. Thanks, I missed this one at least 
50
times and I wont forget to name my packages correctly from now on.
[..]

You might want to take the time to read

	perldoc h2xs

it can be such a help when one is starting
out with creating perl modules.
ciao
drieux
---

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


Re: set a cookie and redirect using CGI.pm

2003-12-03 Thread Wiggins d Anconia


> 
> 
> Hello
> 
> I want to set a user cookie and redirect to a different URL on the
same domain.
> I searched and found alternate ways of doing it.
> 
> I am looking for a way to do using CGI.pm
> 
> Suggestions?
> 

What have you tried and what didn't work?  A cookie is really just a
part of the header (usually) sent before the Location or Content-type,
but presumably could be anywhere in the header. I am not familar enough
with CGI.pm's 'header' method to know whether you can invoke it with a
cookie/location combo, in general I call CGI::Cookie directly to build
my cookies then print them directly as their docs suggest, followed by a
standard CGI->redirect to my location. 

Follow?

http://danconia.org

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



Re: using perl in a c code

2003-12-03 Thread Tassilo von Parseval
On Wed, Dec 03, 2003 at 11:33:53AM -0600 Dan Muey wrote:

> Ok, I can compile this example with:
> cc -o perlemb perlemb.c `perl -MExtUtils::Embed -e ccopts -e ldopts`  
> 
> I can run it like this:
> ./perlemb -e 'print "Howdy";'
> Howdy
> Or
> ./perlemb
> print "Howdy";
> 
> Howdy
> 
> Here's what I have on the inetrnal version (IE the perl to execute is provided 
> inside and not via cmd line)
> 
> #include/* from the Perl distribution */
> #include  /* from the Perl distribution */
> 
> static PerlInterpreter *my_perl;  /***The Perl interpreter***/
> 
> int main(int argc, char **argv, char **env)
> {
> my_perl = perl_alloc();
> perl_construct(my_perl);
> perl_parse(my_perl, NULL, argc, argv, (char **)NULL);
> perl_run(my_perl);
> perl_destruct(my_perl);
> perl_free(my_perl);
> }
> 
> What I'd like to do with this is:
> 
> ./perlemb2
> Howdy
> And eventually through using CGI's param() perhas:
> ./perlemb2 name=JoeMama
> Howdy JoeMama

I would assume that this works with the C program in the very same way
as it works with Perl.

> What I have so far for testing is:
> 
> #include 
> #include 
> 
> static PerlInterpreter *my_perl;
> 
> main (int argc, char **argv, char **env)
> {
>STRLEN n_a;
>const char *perlcode = "use CGI 'header';print header();print 'hello World';";
> 
>my_perl = perl_alloc();
>perl_construct( my_perl );
> 
>perl_parse(my_perl, NULL, argc, argv, (char **)NULL);
> 
>perl_run(my_perl);
> 
>printf("%s", SvPV(eval_pv(perlcode)));
> 
>perl_destruct(my_perl);
>perl_free(my_perl);
> }
> 
> But when I compile it the same way as the first I get:
> 
> perlemb.c:18: macro `SvPV' used with just one arg

Yep, indeed, I forgot the second argument. 

> So I tried it as 
> printf("%s", SvPV(eval_pv(perlcode),n_a));
> Which is how it was in another example and got:
> 
> perlemb.c: In function `main':
> perlemb.c:18: invalid type argument of `->'
> perlemb.c:18: invalid type argument of `->'
> perlemb.c:18: invalid type argument of `->'
> perlemb.c:18: warning: passing arg 1 of `Perl_sv_2pv' makes pointer from integer 
> without a cast

Ah, right. One has to take care with the perlapi since many things are
in fact macros and not functions. SvPV() is one and it wont accept an
expression. You need to use a proper variable:

STRLEN n_a;
SV *res = eval_pv(perlcode);
printf("%s", SvPV(res, n_a));

Maybe I can also point you to [EMAIL PROTECTED] If you want to do the
occasional XS or embedding, this mailing-list is the right place to
consult.

Tassilo
-- 
$_=q#",}])!JAPH!qq(tsuJ[{@"tnirp}3..0}_$;//::niam/s~=)]3[))_$-3(rellac(=_$({
pam{rekcahbus})(rekcah{lrePbus})(lreP{rehtonabus})!JAPH!qq(rehtona{tsuJbus#;
$_=reverse,s+(?<=sub).+q#q!'"qq.\t$&."'!#+sexisexiixesixeseg;y~\n~~;eval


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



RE: using perl in a c code

2003-12-03 Thread david
Dan Muey wrote:

[snip]

> 
> perlemb.c:18: macro `SvPV' used with just one arg
> 
> So I tried it as
> printf("%s", SvPV(eval_pv(perlcode),n_a));
> Which is how it was in another example and got:

you don't need to supply n_a if you are not intested in the length of the 
SV, Perl has another api for that: SvPV_nolen. i am not sure how you can 
compile eval_pv without the error flag, i would write the above as:

printf("%s",SvPV_nolen(eval_pv(perlcode,0)));

> 
> perlemb.c: In function `main':
> perlemb.c:18: invalid type argument of `->'
> perlemb.c:18: invalid type argument of `->'
> perlemb.c:18: invalid type argument of `->'
> perlemb.c:18: warning: passing arg 1 of `Perl_sv_2pv' makes pointer from
> integer without a cast

which line is 18? what version of xssubpp are you using? the following 
should tell you that:

[panda]# perl ${PATH}/xsubpp -v

finally, i am VERY surprise that your code:

>const char *perlcode = "use CGI 'header';print header();print 'hello 
World';";

will work at all. the reason being is that the Perl interpreter you create 
with:

> static PerlInterpreter *my_perl;

does NOT support dynamic loading. if the module that you are trying to use 
is written entirely in Perl, it usually works but 'CGI' is not written 
purely in Perl. any module that uses XS/C must be loaded up during start up 
and the Perl interpreter you created does not support that. even if you can 
compile your script, you will get a nasty error when you actually try to 
run it. the error (depends on what version of xsubpp you are using) usually 
tells you that CGI.pm can not found. the solution is to link a special file 
after you create your interpreter. Embed.pm has a function for creating 
this file:

[panda]# perl -MExtUtils::Embed -e xsinit

this will create a file perlxsi.c in the current directory. once you have 
that, you need to link it against your object file and change:

> perl_parse(my_perl, NULL, argc, argv, (char **)NULL);

to:

perl_parse(my_perl, xs_init, argc, argv, (char **)NULL);

i omit a LOT of details but it's almost impossible to tell you everything 
you need to know to successfully embed Perl in C with a single message.

david
-- 
s,.*,<<,e,y,\n,,d,y,.s,10,,s
.ss.s.s...s.sss.s.ss
s.s.s...s...s..s
...s.ss..s.sss..ss.sss.s
s.s.s...ss.sss.s
..s..sss.s.ss.sss...
..ssss.sss.sss.s

,{4},"|?{*=}_'y!'+0!$&;"
,ge,y,!#:$_(-*[./<[EMAIL PROTECTED],b-t,
.y...,$~=q~=?,;^_#+?{~,,$~=~
y.!-&*-/:[EMAIL PROTECTED] ().;s,;,
);,g,s,s,$~s,g,y,y,%,,g,eval

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



RE: Timing several processes

2003-12-03 Thread Wiggins d Anconia
I was going to suggest POE as well, 'til I saw that little word 'simple'
:-)...

Have you read:

perldoc perlipc
perldoc -f fork
perldoc -f wait
perldoc -f waitpid

Of course POE is what makes keeping track of all those spun off
processes trivial, but learning it is I will admit not trivial...

http://danconia.org

> I already have some ideas for how I want to build the page, how 
> to parse the data I will generate, etc.
> 
> As I said, I've looked at some of the other tools out there, 
> and want to stick to some simple perl code to parse out the 
> information and return the results.
> 
> The only bit I'm not sure of is how to tell if all forked processes 
> have completed before moving on.
> 
> 
> -Tony
> 
> -Original Message-
> From: Tom Kinzer [mailto:[EMAIL PROTECTED] 
> Sent: Wednesday, December 03, 2003 12:35 PM
> To: [EMAIL PROTECTED]
> Subject: RE: Timing several processes
> 
> 
>  http://poe.perl.org 
> 
> Maybe this would be a good job for POE?
> 
> -Tom Kinzer
> 
> 
> -Original Message-
> From: Akens, Anthony [mailto:[EMAIL PROTECTED]
> Sent: Wednesday, December 03, 2003 7:49 AM
> To: [EMAIL PROTECTED]
> Subject: Timing several processes
> 
> 
> Hi all!
> 
> I'm wanting to write a simple web-based tool to see the status of
> several servers at a glance.  I know there are many solutions existing,
> but I can't learn as much about perl by just using one 
> of those as I can by writing my own.  The first step I want to do 
> is call a script from cron that runs several basic monitoring tools 
> (sar, vmstat, df, iostat, etc) and saves the output of each to a 
> file. Then I'd parse those files up, and write a summary file.
> 
> Easy enough.  And I could certainly do it with by calling the tools one
> at a time.  However, I'd like to get roughly 1 minute of vmstat, 
> iostat, and sar output Simultaneously.  So I'm supposing I'd 
> want to fork off each process, and then when those are all done 
> come back and run a script that then parses those results out for 
> the individual statistics I'm looking for.
> 
> I've never used fork before, and while it looks fairly straight forward
> what I am not sure of is how to make sure all of those forked 
> processes have completed before moving on and parsing the files.
> 
> Any pointers?
> 
> Thanks in advance
> 
> -Tony
> 


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



Re: search and replace using regex

2003-12-03 Thread drieux
On Dec 3, 2003, at 7:06 AM, Rob Dixon wrote:
[..]
remember that those double quotes will allow things
to be 'interpolated' - which is not what you want.
No they won't: they're not string delimiters in this context
so they'll be treated as any other non-special character between
the real s/// slash delimiters.
Rob
Minor Blonde Hair Moment On my phrasing.
Thanks You for the good catch!
let's look at some code:

my $foo = q|" _ other stuff|;

print "$foo \n";

$foo =~ s|" _
which will generate

" _ other stuff
" other stuff
Now IF the OP really wanted that sort of case,
then while a bit wacko, it will work.
So the question is whether that '"' double
quote token is a part of the pattern that
will be searched for, or is it the sort of
classic cut and paste problem of say
	my $foo = " _

and in the heat of trying to sort out what was
scragged in the RegEx, hoping over the line to
	$_ =~ s/"_\

hoping that by adding in more tokens it
would make it go zoom zoom..
I think that were you or I working the RE
and we wanted to remove ' _<' and replace it
with mere '<' we would have done say
	$_ =~ s| _<|<|g;

Or we might use say

	$_ =~ s|\s*_<|<|g;

to clean out the preceeding 'white space'...

ciao
drieux
---

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


RE: Timing several processes

2003-12-03 Thread Tom Kinzer
Correct.  You could spawn 5 and then do 5 waits.  Assuming you want to do
nothing until all 5 finish.

But:  Do you actually want to do a timer for those 5 processes, run for a
certain amount of time and then have them stop??  Then check to make sure
all 5 are done, then do some other stuff (reporting)??

The code below spawns a process but instead of waiting like it would for a
system call, it says I'm gonna keep on trucking -- course it doesn't do
anything except go straight to a wait in this example, but in theory, the
"main" could be doing other stuff at the same time.

Of course, all this has very little to do with terminating a child at a
certain time...

-Tom Kinzer


-Original Message-
From: Akens, Anthony [mailto:[EMAIL PROTECTED]
Sent: Wednesday, December 03, 2003 10:07 AM
To: Akens, Anthony; Tom Kinzer; [EMAIL PROTECTED]
Subject: RE: Timing several processes


To clarify, I found the following in "Learning Perl".

It doesn't quite make sense to me, though.  Perhaps someone
Can clarify what's going on in this?

defined(my $pid = fork) or die "Cannot fork: $!";
unless ($pid) {
  # Child process is here
  exec "date";
  die "cannot exec date: $!";
}
# Parent process is here
waitpid($pid, 0);


It seems I could use that code, modified to start (5) processes,
And a waitpid() for each of those (5).  It doesn't matter
Which processes would finish first.  (I put the 5 in quotes,
Because right now I'm looking at using 5 different tools that
I want to monitor).

-Tony



-Original Message-
From: Akens, Anthony
Sent: Wednesday, December 03, 2003 12:58 PM
To: Tom Kinzer; [EMAIL PROTECTED]
Subject: RE: Timing several processes


I already have some ideas for how I want to build the page, how
to parse the data I will generate, etc.

As I said, I've looked at some of the other tools out there,
and want to stick to some simple perl code to parse out the
information and return the results.

The only bit I'm not sure of is how to tell if all forked processes
have completed before moving on.


-Tony

-Original Message-
From: Tom Kinzer [mailto:[EMAIL PROTECTED]
Sent: Wednesday, December 03, 2003 12:35 PM
To: [EMAIL PROTECTED]
Subject: RE: Timing several processes


 http://poe.perl.org

Maybe this would be a good job for POE?

-Tom Kinzer


-Original Message-
From: Akens, Anthony [mailto:[EMAIL PROTECTED]
Sent: Wednesday, December 03, 2003 7:49 AM
To: [EMAIL PROTECTED]
Subject: Timing several processes


Hi all!

I'm wanting to write a simple web-based tool to see the status of
several servers at a glance.  I know there are many solutions existing,
but I can't learn as much about perl by just using one
of those as I can by writing my own.  The first step I want to do
is call a script from cron that runs several basic monitoring tools
(sar, vmstat, df, iostat, etc) and saves the output of each to a
file. Then I'd parse those files up, and write a summary file.

Easy enough.  And I could certainly do it with by calling the tools one
at a time.  However, I'd like to get roughly 1 minute of vmstat,
iostat, and sar output Simultaneously.  So I'm supposing I'd
want to fork off each process, and then when those are all done
come back and run a script that then parses those results out for
the individual statistics I'm looking for.

I've never used fork before, and while it looks fairly straight forward
what I am not sure of is how to make sure all of those forked
processes have completed before moving on and parsing the files.

Any pointers?

Thanks in advance

-Tony

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


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


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


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


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



RE: using perl in a c code

2003-12-03 Thread Dan Muey
Thanks for the info.

> On Dec 3, 2003, at 7:06 AM, Dan Muey wrote:
> 
> > Don't get me wrong, I have no practical reason
> > for running website stuff from C. I think it may
> > be valueable to know at some point and would be a
> > terrific learning experience.
> 
> Sorry for panicking Early
> 
> Technically I can understand the Intellectual Interest.
> But I feel obliged to note:
> 
>   There are many very effective Drug Therapies
>   that can help with this type of Personality Disorder
> 
> You might want to start down the 'c trail' on it's own
> and then come back around the horn to look at how to expose 
> your c-code in Perl with the standard XS mechanisms. cf 
> perldoc h2xs et al.
> 
> But that is driven by my background in c, and
> therefore the fact that I can hack the c, the
> makeFile, the ar to make the lib, etc... But
> having access to that code in Perl makes some
> other solutions simpler.
> 
> One variation on that theme is: 
> 
> 
> There are enough weirdnesses in the process of keeping
> a 'c code' application, and the associated libraries,
> static and/or dynamic 'stable' to drive most normal
> people to Perl
> 
> [..]
> > Put some perl code, that if run from a command line or browser or
> > whatever
> > with or with our input of some sort would output some ascii text,
> > Inside of C program, probably as avariable I'm guessing then use
> > C to execute it and take what it outputs and , well oout put it.
> [..]
> 
> So let's toss of the 'web stuff' - which is hairy
> enough as it is, since one has to grok perl,
> HTML/XHTML, a bit of the HTTP stuff, the CGI
> calling conventions, a bit of Java Script, and
> the three Major DOM's - which is enough in itself
> and go back to the simpler idea...
> 
> Going the Otherway, as you are asking, finding
> a way to stuff Perl into C code does not make
> a lot of sense to me. Albeit it is a way to
> oblige one's self to 'get it' about making
> c code, and what the trade off at that point would be.
> In Terms of GENERAL CODING for the Application Coder
> You might find it better to start with a known piece
> of perl code that you know does what it is suppose to
> do, and then see what it would take to code it up
> to work in 'c'. That would give you a better apples
> to apples comparison.
> 
> you may want to check out
> 
> 
> and download the PCRE project and look into it.
> 
> ciao
> drieux
> 
> ---
> 
> 
> -- 
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
> 
> 

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



RE: Timing several processes

2003-12-03 Thread Tom Kinzer
Right.  POE may be a good tool for handling those children processes.
(Instead of forking at all.)

 -Tom Kinzer

-Original Message-
From: Akens, Anthony [mailto:[EMAIL PROTECTED]
Sent: Wednesday, December 03, 2003 9:58 AM
To: Tom Kinzer; [EMAIL PROTECTED]
Subject: RE: Timing several processes


I already have some ideas for how I want to build the page, how
to parse the data I will generate, etc.

As I said, I've looked at some of the other tools out there,
and want to stick to some simple perl code to parse out the
information and return the results.

The only bit I'm not sure of is how to tell if all forked processes
have completed before moving on.


-Tony

-Original Message-
From: Tom Kinzer [mailto:[EMAIL PROTECTED]
Sent: Wednesday, December 03, 2003 12:35 PM
To: [EMAIL PROTECTED]
Subject: RE: Timing several processes


 http://poe.perl.org

Maybe this would be a good job for POE?

-Tom Kinzer


-Original Message-
From: Akens, Anthony [mailto:[EMAIL PROTECTED]
Sent: Wednesday, December 03, 2003 7:49 AM
To: [EMAIL PROTECTED]
Subject: Timing several processes


Hi all!

I'm wanting to write a simple web-based tool to see the status of
several servers at a glance.  I know there are many solutions existing,
but I can't learn as much about perl by just using one
of those as I can by writing my own.  The first step I want to do
is call a script from cron that runs several basic monitoring tools
(sar, vmstat, df, iostat, etc) and saves the output of each to a
file. Then I'd parse those files up, and write a summary file.

Easy enough.  And I could certainly do it with by calling the tools one
at a time.  However, I'd like to get roughly 1 minute of vmstat,
iostat, and sar output Simultaneously.  So I'm supposing I'd
want to fork off each process, and then when those are all done
come back and run a script that then parses those results out for
the individual statistics I'm looking for.

I've never used fork before, and while it looks fairly straight forward
what I am not sure of is how to make sure all of those forked
processes have completed before moving on and parsing the files.

Any pointers?

Thanks in advance

-Tony

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


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


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


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



RE: Timing several processes

2003-12-03 Thread Akens, Anthony
To clarify, I found the following in "Learning Perl".

It doesn't quite make sense to me, though.  Perhaps someone
Can clarify what's going on in this?

defined(my $pid = fork) or die "Cannot fork: $!";
unless ($pid) {
  # Child process is here
  exec "date";
  die "cannot exec date: $!";
}
# Parent process is here
waitpid($pid, 0);


It seems I could use that code, modified to start (5) processes,
And a waitpid() for each of those (5).  It doesn't matter
Which processes would finish first.  (I put the 5 in quotes,
Because right now I'm looking at using 5 different tools that
I want to monitor).

-Tony



-Original Message-
From: Akens, Anthony 
Sent: Wednesday, December 03, 2003 12:58 PM
To: Tom Kinzer; [EMAIL PROTECTED]
Subject: RE: Timing several processes


I already have some ideas for how I want to build the page, how 
to parse the data I will generate, etc.

As I said, I've looked at some of the other tools out there, 
and want to stick to some simple perl code to parse out the 
information and return the results.

The only bit I'm not sure of is how to tell if all forked processes 
have completed before moving on.


-Tony

-Original Message-
From: Tom Kinzer [mailto:[EMAIL PROTECTED] 
Sent: Wednesday, December 03, 2003 12:35 PM
To: [EMAIL PROTECTED]
Subject: RE: Timing several processes


 http://poe.perl.org 

Maybe this would be a good job for POE?

-Tom Kinzer


-Original Message-
From: Akens, Anthony [mailto:[EMAIL PROTECTED]
Sent: Wednesday, December 03, 2003 7:49 AM
To: [EMAIL PROTECTED]
Subject: Timing several processes


Hi all!

I'm wanting to write a simple web-based tool to see the status of
several servers at a glance.  I know there are many solutions existing,
but I can't learn as much about perl by just using one 
of those as I can by writing my own.  The first step I want to do 
is call a script from cron that runs several basic monitoring tools 
(sar, vmstat, df, iostat, etc) and saves the output of each to a 
file. Then I'd parse those files up, and write a summary file.

Easy enough.  And I could certainly do it with by calling the tools one
at a time.  However, I'd like to get roughly 1 minute of vmstat, 
iostat, and sar output Simultaneously.  So I'm supposing I'd 
want to fork off each process, and then when those are all done 
come back and run a script that then parses those results out for 
the individual statistics I'm looking for.

I've never used fork before, and while it looks fairly straight forward
what I am not sure of is how to make sure all of those forked 
processes have completed before moving on and parsing the files.

Any pointers?

Thanks in advance

-Tony

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


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


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


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



Re: using perl in a c code

2003-12-03 Thread drieux
On Dec 3, 2003, at 7:06 AM, Dan Muey wrote:

Don't get me wrong, I have no practical reason
for running website stuff from C. I think it may
be valueable to know at some point and would be a
terrific learning experience.
Sorry for panicking Early

Technically I can understand the Intellectual Interest.
But I feel obliged to note:
There are many very effective Drug Therapies
that can help with this type of Personality Disorder
You might want to start down the 'c trail' on it's own
and then come back around the horn to look at how to expose
your c-code in Perl with the standard XS mechanisms.
cf perldoc h2xs et al.
But that is driven by my background in c, and
therefore the fact that I can hack the c, the
makeFile, the ar to make the lib, etc... But
having access to that code in Perl makes some
other solutions simpler.
One variation on that theme is:

There are enough weirdnesses in the process of keeping
a 'c code' application, and the associated libraries,
static and/or dynamic 'stable' to drive most normal
people to Perl
[..]
Put some perl code, that if run from a command line or browser or 
whatever
with or with our input of some sort would output some ascii text,
Inside of C program, probably as avariable I'm guessing then use
C to execute it and take what it outputs and , well oout put it.
[..]

So let's toss of the 'web stuff' - which is hairy
enough as it is, since one has to grok perl,
HTML/XHTML, a bit of the HTTP stuff, the CGI
calling conventions, a bit of Java Script, and
the three Major DOM's - which is enough in itself
and go back to the simpler idea...
Going the Otherway, as you are asking, finding
a way to stuff Perl into C code does not make
a lot of sense to me. Albeit it is a way to
oblige one's self to 'get it' about making
c code, and what the trade off at that point would be.
In Terms of GENERAL CODING for the Application Coder
You might find it better to start with a known piece
of perl code that you know does what it is suppose to
do, and then see what it would take to code it up
to work in 'c'. That would give you a better apples
to apples comparison.
you may want to check out

and download the PCRE project and look into it.

ciao
drieux
---

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


Re: perl -ne 'if(/rcn/) {print "$ARGV: $_" unless -d}' *

2003-12-03 Thread Jerry Rocteur
On Tuesday, Dec 2, 2003, at 21:06 Europe/Brussels, John W. Krahn wrote:

Jerry Rocteur wrote:
Hi,
Hello,

I'm trying to use perl for most shell stuff and this is some of the
stuff I'm using for grep ..
perl -ne 'print "$ARGV: $_" if /jerry/i ' *
perl -ne 'print  if /jer{1,}y/i ' *
perl -ne 'print  unless /jer{1,}y/i ' *
I'm enjoying this as I can do a lot more than I can with the old egrep
on our Solaris boxes..
What I'd like to do is to make a simple change NOT to check in binary
files and directories..
I've toyed with all sorts of variations and started like this.

perl -ne '-f &&print  if /satreq/ ' * # Don't laugh this is one of 
very
many attempts ;-((

Then I tried this:

perl  -ne 'if(/rcn/) {print "$ARGV: $_" unless -d}' *

Which seems to do the trick but this is just excluding directories I
think..
But this gives me the same:

perl  -ne 'if(/.it/) {print "$ARGV: $_" unless -f}' *

How do I improve it to ONLY look in text files ?

I don't want to use the grep.pl's around or the grep from power tools,
I want to impress the ladies by typing these on the CLI ;-)) 
Seriously,
I love one liners..
Something like this might work (untested):

perl -ne' close ARGV unless -f ARGV && -T _; print if /jer+y/i ' *

From: Steve Mayer <[EMAIL PROTECTED]>
Jerry,
 Shouldn't you just be able to plug it in as you did below with the -d
 and -f operators?  Otherwise, you might be able to do something like
 this:
 perl -ne 'if( -T $ARGV && /.it/) {print "$ARGV: $_"}' *

Steve

Thanks very much for the answers on and off list.

I like these two above and I'll be testing them both during the next 
few days to see which one works the best..

Thanks heaps,

Jerry

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


RE: Timing several processes

2003-12-03 Thread Akens, Anthony
I already have some ideas for how I want to build the page, how 
to parse the data I will generate, etc.

As I said, I've looked at some of the other tools out there, 
and want to stick to some simple perl code to parse out the 
information and return the results.

The only bit I'm not sure of is how to tell if all forked processes 
have completed before moving on.


-Tony

-Original Message-
From: Tom Kinzer [mailto:[EMAIL PROTECTED] 
Sent: Wednesday, December 03, 2003 12:35 PM
To: [EMAIL PROTECTED]
Subject: RE: Timing several processes


 http://poe.perl.org 

Maybe this would be a good job for POE?

-Tom Kinzer


-Original Message-
From: Akens, Anthony [mailto:[EMAIL PROTECTED]
Sent: Wednesday, December 03, 2003 7:49 AM
To: [EMAIL PROTECTED]
Subject: Timing several processes


Hi all!

I'm wanting to write a simple web-based tool to see the status of
several servers at a glance.  I know there are many solutions existing,
but I can't learn as much about perl by just using one 
of those as I can by writing my own.  The first step I want to do 
is call a script from cron that runs several basic monitoring tools 
(sar, vmstat, df, iostat, etc) and saves the output of each to a 
file. Then I'd parse those files up, and write a summary file.

Easy enough.  And I could certainly do it with by calling the tools one
at a time.  However, I'd like to get roughly 1 minute of vmstat, 
iostat, and sar output Simultaneously.  So I'm supposing I'd 
want to fork off each process, and then when those are all done 
come back and run a script that then parses those results out for 
the individual statistics I'm looking for.

I've never used fork before, and while it looks fairly straight forward
what I am not sure of is how to make sure all of those forked 
processes have completed before moving on and parsing the files.

Any pointers?

Thanks in advance

-Tony

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


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


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



RE: using perl in a c code

2003-12-03 Thread Dan Muey
> 
> Can you once more explain why you want a C program that
> executes Perl code given as a string? 

Mainly learning purposes to better my mind

> And how should the Perl
> code be injected into the C program?

To illustrate it in Perl:
$perlcode = q(print "monkey";);
eval $perlcode;
Excpet in C

Explained a bit more below with the examples...

> 
> You can always do
> 
> const char *perlcode = "use CGI; ...";
> 
> This however is tedious since you can't break literal C
> strings into several lines and have to escape double-quotes 
> etc. There are probably a million ways to fill a string. It 
> really depends on your requirements.
> 
[snip]
> You could do:
> 
> printf("%s", SvPV(eval_pv(perlcode)));
> 
> >string = SvPV(ret, n_a);
> > 
> >perl_destruct(my_perl);
> >perl_free(my_perl);
> > 
> >  /** Would this be better right after string =
> SvPV(...) or after perl_free() ?? **/
> >  printf(string);
> 
> Probably better before you destruct and free the Perl interpreter.
> SvPV() does not return a copy of the string in the scalar
> variable. It returns the pointer in it. So it could happen 
> that the memory this pointer points to has been freed because 
> the Perl interpreter has been destructed.
> 
> How much of the allocated memory perl frees when exiting
> depends on the PERL_DESTRUCT_LEVEL (perl checks the value of 
> this environment variable when exiting). Per default perl 
> doesn't clean up very much and leaves this work to the 
> operating system. Nonetheless, it's safer to access the 
> perl-related memory before perl_free() happens.
> 
>
Thanks for that awesome info Tassilo
Here's where I'm at so far everyone who's keeping score at home:

Ok, I can compile this example with:
cc -o perlemb perlemb.c `perl -MExtUtils::Embed -e ccopts -e ldopts`  

I can run it like this:
./perlemb -e 'print "Howdy";'
Howdy
Or
./perlemb
print "Howdy";

Howdy

Here's what I have on the inetrnal version (IE the perl to execute is provided inside 
and not via cmd line)

#include/* from the Perl distribution */
#include  /* from the Perl distribution */

static PerlInterpreter *my_perl;  /***The Perl interpreter***/

int main(int argc, char **argv, char **env)
{
my_perl = perl_alloc();
perl_construct(my_perl);
perl_parse(my_perl, NULL, argc, argv, (char **)NULL);
perl_run(my_perl);
perl_destruct(my_perl);
perl_free(my_perl);
}

What I'd like to do with this is:

./perlemb2
Howdy
And eventually through using CGI's param() perhas:
./perlemb2 name=JoeMama
Howdy JoeMama

What I have so far for testing is:

#include 
#include 

static PerlInterpreter *my_perl;

main (int argc, char **argv, char **env)
{
   STRLEN n_a;
   const char *perlcode = "use CGI 'header';print header();print 'hello World';";

   my_perl = perl_alloc();
   perl_construct( my_perl );

   perl_parse(my_perl, NULL, argc, argv, (char **)NULL);

   perl_run(my_perl);

   printf("%s", SvPV(eval_pv(perlcode)));

   perl_destruct(my_perl);
   perl_free(my_perl);
}

But when I compile it the same way as the first I get:

perlemb.c:18: macro `SvPV' used with just one arg

So I tried it as 
printf("%s", SvPV(eval_pv(perlcode),n_a));
Which is how it was in another example and got:

perlemb.c: In function `main':
perlemb.c:18: invalid type argument of `->'
perlemb.c:18: invalid type argument of `->'
perlemb.c:18: invalid type argument of `->'
perlemb.c:18: warning: passing arg 1 of `Perl_sv_2pv' makes pointer from integer 
without a cast

I'm sure I'm missing somethgin obvious but I'm fascinated with this!

TIA

Dan

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



RE: Databases - MS Sql Server Desktop Engine

2003-12-03 Thread Paul Kraus
I can't figure out how to connect to the database engine with odbc.


Paul Kraus
Xp pro sp1 workstation.

> -Original Message-
> From: Aman Raheja [mailto:[EMAIL PROTECTED] 
> Sent: Wednesday, December 03, 2003 12:23 PM
> To: [EMAIL PROTECTED]
> Subject: Re: Databases - MS Sql Server Desktop Engine
> 
> 
> Someone will correct me if I am wrong, I don't have much 
> Windows experience.
> 
> Can't ODBC be used, in what you are doing?
> 
> Aman Raheja
> AGF Technologies
> http://www.agftech.com
> 
> 
> - Original Message - 
> From: "Paul Kraus" <[EMAIL PROTECTED]>
> To: <[EMAIL PROTECTED]>
> Sent: Wednesday, December 03, 2003 11:18 AM
> Subject: Databases - MS Sql Server Desktop Engine
> 
> 
> > Is there a DBI driver for the MS Sql Server Desktop Engine?
> > 
> > Paul
> > 
> > 
> > --
> > To unsubscribe, e-mail: [EMAIL PROTECTED]
> > For additional commands, e-mail: [EMAIL PROTECTED]
> > 
> > 
> 
> -- 
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
> 


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



RE: Timing several processes

2003-12-03 Thread Tom Kinzer
 http://poe.perl.org 

Maybe this would be a good job for POE?

-Tom Kinzer


-Original Message-
From: Akens, Anthony [mailto:[EMAIL PROTECTED]
Sent: Wednesday, December 03, 2003 7:49 AM
To: [EMAIL PROTECTED]
Subject: Timing several processes


Hi all!

I'm wanting to write a simple web-based tool to see the status
of several servers at a glance.  I know there are many solutions
existing, but I can't learn as much about perl by just using one 
of those as I can by writing my own.  The first step I want to do 
is call a script from cron that runs several basic monitoring tools 
(sar, vmstat, df, iostat, etc) and saves the output of each to a 
file. Then I'd parse those files up, and write a summary file.

Easy enough.  And I could certainly do it with by calling the tools
one at a time.  However, I'd like to get roughly 1 minute of vmstat, 
iostat, and sar output Simultaneously.  So I'm supposing I'd 
want to fork off each process, and then when those are all done 
come back and run a script that then parses those results out for 
the individual statistics I'm looking for.

I've never used fork before, and while it looks fairly straight
forward what I am not sure of is how to make sure all of those forked 
processes have completed before moving on and parsing the files.

Any pointers?

Thanks in advance

-Tony

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


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



set a cookie and redirect using CGI.pm

2003-12-03 Thread Aman Raheja

Hello

I want to set a user cookie and redirect to a different URL on the same domain.
I searched and found alternate ways of doing it.

I am looking for a way to do using CGI.pm

Suggestions?

Thank you
Aman

Re: Databases - MS Sql Server Desktop Engine

2003-12-03 Thread Aman Raheja
Someone will correct me if I am wrong, I don't have much Windows experience.

Can't ODBC be used, in what you are doing?

Aman Raheja
AGF Technologies
http://www.agftech.com


- Original Message - 
From: "Paul Kraus" <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Sent: Wednesday, December 03, 2003 11:18 AM
Subject: Databases - MS Sql Server Desktop Engine


> Is there a DBI driver for the MS Sql Server Desktop Engine?
> 
> Paul
> 
> 
> -- 
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
> 
> 

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



Databases - MS Sql Server Desktop Engine

2003-12-03 Thread Paul Kraus
Is there a DBI driver for the MS Sql Server Desktop Engine?

Paul


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



Re: Timing several processes

2003-12-03 Thread Casey West
It was Wednesday, December 03, 2003 when Akens, Anthony took the soap box, saying:
: Hi all!
: 
: I'm wanting to write a simple web-based tool to see the status
: of several servers at a glance.  I know there are many solutions
: existing, but I can't learn as much about perl by just using one 
: of those as I can by writing my own.  The first step I want to do 
: is call a script from cron that runs several basic monitoring tools 
: (sar, vmstat, df, iostat, etc) and saves the output of each to a 
: file. Then I'd parse those files up, and write a summary file.

You may be able to save yourself a load of time by using some
already-written tools such as Nagios or mon.

  http://www.nagios.org/
  http://www.kernel.org/software/mon/

  Casey West

-- 
Shooting yourself in the foot with APL 
You shoot yourself in the foot; then spend all day figuring out how to
do it in fewer characters. 


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



Re: Undefined subroutine

2003-12-03 Thread drieux
On Dec 3, 2003, at 3:59 AM, Jan Gruber wrote:
[..]
What could be a possible reason, that functions exported by a module  
appear
like that in the Symbol Table:

Eris_Gate::__ANON__[/usr/lib/perl5/site_perl/5.8.0/Modules/ 
Eris_Gate.pm:146]
Eris_Gate::__ANON__[/usr/lib/perl5/site_perl/5.8.0/Modules/ 
Eris_Gate.pm:147]
Eris_Gate::__ANON__[/usr/lib/perl5/site_perl/5.8.0/Modules/ 
Eris_Gate.pm:148]
that looks like an 'autoloader' event.

First of all, the line numbers are wrong, looking at the source there  
is no
sub definition in these lines.
Ok, so what IS at that lines 146..148 ???

In Eris_Gate.pm:
@EXPORT contains the names for the subs to be exported, @EXPORT_OK is  
empty
and the package @ISA (Exporter).
That is basically bassEndYakWard.
It would be politer to have them in
the @EXPORT_OK, and only push out a few
key default ones in @EXPORT.
I use Modules::Eris_Gate; in the script, but calling a sub defined in  
there
results in "Undefined subroutine &main::return_sumfink called at "
It might help us if you told us where we could
find this module, and what it is suppose to be about.
What am i missing?


As Rob noted, there is that question
of how exactly does the package line
in it read. Does it read as
	package Modules::Eris_Gate;

and hence your

	use Modules::Eris_Gate;

should have picked it up correctly.

OR does it read

	package Eris_Gate;

hence you should have used

use lib "/usr/lib/perl5/site_perl/5.8.0/Modules";
use Eris_Gate;


ciao
drieux
---

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


Re: using perl in a c code

2003-12-03 Thread Tassilo von Parseval
On Wed, Dec 03, 2003 at 09:35:54AM -0600 Dan Muey wrote:

> > On Tue, Dec 02, 2003 at 05:40:14PM -0600 Dan Muey wrote:
> > 
> > > What I was wondering about was how to execute some perl
> > code *inside*
> > > the c program instead of takign it via ARGV.  I  think eval_pv and
> > > eval_sv have somethgin to do with it but I'm a bit cloudy 
> > there. Since
> > > I don't know hardly anythgin about C I'll illustarte it in Perl.
> > > 
> > > my $perlcode = < > >   # instead of getting this via command line argument
> > >   sub simplepage {
> > >   my $name = shift || 'world';
> > >   use CGI qw(header param);
> > >   print header()
> > >   print "I am perl hear me roar $name\n";
> > >   print insult();
> > >   }
> > >   sub insult { return "So is ytour mother\n"; }
> > >   return simplepage(param('name'));
> > > CODE
> > > 
> > > printf eval_pv($perldoc);
> > > 
> > > Basically execute bunch of code, from a one liner to a
> > bunch of lines,
> > > that basically ends with one return value(an html webpage) and then
> > > print that value out.
> > 
> > This can't work because you cannot have return-statements
> > outside of subroutines in Perl. However, why not just leave 
> > the 'return' off:
> > 
> > my $perldocde = < > ...
> > simplepage(param{name});
> > CODE
> > 
> > And from C:
> > 
> > STRLEN  n_a;
> > char*string;
> > SV  *ret;
> > ...
> > ret = eval_pv(perlcode, TRUE);
> 
>   Is that a variable?

Yes. When I wrote 'char *string', I meant 'char *perlcode' actually.

>   How would one safely get some code into a C variable?
>   Like in Perl I can use qq() or similar or escape certain 
>   chacters. So double quotes don't kill me.

I can't really answer that because I don't understand what you want to
achieve. In the above, 'perlcode' is a plain C string containing the C
source. How you populate it is totally up to you.

Can you once more explain why you want a C program that executes Perl
code given as a string? And how should the Perl code be injected into
the C program?

> > string = SvPV(ret, n_a);
> > 
> > eval_pv() returns the last statement evaluated as a SV.
> > 
> 
> Thanks for the insight!  So, if I understand it right (and assuming I
> compile it properly of course ;p) I would need something like this:
> [questions commented]
> 
>#include 
>#include 
> 
>static PerlInterpreter *my_perl;
> 
>main (int argc, char **argv, char **env)
>{
>STRLEN n_a;
>char*string; /** added to perldoc example **/
>SV  *ret;/** added to perldoc example**/
> 
>my_perl = perl_alloc();
>perl_construct( my_perl );
> 
>perl_parse(my_perl, NULL, 3, embedding, NULL);
>perl_run(my_perl);
> 
>ret = eval_pv(perlcode, TRUE); /** So how do I get my code safely into 
> perlcode ?? **/

You can always do

const char *perlcode = "use CGI; ...";

This however is tedious since you can't break literal C strings into
several lines and have to escape double-quotes etc. There are probably a
million ways to fill a string. It really depends on your requirements.

>/** could I just printf(SvPV(...)) right here and shorten it a bit?? **/

You could do:

printf("%s", SvPV(eval_pv(perlcode)));

>string = SvPV(ret, n_a);
> 
>perl_destruct(my_perl);
>perl_free(my_perl);
> 
>/** Would this be better right after string = SvPV(...) or after perl_free() 
> ?? **/
>printf(string); 

Probably better before you destruct and free the Perl interpreter.
SvPV() does not return a copy of the string in the scalar variable. It
returns the pointer in it. So it could happen that the memory this
pointer points to has been freed because the Perl interpreter has been
destructed.

How much of the allocated memory perl frees when exiting depends on the
PERL_DESTRUCT_LEVEL (perl checks the value of this environment variable
when exiting). Per default perl doesn't clean up very much and leaves
this work to the operating system. Nonetheless, it's safer to access the
perl-related memory before perl_free() happens.

Tassilo
-- 
$_=q#",}])!JAPH!qq(tsuJ[{@"tnirp}3..0}_$;//::niam/s~=)]3[))_$-3(rellac(=_$({
pam{rekcahbus})(rekcah{lrePbus})(lreP{rehtonabus})!JAPH!qq(rehtona{tsuJbus#;
$_=reverse,s+(?<=sub).+q#q!'"qq.\t$&."'!#+sexisexiixesixeseg;y~\n~~;eval


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



Re: Undefined subroutine

2003-12-03 Thread Jan Gruber
Hi

> Where is Eris_Gate.pm, and what is its package declaration? From
> what you say it should be in
>   /usr/lib/perl5/site_perl/5.8.0/Modules

Right, its in there.

> and should read
>   package Modules::Eris_Gate

NO, it didn't. 
It read "package Eris_gate" before. Thanks, I missed this one at least 50 
times and I wont forget to name my packages correctly from now on.

Best regards,
Jan
-- 
cat /dev/world | perl -e "while (<>) {(/(^.*?\?) 42\!/) && (print $1)}"
errors->(c)
- 

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



Timing several processes

2003-12-03 Thread Akens, Anthony
Hi all!

I'm wanting to write a simple web-based tool to see the status
of several servers at a glance.  I know there are many solutions
existing, but I can't learn as much about perl by just using one 
of those as I can by writing my own.  The first step I want to do 
is call a script from cron that runs several basic monitoring tools 
(sar, vmstat, df, iostat, etc) and saves the output of each to a 
file. Then I'd parse those files up, and write a summary file.

Easy enough.  And I could certainly do it with by calling the tools
one at a time.  However, I'd like to get roughly 1 minute of vmstat, 
iostat, and sar output Simultaneously.  So I'm supposing I'd 
want to fork off each process, and then when those are all done 
come back and run a script that then parses those results out for 
the individual statistics I'm looking for.

I've never used fork before, and while it looks fairly straight
forward what I am not sure of is how to make sure all of those forked 
processes have completed before moving on and parsing the files.

Any pointers?

Thanks in advance

-Tony

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



Re: RE: Reading files

2003-12-03 Thread mgoland
Hi Bob,

Thanks for a good reply, see my coments under your questions.
- Original Message -
From: Bob Showalter <[EMAIL PROTECTED]>
Date: Wednesday, December 3, 2003 9:54 am
Subject: RE: Reading files

> [EMAIL PROTECTED] wrote:
> > Hello All,
> > I am trying to open a file once , and then duplicate it's
> > File Handle. I am trying to workout example straight from
> > FAQ5, with no luck. 
> 
> What does "no luck" mean? You never tell us what happens when you 
> run your
> code.

When I run my code, I can't read form the duped handle I have created.
> 
> > I will basicly trying to open a file, dup
> > off a few handles and spread them across other processes. 
> 
> Huh? What are you trying to do?

I have very large files, size ranges from 10-25 GB per file. I need to process them. I 
am trying to spawn off threads and each thread will get its own file handle, with a 
position { I plan on using seek to move the position of each handle }

> 
> > Here is the
> > code 
> > 
> > #!/usr/bin/perl -w
> 
> always 'use strict', as others have said.

good point, but this is a test code I wrote on fly.
> 
> > 
> > $file="./text";
> > $|=1;
> > use Fcntl;
> > use IO::Handle;
> > 
> > $D_LOG = $ENV{MHCONTEXTFD};
> 
> What is this supposed to be?

This ws take'n out of FAQ5 example " how can I dup file handles "
> 
> > 
> > open($LOG, "< logfile");
> > open($D_LOG, "<& LOG");
> 
> Check for errors!
> 
> > $LOG->autoflush(1);
> > $D_LOG->autoflush(1);
> 
> Why are you autoflushing handles opened for read? Does nothing.

That is true, I used this code where I was writing to files.
> 
> > 
> > $line1=<$LOG>;
> > $line2=<$D_LOG>;
> > 
> > print "1:$line1 2:$line2";
> > 
> 
> I think this approach is doomed to failure, do to the stdio 
> buffers not
> being shared.

Possibly, I have used sysread with no luck as well.

> 
> Why do you feel you need to dup the input handle? What's the 
> problem are you
> trying to solve?

Basicly as I said I need to process large files. I will write a multi threaded app and 
I dont want each thread to open a file. I'll have the main thread open a file once, 
and dup out handles which it will then distribute to the threads. each thread will get 
it's own small peace of file to work on, which should make processing these jobs alot 
faster. 


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



RE: using perl in a c code

2003-12-03 Thread Dan Muey
> On Tue, Dec 02, 2003 at 05:40:14PM -0600 Dan Muey wrote:
> 
> > What I was wondering about was how to execute some perl
> code *inside*
> > the c program instead of takign it via ARGV.  I  think eval_pv and
> > eval_sv have somethgin to do with it but I'm a bit cloudy 
> there. Since
> > I don't know hardly anythgin about C I'll illustarte it in Perl.
> > 
> > my $perlcode = < > # instead of getting this via command line argument
> > sub simplepage {
> > my $name = shift || 'world';
> > use CGI qw(header param);
> > print header()
> > print "I am perl hear me roar $name\n";
> > print insult();
> > }
> > sub insult { return "So is ytour mother\n"; }
> > return simplepage(param('name'));
> > CODE
> > 
> > printf eval_pv($perldoc);
> > 
> > Basically execute bunch of code, from a one liner to a
> bunch of lines,
> > that basically ends with one return value(an html webpage) and then
> > print that value out.
> 
> This can't work because you cannot have return-statements
> outside of subroutines in Perl. However, why not just leave 
> the 'return' off:
> 
> my $perldocde = < ...
> simplepage(param{name});
> CODE
> 
> And from C:
> 
> STRLEN  n_a;
> char*string;
> SV  *ret;
> ...
> ret = eval_pv(perlcode, TRUE);
  
Is that a variable?
How would one safely get some code into a C variable?
Like in Perl I can use qq() or similar or escape certain 
chacters. So double quotes don't kill me.

> string = SvPV(ret, n_a);
> 
> eval_pv() returns the last statement evaluated as a SV.
> 

Thanks for the insight!
So, if I understand it right (and assuming I compile it properly of course ;p) I would 
need something like this: [questions commented]

   #include 
   #include 

   static PerlInterpreter *my_perl;

   main (int argc, char **argv, char **env)
   {
   STRLEN n_a;
   char*string; /** added to perldoc example **/
   SV  *ret;/** added to perldoc example**/

   my_perl = perl_alloc();
   perl_construct( my_perl );

   perl_parse(my_perl, NULL, 3, embedding, NULL);
   perl_run(my_perl);

   ret = eval_pv(perlcode, TRUE); /** So how do I get my code safely into perlcode 
?? **/

 /** could I just printf(SvPV(...)) right here and shorten it a bit?? **/
   string = SvPV(ret, n_a);

   perl_destruct(my_perl);
   perl_free(my_perl);

 /** Would this be better right after string = SvPV(...) or after perl_free() 
?? **/
 printf(string); 
   }  

I got the first example (IE the -e "print "howdy";' version) working and am playing 
around with having it inside

> Tassilo
> --
> $_=q#",}])!JAPH!qq(tsuJ[{@"tnirp}3..0}_$;//::niam/s~=)]3[))_$-
> 3(rellac(=_$({
> pam{rekcahbus})(rekcah{lrePbus})(lreP{rehtonabus})!JAPH!qq(reh
> tona{tsuJbus#;
> $_=reverse,s+(?<=sub).+q#q!'"qq.\t$&."'!#+sexisexiixesixeseg;y
> ~\n~~;eval
> 
> 

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



Re: search and replace using regex

2003-12-03 Thread Rob Dixon
Saskia Van Der Elst wrote:
>
> I have trouble executing a search and replace through all files in a certain
> directory.
>
> I want to replace " _
> Can I match a white-space?
>
> I have tried the following regex:
>
> s/ _\

RE: using perl in a c code

2003-12-03 Thread Dan Muey
Don't get me wrong, I have no practical reason for running website stuff from C. I 
think it may be valueable to know at some point and would be a terrific learning 
experience.

> Now as for the code fragment:

Which is a Perl example of what I think would be cool to be able to do with C...

>> my $perlcode = <>  # instead of getting this via command line argument
>>  sub simplepage {
#oops I meant to have gotten all that return()ed it instead of 
print()ed...
>>  my $name = shift || 'world';
>>  #use CGI qw(header param); # moved this to above
>>  print header()
>>  print "I am perl hear me roar $name\n";
>>  print insult();
return header()."I am perl hear me roar $name\n".insult();
# there that's what I meant instead of the print statements
>>  }
>>  sub insult { return "So is ytour mother\n"; }
>>  return simplepage(param('name'));
>> CODE
>>
>> printf eval_pv($perldoc);

where printf and evl_pv is the c code I need to output the return value of the code 
$perlcode

> what happens when the simple.cgi is called without arguments?
> eg: if there is no 'name' in the parameter list???

That what the shift || 'world' is for.

> More importantly, how are you planning to differenciate between say a 
> 'POST' request, a 'HEAD' request, and a 'GET' request.

CGI moduile does it for me! (Which I had in the wrong place) 

I think the use of CGI and webpageish environment clouded my question.

What I'd like to see if can be done is this:

Put some perl code, that if run from a command line or browser or whatever 
with or with our input of some sort would output some ascii text, 
Inside of C program, probably as avariable I'm guessing then use 
C to execute it and take what it outputs and , well oout put it.

Like I said NO: 'I'm goanna replace Perl/mod_perl' SIMPLY, purley an 
educational project that I think may help me learn somethgin.

Thanks

Dan


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



Re: search and replace using regex

2003-12-03 Thread Rob Dixon
Drieux wrote:
>
> On Dec 3, 2003, at 12:25 PM, Saskia van der Elst wrote:
>
> > I have trouble executing a search and replace through all files in a
> > certain
> > directory.
> >
> > I want to replace " _ >
> > Can I match a white-space?
> >
> > I have tried the following regex:
> >
> > s/ _\ [..]
>
> I agree with Tom that you get better
> mileage by putting your delimiters to
> something OTHER than a token in the
> pattern that you are matching.
>
> but there is also the little detail
> of putting that "\" in the right place.
>
> $_ =~ s/"_\
> should ahve been
>
> $_ =~ s/_<\/pat/<\/pat/gi; #g for every occurrence, i for
>
> target what you WANT to target and no more.
>
> remember that those double quotes will allow things
> to be 'interpolated' - which is not what you want.

No they won't: they're not string delimiters in this context
so they'll be treated as any other non-special character between
the real s/// slash delimiters.

Rob



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



Re: Undefined subroutine

2003-12-03 Thread Rob Dixon
Jan Gruber wrote:
>
> What could be a possible reason, that functions exported by a module appear
> like that in the Symbol Table:
>
> Eris_Gate::__ANON__[/usr/lib/perl5/site_perl/5.8.0/Modules/Eris_Gate.pm:146]
> Eris_Gate::__ANON__[/usr/lib/perl5/site_perl/5.8.0/Modules/Eris_Gate.pm:147]
> Eris_Gate::__ANON__[/usr/lib/perl5/site_perl/5.8.0/Modules/Eris_Gate.pm:148]
>
> First of all, the line numbers are wrong, looking at the source there is no
> sub definition in these lines.
>
> In Eris_Gate.pm:
> @EXPORT contains the names for the subs to be exported, @EXPORT_OK is empty
> and the package @ISA (Exporter).
>
> I use Modules::Eris_Gate; in the script, but calling a sub defined in there
> results in "Undefined subroutine &main::return_sumfink called at "

At first guess it looks like a problem with DynaLoader. But can
you show us what code you've used to produce your output?

Where is Eris_Gate.pm, and what is its package declaration? From
what you say it should be in

  /usr/lib/perl5/site_perl/5.8.0/Modules

and should read

  package Modules::Eris_Gate

Is that right?

Rob



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



RE: Reading files

2003-12-03 Thread Bob Showalter
[EMAIL PROTECTED] wrote:
> Hello All,
> I am trying to open a file once , and then duplicate it's
> File Handle. I am trying to workout example straight from
> FAQ5, with no luck. 

What does "no luck" mean? You never tell us what happens when you run your
code.

> I will basicly trying to open a file, dup
> off a few handles and spread them across other processes. 

Huh? What are you trying to do?

> Here is the
> code 
> 
> #!/usr/bin/perl -w

always 'use strict', as others have said.

> 
> $file="./text";
> $|=1;
> use Fcntl;
> use IO::Handle;
> 
> $D_LOG = $ENV{MHCONTEXTFD};

What is this supposed to be?

> 
> open($LOG, "< logfile");
> open($D_LOG, "<& LOG");

Check for errors!

> $LOG->autoflush(1);
> $D_LOG->autoflush(1);

Why are you autoflushing handles opened for read? Does nothing.

> 
> $line1=<$LOG>;
> $line2=<$D_LOG>;
> 
> print "1:$line1 2:$line2";
> 

I think this approach is doomed to failure, do to the stdio buffers not
being shared.

Why do you feel you need to dup the input handle? What's the problem are you
trying to solve?

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



RE: Net::SSH and Net::FTP?

2003-12-03 Thread Dan Muey

> Thanks for the reply Dan, the two remote servers do not have 
> FTP running on them, so they must initialize the FTP 

Nuts!

> connection. I've now built the scripts on their ends, I'm 
> working on an SSH script that will login to them and launch 
> the scripts on each server. Got the traffic direction thing 
> going on, so I'm trying to figure out who can login where? 

Here's a nutty idea if permissions allow:
pu the ftp script on one servers and call it via http(s) instead of ssh
I do that to update certain files across multiple places:
- submit a form that modifies a local file
- then it ftp's the new file to several servers giving me 
status on each one so if it fails I can do it by hand

Not sure if that will help or not but you never know!
Of course ssh is cool too so either way I'm happy!

DMuey

> I'll post the results once they all work. Right in the middle 
> of all this, my primary server got upgraded to 5.6.1 so we'll 
> see how that messes everything up? Ever forward.
> 
> Mark-Nathaniel Weisman
> President / Owner
> Outland Domain Group
> Anchorage, Alaska
> 
> 
> 
> -Original Message-
> From: Dan Muey [mailto:[EMAIL PROTECTED] 
> Sent: Tuesday, December 02, 2003 6:38 AM
> To: [EMAIL PROTECTED]
> Subject: RE: Net::SSH and Net::FTP?
> 
> 
> > > 
> > > I would like to use SSH to login to a remote system, then
> > using FTP,
> > > upload a file from the remote machine to another machine 
> which will 
> > > display the data. If I can automate this process, I think
> > I'll be in
> > > great shape, tell me does this code seem like it would work
> > for this?
> 
> Just a thought, if you're having trouble with the ssh part.
> 
> You could just use ftp for both servers?
> 
> use Net::FTP;
> 
> $ftpa = Net::FTP->new("a.host.name", Debug => 0)
>   or die "Cannot connect to a.host.name: $@";
> $ftpb = Net::FTP->new("b.host.name", Debug => 0)
>   or die "Cannot connect to b.host.name: $@";
>  
> $ftpa->login($usera,$passa)
>   or die "Cannot login to A", $ftp->message;
> $ftpb->login($userb,$passb)
>   or die "Cannot login to B", $ftp->message;
> 
> $ftpa->cwd("/files/blah")
>   or die "Cannot change working directory A", $ftp->message;
> $ftpb->cwd("/foo/monkey")
>   or die "Cannot change working directory B", $ftp->message;
> 
> for(@filestotransfer) {
> # then use $ftpa->read() and $ftpb->write() to xfr them 
> between each other, 
> # sorry for lack of example I'm a bit busy!
> }
> 
> $ftpa->quit;
> $ftpb->quit;
> 
> Transfer files back and forth between the 2 Net::FTP objects. I'm not 
> saying it's better or anythgin, just another way to do it 
> that may help 
> if ssh is being tricky as it some times can.
> 
> HTH
> 
> DMuey
> 
> -- 
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
> 
> 
> -- 
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
> 
> 

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



Bio::MAGE

2003-12-03 Thread Sebastian Jünemann
Hi List!

Im new in Perl and just starting with a big Mission...
I have to use teh Bio::MAGE Modul to Parse Mage-ML Files ( these ar 
eXML-Files) and put them in a SQL DB!
But this Modul is really huge and  besides i must modify they due to we use 
02DBI instead of the included SQL.pm!
So my question: Do anyone of you ever get near with on eof this Classes and 
know how the work and how to use them?
I've already gooled and searched at cpan and perl org ...but whithout a 
Conclusion!

thx a lot

_
Schluß mit Spam! http://www.msn.de/antispam/prevention/junkmailfilter Wir 
helfen Ihnen, unerwünschte E-Mails zu reduzieren.

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


RE: Reading files

2003-12-03 Thread Wiggins d Anconia
> OK, but how about:
> 
> 1)where is $LOG being set?

$LOG is the first opened filehandle...

> 2)does it get past the dies shown below?
> 3)got strict?  it's 'fer your own good, you know! ;)
> 

Good question, good point

> -Tom Kinzer
> 
> 
> 
> #!/usr/bin/perl -w
> 
> $file="./text";
> $|=1;
> use Fcntl;
> use IO::Handle;
> 
> $D_LOG = $ENV{MHCONTEXTFD};
> 
> open($LOG, "< logfile") or die "Unable to open 1st handle, stopped";
> open($D_LOG, "<& LOG")  or die "Unable to open 2nd handle, stopped";

In the above (I believe) Perl does not know that LOG is a filehandle
rather than just the name of a file in the local directory or an
improper filehandle/file descriptor. If you intend to pass $LOG as a
filehandle you will need to do so properly. Whether you can use the 2
argument form with a $LOG in there I am not sure (it might get
stringified), you should definitely be able to use a 3 argument form and
then *not* quote $LOG.  That or you should open your filehandle into a
named filehandle such as LOG rather than into a variable. (Regardless
you should add a $! to the error message to know *why* it failed not
just that it did) On top of this you set $file, but then open
'logfile'??? Are you supposed to be opening $file?  And you said $D_LOG
to an environment variable, presumably an open file descriptor???, and
then clobber it by duping the other opened file handle into it?  So
basically I have no idea what your actual intentions are... what are you
*really* trying to do?

perldoc perlopentut
perldoc -f open
perldoc -f pipe

> $LOG->autoflush(1);
> $D_LOG->autoflush(1);
> 
> $line1=<$LOG>;
> $line2=<$D_LOG>;
> 
> print "1:$line1 2:$line2";
> 



http://danconia.org

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



Bio::MAGE

2003-12-03 Thread Sebastian Jünemann
Hi List!

Im new in Perl and just starting with a big Mission...
I have to use teh Bio::MAGE Modul to Parse Mage-ML Files ( these ar 
eXML-Files) and put them in a SQL DB!
But this Modul is really huge and  besides i must modify they due to we use 
02DBI instead of the included SQL.pm!
So my question: Do anyone of you ever get near with on eof this Classes and 
know how the work and how to use them?
I've already gooled and searched at cpan and perl org ...but whithout a 
Conclusion!

thx a lot

_
NEU: Polyphone Klingeltöne und farbige Logos für Ihr Handy! 
http://polyphonetoene.handy.msn.de Jetzt Handy aufpeppen!

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


Undefined subroutine

2003-12-03 Thread Jan Gruber
Hi!

What could be a possible reason, that functions exported by a module appear 
like that in the Symbol Table:

Eris_Gate::__ANON__[/usr/lib/perl5/site_perl/5.8.0/Modules/Eris_Gate.pm:146]
Eris_Gate::__ANON__[/usr/lib/perl5/site_perl/5.8.0/Modules/Eris_Gate.pm:147]
Eris_Gate::__ANON__[/usr/lib/perl5/site_perl/5.8.0/Modules/Eris_Gate.pm:148]

First of all, the line numbers are wrong, looking at the source there is no 
sub definition in these lines.

In Eris_Gate.pm:
@EXPORT contains the names for the subs to be exported, @EXPORT_OK is empty 
and the package @ISA (Exporter).

I use Modules::Eris_Gate; in the script, but calling a sub defined in there 
results in "Undefined subroutine &main::return_sumfink called at "

What am i missing?

TIA
Jan
-- 
cat /dev/world | perl -e "while (<>) {(/(^.*?\?) 42\!/) && (print $1)}"
errors->(c)
- 

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



Something like PHP's PEAR::DB_NestedSet?

2003-12-03 Thread David Garamond
This PHP module looks cool:

 http://pear.php.net/package/DB_NestedSet

is there something like it in CPAN?

--
dave


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


RE: Net::SSH and Net::FTP?

2003-12-03 Thread Mark Weisman
Thanks for the reply Dan, the two remote servers do not have FTP running
on them, so they must initialize the FTP connection. I've now built the
scripts on their ends, I'm working on an SSH script that will login to
them and launch the scripts on each server. Got the traffic direction
thing going on, so I'm trying to figure out who can login where? I'll
post the results once they all work. Right in the middle of all this, my
primary server got upgraded to 5.6.1 so we'll see how that messes
everything up? Ever forward.

Sincerely in Christ,
Mark-Nathaniel Weisman
President / Owner
Outland Domain Group
Anchorage, Alaska



-Original Message-
From: Dan Muey [mailto:[EMAIL PROTECTED] 
Sent: Tuesday, December 02, 2003 6:38 AM
To: [EMAIL PROTECTED]
Subject: RE: Net::SSH and Net::FTP?


> > 
> > I would like to use SSH to login to a remote system, then
> using FTP,
> > upload a file from the remote machine to another machine which will
> > display the data. If I can automate this process, I think 
> I'll be in
> > great shape, tell me does this code seem like it would work
> for this?

Just a thought, if you're having trouble with the ssh part.

You could just use ftp for both servers?

use Net::FTP;

$ftpa = Net::FTP->new("a.host.name", Debug => 0)
  or die "Cannot connect to a.host.name: $@";
$ftpb = Net::FTP->new("b.host.name", Debug => 0)
  or die "Cannot connect to b.host.name: $@";
 
$ftpa->login($usera,$passa)
  or die "Cannot login to A", $ftp->message;
$ftpb->login($userb,$passb)
  or die "Cannot login to B", $ftp->message;

$ftpa->cwd("/files/blah")
  or die "Cannot change working directory A", $ftp->message;
$ftpb->cwd("/foo/monkey")
  or die "Cannot change working directory B", $ftp->message;

for(@filestotransfer) {
# then use $ftpa->read() and $ftpb->write() to xfr them between each
other, 
# sorry for lack of example I'm a bit busy!
}

$ftpa->quit;
$ftpb->quit;

Transfer files back and forth between the 2 Net::FTP objects. I'm not 
saying it's better or anythgin, just another way to do it that may help 
if ssh is being tricky as it some times can.

HTH

DMuey

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


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



Re: using perl in a c code

2003-12-03 Thread Tassilo von Parseval
On Tue, Dec 02, 2003 at 05:40:14PM -0600 Dan Muey wrote:

> What I was wondering about was how to execute some perl code *inside*
> the c program instead of takign it via ARGV.  I  think eval_pv and
> eval_sv have somethgin to do with it but I'm a bit cloudy there.
> Since I don't know hardly anythgin about C I'll illustarte it in Perl.
> 
> my $perlcode = <   # instead of getting this via command line argument
>   sub simplepage {
>   my $name = shift || 'world';
>   use CGI qw(header param);
>   print header()
>   print "I am perl hear me roar $name\n";
>   print insult();
>   }
>   sub insult { return "So is ytour mother\n"; }
>   return simplepage(param('name'));
> CODE
> 
> printf eval_pv($perldoc);
> 
> Basically execute bunch of code, from a one liner to a bunch of lines,
> that basically ends with one return value(an html webpage) and then
> print that value out. 

This can't work because you cannot have return-statements outside of
subroutines in Perl. However, why not just leave the 'return' off:

my $perldocde = <