[32234] in Perl-Users-Digest

home help back first fref pref prev next nref lref last post

Perl-Users Digest, Issue: 3499 Volume: 11

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Thu Sep 15 11:09:27 2011

Date: Thu, 15 Sep 2011 08:09:10 -0700 (PDT)
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)

Perl-Users Digest           Thu, 15 Sep 2011     Volume: 11 Number: 3499

Today's topics:
        accessing parameters in GET response <john1949@yahoo.com>
    Re: accessing parameters in GET response <glex_no-spam@qwest-spam-no.invalid>
    Re: accessing parameters in GET response <john1949@yahoo.com>
    Re: accessing parameters in GET response <hjp-usenet2@hjp.at>
        how to get this type of combinations??? <epradeep.kumar1439@gmail.com>
    Re: how to get this type of combinations??? <RedGrittyBrick@spamweary.invalid>
    Re: how to get this type of combinations??? <tadmc@seesig.invalid>
    Re: how to get this type of combinations??? <jurgenex@hotmail.com>
    Re: how to get this type of combinations??? <tadmc@seesig.invalid>
    Re: how to get this type of combinations??? (Randal L. Schwartz)
        link text retrieval <jinuacademy@gmail.com>
    Re: link text retrieval <tadmc@seesig.invalid>
        Question about range of Lines <dba1@csi.it>
    Re: Question about range of Lines <lcof@nomail.com>
    Re: Question about range of Lines <tadmc@seesig.invalid>
    Re: Question about range of Lines <dba1@csi.it>
    Re: Question about range of Lines <dba1_no_spam@csi.it>
    Re: Question about range of Lines <lcof@nospam.invalid>
    Re: Question about range of Lines <dba1_no_spam@csi.it>
    Re: Question about range of Lines <lcof@nospam.invalid>
    Re: Question about range of Lines <dba1_no_spam@csi.it>
    Re: R and Perl <r.ted.byers@gmail.com>
    Re: Running untrusted code inside a chroot/iptables jai <nostop@nonet.com>
        Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)

----------------------------------------------------------------------

Date: Tue, 13 Sep 2011 12:59:32 +0100
From: "John" <john1949@yahoo.com>
Subject: accessing parameters in GET response
Message-Id: <j4ngj3$8gf$1@news.albasani.net>

I have

use LWP::UserAgent;
my $ua = new LWP::UserAgent;
my $response = $ua->get($url);
my $content = $response->content;

I can get the parameters values a=b c=d etc by @parts=split(/\&/,$content) 
etc etc

but is there an easier way?

Regards
John






------------------------------

Date: Tue, 13 Sep 2011 13:23:28 +0000
From: "J. Gleixner" <glex_no-spam@qwest-spam-no.invalid>
Subject: Re: accessing parameters in GET response
Message-Id: <4e6f5950$0$63199$815e3792@news.qwest.net>

On 09/13/11 11:59, John wrote:
> I have
>
> use LWP::UserAgent;
> my $ua = new LWP::UserAgent;
> my $response = $ua->get($url);
> my $content = $response->content;
>
> I can get the parameters values a=b c=d etc by @parts=split(/\&/,$content)
> etc etc
>
> but is there an easier way?

Seems like a odd value for $content...

Also, if that does work, what could be easier than a 5 line program and 
calling split? (BTW: no need to escape it.)

What are you really trying to do?


------------------------------

Date: Tue, 13 Sep 2011 18:59:52 +0100
From: "John" <john1949@yahoo.com>
Subject: Re: accessing parameters in GET response
Message-Id: <j4o5mn$o4h$1@news.albasani.net>


"J. Gleixner" <glex_no-spam@qwest-spam-no.invalid> wrote in message 
news:4e6f5950$0$63199$815e3792@news.qwest.net...
> On 09/13/11 11:59, John wrote:
>> I have
>>
>> use LWP::UserAgent;
>> my $ua = new LWP::UserAgent;
>> my $response = $ua->get($url);
>> my $content = $response->content;
>>
>> I can get the parameters values a=b c=d etc by 
>> @parts=split(/\&/,$content)
>> etc etc
>>
>> but is there an easier way?
>
> Seems like a odd value for $content...
>
> Also, if that does work, what could be easier than a 5 line program and 
> calling split? (BTW: no need to escape it.)
>
> What are you really trying to do?

Yes, you're right it's only 5 lines.  I was thinking whether there existed a 
one liner - perhaps part of LWP or CGI.

Thanks.
John





------------------------------

Date: Tue, 13 Sep 2011 22:19:09 +0200
From: "Peter J. Holzer" <hjp-usenet2@hjp.at>
Subject: Re: accessing parameters in GET response
Message-Id: <slrnj6velu.1sg.hjp-usenet2@hrunkner.hjp.at>

On 2011-09-13 13:23, J. Gleixner <glex_no-spam@qwest-spam-no.invalid> wrote:
> On 09/13/11 11:59, John wrote:
>> I have
>>
>> use LWP::UserAgent;
>> my $ua = new LWP::UserAgent;
>> my $response = $ua->get($url);
>> my $content = $response->content;
>>
>> I can get the parameters values a=b c=d etc by @parts=split(/\&/,$content)
>> etc etc
>>
>> but is there an easier way?
>
> Seems like a odd value for $content...

Content-Type: application/x-www-form-urlencoded

This is normal for the body of a request, but you are right, it is very
unusual for the body of a response. (Could be part of an API, though -
easier to parse than XML or JSON)


> Also, if that does work, what could be easier than a 5 line program and 
> calling split? (BTW: no need to escape it.)

If it really is application/x-www-form-urlencoded, split alone isn't
sufficient. You have to do something like (WARNING: Untested code):

for my $part (split(/&/, $content)) {
    my ($k, $v) = split(/=/, $part, 2);
    s/=([0-9A-F])/chr(hex($1))/e for ($k, $v);
    $_ = decode('UTF-8', $_) for ($k, $v); # if params in UTF-8
    push @params, [$k, $v];                # or use HoA
}

Interestingly, the CGI module doesn't seem to have a nice, exposed
interface for this stuff (although there are few more or less obvious
hacks to get it to parse urlencoded strings).

	hp


------------------------------

Date: Tue, 13 Sep 2011 07:06:48 -0700 (PDT)
From: pradeep <epradeep.kumar1439@gmail.com>
Subject: how to get this type of combinations???
Message-Id: <4d823461-4f8a-4d9d-8a7b-3b579c4dd473@y39g2000prd.googlegroups.com>

Hi,
I do have a doubt ,
Input :
 1,2,3,4,5,6
output :
1-2,3-4,5-6
1-2,3-5,4-6
1-2,3-6,4-5

1-3,2-4,5-6
1-3,2-5,4-6
1-3,2-6,4-5

1-4,2-3,5-6
1-4,2-5,3-6
1-4,2-6,3-5

1-5,2-3,4-6
1-5,2-4,3-6
1-5,2-6,3-4

1-6,2-3,4-5
1-6,2-4,3-5
1-6,2-5,3-4

Can you help me in this????


------------------------------

Date: Tue, 13 Sep 2011 16:15:31 +0100
From: RedGrittyBrick <RedGrittyBrick@spamweary.invalid>
Subject: Re: how to get this type of combinations???
Message-Id: <4e6f7368$0$2919$fa0fcedb@news.zen.co.uk>

On 13/09/2011 15:06, pradeep wrote:
> Hi,
> I do have a doubt ,
> Input :
>   1,2,3,4,5,6
> output :
> 1-2,3-4,5-6
> 1-2,3-5,4-6
> 1-2,3-6,4-5
>
> 1-3,2-4,5-6
> 1-3,2-5,4-6
> 1-3,2-6,4-5
>
> 1-4,2-3,5-6
> 1-4,2-5,3-6
> 1-4,2-6,3-5
>
> 1-5,2-3,4-6
> 1-5,2-4,3-6
> 1-5,2-6,3-4
>
> 1-6,2-3,4-5
> 1-6,2-4,3-5
> 1-6,2-5,3-4
>
> Can you help me in this????

Yes.

0) Read posting guidelines that are posted here every few days.

1) Don't ask homework questions here. Make an attempt first. Read 
http://www.catb.org/~esr/faqs/smart-questions.html#homework - it really 
is useful.

2) Think of an alogorithm. Implement in concise Perl. Cut & Paste code + 
output here. Describe difference between actual and desired output.

3) Think of keywords (Combinations? Permutations?). Search CPAN for 
modules. Read descriptions. Write concise Perl to use chosen module. Cut 
& Paste code and output here. Describe difference between actual and 
desired output.

-- 
RGB


------------------------------

Date: Tue, 13 Sep 2011 14:25:14 -0500
From: Tad McClellan <tadmc@seesig.invalid>
Subject: Re: how to get this type of combinations???
Message-Id: <slrnj6vaq7.ior.tadmc@tadbox.sbcglobal.net>

RedGrittyBrick <RedGrittyBrick@spamweary.invalid> wrote:
> On 13/09/2011 15:06, pradeep wrote:
>> Hi,
>> I do have a doubt ,
>> Input :
>>   1,2,3,4,5,6
>> output :
>> 1-2,3-4,5-6
>> 1-2,3-5,4-6
>> 1-2,3-6,4-5
>>
>> 1-3,2-4,5-6
>> 1-3,2-5,4-6
>> 1-3,2-6,4-5
>>
>> 1-4,2-3,5-6
>> 1-4,2-5,3-6
>> 1-4,2-6,3-5
>>
>> 1-5,2-3,4-6
>> 1-5,2-4,3-6
>> 1-5,2-6,3-4
>>
>> 1-6,2-3,4-5
>> 1-6,2-4,3-5
>> 1-6,2-5,3-4
>>
>> Can you help me in this????
>
> Yes.
>
> 0) Read posting guidelines that are posted here every few days.
>
> 1) Don't ask homework questions here. Make an attempt first. Read 
> http://www.catb.org/~esr/faqs/smart-questions.html#homework - it really 
> is useful.
>
> 2) Think of an alogorithm. Implement in concise Perl. Cut & Paste code + 
> output here. Describe difference between actual and desired output.
>
> 3) Think of keywords (Combinations? Permutations?). Search CPAN for 
> modules. Read descriptions. Write concise Perl to use chosen module. Cut 
> & Paste code and output here. Describe difference between actual and 
> desired output.


4) Do NOT search the internet for the email address of someone
who looks like they know Perl and then send them email containing
your question!



-- 
Tad McClellan
email: perl -le "print scalar reverse qq/moc.liamg\100cm.j.dat/"
The above message is a Usenet post.
I don't recall having given anyone permission to use it on a Web site.


------------------------------

Date: Tue, 13 Sep 2011 17:38:36 -0700
From: Jürgen Exner <jurgenex@hotmail.com>
Subject: Re: how to get this type of combinations???
Message-Id: <mltv671kg386jsu0o14lrmk40p2ict1to4@4ax.com>

pradeep <epradeep.kumar1439@gmail.com> wrote:
>I do have a doubt ,

You have a doubt about what?

>Input :
> 1,2,3,4,5,6

Well, ok, so I guess this is a list of 5 numbers?

>output :
>1-2,3-4,5-6
>1-2,3-5,4-6
>1-2,3-6,4-5
[...]

Ok, so you are getting this output. 

>Can you help me in this????

Help you with what? You didn't even ask a question or stated a problem
yet. 
Not to mention that you forgot to post your code and the desired output.
Therefore there is no way for us to tell what is wrong with your code.

jue


------------------------------

Date: Tue, 13 Sep 2011 22:21:22 -0500
From: Tad McClellan <tadmc@seesig.invalid>
Subject: Re: how to get this type of combinations???
Message-Id: <slrnj706mr.jm4.tadmc@tadbox.sbcglobal.net>

Jürgen Exner <jurgenex@hotmail.com> wrote:
> pradeep <epradeep.kumar1439@gmail.com> wrote:

>>Input :
>> 1,2,3,4,5,6
>
> Well, ok, so I guess this is a list of 5 numbers?


Six, m'Lord.


-- 
Tad McClellan
email: perl -le "print scalar reverse qq/moc.liamg\100cm.j.dat/"
The above message is a Usenet post.
I don't recall having given anyone permission to use it on a Web site.


------------------------------

Date: Wed, 14 Sep 2011 16:52:30 -0700
From: merlyn@stonehenge.com (Randal L. Schwartz)
Subject: Re: how to get this type of combinations???
Message-Id: <86ipou1y2p.fsf@red.stonehenge.com>

>>>>> "Tad" == Tad McClellan <tadmc@seesig.invalid> writes:

Tad> 4) Do NOT search the internet for the email address of someone
Tad> who looks like they know Perl and then send them email containing
Tad> your question!

Oh, you too?

Ok, I'm ignoring the loon then.

[mail deleted]

-- 
Randal L. Schwartz - Stonehenge Consulting Services, Inc. - +1 503 777 0095
<merlyn@stonehenge.com> <URL:http://www.stonehenge.com/merlyn/>
Smalltalk/Perl/Unix consulting, Technical writing, Comedy, etc. etc.
See http://methodsandmessages.posterous.com/ for Smalltalk discussion


------------------------------

Date: Tue, 13 Sep 2011 12:08:15 -0700 (PDT)
From: byung <jinuacademy@gmail.com>
Subject: link text retrieval
Message-Id: <2d473f6c-f433-434d-8f48-4bfab336d038@h32g2000prl.googlegroups.com>

I am using ..

$mech->find_all_links( ... )

in www::mechanize in order to find all links in a page.

Now how can I retrieve the link text in addition to url of the link??

suppose there is a link - click_here, with url - www.clickhere.com.

Using $mech->find_all_links( ... ), I can find www.clickhere.com, but
how can I retrieve the text 'click_here' also??

Please help.  will deeply appreciate.

Thank you.


------------------------------

Date: Tue, 13 Sep 2011 14:22:38 -0500
From: Tad McClellan <tadmc@seesig.invalid>
Subject: Re: link text retrieval
Message-Id: <slrnj6valb.ior.tadmc@tadbox.sbcglobal.net>

byung <jinuacademy@gmail.com> wrote:
> I am using ..
>
> $mech->find_all_links( ... )
>
> in www::mechanize in order to find all links in a page.


How are you using it?

In list context?

In scalar context?

You should provide a short and complete program that we can run...


> Now how can I retrieve the link text in addition to url of the link??
                                  ^^^^
                                  ^^^^

Errr, by calling the strangley named "text()" method perhaps?


------------------
#!/usr/bin/perl
use warnings;
use strict;
use WWW::Mechanize;

my $mech = WWW::Mechanize->new();
$mech->get('http://www.perl.org');

foreach my $link ($mech->find_all_links) {
    print $link->url, "\n";
    print "    ", $link->text, "\n";
}
------------------


-- 
Tad McClellan
email: perl -le "print scalar reverse qq/moc.liamg\100cm.j.dat/"
The above message is a Usenet post.
I don't recall having given anyone permission to use it on a Web site.


------------------------------

Date: Thu, 15 Sep 2011 09:28:42 +0200
From: mauro papandrea <dba1@csi.it>
Subject: Question about range of Lines
Message-Id: <j4s9fa$32g$1@mophus.csi.it>

Given this simple file:

cat t1

Sunday
Monday
Tuesday
Wednesday
Thursday
Friday
Saturday

with

perl -ne 'print if /Tuesday/ ..  /Friday/;' t1

I can get:

Tuesday
Wednesday
Thursday
Friday


Is there a simple way to modify the range selection in order to get all 
the lines but the last in the range?
Namely, getting this output:

Tuesday
Wednesday
Thursday

An idea could be to push back last line but I do not know how to do that.

Thank you

Regards

Mauro

PS this is an oversimplified case for the sake of simplicity


------------------------------

Date: Thu, 15 Sep 2011 12:17:11 +0000 (UTC)
From: lcof <lcof@nomail.com>
Subject: Re: Question about range of Lines
Message-Id: <j4sqc7$f62$1@speranza.aioe.org>

The Thu, 15 Sep 2011 09:28:42 +0200, mauro papandrea wrote :

> Given this simple file:
> 
> cat t1
> 
> Sunday
> Monday
> Tuesday
> Wednesday
> Thursday
> Friday
> Saturday
> 
> with
> 
> perl -ne 'print if /Tuesday/ ..  /Friday/;' t1
> 
> I can get:
> 
> Tuesday
> Wednesday
> Thursday
> Friday
> 
> 
> Is there a simple way to modify the range selection in order to get all
> the lines but the last in the range?
> Namely, getting this output:
> 
> Tuesday
> Wednesday
> Thursday
> 
> An idea could be to push back last line but I do not know how to do
> that.
> 
> Thank you
> 
> Regards
> 
> Mauro
> 
> PS this is an oversimplified case for the sake of simplicity

You mean, something like this ?

perl -ne 'while(<>) { push @a, $_ if /Tuesday/ ..  /Friday/; } pop @a; 
print @a' < t1


------------------------------

Date: Thu, 15 Sep 2011 07:34:44 -0500
From: Tad McClellan <tadmc@seesig.invalid>
Subject: Re: Question about range of Lines
Message-Id: <slrnj73rg2.rbf.tadmc@tadbox.sbcglobal.net>

mauro papandrea <dba1@csi.it> wrote:
> Given this simple file:
>
> Sunday
> Monday
> Tuesday
> Wednesday
> Thursday
> Friday
> Saturday


> Namely, getting this output:
>
> Tuesday
> Wednesday
> Thursday


    perl -ne '$a = 1 if /Tuesday/; $a = 0 if /Friday/; print if $a' t1


-- 
Tad McClellan
email: perl -le "print scalar reverse qq/moc.liamg\100cm.j.dat/"
The above message is a Usenet post.
I don't recall having given anyone permission to use it on a Web site.


------------------------------

Date: Thu, 15 Sep 2011 15:50:18 +0200
From: Mauro <dba1@csi.it>
Subject: Re: Question about range of Lines
Message-Id: <j4suco$bkj$1@mophus.csi.it>

On 15/09/2011 14.17, lcof wrote:
> You mean, something like this ?
>
> perl -ne 'while(<>) { push @a, $_ if /Tuesday/ ..  /Friday/; } pop @a;
> print @a'<  t1

Thank you

However it is not so clear how it works; I thought that -n option was 
supposed to add an implicit loop and there were no need to add a further 
while (<>), not to say anything about reading from a redirection instead 
of reading directly the file.

Regards

Mauro


------------------------------

Date: Thu, 15 Sep 2011 15:53:18 +0200
From: Mauro <dba1_no_spam@csi.it>
Subject: Re: Question about range of Lines
Message-Id: <j4suid$bkj$2@mophus.csi.it>

On 15/09/2011 14.34, Tad McClellan wrote:
>
>      perl -ne '$a = 1 if /Tuesday/; $a = 0 if /Friday/; print if $a' t1
>

Thanl you

This appears much clearer, I hope to be able to adapt it to solve my 
original problem, that was slightly different ( I am afraid I 
oversimplified too much ).

Regards



------------------------------

Date: Thu, 15 Sep 2011 14:29:39 +0000 (UTC)
From: Lucien Coffe <lcof@nospam.invalid>
Subject: Re: Question about range of Lines
Message-Id: <j4t24j$4jj$1@speranza.aioe.org>

Mauro wrote :

> On 15/09/2011 14.17, lcof wrote:
>> You mean, something like this ?
>>
>> perl -ne 'while(<>) { push @a, $_ if /Tuesday/ ..  /Friday/; } pop @a;
>> print @a'<  t1
> 
> Thank you
> 
> However it is not so clear how it works; I thought that -n option was
> supposed to add an implicit loop and there were no need to add a further
> while (<>), not to say anything about reading from a redirection instead
> of reading directly the file.
> 
> Regards
> 
> Mauro

Sure, I did not took off the -n option after copy-pasting your line, so I 
used a redirection. Consider the following :

perl -e 'while(<>) { push @a, $_ if /Tuesday/../Friday/ } pop @a; print 
@a' t1

Good luck with your algorithm. Btw Tad McClellan's solution is much more 
efficient.

-- 
perl -e 's;;{]``*%)}`_^[&)/#%(`&;;y;%^)([]/*#&`_{};.
\100acghiklmopsz;;print'


------------------------------

Date: Thu, 15 Sep 2011 16:39:21 +0200
From: Mauro <dba1_no_spam@csi.it>
Subject: Re: Question about range of Lines
Message-Id: <j4t18o$cvq$1@mophus.csi.it>

> Sure, I did not took off the -n option after copy-pasting your line, so I
> used a redirection. Consider the following :
>
> perl -e 'while(<>) { push @a, $_ if /Tuesday/../Friday/ } pop @a; print
> @a' t1
>
> Good luck with your algorithm. Btw Tad McClellan's solution is much more
> efficient.

Well, now it is much clearer; just wondering why this do not work:

perl -ne '{ push @a, $_ if /Tuesday/../Friday/ } pop @a; print @a' t1

Regards

Mauro


------------------------------

Date: Thu, 15 Sep 2011 14:54:44 +0000 (UTC)
From: Lucien Coffe <lcof@nospam.invalid>
Subject: Re: Question about range of Lines
Message-Id: <j4t3jk$8j9$1@speranza.aioe.org>

Mauro wrote :

>> Sure, I did not took off the -n option after copy-pasting your line, so
>> I used a redirection. Consider the following :
>>
>> perl -e 'while(<>) { push @a, $_ if /Tuesday/../Friday/ } pop @a; print
>> @a' t1
>>
>> Good luck with your algorithm. Btw Tad McClellan's solution is much
>> more efficient.
> 
> Well, now it is much clearer; just wondering why this do not work:
> 
> perl -ne '{ push @a, $_ if /Tuesday/../Friday/ } pop @a; print @a' t1

This gives :

while(<>) {
	{
		push @a, $_ if /Tuesday/../Friday/
	}
	pop @a;
	print @a
}

That's not what you want. You have to use an END block to get the pop and 
print instructions out of the while loop, like this :

perl -ne 'push @a, $_ if /Tuesday/../Friday/; END { pop @a; print @a }' t1

> 
> Regards
> 
> Mauro

{ push @a, $_ if /Tuesday/../Friday/ } pop @a; print @a


-- 
perl -e 's;;{]``*%)}`_^[&)/#%(`&;;\
y;%^)([]/*#&`_{};.\100acghiklmopsz;;print'


------------------------------

Date: Thu, 15 Sep 2011 16:59:47 +0200
From: Mauro <dba1_no_spam@csi.it>
Subject: Re: Question about range of Lines
Message-Id: <j4t2f2$dgo$1@mophus.csi.it>

On 15/09/2011 16.54, Lucien Coffe wrote:
>> Well, now it is much clearer; just wondering why this do not work:
>>
>> perl -ne '{ push @a, $_ if /Tuesday/../Friday/ } pop @a; print @a' t1
>
> This gives :
>
> while(<>) {
> 	{
> 		push @a, $_ if /Tuesday/../Friday/
> 	}
> 	pop @a;
> 	print @a
> }
>

Oh, I see, those two {} more ... that is the difference, I missed that

Thank you for pointing out it to me

Regards

Mauro


------------------------------

Date: Wed, 14 Sep 2011 11:16:01 -0700 (PDT)
From: Ted Byers <r.ted.byers@gmail.com>
Subject: Re: R and Perl
Message-Id: <10d3b0cd-f80d-4945-b959-a56fa14b0b3a@w8g2000yqi.googlegroups.com>

On Sep 7, 6:26=A0pm, ccc31807 <carte...@gmail.com> wrote:
> On Sep 6, 3:03=A0am, azrazer <dsfq...@poupidoup.com> wrote:
>
> > Could you be a bit more precise about what you want to do.
>
> I have multiple data files that I will retrieve from a database query.
> These will be on the order of 150K rows, and an indeterminate number
> of columns. The columns will include both dates and status codes, and
> I will need to build a data structure containing the cumulative count
> of status codes over several months, day by day. Then, I need to build
> graphical files with line charts.
>
> This is currently done by hand in Excel, and I have been tasked with
> automating the process.
>
> Munging the data and getting the cumulative count per status code per
> day is a snap in Perl, and while I've generated charts in Perl using
> GD::Graph, using R is certainly a lot easier, and besides, I am
> motivated to learn R.
>
> > AFAIK, from experience, the best thing to do would be to format your
> > data using Perl without making any modification on your data
>
> The raw data needs to be processed. The 'data' that I will use will be
> contained in hashes, the keys will be status codes, the sub keys will
> be dates, and the values will be integers, sort of like this:
>
> $hash{S}{20110601} =3D> 10
> $hash{S}{20110602} =3D> 13
> $hash{S}{20110603} =3D> 21
> $hash{S}{20110604} =3D> 19
> $hash{S}{20110605} =3D> 25
> $hash{S}{20110606} =3D> 29
> $hash{S}{20110607} =3D> 28
>
> So, I can print out the hash in an R compatible data frame and use it
> directly to generate a PDF.
>
> > Could you be more precise about why you cannot use perl to generate the
> > input data for R ? --and if so, why calling system() is a problem
>
> I will use Perl to munge the data and produce as output an input file
> for R. I want to be able to push a button and have the computer do all
> the work.
>
> Thanks for your reply, CC.
>
>

Actually, while the other responses are correct, there is a simpler
way still.  Well, actually two; but it may be blasphemy to say so in
this forum.  ;-)  Understand, as long as your DB is one of the common
ones (e.g. MS SQL Server, MySQL, PostgreSQL, &c.) there are drivers
that let your R script connect directly to the DB (equivalent to
Perl's DBI).  There is therefore no need to waste time on making CSV
files.  And, given that, you can either do any data manipluation using
SQL or you can load the raw data into R and use a selection of one of
its packages to do the sort of manipulations you'd otherwise do using
SQL.  Either of these options will be faster than getting Perl
involved in some of the data manipulation.  Trust me, I have tried it
in all variations (having perl get/manipulate the data, having the DB
do the manipulation up to the point where my models can do their
various analyses, to importing raw data directly from the DB into R
and having R do it all.  In my experience, the latter turned out to be
the faastest.  using SQL's data manipulation capability is faster if
the R script and the DB are on different machines communicating over a
slow network.

HTH

Ted

This reduces Perl to simplify invoking the R script (e.g., the only
way I could make my R programs scheduled tasks is to write a simple
perl script that starts it.)


------------------------------

Date: Wed, 14 Sep 2011 19:09:11 -0700
From: NoStop <nostop@nonet.com>
Subject: Re: Running untrusted code inside a chroot/iptables jail
Message-Id: <J7dcq.14719$9w.11368@newsfe18.iad>

Ignoramus4738 wrote:

> I have a system where users can write untrusted code in perl (algebra
> calculators for algebra.com).
> 
> They used to be able to call one another, which, I thought, was
> cool.
> 
> I used to use the Safe.pm module to run them. Unfortunately, something
> changed in Safe.pm and I can no longer have those untrusted pieces of
> code call each other, as Safe.pm refuses to do so and says "require
> trapped".
> 
> This leads to solvers not working and users leaving those nonworking
> pages.
> 
> I want to re-architect the whole thing and go away from Safe.pm
> entirely.
> 
> My plan is to do the following:
> 
> 1) Run a calculation daemon as user "algebracalc".
> 
> 2) It would listen on localhost only, to queries from my mod_perl
>    (CGI) scripts.
> 
> 3) It would load all required perl modules and open a MySQL connection
> with a MySQL user 'algebracalc", which only has a SELECT privilege on
> only the one table that it needs (table with source code of said
> calculators).
> 
> The untrusted code will have access to this MySQL handle, though not
> directly through any variables, but it will inherit it and it will be
> accessible.
> 
> 4) Upon receiving an internal connection, the daemon would
>   a) Fork
>   b)_Chroot to a "chroot jail". So, the code will be executed in a
>      chroot jail.
> 
> 5) Using iptables, user "algebracalc" will NOT be allowed to make any
> network connections, to localhost or any other IP address, or to use UDP.
> 
> 6) Code will have some ulimits set to not abuse my memory or CPU.
> 
> Items 1-6 ensure, in my mind, that the unauthorized code will not be
> able to abuse my system in any way, such as by sending spams,
> accessing unauthorized files, etc.
> 
> What have I missed?
> 
> Thanks
> 
> i

How will it know when the bread is toasted enough to eject it?

Cheers.



------------------------------

Date: 6 Apr 2001 21:33:47 GMT (Last modified)
From: Perl-Users-Request@ruby.oce.orst.edu (Perl-Users-Digest Admin) 
Subject: Digest Administrivia (Last modified: 6 Apr 01)
Message-Id: <null>


Administrivia:

To submit articles to comp.lang.perl.announce, send your article to
clpa@perl.com.

Back issues are available via anonymous ftp from
ftp://cil-www.oce.orst.edu/pub/perl/old-digests. 

#For other requests pertaining to the digest, send mail to
#perl-users-request@ruby.oce.orst.edu. Do not waste your time or mine
#sending perl questions to the -request address, I don't have time to
#answer them even if I did know the answer.


------------------------------
End of Perl-Users Digest V11 Issue 3499
***************************************


home help back first fref pref prev next nref lref last post