HTML indentation not fine

2004-10-13 Thread Anish Kumar K.
I wrote a program which will replace all the hardcoded things to some values specific 
to one client. for example
designed a template 
with body bgcolor=%bg_color%?.

I have a config.txt file which says bg_color=yellow. This may vary with clients...some 
like blue,

I could successfully replace the files. the problem is after the replacing I opened 
the HTML file..The look and feel is dfferent/..It is not ordered say is looks like 
body bgcolor=
 yellow

This comes in two lines or so...I happen to saw some mail regarding indentation of 
HTML files...with some pacakge in perl..It would be nice if someone could shed light 
into this ...

Thanks
Anish



$_. and $_,

2004-10-13 Thread E.Horn
Hallo!
Stupid question, but i am a perlbeginner! :-(
What is the difference between $_. and $_, ??

Regards


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




Re: $_. and $_,

2004-10-13 Thread Jose Alves de Castro
On Wed, 2004-10-13 at 10:48, E.Horn wrote:
 Hallo!

Hi.

 Stupid question, but i am a perlbeginner! :-(
 What is the difference between $_. and $_, ??

$_ is a variable (the context variable)
A single dot is the concatenation operator
A single comma is the list separator

So:

$_. isn't really something, but two different things: a variable and
 an operator... and that will only be valid if something else would
 follow (so that the operator could have something to work on). Example:

$_ . \n

That would result in the concatenation of $_ with a string containing
 the new line character, \n.

$_, would be valid code, but it would probably serve no other purpose
 than the one of $_ by itself.

Was that helpful?

If not, give an example and we'll try to put some light on it :-)

 Regards

Best regards,

jac

-- 
José Alves de Castro [EMAIL PROTECTED]
  http://natura.di.uminho.pt/~jac


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




Building an Array

2004-10-13 Thread Thomas Drought
Real Perl newbie question...

I have a script that retrieves a response using HTTP:Request and
HTTP:Response. I get back a response in the content as a URLEncoded string.
For example 'id=101results=passed'

I would like to take this response, and parse it into an array where I can
call each value by it's key name, for example:

print 'My ID = %myarray['id']';
print 'My Results = %myarray['results']';


How can I do this?

Thanks,
Tom


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




RE: Building an Array

2004-10-13 Thread Charles K. Clarkson
Thomas Drought [EMAIL PROTECTED] wrote:

: Real Perl newbie question...
: 
: I have a script that retrieves a response using HTTP:Request
: and HTTP:Response. I get back a response in the content as a
: URLEncoded string. For example 'id=101results=passed'
: 
: I would like to take this response, and parse it into an
: array where I can call each value by it's key name, for
: example:

Arrays use indexes (integers) to identify their individual
values. Hashes use keys. You probably want a hash.

: print 'My ID = %myarray['id']';
: print 'My Results = %myarray['results']';

Parsing is breaking something down into its component
parts. You are printing here. Read 'perldata'. It is a file
included in the standard perl distribution. It will help you
with syntax. URI::URL and URI::QueryParam have functions to
parse queries.


HTH,

Charles K. Clarkson
-- 
Mobile Homes Specialist
254 968-8328




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




Re: HTML indentation not fine

2004-10-13 Thread Chris Devers
On Wed, 13 Oct 2004, Anish Kumar K. wrote:

 I wrote a program which will replace all the hardcoded things to some 
 values specific to one client. for example designed a template with 
 body bgcolor=%bg_color%?.

Are you using a template package like HTML::Template, Template Toolkit, 
or Mason?

If not, why not?

This is a solved problem. 

If you use the existing libraries, you shouldn't have to deal with 
problems like this, and you can focus on what you really want to 
accomplish with your programs.


One way or another, it is impossible for anyone here to help you without 
seeing the code you're using, and you have shown none. However, if the 
code is using some kind of hand-rolled template system, the obvious fix 
is to switch to one of the standard ones. They're easy to use, they can 
be very flexible (especially, in different ways, TT and Mason), and 
using them is a hell of a lot better than doing this from scratch! :-)

 

-- 
Chris Devers

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




Regex to match valid host or dns names

2004-10-13 Thread perl

Hi,

How do I best test for a valid host name? My script will read from a
file which contains IP addresses and/or dns name, so I'm trying to sort
out valid IP addresses or host name (using regex). For some reason, my
regex fails to match host names with one or more dash (-). IN the
example below, it fails to match host-no.top-level as a valid host
name. I modify the regex several times - but still don't get the right
outlook.


my @hosts = qw(192.168.22.1 192.168.22.18 localhost another.host.domain
host-no.top-level my.host.domain.com);
foreach (@hosts){
# Works ok
push (@ips, $_ ) if $_ =~ /^\d{1,3}\.\d{1,3}\.\d{1|3}/; 
 
# Can't match host-no.top-level. 
push (@dns, $_) if $_ =~ /^\w+-?[\w+]?\.?[\w+.{1}]*\w+$/;
}

Thanks..


Babs

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




perl's equivalent for jpgraph (www.aditus.nu/jpgraph/)

2004-10-13 Thread quincy
greetings;

any suggestion for perl's equivalent for jpgraph (www.aditus.nu/jpgraph/) ?

Re: Email Address Arguments

2004-10-13 Thread Errin Larsen
I figured it out.  I thought I'd post what I found.

 I've cobbled some code together to test stuff out with:
 
 #!/usr/bin/perl
 
 use warnings;
 use strict;
 
 my @addresses;
 my @message;
 
 if( @ARGV ) {
 print There are arguments\n;
 while( $ARGV[0] =~ /[EMAIL PROTECTED]/ ) {

  The above line of code was the culprit.  I added a check to make
sure @ARGV wasn't empty and everything worked out.  This line looks
like this now:
  while( @ARGV  $ARGV[0] =~ /[EMAIL PROTECTED]/ ) {

 push @addresses, $ARGV[0].', ';
 shift;
 }
 print @addresses\n;
 } else {
 print There are no arguments\n;
 }
 
 while(  ) {
 if( /^.$/ ) {
 last;
 } else {
 push @message, $_;
 }
 }
 
 print \n\nThe following message will be sent:\n;
 print @message\n;
 

--Errin

-- 
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's equivalent for jpgraph (www.aditus.nu/jpgraph/)

2004-10-13 Thread Wiggins d Anconia
 
 greetings;
 
 any suggestion for perl's equivalent for jpgraph
(www.aditus.nu/jpgraph/) ?
 

A quick search of CPAN turns up some options. I have personally had
success with GD::Graph. Don't know that it is as powerful (read: makes
things as pretty) as the one you mention. Though since they both use GD
presumably everything accomplishable with jpgraph can be done by Perl
and possibly GD::Graph.

Starting here my make some sense:

http://search.cpan.org/modlist/Graphics

http://danconia.org

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




Re: cannot call a process via telnet

2004-10-13 Thread Christian Stalp
I just want you to know that the solution of my problem was to change the 
prompt! 

When I call the remote bash via telnet to change the directory it expacted 
the old prompt which was guilty while login:
Prompt = '/\[datagate\]\/KOMM\/datagate  

But after changing the directory the prompt was modified. So the solution to 
call a simple ls is:

@ra = $t-cmd ( String = 'ls',
  Prompt = '/\[datagate\]\/KOMM\/datagate\/STALP\/PERL\/BERT 
 /');
 print @ra;

And to call a routine is:

$rs = $t-cmd ( String = 'komm-test.pl',
 Prompt = '/\[datagate\]\/KOMM\/datagate\/STALP\/PERL\/BERT 
 /');


Hope this helps anybody who'll encounter the same problem ...
MIND THE PROMPT ;-) 

Thanks all for help

Gruss Christian


-- 
Christian Stalp

Institut für Medizinische Biometrie, Epidemiologie und Informatik (IMBEI)
Obere Zahlbacher Straße 69
55131 Mainz
Tel.: 06131/ 17-6852

E-Mail: [EMAIL PROTECTED]
Internet: www.imbei.de

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




RE: Regex:: using variables to hold replacement text

2004-10-13 Thread Radhika
Hi Bob,
I tried what you suggested and I keep getting a unitialized value error.
here is my code. If you could point me to how I could do what William is
trying to do.

Thanks
Radhika

$_= goodbarrad;
#$foo =~ s/(.*)bar(.*)/$replacement/g;
my $foo =~ s/(.*)bar(.*)/eval $1/ge;
print \$1 is: $1\n;
print $foo\n;


--
 On Thu, 2004-09-30 at 10:58, Bob Showalter wrote:
 William Lewis Brown wrote:
  Hi,
  I have a need to store replacement text for a regex
  substitution in a variable.  In other words, I have code in a perl
  script like so::
 
  $foo =~ s/(.*)bar(.*)/$replacement/g;
 
  The $replacement string needs to contain a reference to $1.  In
  other words, the string $replacement will contain the string $1.  I
  need to have the $1 string interpreted so that it will be replaced
  with the text of the first '(.*)' expression.  I have not yet found a
  way to get this to happen.  The $1 string always seems to be
  interpreted as a plain string.

 You need to use eval and /e

 $foo =~ s/(.*)bar(.*)/eval $replacement/ge;

 Hi,
   That definitely did the trick.  I had tried eval and /e but never
 in conjunction.  Thanks for your time and your help.

   Bill

 --
 William L. Brown
 Email: [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





-- 
It's all a matter of perspective. You can choose your view by choosing
where to stand.
Larry Wall
---

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




Re: Regex to match valid host or dns names

2004-10-13 Thread K.Prabakar

 example below, it fails to match host-no.top-level as a valid host
 name. I modify the regex several times - but still don't get the right
 outlook.
 
 my @hosts = qw(192.168.22.1 192.168.22.18 localhost another.host.domain
 host-no.top-level my.host.domain.com);
 foreach (@hosts){
 # Works ok
 push (@ips, $_ ) if $_ =~ /^\d{1,3}\.\d{1,3}\.\d{1|3}/; 
  
 # Can't match host-no.top-level. 
 push (@dns, $_) if $_ =~ /^\w+-?[\w+]?\.?[\w+.{1}]*\w+$/;
 }
 


  
 /^\w+-?[\w+]?\.?[\w+.{1}]*\w+$/--Here you look for only one - and 
also not allowing any other non-word charaters(like hyphen).

The . can match any character even other than - .

You can think like this:(For IP's)
 search for a number with maximum 3 digits and 
then followed by the same kind of 3 numbers but prefixed with a dot.
Try this --- $_ =~ /^\d{1,3}[\.\d{1,3}]{3}/

You can think like this:(For DNS's)
search for a WORD which may(-?) contain hyphen 
within it and then followed by the same kind of zero-or-more-WORDs 
but prefixed with a dot which is a normal dns name pattern.

Try this  $_ =~ /^\w\w*-?\w+?[\.\w\w*-?\w+?]*$/

But this will allow IP's also in your @dns because \w can match digits 
also.

 

-- 
Regards,   
K.Prabakar 

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




RE: Regex:: using variables to hold replacement text

2004-10-13 Thread Bob Showalter
Radhika wrote:
 Hi Bob,
 I tried what you suggested and I keep getting a unitialized value
 error. here is my code. If you could point me to how I could do what
 William is trying to do.

Sorry, I don't know what you're trying to do. Let's start over from the
beginning. What are you trying to do?

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




Re: Regex to match valid host or dns names

2004-10-13 Thread Steve Bertrand

 example below, it fails to match host-no.top-level as a valid host
 name. I modify the regex several times - but still don't get the
 right
 outlook.

 my @hosts = qw(192.168.22.1 192.168.22.18 localhost
 another.host.domain
 host-no.top-level my.host.domain.com);
 foreach (@hosts){
 # Works ok
 push (@ips, $_ ) if $_ =~ /^\d{1,3}\.\d{1,3}\.\d{1|3}/;

 # Can't match host-no.top-level.
 push (@dns, $_) if $_ =~ /^\w+-?[\w+]?\.?[\w+.{1}]*\w+$/;
 }

I'm just beginning to learn a bit about some of the more obscure
regex's, but I'd like to ask if this following regex would ensure no
IP's got trapped in the @dns array? (Assuming that no .tld ends in a
\d):

push (@dns, $_) if $_ =~ /^\w+-?[\w+]?\.?[\w+.{1}]*[a-zA-Z]{2,3}$/;

Steve








  /^\w+-?[\w+]?\.?[\w+.{1}]*\w+$/--Here you look for only one -
 and
 also not allowing any other non-word charaters(like hyphen).

 The . can match any character even other than - .

 You can think like this:(For IP's)
  search for a number with maximum 3 digits and
 then followed by the same kind of 3 numbers but prefixed with a dot.
 Try this --- $_ =~ /^\d{1,3}[\.\d{1,3}]{3}/

 You can think like this:(For DNS's)
 search for a WORD which may(-?) contain hyphen
 within it and then followed by the same kind of zero-or-more-WORDs
 but prefixed with a dot which is a normal dns name pattern.

 Try this  $_ =~ /^\w\w*-?\w+?[\.\w\w*-?\w+?]*$/

 But this will allow IP's also in your @dns because \w can match
 digits
 also.



 --
 Regards,
 K.Prabakar

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






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




Re: Regex to match valid host or dns names

2004-10-13 Thread Randal L. Schwartz
 Steve == Steve Bertrand [EMAIL PROTECTED] writes:

Steve I'm just beginning to learn a bit about some of the more obscure
Steve regex's, but I'd like to ask if this following regex would ensure no
Steve IP's got trapped in the @dns array? (Assuming that no .tld ends in a
Steve \d):

Steve push (@dns, $_) if $_ =~ /^\w+-?[\w+]?\.?[\w+.{1}]*[a-zA-Z]{2,3}$/;

This is wrong because it uses \w repeatedly, not [-0-9a-zA-Z], which
is needed.  Underscore is not legal in hostname parts.  Dash is.

-- 
Randal L. Schwartz - Stonehenge Consulting Services, Inc. - +1 503 777 0095
[EMAIL PROTECTED] 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: Regex to match valid host or dns names

2004-10-13 Thread Randal L. Schwartz
 K == K Prabakar [EMAIL PROTECTED] writes:

K Try this  $_ =~ /^\w\w*-?\w+?[\.\w\w*-?\w+?]*$/

Try is usually a good clue to mean This is not your solution.

In this case, you've got all sorts of stuff going on in a character class.
Wrong stuff.  Try again.  Please.

-- 
Randal L. Schwartz - Stonehenge Consulting Services, Inc. - +1 503 777 0095
[EMAIL PROTECTED] 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: Regex to match valid host or dns names

2004-10-13 Thread Babale Fongo

Hi,

My original regex to match ips is this:
 $_ =~ /^\d{1,3}\.\d{1,3}\.\d{1,3}/;, which is ok. But matching dns name
is still a problem. 

K.Prabakar's  suggestion looks good but also failed the test:

$_ =~ /^\w\w*-?\w+?[\.\w\w*-?\w+?]*$/,

 It will match an invalid dns name like this (host-.domain.com) as a valid.
I'm still working on it, but will welcome any other suggestion.

Babs

||-Original Message-
||From: Steve Bertrand [mailto:[EMAIL PROTECTED]
||Sent: Wednesday, October 13, 2004 5:24 PM
||To: K.Prabakar
||Cc: [EMAIL PROTECTED]; [EMAIL PROTECTED]
||Subject: Re: Regex to match valid host or dns names
||
||
|| example below, it fails to match host-no.top-level as a valid host
|| name. I modify the regex several times - but still don't get the
|| right
|| outlook.
||
|| my @hosts = qw(192.168.22.1 192.168.22.18 localhost
|| another.host.domain
|| host-no.top-level my.host.domain.com);
|| foreach (@hosts){
|| # Works ok
|| push (@ips, $_ ) if $_ =~ /^\d{1,3}\.\d{1,3}\.\d{1|3}/;
||
|| # Can't match host-no.top-level.
|| push (@dns, $_) if $_ =~ /^\w+-?[\w+]?\.?[\w+.{1}]*\w+$/;
|| }
||
||I'm just beginning to learn a bit about some of the more obscure
||regex's, but I'd like to ask if this following regex would ensure no
||IP's got trapped in the @dns array? (Assuming that no .tld ends in a
||\d):
||
||push (@dns, $_) if $_ =~ /^\w+-?[\w+]?\.?[\w+.{1}]*[a-zA-Z]{2,3}$/;
||
||Steve
||
||
||
||
||
||
||
||
||  /^\w+-?[\w+]?\.?[\w+.{1}]*\w+$/--Here you look for only one -
|| and
|| also not allowing any other non-word charaters(like hyphen).
||
|| The . can match any character even other than - .
||
|| You can think like this:(For IP's)
||  search for a number with maximum 3 digits and
|| then followed by the same kind of 3 numbers but prefixed with a dot.
|| Try this --- $_ =~ /^\d{1,3}[\.\d{1,3}]{3}/
||
|| You can think like this:(For DNS's)
|| search for a WORD which may(-?) contain hyphen
|| within it and then followed by the same kind of zero-or-more-WORDs
|| but prefixed with a dot which is a normal dns name pattern.
||
|| Try this  $_ =~ /^\w\w*-?\w+?[\.\w\w*-?\w+?]*$/
||
|| But this will allow IP's also in your @dns because \w can match
|| digits
|| also.
||
||
||
|| --
|| Regards,
|| K.Prabakar
||
|| --
|| To unsubscribe, e-mail: [EMAIL PROTECTED]
|| For additional commands, e-mail: [EMAIL PROTECTED]
|| http://learn.perl.org/ http://learn.perl.org/first-response
||
||
||
||
||
||
||--
||To unsubscribe, e-mail: [EMAIL PROTECTED]
||For additional commands, e-mail: [EMAIL PROTECTED]
||http://learn.perl.org/ http://learn.perl.org/first-response




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




What function to get a file thru HTTP

2004-10-13 Thread Dave Kettmann
Hi list,

I have been doing some searching and I'm looking for a recomendation. I need to pull a 
file via HTTP in my perl script. Just looking for a good module to use. Most 
everything I have found has been for FTP. Not asking for code, just a recomendation :)

Dave Kettmann
NetLogic

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




RE: Regex to match valid host or dns names

2004-10-13 Thread Wiggins d Anconia
 
 Hi,
 
 My original regex to match ips is this:
  $_ =~ /^\d{1,3}\.\d{1,3}\.\d{1,3}/;, which is ok. But matching dns name
 is still a problem. 
 

For some definitions of ok. Seen an IP like: 987.654.321.0 ??  Or how
about, 255.255.255.255.1.3.4.5.6 ?? I am assuming you had at least four
of those C\d{1,3}\. in the mix and hopefully a trailing C$.

If you really want to match IPs you might consider checking out the
excellent Mastering Regex book, 

(?:[01]?\d\d?|2[0-4]\d|25[0-5])\.

Gives you a hint, so cool. You may also be interested in the
Regexp::Common suite.

snip

http://danconia.org

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




Re: What function to get a file thru HTTP

2004-10-13 Thread Wiggins d Anconia
 Hi list,
 
 I have been doing some searching and I'm looking for a recomendation.
I need to pull a file via HTTP in my perl script. Just looking for a
good module to use. Most everything I have found has been for FTP. Not
asking for code, just a recomendation :)
 
 Dave Kettmann
 NetLogic
 

LWP::UserAgent

http://danconia.org


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




Re: What function to get a file thru HTTP

2004-10-13 Thread Chris Devers
On Wed, 13 Oct 2004, Dave Kettmann wrote:

 I have been doing some searching and I'm looking for a recomendation. 
 I need to pull a file via HTTP in my perl script. Just looking for a 
 good module to use. Most everything I have found has been for FTP. Not 
 asking for code, just a recomendation :)
 
You need the LWP module: `sudo perl -MCPAN -e 'install Bundle::LWP'` 

LWP provides several ways to do this, including LWP::Simple.

See the perldoc for LWP and its modules or search Google.


-- 
Chris Devers

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




RE: What function to get a file thru HTTP

2004-10-13 Thread Dave Kettmann
Thanks Chris and Wiggins, will definately look into this.

 -Original Message-
 From: Chris Devers [mailto:[EMAIL PROTECTED]
 Sent: Wednesday, October 13, 2004 1:57 PM
 To: Dave Kettmann
 Cc: Perl List (E-mail)
 Subject: Re: What function to get a file thru HTTP
 
 
 On Wed, 13 Oct 2004, Dave Kettmann wrote:
 
  I have been doing some searching and I'm looking for a 
 recomendation. 
  I need to pull a file via HTTP in my perl script. Just 
 looking for a 
  good module to use. Most everything I have found has been 
 for FTP. Not 
  asking for code, just a recomendation :)
  
 You need the LWP module: `sudo perl -MCPAN -e 'install Bundle::LWP'` 
 
 LWP provides several ways to do this, including LWP::Simple.
 
 See the perldoc for LWP and its modules or search Google.
 
 
 -- 
 Chris Devers
 

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




Re: Regex to match valid host or dns names

2004-10-13 Thread Dan Jones
On Wed, 2004-10-13 at 15:06, K.Prabakar wrote:
  example below, it fails to match host-no.top-level as a valid host
  name. I modify the regex several times - but still don't get the right
  outlook.
  
  my @hosts = qw(192.168.22.1 192.168.22.18 localhost another.host.domain
  host-no.top-level my.host.domain.com);
  foreach (@hosts){
  # Works ok
  push (@ips, $_ ) if $_ =~ /^\d{1,3}\.\d{1,3}\.\d{1|3}/; 
   
  # Can't match host-no.top-level. 
  push (@dns, $_) if $_ =~ /^\w+-?[\w+]?\.?[\w+.{1}]*\w+$/;
  }
  
 
 
   
  /^\w+-?[\w+]?\.?[\w+.{1}]*\w+$/--Here you look for only one - and 
 also not allowing any other non-word charaters(like hyphen).
 
 The . can match any character even other than - .
 
 You can think like this:(For IP's)
  search for a number with maximum 3 digits and 
 then followed by the same kind of 3 numbers but prefixed with a dot.
 Try this --- $_ =~ /^\d{1,3}[\.\d{1,3}]{3}/
 
 You can think like this:(For DNS's)
 search for a WORD which may(-?) contain hyphen 
 within it and then followed by the same kind of zero-or-more-WORDs 
 but prefixed with a dot which is a normal dns name pattern.
 
 Try this  $_ =~ /^\w\w*-?\w+?[\.\w\w*-?\w+?]*$/
 
 But this will allow IP's also in your @dns because \w can match digits 
 also.

Isn't this easily solved?

foreach (@hosts){
 if($_ =~ /^\d{1,3}[\.\d{1,3}]{3}/) {
  push (@ips, $_ );
 }
 elsif($_ =~ /^\w\w*-?\w+?[\.\w\w*-?\w+?]*$/) {
  push (@dns, $_) 
 }
}




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




Re: What function to get a file thru HTTP

2004-10-13 Thread JupiterHost.Net

Dave Kettmann wrote:
Hi list,
Howdy Dave :)
I have been doing some searching and I'm looking for a recomendation. I need to pull a file via HTTP in my perl script. Just looking for a good module to use. Most everything I have found has been for FTP. Not asking for code, just a recomendation :)
Take a look on search.cpan.org for LWP
Dave Kettmann
Lee.M - JupiterHost.Net
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/ http://learn.perl.org/first-response



form content passing

2004-10-13 Thread Adamiec, Larry
Hello,

I am having troubles getting started.  I have a Unix (Solaris 9) cgi
script which parses a form, processes the contents of the form, and then
sends it to a Windows ASP script for more processing and insertion into
a Access database.  I haven't been able to determine the correct or most
efficient way of sending all the form contents to the ASP script.  In
the code below, hidden_1 and hidden_2 are only for testing.  The actual
fields will number over 40 and have labels such as first_name,
last_name, email_address, etc.  The code below does work with the two
test variables.  I have omitted warnings and strict etc for clarity.

Any help will be appreciated.

Lawrence Adamiec
Unix Manager
Rm. 525B 
565 W. Adams St.
Chicago-Kent College of Law
Illinois Institute of Technology
Chicago, Illinois
312-906-5301

* Start of Code *

ReadParse;

my $ua = LWP::UserAgent-new;

my $req = POST 'http://some_server/test2.asp',
  [ hidden_1 = 'XXaaXX',
hidden_2 = $in{'hidden_2'}
  ];
my $content = $ua-request($req)-as_string;

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




Re: form content passing

2004-10-13 Thread JupiterHost.Net

ReadParse;
Oi, first off don't do this
use CGI 'param';
instead
then instead of $in{'hidden_2'} you get the value from param('hidden_2')
So
hidden_2 = $in{'hidden_2'}
becomes
my $hid2 = param('hidden_2');
...
hidden_2 = $hid2
See
 perldoc CGI
for details
Also:
use strict;
use warnings;
always!!
my $ua = LWP::UserAgent-new;
my $req = POST 'http://some_server/test2.asp',
  [ hidden_1 = 'XXaaXX',
hidden_2 = $in{'hidden_2'}
  ];
my $content = $ua-request($req)-as_string;
see
 perldoc LWP::UserAgent
for details about how to POST values to a url.
HTH :)
Lee.M - JupiterHost.Net
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/ http://learn.perl.org/first-response



Re: form content passing

2004-10-13 Thread Gunnar Hjalmarsson
Larry Adamiec wrote:
I am having troubles getting started.  I have a Unix (Solaris 9)
cgi script which parses a form, processes the contents of the form,
and then sends it to a Windows ASP script for more processing and
insertion into a Access database.  I haven't been able to determine
the correct or most efficient way of sending all the form contents
to the ASP script.  In the code below, hidden_1 and hidden_2 are
only for testing.  The actual fields will number over 40 and have
labels such as first_name, last_name, email_address, etc.  The code
below does work with the two test variables.
No it does not. It results in a compilation error.
If you want help with a problem, please post a short but *complete*
program that illustrates the problem you are encountering! In this
case it probably should include the HTML form. Also, don't retype the
code, but copy and paste into the message the code you have actually
tried to execute.
I have omitted warnings and strict etc for clarity.
Bad idea. You'd better include them in order to demonstrate that you
let Perl give you some basic help with debugging.
ReadParse;
That line indicates that you are using an old library, or possibly a
subroutine derived from that library, for parsing form data. It would
be a good idea to replace it with e.g.:
use CGI;
my %in = new CGI-Vars;
Please acquaint yourself with the docs for CGI.pm:
perldoc CGI
my $ua = LWP::UserAgent-new;
my $req = POST 'http://some_server/test2.asp',
  [ hidden_1 = 'XXaaXX',
hidden_2 = $in{'hidden_2'}
  ];
Assuming that the form data have been stored in %in, you might be able
to do something like:
my $url = 'http://some_server/test2.asp';
my $req = new HTTP::Request(post = $url);
$req-content_type('application/x-www-form-urlencoded');
$req-content( [ %in ] );
Please study the libwww-perl docs, such as:
perldoc LWP
perldoc lwpcook
--
Gunnar Hjalmarsson
Email: http://www.gunnar.cc/cgi-bin/contact.pl
--
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's equivalent for jpgraph (www.aditus.nu/jpgraph/)

2004-10-13 Thread Daniel Kasak
quincy wrote:
greetings;
any suggestion for perl's equivalent for jpgraph (www.aditus.nu/jpgraph/) ?
 

I would be *very* interested to find out what you decide on, and a brief 
description of your reasoning.
I'm a jpgraph user, and I'm migrating our Access database to gtk2-perl. 
Pretty soon I'm going to need a graphing solution as well...

--
Daniel Kasak
IT Developer
NUS Consulting Group
Level 5, 77 Pacific Highway
North Sydney, NSW, Australia 2060
T: (+61) 2 9922-7676 / F: (+61) 2 9922 7989
email: [EMAIL PROTECTED]
website: http://www.nusconsulting.com.au
-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/ http://learn.perl.org/first-response


RE: Regex to match valid host or dns names

2004-10-13 Thread K.Prabakar
On Thu, 14 Oct 2004, K.Prabakar wrote:

 On Wed, 13 Oct 2004, Babale Fongo wrote:
 
  K.Prabakar's  suggestion looks good but also failed the test:
  
  $_ =~ /^\w\w*-?\w+?[\.\w\w*-?\w+?]*$/,
  
   It will match an invalid dns name like this (host-.domain.com) as a valid.
  I'm still working on it, but will welcome any other suggestion.
  
  Babs
  
 
 As Randal L. Schwartz pointed out I used character class[] in the 
 above regex which is wrong. That should be () like 
 
 this-- /^\w\w*-?\w+?(\.\w\w*-?\w+?)*$/
 Now it won't match host-.domain.com like names.
 
 Other thing is this will allow dns names starting with DEGITS.In that 
case the worst case solution will be 
 
 /^[a-zA-Z]\w*-?\w+?(\.[a-zA-Z]\w*-?\w+?)*$/ .
 
 This will allow names like
 bla-3bla.bla , bla-bla but won't allow 3bla.bla and bla.4bla
 To avoid underscore again the worst case will be to replace \w with 
 [-a-zA-Z] in the above expression. That won't look good at all. 
 
 

-- 
Regards,   
K.Prabakar 

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