RE: Why is parsing your own form data a bad idea?

2003-11-06 Thread Tore Aursand
On Wed, 05 Nov 2003 17:22:43 -0600, Dan Muey wrote:
>> If it comes to the point where you need to "hack around" CGI.pm, I'd
>> say go with your original inclination to just do it yourself.

> Give me one example when you'd need to hack CGI.pm to handle input that
> you can't do without hacking it.

This might not justify as "hacking" the CGI.pm, but once I had to do
something really special related to session handling.  The solution wasn't
to hack, change or write my own CGI handling module, but simply subclass
the original CGI.pm.


-- 
Tore Aursand <[EMAIL PROTECTED]>


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



RE: Regex search using scalar

2003-11-06 Thread Paul Harwood
The search patterns I am looking for are contained inside the list (each
element of the list is going to be used to scan an entire log file). So
"if ( /match/ )" needs to reference each element of the FOREACH loop
which I will have nested inside a while  loop. That's what's
confusing me.

-Original Message-
From: news [mailto:[EMAIL PROTECTED] On Behalf Of Tore Aursand
Posted At: Wednesday, November 05, 2003 5:12 AM
Posted To: Perl
Conversation: Regex search using scalar
Subject: Re: Regex search using scalar

On Tue, 04 Nov 2003 20:41:17 -0800, Paul Harwood wrote:
> I would like to enumerate a list and search through each element like
> so:
> [...]

Why do you want to enumerate the list?  Do you _really_ need to know the
index of the current element?  If really so:

  my $i = 0;
  foreach ( @list ) {
  $i++;
  if ( /match/ ) {
  # ...
  }
  }

> If (/$logs[i]/)

Please post _real_ Perl code.  The code above has no meaning and won't
even compile.


-- 
Tore Aursand <[EMAIL PROTECTED]>


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




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



Re: searchable webpage

2003-11-06 Thread Desmond Coughlan
Le Wed, Nov 05, 2003 at 09:59:15PM -0800, R. Joseph Newton a écrit ... 

> > I know that this exists already, but I can't find any code to pinch on
> > the web.  :-(
> >
> > The thing I want to do, is to create a searchable index on a webpage.
> > It's a spoof newsgroup designed to take the piss out of someone on an
> > Internet group.  The address is
> > url:http://www.zeouane.org/peinedemort/gimmicks/
> >
> > I can do the HTML, but as it'll be a CGI, I reckon, there's going to be
> > a fair bit of perl lurking in the background.  :-)

> Don't expect a whole lot of help with this here.  We actually like
> newsgroups to work properly.  Spoofing is not good for anyone,
> particularly the person who does it.

Perhaps I should be more precise.  The newsgroup is not 'spoofed' in the
sense that I wrote it to 'pretend' to be someone else.  In that context,
it's a 'genuine' site.  A more accurate description would probably have
been 'it's a humour website' ... 

I'll check out CPAN and see if they have anything suitable.  Thanks.

D.


-- 
Desmond Coughlan  |'Io non mori, e non rimasi vivo'
[EMAIL PROTECTED] 
http://www.zeouane.org


pgp0.pgp
Description: PGP signature


Re: Need help on perl graphical interface

2003-11-06 Thread John
Use Perl/Tk to create powerful GUI's (There is a mailing list that deals
with this subject)


- Original Message -
From: "Pandey Rajeev-A19514" <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Sent: Thursday, November 06, 2003 8:47 AM
Subject: Need help on perl graphical interface


> Hi,
>
> I don't know anything about perl graphics. I would explain excatly what I
want.
>
> I want to develope a interactive graphical interface which can display all
the nodes in a network in a tree representation.
> I should be able to draw that tree upon reading a data base (or real time
data).
> I should be able to click on to a particular node in that network and
should be able to do what I wish on that node( i.e. to make it interactive
and what I wish to do is not that important right now).
>
> Can any one tell me is it possible in perl ? I have the necessary backend
support in perl.
>
> Do you recommend to use XML or Jawa or Xwindows instead ?
>
> Regards
> Rajeev
>
> --
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
>



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



Re: Regex search using scalar

2003-11-06 Thread Sudarshan Raghavan
Paul Harwood wrote:

The search patterns I am looking for are contained inside the list (each
element of the list is going to be used to scan an entire log file). So
"if ( /match/ )" needs to reference each element of the FOREACH loop
which I will have nested inside a while  loop. That's what's
confusing me.
This is a FAQ
perldoc -q 'How do I efficiently match many regular expressions at once'


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


RE: Why is parsing your own form data a bad idea?

2003-11-06 Thread Jenda Krynicky
From: Tore Aursand <[EMAIL PROTECTED]>
> On Wed, 05 Nov 2003 17:22:10 -0500, Dan Anderson wrote:
> > So I got so far with my own creation and am wondering if it should
> > be given the axe or continued.
> 
> Axe it.  Really.  There is absolutely _no_ reason why one shouldn't
> use the CGI.pm module.

There is one. If /s?he/ is using CGI::Lite instead ;-)

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]



Re: Is foo qw (arg1 arg2) equivalent to foo (arg1, arg2)?

2003-11-06 Thread Jeff 'japhy' Pinyan
On Nov 5, Dan Anderson said:

>I've noticed that in code examples something like the following will be
>used:
>
>use Data::Dump qw(dump);
>foo->bar qw(foo bar);
>
>(Syntax may not be 100% correct).
>
>Am I correct in assuming that if I have a subroutine foo (or method if
>called with a package name), and I use qw() it takes all words seperated
>by spaces, and passes them in as arguments.
>
>So: foo->bar qw(foo bar); is equivalent to foo->bar("foo","bar"); ?
>
>Thanks in advance,
>
>Dan
>
>

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


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



Re: Is foo qw (arg1 arg2) equivalent to foo (arg1, arg2)?

2003-11-06 Thread Jeff 'japhy' Pinyan
[sorry about that first post, I got ^X-happy]

On Nov 5, Dan Anderson said:

>use Data::Dump qw(dump);
>foo->bar qw(foo bar);

>Am I correct in assuming that if I have a subroutine foo (or method if
>called with a package name), and I use qw() it takes all words seperated
>by spaces, and passes them in as arguments.
>
>So: foo->bar qw(foo bar); is equivalent to foo->bar("foo","bar"); ?

The qw() operator changes your source code at compile-time, which is why
you can say

  $object->method qw(...)

when ordinarily you'd need

  $object->method(...)

When you use qw(this that those), Perl changes that to

  ('this', 'that', 'those')

Perl splits the qw(...) on spaces, and returns the raw data,
single-quoted.  This means no variables.  You can't even escape a space:

  qw( abc\ def )

becomes

  ('abc\\', 'def')

That is all.

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





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



RE: Why is parsing your own form data a bad idea?

2003-11-06 Thread Dan Muey
> On Wed, 05 Nov 2003 17:22:43 -0600, Dan Muey wrote:
> >> If it comes to the point where you need to "hack around" 
> CGI.pm, I'd 
> >> say go with your original inclination to just do it yourself.
> 
> > Give me one example when you'd need to hack CGI.pm to handle input 
> > that you can't do without hacking it.
> 
> This might not justify as "hacking" the CGI.pm, but once I 
> had to do something really special related to session 
> handling.  The solution wasn't to hack, change or write my 
> own CGI handling module, but simply subclass the original CGI.pm.

So that was basically taking input and doing something specific with it right?
The OP was simply parsing form data to do whatever with it. Whether that is 
printing it out, emailing it, putting in a database, or doing some special 
session handling, they never said so it's all still the same, close but no cigar :)

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



RE: Why is parsing your own form data a bad idea?

2003-11-06 Thread Dan Muey
> > Give me one example when you'd need to hack CGI.pm to handle input 
> > that you can't do without hacking it.
> 
> Are you asking me?  I said, "if it comes to the point that..."
> 
> However, my example would be, as someone previously 
> mentioned, doing something 
> out-of-spec (assuming of course, there is not a way to solve 
> the issue 
> in-spec).   *IF* (please notice the IF) your choice comes down to a 
> convoluted solution with CGI.pm, or just snagging GET and 
  ^^ 
Do you even know what this means?

How is 

use CGI qw(param);
my $name = param('name');

More convoluted than a forty line monstrosity that won't be 
reusable and probably won't cover all conceivable issues (like file uploading for 
instance)

You could say CGI is convoluted in the sense that it is intricate and complex, 
but it has to be for what it does is intricate and complex. However if you 
simply need to handle input just import param().

But your method is more convoluted in the negative sense that it is inticate 
and complex in a bulky hard to deal with manner.

Do what you want but I think everyone here is tryign to save you a massive headache.

*And* if you do it homebrew style then to reuse it, which you probably will, 
you still have to make it portable somehow. And if you need help with why 
something isn't working you'll do this :

[examle]
you> My code doesn't work:

you> &ParseMonkey;
you> for(keys %POST) { print; }

you> It doesn't print anythign! 

What the heck is ParseMonkey ?
Are you using strict; ??
Try this and see if it works:
 use CGI qw(param);
 for(param()) { print; }

[/example]



> POST on your own, 
> my position is to do it cleanly, and on your own.
  ^^^
On your own is not cleanly, again how is 
use CGI qw(param);
...
Messier than tons of lines of code that will likely have problems.
And besides file uploads, how do plan on handling menus or checkboxes that have 
multiple values?
 You say: BUT I SAID **IF** I have a situation that needs special ." Yes but what 
**IF**
You ever need to expand it, it will much harder to do later.

Do what you want but doing it home brew is a pretty bad idea.

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



Re: Need help on perl graphical interface

2003-11-06 Thread Rob Dixon
Pandey Rajeev-A19514 wrote:
>
> I don't know anything about perl graphics. I would
> explain excatly what I want.
>
> I want to develope a interactive graphical interface
> which can display all the nodes in a network in a
> tree representation. I should be able to draw that
> tree upon reading a data base (or real time data).
>
> I should be able to click on to a particular node
> in that network and should be able to do what I
> wish on that node( i.e. to make it interactive and
> what I wish to do is not that important right now).
>
> Can any one tell me is it possible in perl ?
> I have the necessary backend support in perl.

Perl on its own has no graphical capability, but almost
anything is possible via its modular extensions.

Check out the module

  Tk - a graphical user interface toolkit for Perl

but beware that a user interface is always at least
95% of the design and about 80% of the implementation :)

Rob



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



RE: Need help on perl graphical interface

2003-11-06 Thread NYIMI Jose (BMB)
About the design:
you should yourself ask this question:
"should i biuld a UI from scratch with Tk module or
should i consider biulding a web application (browser as client)".

Investigate if a web application will meet your requirements ...

José.

-Original Message-
From: Rob Dixon [mailto:[EMAIL PROTECTED] 
Sent: Thursday, November 06, 2003 4:44 PM
To: [EMAIL PROTECTED]
Subject: Re: Need help on perl graphical interface


Pandey Rajeev-A19514 wrote:
>
> I don't know anything about perl graphics. I would
> explain excatly what I want.
>
> I want to develope a interactive graphical interface
> which can display all the nodes in a network in a
> tree representation. I should be able to draw that
> tree upon reading a data base (or real time data).
>
> I should be able to click on to a particular node
> in that network and should be able to do what I
> wish on that node( i.e. to make it interactive and
> what I wish to do is not that important right now).
>
> Can any one tell me is it possible in perl ?
> I have the necessary backend support in perl.

Perl on its own has no graphical capability, but almost anything is possible via its 
modular extensions.

Check out the module

  Tk - a graphical user interface toolkit for Perl

but beware that a user interface is always at least
95% of the design and about 80% of the implementation :)

Rob



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



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



Re: Is foo qw (arg1 arg2) equivalent to foo (arg1, arg2)?

2003-11-06 Thread Randal L. Schwartz
> "Dan" == Dan Anderson <[EMAIL PROTECTED]> writes:

Dan> So: foo->bar qw(foo bar); is equivalent to foo->bar("foo","bar"); ?

Only in recent Perls.  The mapping of qw(...) to a (...) list at compile
time is a modern addition.  Older Perls replaced it with a runtime
split on the string, and probably would not accept it as the arglist
of a method call.

-- 
Randal L. Schwartz - Stonehenge Consulting Services, Inc. - +1 503 777 0095
<[EMAIL PROTECTED]> 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]



Re: Reading and from more than one filehandle / memory question

2003-11-06 Thread James Edward Gray II
On Wednesday, November 5, 2003, at 05:20 PM, [EMAIL PROTECTED] 
wrote:

This is my first attempt.   My misunderstanding was in the fact that I 
could
put the filehandles inside another filehandles while loop.
Good start.  Now I'll help.  ;)

#!perl
#!/usr/bin/perl

...is more standard.

use strict;
and...

use warnings;

&read_the_files;
Yuck.  Don't do this.  Call subs with:

sub_name();

Trust me.

While we're at it, don't stick in a sub just for the sake of a sub.  If 
you're defining and calling it at the same place, what's the point?

sub read_the_files{
print "\nread_the_files";#
my$file1 ="./file1.txt";
#contents of file1.txt
#1
#6
my$file2 = "./file2.txt";
#contents of file2.txt
#5
#10
my$file3 = "./file3.txt";
#contents of file3.txt
#;;;4;
#;;;9;
my$file4 = "./file4.txt";
#contents of file3.txt
I believe this is a misprint and you meant #...file4.txt

#5
#10
This is identical to file2.txt.  What do you do then, overwrite?

my$writing =  "./combined.txt";
my$count;
unless(open(FH, $file1)){print  "\nCouldn't read 
$file1";exit}else{print
"\nOpen successful"}

###
#this next bit of code seems old and sloppy.
[ snip rest of code }

You're right, sloppy.  I mean that in the best possible way though.  :D

Anytime you find yourself typing nearly the same lines over and over 
again, you're probably missing a needed loop.  That's exactly what 
loops are for in fact, repeating code.

Here's my first crack at your problem, see what you think:

#!/usr/bin/perl

use strict;
use warnings;
my @results;

for my $file (qw(file1 file2 file3 file4)) {
open IN, '<', "$file.txt" or die "Input error:  $!\n";
while () {
$results[$. - 1] = [ ] unless $results[$. - 1];
$results[$. - 1][length $1] = $2 if /^(;*)(\d+)/;
}
close IN;
}
open OUT, '>', 'combined.txt' or die "Output error:  $!\n";
{
no warnings 'uninitialized';
print OUT join(':', @$_), "\n" foreach @results;
}
close OUT;
Even better, in my opinion, would be to remove those hard coded files 
and make a UNIX filter you would call with something like:

perl filter file?.txt >combined.txt

That looks like this:

#!/usr/bin/perl

use strict;
use warnings;
my @results;

while (<>) {
$results[$. - 1] = [ ] unless $results[$. - 1];
$results[$. - 1][length $1] = $2 if /^(;*)(\d+)/;
close ARGV if eof;
}
{
no warnings 'uninitialized';
print join(':', @$_), "\n" foreach @results;
}
Well, hopefully that at least gives you a couple of ideas.  Good luck.

James

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


RFC on first perl script

2003-11-06 Thread drowl


Hi all
 well im trying at lerning this perl stuff.. reading from the "learning
perl" oreilly book and a few other places,
but also using perl a long time before i should ie making the below script,
so that i dont get in to any very bad habbits at such an early stage.
could some one please have a look at the code below and give comments, the
code does do what i want it to ( well at leest from this stage).


#!/usr/bin/perl -w

# this function creates a arf rule file from an input file
# Version 0.1 6/11/03

@dataFile=<>; # read in file from command line
@standardRules=`cat standard.for.arf.txt` ;

foreach $site (@dataFile) {  # loop  for each line/site in dataFile
chomp $site;

($siteLink,$siteNoOfPVCs,$siteAllPVCs)=split(/:/,$site,3); #split
up main / pvc info

($siteIP,$siteString,$SiteName,$siteGroup,$siteCCTReff,$siteACRate)=split(/,/,$siteLink,6);
#split up main info
(@sitePVCs)=split(/;/,$siteAllPVCs,$siteNoOfPVCs);

my $siteARFfile = "$siteIP.arf";
open(ARFfile, ">$siteARFfile") or die("can not open
'$siteARFfile': $!");

print ARFfile
("##
\n# \n# Discover Rule for:
$siteIP \n#
\n##
\n\n"); # print header

print ARFfile ("@standardRules\n"); #print standard bits

print ARFfile ("name matches  \".*-Cpu-.*\": {\n \tsetName
(\"$SiteName-RH-Cpu\") ;\n \tsetGroup (\"$siteGroup\")
;\n \tsetAlias (\"RH-Cpu\") ;\n} \n\n" ); # print -Cpu- rule

print ARFfile ("name matches  \".*-RH\": { \n \tsetName
(\"$SiteName-RH\") ;\n \tsetGroup (\"$siteGroup\") ; \n \t
setAlias (\"RH\") ;\n} \n\n" ); # print -RH rule

print ARFfile ("name matches  \".*RH-Serial.*\": {\n \tsetName
(\"$SiteName-RH-WAN\$2\") ;\n \tsetGroup (\"$siteGr
oup\") ;\n \tsetAlias (\"$siteCCTReff\") ;\n \tsetSpeedIn
(\"$siteACRate\") ;\n \tsetSpeedOut (\"$siteACRate\") ;\n \tsetD
eviceSpeedIn (\"$siteACRate\") ;\n \tsetDeviceSpeedOut (\"$siteACRate\")
;\n} \n\n"); # print RH-Serial rule


print ARFfile ("name matches  \".*-Serial.*\": {\n \tsetName
(\"$SiteName-WAN\$2\") ;\n \tsetGroup (\"$siteGroup\"
) ;\n \tsetAlias (\"$siteCCTReff\") ;\n \tsetSpeedIn (\"$siteACRate\") ;\n
\tsetSpeedOut (\"$siteACRate\") ;\n \tsetDevice
SpeedIn (\"$siteACRate\") ;\n \tsetDeviceSpeedOut (\"$siteACRate\") ;\n}
\n\n"); # print -Serial rule

for ($i = 0; $i < $siteNoOfPVCs ; $i++ ) { # loop for each PVC

($PVCdlci,$PVCname,$PCVreff,$PVCcir)=split(/,/,"$sitePVCs[$i]",4);
# split out pvc info

print ARFfile ("name matches  \".*-dlci-$PVCdlci\": {\n
\tsetName (\"$SiteName-$PVCname\") ;\n \tsetGroup
(\"$siteGroup\") ;\n \tsetAlias (\"$PCVreff\") ;\n \tsetSpeedIn
(\"$PVCcir\") ;\n \tsetSpeedOut (\"$PVCcir\") ;\n \tsetDev
iceSpeedIn (\"$PVCcir\") ;\n \tsetDeviceSpeedOut (\"$PVCcir\") ;\n}
\n\n"); # print PVC rules


}

close(ARFfile) or die("can not close '$siteARFfile': $!");
}



---
fnord
yes im a Concord Engineer, no it never flown!



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



RE: RFC on first perl script

2003-11-06 Thread Hanson, Rob
> please have a look at the code below and give comments

Here are some quick comments.

#1. Always "use strict"
#2. See #1.

When you "use strict" it foeces you to do things the "right way" and will
help catch errors because of the extra checks it makes.

So something like this:
> @dataFile=<>; # read in file from command line

Needs to be changed to this by explicitly declaring that variable:
my @dataFile=<>; # read in file from command line

> @standardRules=`cat standard.for.arf.txt` ;

This isn't portable (if you care for it to be), and does not check for
errors.  This might be better:

open IN, 'standard.for.arf.txt' or die $!;
my @standardRules = ;
close IN;

> (@sitePVCs)=split(/;/,$siteAllPVCs,$siteNoOfPVCs);

The "(" and ")" force list context.  The array @sitePVCs will already force
list context without the parens.  This can be rewriten like this, which may
or may not be more readable to you:

my @sitePVCs = split(/;/,$siteAllPVCs,$siteNoOfPVCs);

> open(ARFfile, ">$siteARFfile") or die("can not open

Typically filehandles are in all caps.  They don't need to be, but it is the
usual way of doing things because it makes them easier to spot (especially
to people other than the author).  Also the parens are not needed because
"or" has very low precedence.  I also tend to put my error condition on the
next line, but that is just my preference.

open ARFFILE, ">$siteARFfile"
  or die "can not open '$siteARFfile': $!";

Again, parens not needed here, but they don't hurt either:

> print ARFfile ("@standardRules\n"); #print standard bits
print ARFFILE "@standardRules\n"; #print standard bits

This is pretty icky:
>print ARFfile ("name matches  \".*RH-Serial.*\":
> {\n \tsetName(\"$SiteName-RH-WAN\$2\") ;\n \tsetGroup
> (\"$siteGroup\") "); # print RH-Serial rule

Try a here-document instead:

# print RH-Serial rule
print ARFFILE ; # read in file from command line
@standardRules=`cat standard.for.arf.txt` ;

foreach $site (@dataFile) {  # loop  for each line/site in dataFile
chomp $site;

($siteLink,$siteNoOfPVCs,$siteAllPVCs)=split(/:/,$site,3); #split
up main / pvc info
 
($siteIP,$siteString,$SiteName,$siteGroup,$siteCCTReff,$siteACRate)=split(/,
/,$siteLink,6);
#split up main info
(@sitePVCs)=split(/;/,$siteAllPVCs,$siteNoOfPVCs);

my $siteARFfile = "$siteIP.arf";
open(ARFfile, ">$siteARFfile") or die("can not open
'$siteARFfile': $!");

print ARFfile
("##
\n# \n# Discover Rule for:
$siteIP \n#
\n##
\n\n"); # print header

print ARFfile ("@standardRules\n"); #print standard bits

print ARFfile ("name matches  \".*-Cpu-.*\": {\n \tsetName
(\"$SiteName-RH-Cpu\") ;\n \tsetGroup (\"$siteGroup\")
;\n \tsetAlias (\"RH-Cpu\") ;\n} \n\n" ); # print -Cpu- rule

print ARFfile ("name matches  \".*-RH\": { \n \tsetName
(\"$SiteName-RH\") ;\n \tsetGroup (\"$siteGroup\") ; \n \t
setAlias (\"RH\") ;\n} \n\n" ); # print -RH rule

print ARFfile ("name matches  \".*RH-Serial.*\": {\n \tsetName
(\"$SiteName-RH-WAN\$2\") ;\n \tsetGroup (\"$siteGr
oup\") ;\n \tsetAlias (\"$siteCCTReff\") ;\n \tsetSpeedIn
(\"$siteACRate\") ;\n \tsetSpeedOut (\"$siteACRate\") ;\n \tsetD
eviceSpeedIn (\"$siteACRate\") ;\n \tsetDeviceSpeedOut (\"$siteACRate\")
;\n} \n\n"); # print RH-Serial rule


print ARFfile ("name matches  \".*-Serial.*\": {\n \tsetName
(\"$SiteName-WAN\$2\") ;\n \tsetGroup (\"$siteGroup\"
) ;\n \tsetAlias (\"$siteCCTReff\") ;\n \tsetSpeedIn (\"$siteACRate\") ;\n
\tsetSpeedOut (\"$siteACRate\") ;\n \tsetDevice
SpeedIn (\"$siteACRate\") ;\n \tsetDeviceSpeedOut (\"$siteACRate\") ;\n}
\n\n"); # print -Serial rule

for ($i = 0; $i < $siteNoOfPVCs ; $i++ ) { # loop for each PVC

 
($PVCdlci,$PVCname,$PCVreff,$PVCcir)=split(/,/,"$sitePVCs[$i]",4);
# split out pvc info

print ARFfile ("name matches  \".*-dlci-$PVCdlci\": {\n
\tsetName (\"$SiteName-$PVCname\") ;\n \tsetGroup
(\"$siteGroup\") ;\n \tsetAlias (\"$PCVreff\") ;\n \tsetSpeedIn
(\"$PVCcir\") ;\n \tsetSpeedOut (\"$PVCcir\") ;\n \tsetDev
iceSpeedIn (\"$PVCcir\"

Re: Reading and from more than one filehandle / memory question

2003-11-06 Thread Tore Aursand
On Thu, 06 Nov 2003 10:31:18 -0600, James Edward Gray II wrote:
> my @results;
> [...]

Wasn't it the whole point that the OP _couldn't_ store this in an array,
as it would consume too much memory?  The solution goes like this;

  1. Define the files in an array
  2. Start reading the first file
  3. For each line in the first file, read a line from
 the other files.  Push the lines to an array.
  4. Process the array, output the result, go back to #3.


-- 
Tore Aursand <[EMAIL PROTECTED]>


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



Re: RFC on first perl script

2003-11-06 Thread Tore Aursand
On Thu, 06 Nov 2003 16:33:41 +, drowl wrote:
> #!/usr/bin/perl -w

No big deal, but - IMO - easier to read, and it adds strict;

  #!/usr/bin/perl
  #
  use strict;
  use warnings;

> @dataFile=<>; # read in file from command line
> @standardRules=`cat standard.for.arf.txt` ;

  my @dataFile  = <>;
  my @standardRules = `cat standard.for.arf.txt`;

Also have in mind that this is platform dependent, as there is no 'cat'
command in DOS/Windows (or on many other platforms, I would guess).

Instead of doing the whole work with open, read and close all the time,
you could do as me:  Write your own module which has a 'read_file'
function;

  sub read_file {
  my $filename = shift || '';

  my @lines = ();
  if ( $filename && -e $filename ) {
  if ( open(FILE, $filename) ) {
  @lines = ;
  close( FILE );
  chomp( @lines );
  }
  }

  return ( wantarray ) ? @lines : join("\n", @lines);
  }

This one is very simplified, but it gives you and idea.  Next time you
need to read a (text) file:

  my $text = read_file( 'text.txt' );

> #split up main / pvc info
> ($siteLink,$siteNoOfPVCs,$siteAllPVCs)=split(/:/,$site,3);

As long as we don't know what the contents of $site looks like, we can't
comment on this.

> for ($i = 0; $i < $siteNoOfPVCs ; $i++ ) { # loop for each PVC

I guess this should do the trick:

  foreach ( @sitePVCs ) {
  # ...
  }


-- 
Tore Aursand <[EMAIL PROTECTED]>


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



Re: Is foo qw (arg1 arg2) equivalent to foo (arg1, arg2)?

2003-11-06 Thread Dan Anderson

> Dan> So: foo->bar qw(foo bar); is equivalent to foo->bar("foo","bar"); ?
> 
> Only in recent Perls.  

Do you know exactly how recent?  Are we talking 5 or better or 3 or
better?

Thanks in advance,

-Dan

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



RE: Why is parsing your own form data a bad idea?

2003-11-06 Thread Tore Aursand
On Thu, 06 Nov 2003 13:21:15 +0100, Jenda Krynicky wrote:
>> There is absolutely _no_ reason why one shouldn't use the CGI.pm
>> module.

> There is one. If /s?he/ is using CGI::Lite instead ;-)

In that case, there are many reasons.  There are a lot of CGI::* modules
out there.

My point is still valid, though;  Why do one want to use CGI::Lite instead
of CGI.pm?  Is it better?  No.  Is it safer?  No.  Is it faster?  No.  Is
it more widely used?  No.  Does it come with the Perl distribution?  No.


-- 
Tore Aursand <[EMAIL PROTECTED]>


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



use of File::Find

2003-11-06 Thread West, William M

find (\&transfer, $path);

sub transfer {
my ($newpath, $oldstring, $newstring) = @_;
otherstuff ($oldstring, $newstring);

#   etc...


}


now- how do i pass parameters to transfer() when it's called 
with find??

i want the recursive fileprocessing to change file contents and
put the changed file in a mirrored directory structure-  i am
doing well enough making the program, but the documentation
had been hard to work with with regard to File::Find...

don't worry- i'm looking at perldoc File::Find too... :)

thanks all,

willy

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



RE: use of File::Find

2003-11-06 Thread Bob Showalter
West, William M wrote:
> find (\&transfer, $path);
> 
> sub transfer {
>   my ($newpath, $oldstring, $newstring) = @_;
>   otherstuff ($oldstring, $newstring);
> 
> # etc...
> 
> 
> }
> 
> 
> now- how do i pass parameters to transfer() when it's called with
> find?? 
> 
> i want the recursive fileprocessing to change file contents and
> put the changed file in a mirrored directory structure-  i am
> doing well enough making the program, but the documentation
> had been hard to work with with regard to File::Find...
> 
> don't worry- i'm looking at perldoc File::Find too... :)

Good, then you'll see that $_ has file file name, and $File::Find::dir has
the directory name. As for $oldstring and $newstring, you can either put
them in global variables, or do something like:

   find( sub { transfer($oldstring, $newstring) }, $path);

That arranges to pass $oldstring and $newstring to each invocation of
transfer.

HTH

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



RE: RFC on first perl script

2003-11-06 Thread drowl

 Good stuff all taken on board
  did take me a while to figger out that EOF had to be at the begging of
the line tho, but i got there in the end...

and a question about "use strict"

i now get the below warning along with many others...
how does one declair a varible then?

Global symbol "$site" requires explicit package name at ./makeArf.pl line 17.



 thank you
   Ritch

>> please have a look at the code below and give comments
>
> Here are some quick comments.
>
> #1. Always "use strict"
> #2. See #1.
>
> When you "use strict" it foeces you to do things the "right way" and
> will help catch errors because of the extra checks it makes.
>
> So something like this:
>> @dataFile=<>; # read in file from command line
>
> Needs to be changed to this by explicitly declaring that variable: my
> @dataFile=<>; # read in file from command line
>
>> @standardRules=`cat standard.for.arf.txt` ;
>
> This isn't portable (if you care for it to be), and does not check for
> errors.  This might be better:
>
> open IN, 'standard.for.arf.txt' or die $!;
> my @standardRules = ;
> close IN;
>
>> (@sitePVCs)=split(/;/,$siteAllPVCs,$siteNoOfPVCs);
>
> The "(" and ")" force list context.  The array @sitePVCs will already
> force list context without the parens.  This can be rewriten like this,
> which may or may not be more readable to you:
>
> my @sitePVCs = split(/;/,$siteAllPVCs,$siteNoOfPVCs);
>
>> open(ARFfile, ">$siteARFfile") or die("can not open
>
> Typically filehandles are in all caps.  They don't need to be, but it is
> the usual way of doing things because it makes them easier to spot
> (especially to people other than the author).  Also the parens are not
> needed because "or" has very low precedence.  I also tend to put my
> error condition on the next line, but that is just my preference.
>
> open ARFFILE, ">$siteARFfile"
>   or die "can not open '$siteARFfile': $!";
>
> Again, parens not needed here, but they don't hurt either:
>
>> print ARFfile ("@standardRules\n"); #print standard bits
> print ARFFILE "@standardRules\n"; #print standard bits
>
> This is pretty icky:
>>print ARFfile ("name matches  \".*RH-Serial.*\":
>> {\n \tsetName(\"$SiteName-RH-WAN\$2\") ;\n \tsetGroup
>> (\"$siteGroup\") "); # print RH-Serial rule
>
> Try a here-document instead:
>
> # print RH-Serial rule
> print ARFFILE < name matches  ".*RH-Serial.*": {
> setName("$SiteName-RH-WAN\$2");
> setGroup("$siteGroup");
> setAlias("$siteCCTReff");
> setSpeedIn("$siteACRate");
> setSpeedOut("$siteACRate");
> setDeviceSpeedIn("$siteACRate");
> setDeviceSpeedOut("$siteACRate");
> }
> EOF
>
> It makes it a lot easier to read, not to mention I could remove the \n
> and the \" escapes.  BTW - If you have quotes in your string you can do
> this qq[a "blah" b] instead of "a \"blah\" b".  The char following the
> "qq" can be any char, so you could use qq{}, qq||, qq**, etc.
>
> In general there isn't anything *wrong* with the script... but "use
> strict" is STRONGLY encouraged.  The rest are just suggestions for
> readability.
>
> Rob
>
> -Original Message-
> From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]
> Sent: Thursday, November 06, 2003 11:34 AM
> To: [EMAIL PROTECTED]
> Subject: RFC on first perl script
>
>
>
>
> Hi all
>  well im trying at lerning this perl stuff.. reading from the "learning
> perl" oreilly book and a few other places,
> but also using perl a long time before i should ie making the below
> script, so that i dont get in to any very bad habbits at such an early
> stage. could some one please have a look at the code below and give
> comments, the code does do what i want it to ( well at leest from this
> stage).
>
>
> #!/usr/bin/perl -w
> 
> # this function creates a arf rule file from an input file
> # Version 0.1 6/11/03
> 
> @dataFile=<>; # read in file from command line
> @standardRules=`cat standard.for.arf.txt` ;
>
> foreach $site (@dataFile) {  # loop  for each line/site in dataFile
> chomp $site;
>
> ($siteLink,$siteNoOfPVCs,$siteAllPVCs)=split(/:/,$site,3);
> #split
> up main / pvc info
>
> ($siteIP,$siteString,$SiteName,$siteGroup,$siteCCTReff,$siteACRate)=split(/,
> /,$siteLink,6);
> #split up main info
> (@sitePVCs)=split(/;/,$siteAllPVCs,$siteNoOfPVCs);
>
> my $siteARFfile = "$siteIP.arf";
> open(ARFfile, ">$siteARFfile") or die("can not open
> '$siteARFfile': $!");
>
> print ARFfile
> ("##
> \n# \n# Discover Rule for:
> $siteIP \n#
> \n##
> \n\n"); # print header
>
> print ARFfile ("@standardRules\n"); #print standard bits
>
> print ARFfile ("name matches  \".*-Cpu-.*\": {\n \tsetName
> (\"$SiteName-RH-Cpu\") ;\n \tsetGroup (\"$siteGroup\")
> ;\n \tsetAlias 

Re: Is foo qw (arg1 arg2) equivalent to foo (arg1, arg2)?

2003-11-06 Thread Jeff 'japhy' Pinyan
On Nov 6, Dan Anderson said:

>
>> Dan> So: foo->bar qw(foo bar); is equivalent to foo->bar("foo","bar"); ?
>>
>> Only in recent Perls.
>
>Do you know exactly how recent?  Are we talking 5 or better or 3 or
>better?

Without check perldeltas, I'd say 5.6.

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


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



Re: Why is parsing your own form data a bad idea?

2003-11-06 Thread drieux
On Thursday, Nov 6, 2003, at 09:13 US/Pacific, Tore Aursand wrote:
[..]
My point is still valid, though;
p0: there is a cgi beginner's mailing list <[EMAIL PROTECTED]>
that is devoted to the specific fun/horror of cgi coding in perl
for those interested in raising the general issues.
p1: barring that, forgive me for showing up late for this, but
allow me to argue the counter point if I may. Jenda, as usual
has a bit of tongue in cheek worth being enjoyed! But the
real 'argument' if one wishes to make it is
	getting one's head around how CGI.pm actually does it's voodoo

Folks really should pull it up with say

	perldoc -m CGI

and read the comment bars, whinings, complainings, and general
technical kvetchings. Folks really will get a much better feel
for what is going on in that space, Lincoln D. Stein, and
the freaks supporting the CGI code line have done some serious
Grand Master FunkaDelik coding to keep it alive and practical.
So let us therefore assume that folks who start out as 'beginners'
have some desire to become our replacements and start maintaining
the code lines for the Next Cool Techno Wave! And not merely be
the simple typists of text for ever. So we need to help them
understand both sides of the dark horror. The 'traditionalist'
position of 'just use the stock modules', as well as the more
'experimentalist' approach of 'hey, it IS going to hurt for a
while, and you will ENJOY the CGI module more once you survive
your folly...' since, well, as the CGI module itself notes,
there were a few things that should have started out other ways
but, well, we were all a lot younger back then.
p2: The logical extension of course is that 'parsing form data'
is a reasonably good place to step into the basics of Regular Expression
mastery, and how that Voodoo Works, while also getting one's head
around what IS required in Forms, what is cooler in Forms, and
what is SUCH a bad idea.
So the real question is not whether parsing one's own is 'good or bad'
but 'what is it that the OP is really working on'.




ciao
drieux
---

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


Re: RFC on first perl script

2003-11-06 Thread drieux
On Thursday, Nov 6, 2003, at 09:56 US/Pacific, [EMAIL PROTECTED] wrote:

i now get the below warning along with many others...
how does one declair a varible then?
Global symbol "$site" requires explicit package name at ./makeArf.pl 
line 17.


I think your hit is at:

	foreach $site (@dataFile) {  # loop

and that should have been

	foreach my $site (@dataFile) {  # loop

this way '$site' is limited to the scope of the foreach loop.

ciao
drieux
---

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


Re: RFC on first perl script

2003-11-06 Thread drowl
> On Thu, 06 Nov 2003 16:33:41 +, drowl wrote:
>> #!/usr/bin/perl -w
>
> No big deal, but - IMO - easier to read, and it adds strict;
>
>   #!/usr/bin/perl
>   #
>   use strict;
>   use warnings;
>
>> @dataFile=<>; # read in file from command line
>> @standardRules=`cat standard.for.arf.txt` ;
>
>   my @dataFile  = <>;
>   my @standardRules = `cat standard.for.arf.txt`;
>
> Also have in mind that this is platform dependent, as there is no 'cat'
> command in DOS/Windows (or on many other platforms, I would guess).
>
> Instead of doing the whole work with open, read and close all the time,
> you could do as me:  Write your own module which has a 'read_file'
> function;
>
>   sub read_file {
>   my $filename = shift || '';
>
>   my @lines = ();
>   if ( $filename && -e $filename ) {
>   if ( open(FILE, $filename) ) {
>   @lines = ;
>   close( FILE );
>   chomp( @lines );
>   }
>   }
>
>   return ( wantarray ) ? @lines : join("\n", @lines);
>   }
>
> This one is very simplified, but it gives you and idea.  Next time you
> need to read a (text) file:
>
>   my $text = read_file( 'text.txt' );
>

nice... how ever i hope to turn this into a sub with  $site as input
and $siteIP and $siteString as output + the arf file of course

but maybe i can use this in the main proggi..

>> #split up main / pvc info
>> ($siteLink,$siteNoOfPVCs,$siteAllPVCs)=split(/:/,$site,3);
>
> As long as we don't know what the contents of $site looks like, we can't
> comment on this.

$site would look like:
127.0.0.1,comunityString,sitename,group,e23,2:2:bsite,21,p235,32000;csite,22,p523,64000

>
>> for ($i = 0; $i < $siteNoOfPVCs ; $i++ ) { # loop for each PVC
>
> I guess this should do the trick:
>
>   foreach ( @sitePVCs ) {
>   # ...
>   }
>
>
humm then would i just use ...=split(/,/,$_,4);  ???


> --
> Tore Aursand <[EMAIL PROTECTED]>
>
>
>


Thanks
   Ritch
-- 
fnord
yes im a Concord Engineer, no it never flown!



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



RE: RFC on first perl script

2003-11-06 Thread Dan Anderson
> Global symbol "$site" requires explicit package name at ./makeArf.pl line 17.

One of the things about strict is it makes you declare the scope of your
variables before using them.  So, for instance, while:

#! /usr/bin/perl
$foo = "foo\n";
print $foo;

Would run, the following wouldn't:

#! /usr/bin/perl
use warnings;  # yelp and whine if we screw up
use strict;# force us to not be sloppy.
$foo = "foo\n";
print $foo;

It would cause perl to say:
Global symbol "$foo" requires explicit package name at - line 4

We could fix that by changing like 4 to one of the following:
my $foo = "foo\n";   
our $foo = "foo\n";
local $foo = "foo\n";

>From Perldoc:

my EXPR
my TYPE EXPR
my EXPR : ATTRS
my TYPE EXPR : ATTRS

A "my" declares the listed variables to be local (lexically)
to the enclosing block, file, or "eval". If more than one value is
listed, the list must be placed in parentheses.  

The exact semantics and interface of TYPE and ATTRS are
still evolving. TYPE is currently bound to the use of "fields" pragma,
and attributes are handled using the "attributes" pragma, or starting
from Perl 5.8.0 also via the "Attribute::Handlers" module. See "Private
Variables via my()" in perlsub for details, and fields, attributes, and
Attribute::Handlers. 

local EXPR

You really probably want to be using "my" instead, because
"local" isn't what most people think of as "local". See
"Private Variables via my()" in perlsub for details.

A local modifies the listed variables to be local to the
enclosing block, file, or eval. If more than one value is
listed, the list must be placed in parentheses. See "Temporary   our
EXPR
our EXPR TYPE
our EXPR : ATTRS
our TYPE EXPR : ATTRS

An "our" declares the listed variables to be valid globals
within the enclosing block, file, or "eval". That is, it has the
same scoping rules as a "my" declaration, but does not create a
local variable. If more than one value is listed, the list must
be placed in parentheses. The "our" declaration has no semantic
effect unless "use strict vars" is in effect, in which case it
lets you use the declared global variable without qualifying it
with a package name. (But only within the lexical scope of the
"our" declaration. In this it differs from "use vars", which is
package scoped.)

An "our" declaration declares a global variable that will be
visible across its entire lexical scope, even across package
boundaries. The package in which the variable is entered is
determined at the point of the declaration, not at the point of
use. This means the following behavior holds:

package Foo;
our $bar;   # declares $Foo::bar for rest of lexical scope
$bar = 20;

package Bar;
print $bar; # prints 20

Multiple "our" declarations in the same lexical scope are
allowed if they are in different packages. If they happened to
be in the same package, Perl will emit warnings if you have
asked for them.

use warnings;
package Foo;
our $bar;   # declares $Foo::bar for rest of lexical scope
$bar = 20;

package Bar;
our $bar = 30;  # declares $Bar::bar for rest of lexical scope
print $bar; # prints 30

our $bar;   # emits warning

An "our" declaration may also have a list of attributes
associated with it.

The exact semantics and interface of TYPE and ATTRS are still
evolving. TYPE is currently bound to the use of "fields" pragma,
and attributes are handled using the "attributes" pragma, or
starting from Perl 5.8.0 also via the "Attribute::Handlers"
module. See "Private Variables via my()" in perlsub for details,
and fields, attributes, and Attribute::Handlers.

The only currently recognized "our()" attribute is "unique"
which indicates that a single copy of the global is to be used
by all interpreters should the program happen to be running in a
multi-interpreter environment. (The default behaviour would be
for each interpreter to have its own copy of the global.)
Examples:

our @EXPORT : unique = qw(foo);
our %EXPORT_TAGS : unique = (bar => [qw(aa bb cc)]);
our $VERSION : unique = "1.00";

Note that this attribute also has the effect of making the
global readonly when the first new interpreter is cloned (for
example, when the first new thread is created).

Multi-interpreter environments can come to being either through
the fork() emulation on Windows platforms, or by embedding perl
in a multi-threaded application. The "unique" attribute does
nothing in all other environments.

Values via local()" in perlsub for details, including issues
with tied arrays and hashes.

-Dan

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



RE: Why is parsing your own form data a bad idea?

2003-11-06 Thread Dan Muey
> > There is one. If /s?he/ is using CGI::Lite instead ;-)
> 
> In that case, there are many reasons.  There are a lot of 
> CGI::* modules out there.
> 
> My point is still valid, though;  Why do one want to use 
> CGI::Lite instead of CGI.pm?  Is it better?  No.  Is it 
> safer?  No.  Is it faster?  No.  Is it more widely used?  No. 
>  Does it come with the Perl distribution?  No.

Didn't you see the ;-) ? It's a joke, ha ha ha :)
> 
> 
> -- 
> Tore Aursand <[EMAIL PROTECTED]>

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



RE: RFC on first perl script

2003-11-06 Thread Dan Muey
Howdy, 

Always use strict;
Then your variables won't get messy, see the perldoc strict for more details.

> foreach $site (@dataFile) {  # loop  for each line/site in dataFile
> chomp $site;

You might make your life easier to by not declaring a variable at all here:

for(@datafile) {
chomp;
...

Then you just use $_ where you would have used $site and you're all set. 
(Except with functions that are expecting $_ if nothing else is specified, 
like chomp for instance.)

But yes to declare a variable with use strcit you need to do my before and 
that will elt you use it within the block you declared it in.

HTH

DMuey

> 
> 
> ($siteLink,$siteNoOfPVCs,$siteAllPVCs)=split(/:/,$site,3); 
> #split up main / pvc info
> 
> ($siteIP,$siteString,$SiteName,$siteGroup,$siteCCTReff,$siteAC
> Rate)=split(/,/,$siteLink,6);
> #split up main info
> (@sitePVCs)=split(/;/,$siteAllPVCs,$siteNoOfPVCs);
> 
> my $siteARFfile = "$siteIP.arf";
> open(ARFfile, ">$siteARFfile") or die("can not open
> '$siteARFfile': $!");
> 
> print ARFfile 
> ("
> ##
> \n# \n# Discover Rule for:
> $siteIP \n# 
> \n
> ##
> \n\n"); # print header
> 
> print ARFfile ("@standardRules\n"); #print standard bits
> 
> print ARFfile ("name matches  \".*-Cpu-.*\": {\n \tsetName
> (\"$SiteName-RH-Cpu\") ;\n \tsetGroup (\"$siteGroup\")
> ;\n \tsetAlias (\"RH-Cpu\") ;\n} \n\n" ); # print -Cpu- rule
> 
> print ARFfile ("name matches  \".*-RH\": { \n \tsetName
> (\"$SiteName-RH\") ;\n \tsetGroup (\"$siteGroup\") ; \n \t 
> setAlias (\"RH\") ;\n} \n\n" ); # print -RH rule
> 
> print ARFfile ("name matches  \".*RH-Serial.*\": {\n \tsetName
> (\"$SiteName-RH-WAN\$2\") ;\n \tsetGroup (\"$siteGr
> oup\") ;\n \tsetAlias (\"$siteCCTReff\") ;\n \tsetSpeedIn
> (\"$siteACRate\") ;\n \tsetSpeedOut (\"$siteACRate\") ;\n 
> \tsetD eviceSpeedIn (\"$siteACRate\") ;\n \tsetDeviceSpeedOut 
> (\"$siteACRate\") ;\n} \n\n"); # print RH-Serial rule
> 
> 
> print ARFfile ("name matches  \".*-Serial.*\": {\n \tsetName
> (\"$SiteName-WAN\$2\") ;\n \tsetGroup (\"$siteGroup\"
> ) ;\n \tsetAlias (\"$siteCCTReff\") ;\n \tsetSpeedIn 
> (\"$siteACRate\") ;\n \tsetSpeedOut (\"$siteACRate\") ;\n 
> \tsetDevice SpeedIn (\"$siteACRate\") ;\n \tsetDeviceSpeedOut 
> (\"$siteACRate\") ;\n} \n\n"); # print -Serial rule
> 
> for ($i = 0; $i < $siteNoOfPVCs ; $i++ ) { # loop for each PVC
> 
> 
> ($PVCdlci,$PVCname,$PCVreff,$PVCcir)=split(/,/,"$sitePVCs[$i]",4);
> # split out pvc info
> 
> print ARFfile ("name matches  
> \".*-dlci-$PVCdlci\": {\n \tsetName (\"$SiteName-$PVCname\") 
> ;\n \tsetGroup
> (\"$siteGroup\") ;\n \tsetAlias (\"$PCVreff\") ;\n \tsetSpeedIn
> (\"$PVCcir\") ;\n \tsetSpeedOut (\"$PVCcir\") ;\n \tsetDev 
> iceSpeedIn (\"$PVCcir\") ;\n \tsetDeviceSpeedOut 
> (\"$PVCcir\") ;\n} \n\n"); # print PVC rules
> 
> 
> }
> 
> close(ARFfile) or die("can not close '$siteARFfile': $!"); }
> 
> 
> 
> ---
> fnord
> yes im a Concord Engineer, no it never flown!
> 
> 
> 
> -- 
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
> 
> 

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



How do I glob with escaped spaces in a directory

2003-11-06 Thread Dan Anderson
When I use:

my @foo = glob "/foo/bar baz/*";
or
my @foo = glob "/foo/bar\ baz/*";

Glob doesn't return the files in those directories, @foo equals
("/foo/bar");

However, if I do:

my @foo = glob "/foo/bar*baz/*";

@foo equals an array with all the files in "/foo/bar\ baz/", which is
what I"m trying for.

How do I escape spaces?  Perldoc glob doesn't say.

Thanks in advance,

Dan

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



RE: Need help on perl graphical interface

2003-11-06 Thread Dan Anderson
> Investigate if a web application will meet your requirements ...

To expand on JosÃ's point, if you can use a web application you can buy
some slick looking templates for $20 off the 'net, and/or edit your web
page in Dreamweaver/Frontpage pro, or even just export an OpenOffice.org
document to HTML.  Then you can just cut and paste the code into a
HEREDOC without many problems.

I'm not sure there is a visual gui maker for TK, although I assume there
would be one somewhere.  (Quality possibly varying)

-Dan

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



Why can't I create a binary file ?

2003-11-06 Thread Bee
open FH, ">1.txt";
binmode FH;
binmode STDOUT;
print FH "123m,zxnc,mzxnc,mzncm,zxc";
close FH;

Why the output still a text file ?

Re: Why can't I create a binary file ?

2003-11-06 Thread Dan Anderson
> Why the output still a text file ?

This is a stab in the dark, but the binary equivalent of the characters in the string 
are characters, correct?  Have you tried seeing what happens when you output hex 
values?

-Dan

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



RE: Why can't I create a binary file ?

2003-11-06 Thread Wagner, David --- Senior Programmer Analyst --- WGO
Bee wrote:
> open FH, ">1.txt";
> binmode FH;
> binmode STDOUT;
> print FH "123m,zxnc,mzxnc,mzncm,zxc";
> close FH;
> 
> Why the output still a text file ?

Only thing binmode gives you is that what you put in will not be in any way 
translated as part of the print and/or write.  If you want to have binary data, then 
you would use pack and its parameters to put onto your file binary data.

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]



RE: Why is parsing your own form data a bad idea?

2003-11-06 Thread NYIMI Jose (BMB)
One reason to not use CGI.pm:

An important concern today in the integration architecture is to provide a means to 
support different type of clients.
Unfortunately CGI.pm will not fulfill the increasing requirements to support clients 
expecting other format than HTML.
Such clients can be palm top computers, mobile phones or other device that enables 
client access.

While there is no hindrance developping differents web components that would generate 
different presentation format, this solution is costly because it requires additional 
developement of web component for each distinct client type.
These web component also contains very similar logic - they different only in the way 
they present data - which introduces maintenance problems.

Rather than generating HTML pages on the web component tier (CGI.pm), we can generate 
XML.
HTML pages contain information on how to present the data to the web browser.
XML, on the other hand, simply describes the semantics of the data - it does not say 
anything about the preseentation.

Afterwards, such XML has to be transformed to a presentation appropriate for the 
client. This can be HTML for web browser, WML for WAP devices or any other appropriate 
format.

That's here technology like XSLT (eXtensible StyleSheet Language for Transformation) 
gets into the scene.
XSLT engine will tranform the XML to presentation format of your client.

There are several XML and XSLT modules from CPAN that can help achiving aforementioned 
requiremnts, CGI.pm will not ...

And this is not a joke :-)

My 0.02

José.


-Original Message-
From: news [mailto:[EMAIL PROTECTED] On Behalf Of Tore Aursand
Sent: Thursday, November 06, 2003 6:14 PM
To: [EMAIL PROTECTED]
Subject: RE: Why is parsing your own form data a bad idea?


On Thu, 06 Nov 2003 13:21:15 +0100, Jenda Krynicky wrote:
>> There is absolutely _no_ reason why one shouldn't use the CGI.pm 
>> module.

> There is one. If /s?he/ is using CGI::Lite instead ;-)

In that case, there are many reasons.  There are a lot of CGI::* modules out there.

My point is still valid, though;  Why do one want to use CGI::Lite instead of CGI.pm?  
Is it better?  No.  Is it safer?  No.  Is it faster?  No.  Is it more widely used?  
No.  Does it come with the Perl distribution?  No.


-- 
Tore Aursand <[EMAIL PROTECTED]>


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



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



RE: Why can't I create a binary file ?

2003-11-06 Thread Bob Showalter
Bee wrote:
> open FH, ">1.txt";
> binmode FH;
> binmode STDOUT;
> print FH "123m,zxnc,mzxnc,mzncm,zxc";
> close FH;
> 
> Why the output still a text file ?

A file's a file. Terms like "text" and "binary" are just conventions. To the
OS, a file's just a collection of bytes.

What were you expecting to be in the file?

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



RE: Why is parsing your own form data a bad idea?

2003-11-06 Thread Jenda Krynicky
From: Tore Aursand <[EMAIL PROTECTED]>
> On Thu, 06 Nov 2003 13:21:15 +0100, Jenda Krynicky wrote:
> >> There is absolutely _no_ reason why one shouldn't use the CGI.pm
> >> module.
> 
> > There is one. If /s?he/ is using CGI::Lite instead ;-)
> 
> In that case, there are many reasons.  There are a lot of CGI::*
> modules out there.

Yep, two of them mine.

> My point is still valid, though;  Why do one want to use CGI::Lite
> instead of CGI.pm?  Is it better?  No.  

Define better.

> Is it safer?  No.  

Can't say. I guess not. But you can't be safer than safe, can you ;-)

> Is it faster?  No.  

Oh yeah.
See http://www.perlmonks.org/index.pl?node_id=145790

> Is it more widely used?  No.
> Does it come with the Perl distribution?  No.

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]



RE: Why is parsing your own form data a bad idea?

2003-11-06 Thread Dan Muey
> There are several XML and XSLT modules from CPAN that can 
> help achiving aforementioned requiremnts, CGI.pm will not ...
> 

The OP was interested in parsing form data, apparently from html.

Yes CGI does not parse/handle XML, 
You would need an XML handling type module to do that.

And this self brew thing is going to parse and handle XML then also?
That would be a learning experience.

CGI also does not make coffee,
You would need a coffee maker of some sort to do that.

The fact still remains, it's a bad idea to parse your own input, 
whether it's html, xml, whatever - if there's a standard, portable, 
safe, etc way to do it.

My last 0.02, this is getting anoying. Do what you want.

> And this is not a joke :-)

Yes it is! :)

> 
> My 0.02
> 
> José.

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



Re: Reading and from more than one filehandle / memory question

2003-11-06 Thread James Edward Gray II
On Thursday, November 6, 2003, at 11:13 AM, Tore Aursand wrote:

On Thu, 06 Nov 2003 10:31:18 -0600, James Edward Gray II wrote:
my @results;
[...]
Wasn't it the whole point that the OP _couldn't_ store this in an 
array,
as it would consume too much memory?  The solution goes like this;
You are correct, of course.  I had forgotten this and as the test data 
he posted wasn't anywhere near a problem, I opted for the simple way 
out.  Thanks for keeping me honest.

James

#!/usr/bin/perl

use strict;
use warnings;
my @files;
my $index = 0;
for my $file (qw(file1 file2 file3 file4)) {
open $files[$index++], '<', "$file.txt" or die "Input error:  $!\n";
}
open OUT, '>', 'combined.txt' or die "Output error:  $!\n";
do {
my @line;
foreach my $file (@files) {
my $line = <$file>;
$line[length $1] = $2 if defined($line) && $line =~ /^(;*)(\d+)/;
}
{
no warnings 'uninitialized';
print OUT join(':', @line), "\n";
}
} until (eof $files[0]);
close $_ foreach @files;
close OUT;
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]


Re: How do I glob with escaped spaces in a directory

2003-11-06 Thread drieux
On Thursday, Nov 6, 2003, at 10:21 US/Pacific, Dan Anderson wrote:
[..]
How do I escape spaces?  Perldoc glob doesn't say.

[..]

an interesting problem, one thing that may influence
the problem is how your underlying shell does the
'expansion' - as the perldoc -f glob notes, with
perl 5.6 this is resolved with the File::Glob module.
How do you normally escape the spaces when you are at
the shell level??? the '*' solution is basically
cool enough - and yes that with the "bar\ baz" should
have worked as you would have expected it. EXCEPT that
it was inside double quotes, hence would be interpreted
once by perl, which will remove your "\" - so you either
want to go with
a. print_glob("$dir/foo/bar*baz/*");
b. print_glob( $dir . '/foo/bar\ baz/*');
c. print_glob("$dir/foo/bar\\ baz/*");
and resolve who gets to solve which interpolation where.

ciao
drieux
---
a bit of code to illustrate the fun of it all:
my $dir = ;

print_glob("$dir/foo/bar baz/*");
print_glob($dir . '/foo/bar baz/*');
print_glob("$dir/foo/bar\ baz/*");
print_glob("$dir/foo/bar*baz/*");
print_glob("$dir/foo/*bar*/*");
print_glob("$dir/foo/bar' 'baz/*");
print_glob( $dir . '/foo/bar\ baz/*');
print_glob("$dir/foo/bar\\ baz/*");


#
#
sub print_glob
{
my ($tag) = @_;

my @foo = glob $tag;
print "given :$tag: we see the glob as:\n";
foreach my $file (@foo)
{
print "\t:$file:\n";
}
} # end of print_glob
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]


Re: How do I glob with escaped spaces in a directory

2003-11-06 Thread david
Dan Anderson wrote:

> When I use:
> 
> my @foo = glob "/foo/bar baz/*";
> or
> my @foo = glob "/foo/bar\ baz/*";
> 
> Glob doesn't return the files in those directories, @foo equals
> ("/foo/bar");
> 
> However, if I do:
> 
> my @foo = glob "/foo/bar*baz/*";
> 
> @foo equals an array with all the files in "/foo/bar\ baz/", which is
> what I"m trying for.
> 
> How do I escape spaces?  Perldoc glob doesn't say.

here is one way doing it:

[panda]# touch "foo .txt"
[panda]# perl -MFile::Glob=:glob -le 'print bsd_glob("foo .txt",GLOB_QUOTE)'
foo .txt
[panda]# rm -f "foo .txt"
[panda]# perl -MFile::Glob=:glob -le 'print bsd_glob("foo .txt",GLOB_QUOTE)'

[panda]#

perldoc File::Glob

david
-- 
$_=q,015001450154015401570040016701570162015401440041,,*,=*|=*_,split+local$";
map{~$_&1&&{$,<<=1,[EMAIL PROTECTED]||3])=>~}}0..s~.~~g-1;*_=*#,

goto=>print+eval

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



upgrading

2003-11-06 Thread Tim
Hi,
I have perl 5.6.0 on a Linux box and want to install 5.8.1 on it and remove 
the earlier version.

The install is pretty straightforward, but I don't know how best to remove 
the old version. Intuitively it would appear that blowing off everything 
that has 'perl' in the filename in /usr/bin (maybe /usr/sbin as well) and 
all the directories in @INC.

Thanks for sharing any relevant experiences.
Cheers,
Tim
email: 

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


Re: upgrading

2003-11-06 Thread Dan Anderson
What distro?  Most of the times either you'll do something like $ rpm -U
./perl.rpm or make clean.

-Dan

-Dan
On Thu, 2003-11-06 at 16:50, Tim wrote:
> Hi,
> I have perl 5.6.0 on a Linux box and want to install 5.8.1 on it and remove 
> the earlier version.
> 
> The install is pretty straightforward, but I don't know how best to remove 
> the old version. Intuitively it would appear that blowing off everything 
> that has 'perl' in the filename in /usr/bin (maybe /usr/sbin as well) and 
> all the directories in @INC.
> 
> Thanks for sharing any relevant experiences.
> Cheers,
> Tim
> 
> email: 
> 

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



Re: Splitting OR Regex

2003-11-06 Thread R. Joseph Newton
Rob Dixon wrote:

> my @fields = $string =~ m/\w+=(?:"[^"]+"|\S+)/g;

Nice!!

Joseph


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



Re: how to extract data in specified format to another file

2003-11-06 Thread John W. Krahn
Chandrasekaran Mythili wrote:
> 
> HI,

Hello,

> I am new to Perl and I need some help regarding tranfering the contents of
> one file to other file in specified format using perl.
> 
> the problem is i have one file with data(data is in hex) as follows:
> 48
> 30
> 20
> 2E
> 2E
> 2E
> 0
> 0
> 0
> 
> i want to copy the contents of this file to another file till 0 is
> encountered.that is i want the resultant file to have
> 
> 4830202E2E2E
> 
> what command should i use get all the data in the same line?

perl -ne'0+$_&&print/./g' file1 > file2


:-)

John
-- 
use Perl;
program
fulfillment

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



Re: Deleting # and other characters

2003-11-06 Thread John W. Krahn
Raghu Murthy wrote:
> 
> I need to remove ./ and #from a list of files. I can do it in sed but I am
> not able to use it in my perl script. I tried to do something like this
> 
> chomp ($txtlist = );
> qx' sed -e "/^#/d $txtlist'; # To remove lines starting with a #
> qx' sed -e"s?\([  /]\)\./?\1?g" $txtlist; # To remove lines starting with a
> ./
> 
> I can do it if i hard code the file name but if i try to use $txtlist it
> does not work. What am i doing wrong.

Perl comes with a handy utility called s2p (sed to perl) that will help
you convert sed scripts to perl.  $txtlist does not work because qx runs
the sed program and returns the results to your perl program but you are
not doing anything with the results.

You can do it in perl something like this:

perl -i~ -pe's|^#||; s|([  /])\./|$1|g' file1 file2 file3 ... fileN


John
-- 
use Perl;
program
fulfillment

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



Re: Deleting # and other characters

2003-11-06 Thread Dan Anderson
> > I need to remove ./ and #from a list of files. I can do it in sed but I am
> > not able to use it in my perl script. I tried to do something like this

# delete all .s and /s
$variable_to_remove_from =~ tr/\.\///d;
# remove the first ./ and anything before it from
# $variable_to_remove_from
if ($variable_to_remove_from =~ m/\.\//) {
  $variable_to_remove_from =~ m/\.\//;
  $variable_to_remove_from = $';  
}
# remove only ./ from the file if it exists and is on a word boundary
if ($variable_to_remove_from =~ m/\b\.\//) {
  $variable_to_remove_from =~ m/\b\.\//;
  $variable_to_remove_from = $';  
}



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



Re: substitution problem

2003-11-06 Thread John W. Krahn
Steve Massey wrote:
> 
> Hi

Hello,

> I though I had sussed this s/ stuff but
> 
> #! /usr/bin/perl -w
> 
> $test =  "BRIGHTON (Firm)";
> 
> print "$test\n";
> $test =~ s/,*/,/;
> $test =~ s/,*$/,/g;
> 
> print "$test\n";
> 
> does not work, I want to substitute all multiple commas into a single one.

You should use tr/// instead of s///.  :-)

$test =~ tr/,//s;


John
-- 
use Perl;
program
fulfillment

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



Simple CGI question

2003-11-06 Thread Jack
Hello,

I'm trying to redirect the output of my CGI (written
in Perl) to another frame,
but I'm not exactly sure how to do this.  i.e. I have
two frames on my page
one on the right and one on the left.  There is a form
on the right frame.  When
the user clicks on the Submit button on my form, I'd
like to call a CGI script and
redirect its output to the left frame.  Could anyone
please tell me how I can do this?

Any help would be greatly appreciated.

Thanks,

 Jack

__ 
Post your free ad now! http://personals.yahoo.ca

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



Re: Why can't I create a binary file ?

2003-11-06 Thread Bee
> Bee wrote:
> > open FH, ">1.txt";
> > binmode FH;
> > binmode STDOUT;
> > print FH "123m,zxnc,mzxnc,mzncm,zxc";
> > close FH;
> > 
> > Why the output still a text file ?
> 

Thanks everybody, the way I tried to make files to binary
format is just because I want to learn how to sysread and
syswrite. I suppose I can write some bytes anywhere I like,
without re-writing the whole file again...

So, for the advise of using "pack"... any example or hints ?
For what I am expecting to see in the content, I guess I would
see some monster chars I guess, at least not as is the content
itself.
 
Thanks in advise


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



Re: Simple CGI question

2003-11-06 Thread Bee
You would like to use this :


in your html page of your right frame.

Hope this help

- Original Message - 
From: "Jack" <[EMAIL PROTECTED]>
To: "CGI1" <[EMAIL PROTECTED]>
Sent: Friday, November 07, 2003 8:11 AM
Subject: Simple CGI question


> Hello,
> 
> I'm trying to redirect the output of my CGI (written
> in Perl) to another frame,
> but I'm not exactly sure how to do this.  i.e. I have
> two frames on my page
> one on the right and one on the left.  There is a form
> on the right frame.  When
> the user clicks on the Submit button on my form, I'd
> like to call a CGI script and
> redirect its output to the left frame.  Could anyone
> please tell me how I can do this?
> 
> Any help would be greatly appreciated.
> 
> Thanks,
> 
>  Jack
> 
> __ 
> Post your free ad now! http://personals.yahoo.ca
> 
> -- 
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
> 
> 


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



removing apache

2003-11-06 Thread BetaGamma
Hi guys...
 
If I want to remove my apache server do I need to only delete the $HOME/apache 
directory and delete the enteris from my .cshrc or anything else is also required.
 
Thanks
 
Pawan


-
Do you Yahoo!?
Protect your identity with Yahoo! Mail AddressGuard

Re: Simple CGI question

2003-11-06 Thread Eric Walker
Newbie here but hope this helps.

You have a page linked to the frame on the left right?  All you need to
do is have your CGI script write the new page.  You use the info from
the frame on the right and pass the values to your cgi script. Then let
your CGI script write out a new html page using the values you sent it. 
Ok heres is the hard part.. All of you pros correct me if I am wrong.

In the past I have use the "use CGI" module.  When you click submit you
need to call
your cgi a certain way to pass the values from the form to it.

http://myfile.cgi?=&=&=&

you need a variablename and value for every variable value pair you need
to send to the CGI.

Once you get to doing the CGI this is your next step.  Make sure you
have
use CGI; and my $q = new CGI; toward the top of the file.

$myvariable = $q->param("");
This will take the value sent to the CGI and put it into $myvariable. 
After that you just print the value the the html page linked in your
left frame.  I think you will have to do a refresh to get the new
content to show. Hope this helps and hope I am not too terribly off.

PEACE
Beginner










On Thu, 2003-11-06 at 17:11, Jack wrote:

Hello,

I'm trying to redirect the output of my CGI (written
in Perl) to another frame,
but I'm not exactly sure how to do this.  i.e. I have
two frames on my page
one on the right and one on the left.  There is a form
on the right frame.  When
the user clicks on the Submit button on my form, I'd
like to call a CGI script and
redirect its output to the left frame.  Could anyone
please tell me how I can do this?

Any help would be greatly appreciated.

Thanks,

 Jack

__ 
Post your free ad now! http://personals.yahoo.ca

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




Re: removing apache

2003-11-06 Thread drieux
On Thursday, Nov 6, 2003, at 16:40 US/Pacific, BetaGamma wrote:
[..]
If I want to remove my apache server do I need to only delete the 
$HOME/apache directory and delete the enteris from my .cshrc or 
anything else is also required.

[..]

well there is that whole bunch of questions about
which OS and how did you install it.
Most servers will have ganglia of the web server
all over the place, including /etc/httpd, as well
as the init scripts that are called to start and
stop it when the system is booted.
But if you as a user installed it locally in your
home directory, then you should be kosher about
having all of the stuff contained there.
Then there are the folks who ...

ciao
drieux
---

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


Re: Parse and Compare Text Files

2003-11-06 Thread John W. Krahn
Mike M wrote:
> 
> Hi,

Hello,

> I'm new to Perl and have what I hope is a simple question:  I have a Perl
> script that parses a log file from our proxy server and reformats it to a
> more easily readable space-delimited text file.  I also have another file
> that has a categorized list of internet domains, also space-delimited.  A
> snippet of both text files is below:
> 
> Proxy Log
> snip
> 10/23/2003 4:18:32 192.168.0.100 http://www.squid-cache.org OK
> 10/23/2003 4:18:33 192.168.1.150 http://msn.com OK
> 10/23/2003 4:18:33 192.168.1.150 http://www.playboy.com DENIED
> snip
> 
> Categorized Domains List
> snip
> msn.com news
> playboy.com porn
> squid-cache.com software
> snip
> 
> What I would like to do is write a script that compares the URL in the proxy
> log with the categorized domains list file and creates a new file that looks
> something like this:
> 
> New File
> snip
> 10/23/2003 4:18:32 192.168.0.100 http://www.squid-cache.org software OK
> 10/23/2003 4:18:33 192.168.1.150 http://msn.com news OK
> 10/23/2003 4:18:33 192.168.1.150 http://www.playboy.com porn DENIED
> snip
> 
> Is this possible with Perl??  I've been trying to do this by importing the
> log files into SQL and then running queries, but it's so much slower than
> Perl (the proxy logs are roughly 1 million lines).  Any ideas?

You could do something like this:

#!/usr/bin/perl -w
use strict;

my $file = 'domains.txt';
my $log  = 'access.log';
my $out  = 'access.out';

my %domains = do {
open my $fh, $file or die "Cannot open $file: $!";
local $/;
map split, <$fh>;
};

my $search = qr/@{[ join '|', map "\Q$_", keys %domains ]}/i;

open OUT, ">> $out" or die "Cannot open $out: $!";
open FILE, $log or die "Cannot open $log: $!";

while (  ) {
s/\b($search)(?=\s+(?:OK|DENIED)$)/ $1 ? "$1 $domains{$1}" : $1 /e;
print OUT;
}

__END__


John
-- 
use Perl;
program
fulfillment

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



Using Perl with PC Anywhere?

2003-11-06 Thread Trent Rigsbee
Hi! Newbie question here but is it possible to use PC Anywhere with Perl? If 
so, how? What kinds of things can you do? This question came up in a 
conversation with some friends and so I thought I'd ask the group. I'm sure 
I'm a typical newbie in that I'm having trouble sensing the possibilities 
that one can do with a language.

_
Compare high-speed Internet plans, starting at $26.95.  
https://broadband.msn.com (Prices may vary by service area.)

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


RE: Using Perl with PC Anywhere?

2003-11-06 Thread Tim Johnson

I guess it depends on what you mean by using it "with" PCAnywhere.  Many
of the things you would use PCAnywhere to do, you can do with Perl
without needing a program like PCAnywhere to do it, for example if you
wanted to install programs, change settings, etc.

-Original Message-
From: Trent Rigsbee [mailto:[EMAIL PROTECTED] 
Sent: Thursday, November 06, 2003 5:57 PM
To: [EMAIL PROTECTED]
Subject: Using Perl with PC Anywhere? 

Hi! Newbie question here but is it possible to use PC Anywhere with
Perl? If so, how? What kinds of things can you do? This question came up
in a conversation with some friends and so I thought I'd ask the group.
I'm sure I'm a typical newbie in that I'm having trouble sensing the
possibilities that one can do with a language.

_
Compare high-speed Internet plans, starting at $26.95.  
https://broadband.msn.com (Prices may vary by service area.)


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


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



Re: Why is parsing your own form data a bad idea?

2003-11-06 Thread R. Joseph Newton
Tore Aursand wrote:

> On Wed, 05 Nov 2003 17:22:43 -0600, Dan Muey wrote:
> >> If it comes to the point where you need to "hack around" CGI.pm, I'd
> >> say go with your original inclination to just do it yourself.
>
> > Give me one example when you'd need to hack CGI.pm to handle input that
> > you can't do without hacking it.
>
> This might not justify as "hacking" the CGI.pm, but once I had to do
> something really special related to session handling.  The solution wasn't
> to hack, change or write my own CGI handling module, but simply subclass
> the original CGI.pm.

Excellent idea.  It's really the core of OOPs power.  How is CGI for
subclassing?

Joseph


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



Re: Why is parsing your own form data a bad idea?

2003-11-06 Thread R. Joseph Newton
"NYIMI Jose (BMB)" wrote:

> One reason to not use CGI.pm:
>
> An important concern today in the integration architecture is to provide a means to 
> support different type of clients.
> Unfortunately CGI.pm will not fulfill the increasing requirements to support clients 
> expecting other format than HTML.
> Such clients can be palm top computers, mobile phones or other device that enables 
> client access.

Hold it!  We are talking about CGI work and the Web.  The web is defined as the set 
links that connect html pages to each other.  For other programming or iInternet 
communication tasks, you certainly would find other functionality more
appropriate.

Joseph


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



Re: Need help on perl graphical interface

2003-11-06 Thread R. Joseph Newton
Pandey Rajeev-A19514 wrote:

> Hi,
>
> I don't know anything about perl graphics. I would explain excatly what I want.
>
> I want to develope a interactive graphical interface which can display all the nodes 
> in a network in a tree representation.
> I should be able to draw that tree upon reading a data base (or real time data).
> I should be able to click on to a particular node in that network and should be able 
> to do what I wish on that node( i.e. to make it interactive and what I wish to do is 
> not that important right now).

On 'nix:

> perl -MCPAN -e shell

On Windows [ActiveState]:
 >ppm

On either:

ppm|CPAN> install Tk

then:

> perldoc Tk
> perldoc Tk::Tree
> perldoc Tk::Scrolled

Tree is a great object, with infinite possibilities for its application.  Get to know 
it.

Joseph



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



Re: RFC on first perl script

2003-11-06 Thread R. Joseph Newton
[EMAIL PROTECTED] wrote:

> Hi all
>  well im trying at lerning this perl stuff.. reading from the "learning
> perl" oreilly book and a few other places,
> but also using perl a long time before i should ie making the below script,
> so that i dont get in to any very bad habbits at such an early stage.
> could some one please have a look at the code below and give comments, the
> code does do what i want it to ( well at leest from this stage).

I would comment on the process here.  I am sure that you know what you want, but do 
we?  Since you say
it does what you want, I assume it compiles.  While it may not be impossible to write 
good code by just
jumping into the coding, it is highly unlikely to happen.

> #!/usr/bin/perl -w
> 
> # this function creates a arf rule file from an input file
> # Version 0.1 6/11/03
> 

use strict;
use warnings;

> [snip]

Now recompile your code with those two lines at the top, and then repost, referably 
telling us, in
real-world terms, what problem you are trying to solve, or what task you are trying to 
accomplish, with
your program.  Defining your objective is the first step in solid programming.

Joseph



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



Re: pattern matching

2003-11-06 Thread John W. Krahn
Christiane Nerz wrote:
> 
> Hi everybody!

Hello,

> Two questions:
> I've got a test-file and want to add something to some lines, while
> reading it out.
> I tried the following code:
> 
> while () {
>   if (/pattern/) {
>  #$line = $_ . $something;
>  #push (@new_array, $line);
>   }
>   else {
> #$line = $_;
> #push (@new_array, $line);
>   }
> }
> 
> But @new_array didn't get the lines!
> 
> The textfile look like
> 
>  >SA texttexttext...\n
> texttexttext\n
> texttexttext\n
> texttexttext\n
>  >SA texttexttext...\n
> texttexttext\n
> texttexttext\n
> texttexttext\n
>  >SA texttexttext...\n
> texttexttext\n
> texttexttext\n
> texttexttext\n
> 
> I tried to get the >SA..-lines by
> 
> if (/^SA[.]*\n/) {
> do...
> 
> but the pattern was not be found.
> Whats wrong with it?

Your pattern specifies that the line must start with the characters 'S'
and 'A' followed by zero or more of the '.' character followed by a
newline character but your example shows that the line starts with the
characters ' ', '>', 'S', 'A' and ' '.

while (  ) {
if ( /^ >SA .*\n/ ) {
push @new_array, $_ . $something;
}
else {
push @new_array, $_;
}
}


> Or does anyone knows a simple method to read the lines in a hash -
> every-SA-line should be the key, the following lines until the next >SA
> the value. That'll be much more simple to handle..

my ( $key, %hash );
while (  ) {
if ( /^ >SA .*\n/ ) {
$key = $_;
}
elsif ( defined $key ) {
$hash{ $key } .= $_;
}
}


John
-- 
use Perl;
program
fulfillment

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



Re: how to optimize a string search

2003-11-06 Thread John W. Krahn
Ramprasad A Padmanabhan wrote:
> 
> I know this is more of an algorithm question but please bear with me.
> 
> In my program I am checking wether a emailid exists in a list
> I have in the complete_list a string like
> $complete_string="<[EMAIL PROTECTED]> <[EMAIL PROTECTED]> <[EMAIL PROTECTED]> ... 
> <[EMAIL PROTECTED]>";

Why store it in a string and not an array?

> #  that is a string of emailids sorted
> 
> Now I want to find out if another ID  "<[EMAIL PROTECTED]>" exists in this list
> 
> How is it possible to optimize the search  given that the complete list
> string is sorted in order

The fastest string search method IIRC is Boyer-Moore and variants
thereof.  Perl provides the index() function for searching strings which
may be fast enough for your purposes.  If you had stored the sorted list
in an array then you could have used a binary search which is very
efficient.

> The alternative I am considering is
>1) Create a hash array with each of the ids as keys and just use the
> exits function

This is also very efficient as long as the keys are unique.

> like
> my %hash=();
> while($complete_list=~/(\<.*?\>)/g){ $hash{$1}=1 };

Or:

my %hash = map { $_ => 1 } $complete_list =~ /<[^>]*>/g

> 
> if(exists($hash{$emailid})) {
> # FOUND id in string
> }
> 
> Is this the best way

The hash has faster lookups but uses more memory then a single string.

> Is there no way directly to use the string

If all the entries in the string were the same length (space padded)
then you could use a binary search on the string.


John
-- 
use Perl;
program
fulfillment

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



Re: Regex search question

2003-11-06 Thread John W. Krahn
Paul Harwood wrote:
> 
> I know that
> 
> if ( /VALUE={1}(\d+)/ ) {
> 
> looks for the first occurrence of value. How do I find the last occurrence?

Probably the most efficient way:

my $rev = reverse $_;
if ( $rev =~ /(\d+)=EULAV/ ) {


John
-- 
use Perl;
program
fulfillment

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



Re: Regex search question

2003-11-06 Thread Jeff 'japhy' Pinyan
On Nov 6, John W. Krahn said:

>Paul Harwood wrote:
>>
>> if ( /VALUE={1}(\d+)/ ) {
>>
>> looks for the first occurrence of value. How do I find the last occurrence?
>
>Probably the most efficient way:
>
>my $rev = reverse $_;
>if ( $rev =~ /(\d+)=EULAV/ ) {

Remember to reverse $1, though.  You could also do

  /.*VALUE=(\d+)/

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


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