was php Perl, now reusable page elements

2004-11-03 Thread Cat
Hi all,

And thanks to David for his response re using php  perl together.

What made me work with php was it's ability to draw reusable page elements like the 
header, menu, footer from another html page from a fixed html page.

Now I know that this can be done in perl when the pages are generated by a script, but 
my pages are fixed html to take advantage of meta tags etc plus completely different 
layouts required within the one function.  So I was attemtping to use the function in 
php to call headers, footers etc from another html page so that I don't have to alter 
150 odd pages each time I change one minor thing in the layout.

So, I am not sure that it would be a great idea to call a subroutined directly from a 
fixed html page even if it can be doneso how else would I call my headers. footers 
etc using perl.  Tis the question at the end of all of that  :-)

Thanks in advance.

Cat

Re: was php Perl, now reusable page elements

2004-11-03 Thread David Dorward
On Thu, 2004-11-04 at 15:35 +1100, Cat wrote:
 What made me work with php was it's ability to draw reusable page
 elements like the header, menu, footer from another html page from a
 fixed html page.
 
 Now I know that this can be done in perl when the pages are generated
 by a script,

When a page is generated by PHP it is generated by ... a script! PHP is
just another programming language.

  but my pages are fixed html to take advantage of meta tags etc plus

If you mean static HTML, then:
* That will have no influence of your ability to use meta elements
* That will provide no advantage to any search engine optimisation you
might be trying to do

Static pages do make it somewhat less work to get sane cache control
headers, and that can provide benefits to search engines (and, more
importantly, to visitors).

  completely different layouts required within the one function.

Do I not understand what function means in the context of programming?

   So I was attemtping to use the function in php to call headers,
 footers etc from another html page so that I don't have to alter 150
 odd pages each time I change one minor thing in the layout.

As I believe I suggested before, you can do that with Perl.

 So, I am not sure that it would be a great idea to call a subroutined
 directly from a fixed html page even if it can be done

Again, if you mean static, then you can't - by definition. The moment
you start calling server side scripting functions/methods/subroutines
your page becomes dynamic, not static.

 so how else would I call my headers. footers etc using perl.  Tis the
 question at the end of all of that  :-)

I think I mentioned Template::Toolkit last time. 

http://search.cpan.org/~mjd/Text-Template-1.44/lib/Text/Template.pm

There is also HTML::Template.

http://search.cpan.org/author/SAMTREGAR/HTML-Template-2.7/Template.pm

and Mason.

http://search.cpan.org/author/DROLSKY/HTML-Mason-1.27/lib/HTML/Mason.pm

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




Re: was php Perl, now reusable page elements

2004-11-03 Thread Ing. Branislav Gerzo
Cat [C], on Thursday, November 4, 2004 at 15:35 (+1100) made these
points:

C So, I am not sure that it would be a great idea to call a
C subroutined directly from a fixed html page even if it can be
C doneso how else would I call my headers. footers etc using
C perl.  Tis the question at the end of all of that  :-)

I am using Mason, it is easy, look on it! Also you can use
Apache::ASP, embperl, template toolkit...

some comparing over Mason is at:
http://www.masonbook.com/book/chapter-1.mhtml

-- 

 ...m8s, cu l8r, Brano.

[I laughed for five straight minutes at this!]



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




Re: Sourcing Configuration files

2004-11-03 Thread Gavin Henry
Chris Devers said:
 On Tue, 2 Nov 2004, Gavin Henry wrote:

 What is the easiest way to move variable declarations out into a file
 in /etc/ and requiring a perl program to read them in at startup. If
 they are not there, then the program must complain.

 Have you considered using Tie::File, FreezeThaw or Data::Dumper?

 http://search.cpan.org/~mjd/Tie-File-0.96/lib/Tie/File.pm
 http://search.cpan.org/~ilyaz/FreezeThaw-0.43/FreezeThaw.pm
 http://search.cpan.org/~jhi/perl-5.8.0/ext/Data/Dumper/Dumper.pm

Thanks I will try them. I think it's a bit weird I can't do this out of
the box. Does anyone else?

 Any of these could be effectively used for what you're describing.


 --
 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: Best FREE Perl installation for Windows??

2004-11-03 Thread Robert Hicks
ActiveState


On 11/2/04 9:52 PM, in article [EMAIL PROTECTED], Lone
Wolf [EMAIL PROTECTED] wrote:

 I need to get back to an installed Windows Perl environment.  What's the
 best free option available out there, that everyone would recommend?  I can
 do installs without too much issues, so installer doesn't matter, but ease
 of use does.
 
 Thanks,
 Robert
 
 ---
 Outgoing mail is certified Virus Free.
 Checked by AVG anti-virus system (http://www.grisoft.com).
 Version: 6.0.788 / Virus Database: 533 - Release Date: 11/1/2004
  
 


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




RE: Best FREE Perl installation for Windows??

2004-11-03 Thread NYIMI Jose \(BMB\)


 -Original Message-
 From: Lone Wolf [mailto:[EMAIL PROTECTED] 
 Sent: Wednesday, November 03, 2004 3:52 AM
 To: [EMAIL PROTECTED]
 Subject: Best FREE Perl installation for Windows??
 
 
 I need to get back to an installed Windows Perl environment.  
 What's the best free option available out there, that 
 everyone would recommend?  I can do installs without too much 
 issues, so installer doesn't matter, but ease of use does.
 
 Thanks,
 Robert

IndigoPerl
http://www.indigostar.com/index.html

It comes with Apache + mod_perl

José.


 DISCLAIMER 

This e-mail and any attachment thereto may contain information which is confidential 
and/or protected by intellectual property rights and are intended for the sole use of 
the recipient(s) named above. This email is not intended to create or affect any 
contractual arrangements between the parties.
Any use of the information contained herein (including, but not limited to, total or 
partial reproduction, communication or distribution in any form) by other persons than 
the designated recipient(s) is prohibited. 
If you have received this e-mail in error, please notify the sender either by 
telephone or by e-mail and delete the material from any computer.

Thank you for your cooperation.

For further information about Proximus mobile phone services please see our website at 
http://www.proximus.be or refer to any Proximus agent.


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




Re: Creating Microsoft Word Document with Perl

2004-11-03 Thread Rok Jaklic
Thank you both for usefull information.





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




Re: Sourcing Configuration files

2004-11-03 Thread Chris Devers
On Wed, 3 Nov 2004, Gavin Henry wrote:

 Chris Devers said:
  On Tue, 2 Nov 2004, Gavin Henry wrote:
 
  What is the easiest way to move variable declarations out into a file
  in /etc/ and requiring a perl program to read them in at startup. If
  they are not there, then the program must complain.
 
  Have you considered using Tie::File, FreezeThaw or Data::Dumper?
 
  http://search.cpan.org/~mjd/Tie-File-0.96/lib/Tie/File.pm
  http://search.cpan.org/~ilyaz/FreezeThaw-0.43/FreezeThaw.pm
  http://search.cpan.org/~jhi/perl-5.8.0/ext/Data/Dumper/Dumper.pm
 
 Thanks I will try them. I think it's a bit weird I can't do this out of
 the box. Does anyone else?
 
Data::Dumper should be a core module in at least Perl 5.8.x, and it may 
have been a core module in 5.6.x (I forget). 

So if you have Perl, you've probably got at least that module.

More broadly, there is a line of thinking that core Perl should ship 
with a minimal set of modules, and that people should be in the habit of 
thinking that it's no big deal to grab something off CPAN. Because it's 
not a big deal, really, and if Perl were to ship with *everything* in 
CPAN, it would be many gigabytes -- most of which would be irrelevant to 
most people.

For this particular problem, there are several ways you could go about
writing it, and no clear best way, as different people with similar 
requirements may have different specific needs  constraints. For the 
most part, Python just provides one way to do this -- pickling data 
structures to a file when a program halts, and unpickling them when 
the program is invoked again. Perl's Data::Dumper can be used in about 
the same way, and FreezeThaw comes even closer to that approach. But for 
some people, that's not the way to go at all, and Perl doesn't enforce 
any one approach here (or just about anywhere else). 

 

-- 
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




current perl memory usage

2004-11-03 Thread Bryan R Harris


In Learning Perl 3.1, it says:

Arrays can have any number of elements. The smallest array has no elements,
while the largest array can fill all of available memory. Once again, this
is in keeping with Perl's philosophy of 'no unnecessary limits.'

Is there any way to get the free vs. used memory during runtime?

- Bryan

(Sorry if this is a repost, I never saw the original come across the list
and can't find it in the archive, so I assume it never made it...)



-- 
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 benchmark connection

2004-11-03 Thread JupiterHost.Net

Ing. Branislav Gerzo wrote:
Hi all,
anoyone could me show the start point for measuring response time of
my $start = time();
# do connection
my $stop = time();
my $lapse = $stop - $start;
print It took $lapse seconds\n;
search http://search.cpan.org for Time::HiRes
The 1st 3 results look very promising...
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: using 'my' problem

2004-11-03 Thread JupiterHost.Net

Zeus Odin wrote:
The reason why you don't get the uninitialized warning in the 2nd and 3rd
examples below is that your print is within the for loop. Since both @files
and keys %files contain nothing, the innards of the for loop NEVER get
executed. Therefore, the print is not attempted at all for examples 2 and 3.
Correct, except I still think @ ans % don't get uninitialized value 
warnings while $ does:

$perl -mstrict -we 'my $foo;print hi\n for $foo;'
hi
$
That shows what you said to be accurate.
Then no error:
$ perl -mstrict -we 'my @foo;print @foo;'
$
$ perl -mstrict -we 'my %foo;print %foo;'
$
Error:
$ perl -mstrict -we 'my $foo;print $foo;'
Use of uninitialized value in print at -e line 1.
$
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/ http://learn.perl.org/first-response



RE: Sourcing Configuration files

2004-11-03 Thread Larsen, Errin M HMMA/IT
-Original Message-
From: Gavin Henry [mailto:[EMAIL PROTECTED] 
Sent: Wednesday, November 03, 2004 4:15 AM
To: Perl Beginners List
Subject: Re: Sourcing Configuration files

Chris Devers said:
 On Tue, 2 Nov 2004, Gavin Henry wrote:

 What is the easiest way to move variable declarations out into a
file
 in /etc/ and requiring a perl program to read them in at startup. If
 they are not there, then the program must complain.

 Have you considered using Tie::File, FreezeThaw or Data::Dumper?

 http://search.cpan.org/~mjd/Tie-File-0.96/lib/Tie/File.pm
 http://search.cpan.org/~ilyaz/FreezeThaw-0.43/FreezeThaw.pm

http://search.cpan.org/~jhi/perl-5.8.0/ext/Data/Dumper/Dumper.pm

 Thanks I will try them. I think it's a bit weird I can't do this out
of
 the box. Does anyone else?


Hi Gavin,

Out-of-the-box configuration files, as you say, can be done as the
following simple code demonstrates:

--configtest.pl--
-
#!/usr/bin/perl
use warnings;
use strict;

get_config();

print FOO_VALUE = $Config::FOO_VALUE\n;
print BAR_VALUE = $Config::BAR_VALUE\n;

sub get_config{
package Config;
our $FOO_VALUE;
our $BAR_VALUE;
do '/etc/my_values.conf'
}


--/etc/my_values.conf--
---
$FOO_VALUE = This is the value of foo;
$BAR_VALUE = This is the value of bar;


I hope that helps.  That 'do' statement is the key.  If you tell perl to
'do' a filename, it will parse it, at run-time, just like any other
code.  I use that sort of thing all the time.  It is not necessary to
declare a package like I did in the above code, it just looks prettier
to me, and it makes sure that if anyone else (later) uses your config
file, they don't have to worry about colliding variable names in their
namespace.

HTH
--Errin

--
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 get name of script

2004-11-03 Thread Zielfelder, Robert
How do I get the name of the current PERL script I am running?  The answer
to this question may be very obvious but I can't seem to locate it in my
books or other resources.

Thanks in advance,

Rob Zielfelder
 

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




Illegal octal digit??

2004-11-03 Thread Konopaske Jr,Raymond E
Forgive me if this is a dumb question.  I'm a newcomer to Perl.

I was trying to do something the other day and ran across this odd
little problem.

I had some lines in my script that looked something like this:

$ddd = 8;
...
if ($ddd == 08) {print ('hi');}

When  I tried to run, I would get the following error:

Illegal octal digit at C:\atest\tryme.pl line 2, at end of line
Execution of C:\atest\tryme.pl aborted due to compilation errors.

I figured out how to get around the problem, but I'm curious about why
it occures, and why it only occurs with 08.

Thanx

-Kono

==
This communication, together with any attachments hereto or links contained herein, is 
for the sole use of the intended recipient(s) and may contain information that is 
confidential or legally protected. If you are not the intended recipient, you are 
hereby notified that any review, disclosure, copying, dissemination, distribution or 
use of this communication is STRICTLY PROHIBITED.  If you have received this 
communication in error, please notify the sender immediately by return e-mail message 
and delete the original and all copies of the communication, along with any 
attachments hereto or links herein, from your system.

==
The St. Paul Travelers e-mail system made this annotation on 11/03/2004, 03:54:29 PM.


RE: How to get name of script

2004-11-03 Thread Wagner, David --- Senior Programmer Analyst --- WGO
Zielfelder, Robert wrote:
 How do I get the name of the current PERL script I am running?  The
 answer to this question may be very obvious but I can't seem to
 locate it in my books or other resources.
 
 Thanks in advance,
 
 Rob Zielfelder

$0 holds the info.

Wags ;)


***
This message contains information that is confidential
and proprietary to FedEx Freight or its affiliates.
It is intended only for the recipient named and for
the express purpose(s) described therein.
Any other use is prohibited.
***


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




RE: Illegal octal digit??

2004-11-03 Thread Bob Showalter
Konopaske Jr,Raymond E wrote:
 Forgive me if this is a dumb question.  I'm a newcomer to Perl.
 
 I was trying to do something the other day and ran across this odd
 little problem.
 
 I had some lines in my script that looked something like this:
 
 $ddd = 8;
 ...
 if ($ddd == 08) {print ('hi');}
 
 When  I tried to run, I would get the following error:
 
 Illegal octal digit at C:\atest\tryme.pl line 2, at end of line
 Execution of C:\atest\tryme.pl aborted due to compilation errors.

A numeric constant starting with a zero is treated as base-8. Octal numbers
use digits 0-7 only, obviously.

See perldoc perldata under the (not-so-obvious) heading Scalar value
constructors

If you want to check for the number 8 (base 10), you need

   $ddd == 8

(or if you prefer octal, $ddd == 010)


-- 
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 get name of script

2004-11-03 Thread Gunnar Hjalmarsson
Robert Zielfelder wrote:
How do I get the name of the current PERL script I am running?  The
answer to this question may be very obvious but I can't seem to
locate it in my books or other resources.
The natural place to look for the answer to such a question is perldoc
perlvar.
--
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



start http request and move on

2004-11-03 Thread JupiterHost.Net
Hey group,
Not sure how I'd go about doing a url (via LWP probably) but not wait
for it to return.
 print Starting...\n;
 nowaiturl($url?foo=bar);
 print $url has been submitted. When it finishes running you'll get an
email. Have a super day\n; # or whatever :)
The idea is to be able to submit data to $url for it to be processed 
(which may take a while)
without waiting for it to finish.

LWP::Parallel does mutiple $urls in parallel but I want to submit a 
single url like you would with LWP but not wait, does that make sense?

Would a fork() of some sort be the best way?
Or what is that even called so I can look around for it?
TIA
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



Which perldoc discuss about loops ?

2004-11-03 Thread Bee
Hi, 

Just a quick question, which perldoc talking about loops ?
for, while, do until... ? I just can't find it out 

TIA,
Bee

Re: Which perldoc discuss about loops ?

2004-11-03 Thread Jenda Krynicky
From:   Bee [EMAIL PROTECTED]
 Just a quick question, which perldoc talking about loops ?
 for, while, do until... ? I just can't find it out 

perlsyn

Jenda
= [EMAIL PROTECTED] === http://Jenda.Krynicky.cz =
When it comes to wine, women and song, wizards are allowed 
to get drunk and croon as much as they like.
-- Terry Pratchett in Sourcery


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




Re: Which perldoc discuss about loops ?

2004-11-03 Thread Bee
Thanks Jenda ! Got it now =)


- Original Message - 
From: Jenda Krynicky [EMAIL PROTECTED]
To: [EMAIL PROTECTED]
Sent: Thursday, November 04, 2004 5:57 AM
Subject: Re: Which perldoc discuss about loops ?


 From:   Bee [EMAIL PROTECTED]
  Just a quick question, which perldoc talking about loops ?
  for, while, do until... ? I just can't find it out

 perlsyn

 Jenda
 = [EMAIL PROTECTED] === http://Jenda.Krynicky.cz =
 When it comes to wine, women and song, wizards are allowed
 to get drunk and croon as much as they like.
 -- Terry Pratchett in Sourcery


 -- 
 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




Is that a DB server need to be installed ?

2004-11-03 Thread Bee
Hi, 

Just start on study about Database programming... Just wonder 
is that a real DB server is needed to be installed before I
start my coding ? If so... which kind of server ( and modules) 
is recommanded, easiest to get start for beginners ? I assume
that I will deal with both simple short data and some CLOB.. 

TIA,
Bee

RE: start http request and move on

2004-11-03 Thread Moon, John
-Original Message-
From: JupiterHost.Net [mailto:[EMAIL PROTECTED] 
Sent: Wednesday, November 03, 2004 4:23 PM
To: [EMAIL PROTECTED]
Subject: start http request and move on

Hey group,

Not sure how I'd go about doing a url (via LWP probably) but not wait
for it to return.


  print Starting...\n;
  nowaiturl($url?foo=bar);
  print $url has been submitted. When it finishes running you'll get an
email. Have a super day\n; # or whatever :)


The idea is to be able to submit data to $url for it to be processed 
(which may take a while)
without waiting for it to finish.

LWP::Parallel does mutiple $urls in parallel but I want to submit a 
single url like you would with LWP but not wait, does that make sense?

Would a fork() of some sort be the best way?

Or what is that even called so I can look around for it?

[jwm] 
Don't use LWP but in my CGI scripts I set $| to nonzero ... to do what you
want... 

jwm


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




Mass Editing 125 files

2004-11-03 Thread Dave Kettmann
Hi List,

I know the number of files probably doesnt matter, but just in case it does I thought 
I would mention it. What I need to do, is look thru 125 zone files and change the IPs. 
Or to be less specific, I need a Find/Replace script that will run thru a list of 
files whose names are in an array. Here is a snippet of code:

--snip--

#!/bin/perl

use strict;

my @files = (
  zone.file1.com,
  zone.file2.com,
  zone.file3.com )

for ( my $i = 0; $i  scalar @files; $i++ )
{
  open TMPFH, $files[$i];  #This is line 123 in the real file
  while ( TMPFH ) {
$_ =~ s/1\.1\.1\.1/5.5.5.5/ ;
print $_ ;
  }
}

--snip--

I dont think I'm writing the substitution line right, but here is the error I'm 
getting:

Use of uninitialized value at zones.1 line 123.
Argument zone.yourofficeplace.com isn't numeric in right_shift at zones.1 line 123.

Wouldnt $file[$i] be initialized? I may be wrong about that, but the 'right_shift' 
thing is what I am not sure of. I know I'm close to being right (or at least I think I 
am). Any help is appreciated.

Thanks,

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: Mass Editing 125 files

2004-11-03 Thread Bee
zone.file3.com )
# A semi-colon missed here

for ( my $i . )

HTH,
Bee


- Original Message - 
From: Dave Kettmann [EMAIL PROTECTED]
To: Perl List (E-mail) [EMAIL PROTECTED]
Sent: Thursday, November 04, 2004 6:28 AM
Subject: Mass Editing 125 files


Hi List,

I know the number of files probably doesnt matter, but just in case it does
I thought I would mention it. What I need to do, is look thru 125 zone files
and change the IPs. Or to be less specific, I need a Find/Replace script
that will run thru a list of files whose names are in an array. Here is a
snippet of code:

--snip--

#!/bin/perl

use strict;

my @files = (
  zone.file1.com,
  zone.file2.com,
  zone.file3.com )

for ( my $i = 0; $i  scalar @files; $i++ )
{
  open TMPFH, $files[$i];  #This is line 123 in the real file
  while ( TMPFH ) {
$_ =~ s/1\.1\.1\.1/5.5.5.5/ ;
print $_ ;
  }
}

--snip--

I dont think I'm writing the substitution line right, but here is the error
I'm getting:

Use of uninitialized value at zones.1 line 123.
Argument zone.yourofficeplace.com isn't numeric in right_shift at zones.1
line 123.

Wouldnt $file[$i] be initialized? I may be wrong about that, but the
'right_shift' thing is what I am not sure of. I know I'm close to being
right (or at least I think I am). Any help is appreciated.

Thanks,

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






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




Re: Mass Editing 125 files

2004-11-03 Thread Bee
One more note, your loop and substitution can be simpliy like this :

for my $i ( 0.. $#files )
{ open FH, $files[$i] or die $!;
{ while (FH) { tr/1/5/; print }
   close FH ; #  I think close FH is quite important here...
}

HTH,
Bee


- Original Message - 
From: Dave Kettmann [EMAIL PROTECTED]
To: Perl List (E-mail) [EMAIL PROTECTED]
Sent: Thursday, November 04, 2004 6:28 AM
Subject: Mass Editing 125 files


Hi List,

I know the number of files probably doesnt matter, but just in case it does
I thought I would mention it. What I need to do, is look thru 125 zone files
and change the IPs. Or to be less specific, I need a Find/Replace script
that will run thru a list of files whose names are in an array. Here is a
snippet of code:

--snip--

#!/bin/perl

use strict;

my @files = (
  zone.file1.com,
  zone.file2.com,
  zone.file3.com )

for ( my $i = 0; $i  scalar @files; $i++ )
{
  open TMPFH, $files[$i];  #This is line 123 in the real file
  while ( TMPFH ) {
$_ =~ s/1\.1\.1\.1/5.5.5.5/ ;
print $_ ;
  }
}

--snip--

I dont think I'm writing the substitution line right, but here is the error
I'm getting:

Use of uninitialized value at zones.1 line 123.
Argument zone.yourofficeplace.com isn't numeric in right_shift at zones.1
line 123.

Wouldnt $file[$i] be initialized? I may be wrong about that, but the
'right_shift' thing is what I am not sure of. I know I'm close to being
right (or at least I think I am). Any help is appreciated.

Thanks,

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






-- 
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 get name of script

2004-11-03 Thread Rajesh Dorairajan
$0

-Original Message-
From: Zielfelder, Robert [mailto:[EMAIL PROTECTED] 
Sent: Wednesday, November 03, 2004 12:18 PM
To: Perl Beginners List (E-mail)
Subject: How to get name of script


How do I get the name of the current PERL script I am running?  The answer
to this question may be very obvious but I can't seem to locate it in my
books or other resources.

Thanks in advance,

Rob Zielfelder
 

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




Re: using 'my' problem

2004-11-03 Thread Zeus Odin
To see the code that is actually getting compiled, try:

$ perl -MO=Deparse -mstrict -we 'my @foo;print @foo;'


JupiterHost.Net [EMAIL PROTECTED] wrote in message ...

 Correct, except I still think @ ans % don't get uninitialized value
 warnings while $ does:

 $perl -mstrict -we 'my $foo;print hi\n for $foo;'
 hi
 $

 That shows what you said to be accurate.

 Then no error:
 $ perl -mstrict -we 'my @foo;print @foo;'
 $
 $ perl -mstrict -we 'my %foo;print %foo;'
 $

 Error:
 $ perl -mstrict -we 'my $foo;print $foo;'
 Use of uninitialized value in print at -e line 1.
 $



-- 
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 get name of script

2004-11-03 Thread Jim
 
 How do I get the name of the current PERL script I am 
 running?  The answer to this question may be very obvious but 
 I can't seem to locate it in my books or other resources.
 
 Thanks in advance,
 

# strip the path info to the script:
(my $prog = $0) =~ s/^.*[\\\/]//;

---
Outgoing mail is certified Virus Free.
Checked by AVG anti-virus system (http://www.grisoft.com).
Version: 6.0.786 / Virus Database: 532 - Release Date: 10/29/2004
 


-- 
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 get name of script

2004-11-03 Thread Christopher Maujean
On Wed, 2004-11-03 at 16:06, Jim wrote:
   How do I get the name of the current PERL script I am 
  running?  The answer to this question may be very obvious but 
  I can't seem to locate it in my books or other resources.
  
  Thanks in advance,
  
 
 # strip the path info to the script:
 (my $prog = $0) =~ s/^.*[\\\/]//;

or use File::Basename to get the path, filename, suffix into different
vars:

# copied from 
# http://search.cpan.org/~nwclark/perl-5.8.5/lib/File/Basename.pm

use File::Basename;
my ($name,$path,$suffix) = fileparse($fullname,@suffixlist);

--Christopher



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




Re: using 'my' problem

2004-11-03 Thread JupiterHost.Net

Zeus Odin wrote:
To see the code that is actually getting compiled, try:
$ perl -MO=Deparse -mstrict -we 'my @foo;print @foo;'
Ok, not sure what that has to do with @ and % not getting uninitialized 
warnings and $ getting them...

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



Re: start http request and move on

2004-11-03 Thread JupiterHost.Net
The idea is to be able to submit data to $url for it to be processed 
(which may take a while)
without waiting for it to finish.

LWP::Parallel does mutiple $urls in parallel but I want to submit a 
single url like you would with LWP but not wait, does that make sense?

Would a fork() of some sort be the best way?
Or what is that even called so I can look around for it?
[jwm] 
Don't use LWP but in my CGI scripts I set $| to nonzero ... to do what you
want... 
Thanks, I'm not worried about flushing output, I want to submit the url 
and move on like so:

say, it takes the entire http session 60 seconds from start to finish to 
submit the url, the script to run and return the results

I want:
 print Starting...\n;
 nowaiturl($url?foo=bar);
 print $url has been submitted, in appx 60 seconds it will finish;
to run in like it had been (obviously it'll take a bit more than print() 
but it illustrates the idea):
 print Starting...\n;
 print $url?foo=bar;
 print $url has been submitted, in appx 60 seconds it will finish;

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



Re: Mass Editing 125 files

2004-11-03 Thread John W. Krahn
Dave Kettmann wrote:
Hi List,
Hello,
I know the number of files probably doesnt matter, but just in case
it does I thought I would mention it. What I need to do, is look thru
125 zone files and change the IPs. Or to be less specific, I need a
Find/Replace script that will run thru a list of files whose names
are in an array. Here is a snippet of code:
You can use perl's inplace edit variable to enable you to edit multiple files 
inplace.


#!/bin/perl
use strict;
my @files = (
  zone.file1.com,
  zone.file2.com,
  zone.file3.com )
  ^
Missing semicolon |

for ( my $i = 0; $i  scalar @files; $i++ )
That is usually written as:
for my $i ( 0 .. $#files )
But you don't really need to array indexing to do this:
for my $file ( @files )

{
  open TMPFH, $files[$i];  #This is line 123 in the real file
^^
You are attempting to open the file for append (which is write-only to the end 
of the file) but since it isn't enclosed in quotes perl is interpreting it as 
the right shift operator.  You should also verify that the file was opened 
correctly before attempting to use the filehandle.


  while ( TMPFH ) {
You are trying to read from an invalid filehandle so the $_ variable will 
receive the undef value.


$_ =~ s/1\.1\.1\.1/5.5.5.5/ ;
Your regular expression isn't anchored so you may unintentionally change the 
wrong IP address.


print $_ ;
  }
}
To do this with perl's inplace edit:
#!/bin/perl
use warnings;
use strict;
@ARGV = qw(
  zone.file1.com
  zone.file2.com
  zone.file3.com
  );
$^I = '.back';  # inplace edit variable. file names must be in @ARGV for this 
to work

while (  ) {
  s/\b1\.1\.1\.1\b/5.5.5.5/;
  print;
  }

John
--
use Perl;
program
fulfillment
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/ http://learn.perl.org/first-response



Re: Extracting Directories and Sub Directories and Counting

2004-11-03 Thread Ron Smith
--- Gunnar Hjalmarsson [EMAIL PROTECTED] wrote:

 Ron Smith wrote:
  If I wanted to add more fields to my output, which
 construct would I
  use to create more fields; something like the
 following?
  
  basenamecountextensionsize
  
  ...maybe 'HoH', or just expand on the 'HoA?
 
 I suppose that you are not really talking about the
 output now, but
 rather about adding more info to the data structure.
 Anyway, it depends
 on what you would like to use it for. I imagine that
 you might want a
 HoAoH with each file being represented by a hash
 reference. Something
 like:
 
  my %HoAoH = (
  dir1 = [
{
  basename = 'name1',
  extension = 'html',
  size = 1000,
},
  ],
  dir2 = [
{
  basename = 'name2',
  extension = 'html',
  size = 2000,
},
{
  basename = 'name3',
  extension = 'gif',
  size = 1500,
},
  ],
  );
 
 -- 
 Gunnar Hjalmarsson
 Email: http://www.gunnar.cc/cgi-bin/contact.pl
 

This looks closer to what I was refering to. But I
didn't even know you could do this. I've been away
from this thread a couple of days mulling over
'perlref' and 'perlreftut'.

I've also picked up a copy of Learning Perl Objects,
References  Modules. Hey, I just recently discovered
this book was out there. I think I'd better go through
this material and what you've given me above, before I
proceed any futher with this thread.

Thanks, everybody, for your help; and especially
Gunnar. I'll be back with other questions regarding
references after I've done further homework. :)

Ron





__ 
Do you Yahoo!? 
Check out the new Yahoo! Front Page. 
www.yahoo.com 
 


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




MySQL+foreach loop.........roy

2004-11-03 Thread Roime bin Puniran
I have doing some modification on my previous script. 
I used foreach loop to read the content of directory. While each file are read, then i 
used foreach loop to open the file and imported it into mysql. The script are running 
successfull, but in mysql database, it's contain only the range of data, and not the 
value..I really2 hit the wall right now and i need someone help..
Here is my code

#!/usr/bin/perl

use DBI;

my $dir=/flow/;
my @files;
my $file;
my $record;
my @log;
my $packet;
my $counter = 0;
my $file_contents;
my @file_array;

my $dbh = DBI-connect('dbi:mysql:ayam','root','roime');

opendir(FILE, $dir) || die(Cannot open directory);
@files= readdir(FILE);
$file_contents = FILE;
closedir(FILE);

foreach $file(@files)
{
unless ( ($file eq .flow) || ($file eq ..) )
{  

print $file\n;

#---
#--Read Data File---
#---

my $full_path = $dir.$file;
open(FILE, $full_path)||die(Could not read file !);
@file_array = FILE;
close(FILE);

my $counter = 0;
@file_array = split(/ /, $file_contents);

foreach $counter(@file_array)
{
{
my $value1 = @file_array[$counter];
$counter = $counter + 1;
my $value2 = @file_array[$counter];
$counter = $counter + 1;
my $value3 = @file_array[$counter];
$counter = $counter + 1;
my $value4 = @file_array[$counter];
$counter = $counter + 1;
my $value6 = @file_array[$counter];
$counter = $counter + 1;
my $value7 = @file_array[$counter];
$counter = $counter + 1;
my $value8 = @file_array[$counter];
$counter = $counter + 1;
my $value9 = @file_array[$counter];
$counter = $counter + 1;
my $value10 = @file_array[$counter];
$counter = $counter + 1;
my $value11 = @file_array[$counter];
$counter = $counter + 1;
}
}
#Prepare the insert SQL
my $rec = $dbh-prepare
(INSERT INTO t_flows
(ipSrc, 
 ipDst, 
 pktSent,
 bytesSent, 
 startTime, 
 endTime, 
 srcPort, 
 dstPort,   
 tcpFlags, 
 proto, 
 tos) 

 VALUES ('$value1', 
 '$value2', 
 '$value3', 
 '$value4', 
 '$value5', 
 '$value6', 
 '$value7', 
 '$value8', 
 '$value9', 
 '$value10', 
 '$value11'));
$rec-execute;
}
}

And here is my picture of MySQL

+---+---+-+---+---+-+-+-+--+---+-+
| ipSrc | ipDst | pktSent | bytesSent | startTime | endTime | srcPort | dstPort | 
tcpFlags | proto | tos |
+---+---+-+---+---+-+-+-+--+---+-+
|   |   |   0 | 0 | 0 |   0 |   0 |   0 |  
  0 | 0 |   0 |
|   |   |   0 | 0 | 0 |   0 |   0 |   0 |  
  0 | 0 |   0 |
|   |   |   0 | 0 | 0 |   0 |   0 |   0 |  
  0 | 0 |   0 |
|   |   |   0 | 0 | 0 |   0 |   0 |   0 |  
  0 | 0 |   0 |
|   |   |   0 | 0 | 0 |   0 |   0 |   0 |  
  0 | 0 |   0 |
|   |   |   0 | 0 | 0 |   0 |