Headers(Location) in Perl??

2006-11-04 Thread Richard Bagshaw
Hi Peeps,

 

This may be an obvious question but I am new to perl and I need some
advice.  Basically I have written a script that makes some changes to a
database when a drop down is selected, after this is done I then want to
goto another page in my system.  In php I could use the
header(Location: www.blah.com) todo this, is there anything like that
in perl?

 

Thx

 

Richard

 



Re: Headers(Location) in Perl??

2006-11-04 Thread David Dorward
On Sat, Nov 04, 2006 at 11:12:51PM -, Richard Bagshaw wrote:
 This may be an obvious question but I am new to perl and I need some
 advice.  Basically I have written a script that makes some changes to a
 database when a drop down is selected, after this is done I then want to
 goto another page in my system.  In php I could use the
 header(Location: www.blah.com) todo this, is there anything like that
 in perl?

You can just print them directly (since CGI expects headers followed
by a blank line followed by message), or CGI.pm has a header method.

-- 
David Dorward  http://dorward.me.uk


-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/ http://learn.perl.org/first-response




Re: Interpolation of backslash-escapes

2006-11-04 Thread Randal L. Schwartz
 Rob == Rob Dixon [EMAIL PROTECTED] writes:
 Can anybody think of an elegant solution?

Rob eval qq($val);

s/elegant/hacky, dangerous, broken/

Consider $val = ), $yourcode_here, (.

-- 
Randal L. Schwartz - Stonehenge Consulting Services, Inc. - +1 503 777 0095
merlyn@stonehenge.com URL:http://www.stonehenge.com/merlyn/
Perl/Unix/security consulting, Technical writing, Comedy, etc. etc.
See PerlTraining.Stonehenge.com for onsite and open-enrollment Perl training!

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/ http://learn.perl.org/first-response




Re: Perl Inheritance(take-2)

2006-11-04 Thread Muttley Meen

On 11/3/06, Mumia W. [EMAIL PROTECTED] wrote:


Please bottom-post.

Why should a call to Create() on an object returned by Package2()
updatethe object $a ?

It shouldn't normally update the containing object, and it doesn't in
your program.

For your education, try this,
print Inside ERR:\t, $a-Package2-err, \n;

Also, typically one uses either containment or inheritance but not both.

Please explain what you're trying to do again.


The ideea is to implement a context based protocol, though you can't
see that from the script.
Let's say that you have several contexts, like
Context1
   -Context2/OP
   -Context2.1/OP
   -Context3/OP
Given this, I wanted to reflect the context structure into the code written by
the module user, something like
Context1-Context2-OP ( Where OP is any givent operation).
Now, the operations might trigger protocol errors, which are
held(counted) in the parent class( Context1 ), and thus should be
modifiable by any child method( in this example,
by Context2/OP, Context2.1/OP, Context3/OP).

getting back the the example script, Package1 would be the base class, meaning
in the same time the top context.
Package2, would be in the same time a method of Package1, in order to
call it like
Package1-Package2-OP, and it would be a package of itself too.

The IncErr method simply (would)increment the number of errors reported
by the protocol.

--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/ http://learn.perl.org/first-response




how to print \n in the output file

2006-11-04 Thread Mihir Kamdar

hi,

I am a beginner in Perl. I am trying to automatically generate a perl test
case file which, on executing, would return HTTP response code and response
time,etc. In the output file that I am getting I want the following line:

print \n ;

Any Suggestions??

thanks,
Mihir


Re: how to print \n in the output file

2006-11-04 Thread Mazhar

On 11/4/06, Mihir Kamdar [EMAIL PROTECTED] wrote:


hi,

I am a beginner in Perl. I am trying to automatically generate a perl test
case file which, on executing, would return HTTP response code and
response
time,etc. In the output file that I am getting I want the following line:

print \n ;

Any Suggestions??

thanks,
Mihir

Hi,


U can keep the \n into a hash table (value) and can access the same using
its key


Regards
Mazhar


Re: how to print \n in the output file

2006-11-04 Thread Ron Smith
--- Mazhar [EMAIL PROTECTED] wrote:

 On 11/4/06, Mihir Kamdar [EMAIL PROTECTED]
 wrote:
 
  hi,
 
  I am a beginner in Perl. I am trying to
 automatically generate a perl test
  case file which, on executing, would return HTTP
 response code and
  response
  time,etc. In the output file that I am getting I
 want the following line:
 
  print \n ;
 
  Any Suggestions??
 
Would the following help?

perl -e 'print \\n\n'

Escape the backslash. This prints \n on a new line.


Ron Smith
[EMAIL PROTECTED]

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/ http://learn.perl.org/first-response




Re: Interpolation of backslash-escapes

2006-11-04 Thread Rob Dixon

Randal L. Schwartz wrote:

Rob == Rob Dixon [EMAIL PROTECTED] writes:

Can anybody think of an elegant solution?


Rob eval qq($val);

s/elegant/hacky, dangerous, broken/

Consider $val = ), $yourcode_here, (.


Old news, out of context, petulant.

Rob

--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/ http://learn.perl.org/first-response




Re: Hi, Everyone, I can't install perl modules correctly using CPAN, why?

2006-11-04 Thread Jen Spinney

On 11/3/06, Jeff Pang [EMAIL PROTECTED] wrote:



Hi, everyone,

When I want to install perl module WWW::Yahoo::KeywordExtractor in

my  Ubuntu damper 6.06 OS, it doesn't work properly.


Looks like something with XML is wrong.
Give a try to install XML::SAX::Expat and XML::Simple at first.


Did you see this?

Fatal error: Your default XML parser (XML::SAX::PurePerl) is broken.

There are known bugs in the PurePerl parser included with version 0.13
and 0.14 of XML::SAX.  The XML::Simple tests will fail with this parser.

One way to avoid the problem is to install XML::SAX::Expat - it will
install itself as the system default XML parser and then you will be able
to install XML::Simple successfully.  XML::SAX::Expat is also much faster
than XML::SAX::PurePerl so you probably want it anyway.


I'd install XML::SAX::Expat, then try again.  Good luck!

- Jen

--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/ http://learn.perl.org/first-response




Re: Perl Inheritance(take-2)

2006-11-04 Thread Mumia W.

On 11/04/2006 06:05 AM, Muttley Meen wrote:

On 11/3/06, Mumia W. [EMAIL PROTECTED] wrote:


Please bottom-post.

Why should a call to Create() on an object returned by Package2()
update the object $a ?

It shouldn't normally update the containing object, and it doesn't in
your program.

For your education, try this,
print Inside ERR:\t, $a-Package2-err, \n;

Also, typically one uses either containment or inheritance but not both.



What I meant was, in a single class (A), usually a programmer will 
either inherit from a base class (B) or contain an object of that class 
(B), but not both inherit from (B) and contain (B).




Please explain what you're trying to do again.


The ideea is to implement a context based protocol, though you can't
see that from the script.
Let's say that you have several contexts, like
Context1
   -Context2/OP
   -Context2.1/OP
   -Context3/OP
Given this, I wanted to reflect the context structure into the code 
written by

the module user, something like
Context1-Context2-OP ( Where OP is any givent operation).
Now, the operations might trigger protocol errors, which are
held(counted) in the parent class( Context1 ), and thus should be
modifiable by any child method( in this example,
by Context2/OP, Context2.1/OP, Context3/OP).

getting back the the example script, Package1 would be the base class, 
meaning

in the same time the top context.
Package2, would be in the same time a method of Package1, in order to
call it like
Package1-Package2-OP, and it would be a package of itself too.

The IncErr method simply (would)increment the number of errors reported
by the protocol.



I suggest you let all of the contexts use the same base class and let 
all of the objects share the same error count variable (using 
references), e.g.


#!/usr/bin/perl
use strict;
use warnings;
use Class::Struct;
use Data::Dumper;

struct ContextBase = { errRef = '$', context = '$' };

package ContextBase;

sub addContext {
no strict 'refs';
my $self = shift;
my $context = shift;# context package name

# Check the context package name.
die Bad context unless ($context =~ /^Context\w/);
my $newctx = $context-new;

# This object now contains a new context object.
$self-context($newctx);

# The new context object should know about the error
# count variable.
$newctx-errRef($self-errRef);

# Create a method for accessing the sub-context.
*{$context} = sub {
my $self = shift;
$self-context(shift()) if (@_);
$self-context;
};
$newctx;
}

sub err {
${shift()-errRef};
}

sub incErr {
++${shift()-errRef}
}

package Context1;
our @ISA = qw(ContextBase);

package Context2;
our @ISA = qw(ContextBase);

package Context3;
our @ISA = qw(ContextBase);

 Main program ###
package main;

my $errCount = 0;
my $obj = Context1-new(errRef = \$errCount);
$obj-addContext('Context2')-addContext('Context3');
print Dumper(\$obj);

print '--', \n;
$obj-incErr;
print 'Error Count: ', $obj-err(), \n;
$obj-Context2-incErr;
print 'Error Count: ', $obj-err(), \n;
$obj-Context2-Context3-incErr;
print 'Error Count: ', $obj-err(), \n;

__END__


If you don't have the Class::Struct module, get it. It simplifies
creating classes that have many accessor methods. Also get
Class::Accessor and Class::Data::Inheritable; they do the same thing as
Class::Struct but are more powerful.


HTH




--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/ http://learn.perl.org/first-response




Re: how to print \n in the output file

2006-11-04 Thread Mihir Kamdar

thanks to all,

i was able to solve the problem with your guidance. The code below worked
for me:

print OUTPUTSCRIPT print qq|\\n|; ;

Now I want to calculate the response time that web server took for a
particular request(GET/POST). My output script is something like the
following:

my $req20 = HTTP::Request-new(POST = 
http://192.168.1.170^M/vodexUi/CVodSchedularViewMgr.php );
$req20-content_type('application/x-www-form-urlencoded');
$req20-content('strPageOp=buildQuerystrUnicastVusArr%5B%5D=regularstrUnicastUrl=rtsp%3A%2F%2FstrUnicastUrlArr%5B%5D=rtsprCPDurationSeconds=strCPRunName=teststrCPSavedRunsArr=test');
# Pass request to user agent  get response
my $resp20 = $browser-request($req20);
print qq|Response code is: |;print $resp20-code;
print qq|\n|;

I am using LWP::UserAgent, HTTP::Request and HTTP::Response here. How can I
calculate the response time on the basis of above data.

As always, your help appreciated,

Mihir
On 11/4/06, Ron Smith [EMAIL PROTECTED] wrote:


--- Mazhar [EMAIL PROTECTED] wrote:

 On 11/4/06, Mihir Kamdar [EMAIL PROTECTED]
 wrote:
 
  hi,
 
  I am a beginner in Perl. I am trying to
 automatically generate a perl test
  case file which, on executing, would return HTTP
 response code and
  response
  time,etc. In the output file that I am getting I
 want the following line:
 
  print \n ;
 
  Any Suggestions??
 
Would the following help?

perl -e 'print \\n\n'

Escape the backslash. This prints \n on a new line.


Ron Smith
[EMAIL PROTECTED]

--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/ http://learn.perl.org/first-response