Re: perl / MySql application overview question

2003-08-14 Thread Wiggins d'Anconia
Hughes, Andrew wrote:
I have a multi-table MySQL database that holds different pieces of
information that will all be displayed on a web page template.  The general
principle is that non web people will be able to populate web pages through
an admin panel.  The data in all of the MqSQL tables will be entered by the
user through forms on the web and bought into a page template using the
unique id for each page.
The user will login with a username and password.  This information will
then be stored in a session using Apachee::Session and a cookie.  The first
form that the user submits will contain general information about the page
itself.  All of this information will be stored in one row in the table and
a unique id will be generated in MySQL for that webpage.  Subsequent forms
will request other information for different areas of that one page.  I plan
on relating all of the information in the rest of the tables to build that
one page back to the specific page based on that page's unique id that was
generated.  I was planning on doing that by somehow getting that generated
unique id into the cookie immediately after it is generated in the MySQL
database.  Then, every time information is added to another table that
relates back to the webpage, I will enter that id from the cookie in the
MySQL insert statement.
Here are my questions:
Is this a proper approach?
If not, what is a better / correct approach?
If it is, how would I go about it? 

I am not asking for someone to do it for me.  I was just wondering if there
were some terms / buzzwords / tutorials that I should follow up on.
This sounds like a common approach and certainly a viable one. In 
general you are talking about precisely what an RDBMS is for and the 
tables you refer to are in general called lookup tables.  In other words 
you store the main record in a master table then you lookup into another 
table based on a unique id from the master.

One item you will want to look into is a join clause. A join clause 
allows you to combine fields from multiple tables in a single select 
statement so that you don't have to do multiple independent selects to 
retrieve the same effect, but that is OT for this forum, but have a look 
at the MySQL documentation for JOIN.

As for retrieving the ID generated by an auto increment in MySQL if you 
are using DBI (which I hope you are) then you can using something like 
the following after an insert:

my $newid = $sth-{'Database'}-{'mysql_insertid'};
unless ($newid) {
   # handle error here
}
Though this may not be portable to other engines, but it saves you the 
pain of having to do multipe statements in an atomic manner (locking), etc.

You will run into other design problems as you go along, and a lot of 
questions, that really can't be avoided without experience, but overall 
your design is fairly sound for some applications and obviously you have 
given it some or a lot of thought before starting, which is usually the 
critical and first mistake made (aka to dive right in).

Good luck,

http://danconia.org

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


Re: Perl line breaks

2003-08-14 Thread Camilo Gonzalez
Yech, what a mess. I think you may need to escape the question mark and 
or dots. In any case, why try to escape such an unwieldy string? Why not 
use a heredoc? Laziness is the mark of a good programmer.

Mike Harrison wrote:

I was trying to find a log file to look at.  I guess half the problem is I
am using a hosting service, and it is on a Microsoft IIS server (Windows
NT-based I think, but definitely not UNIX).  I will have to ask the hosting
admin where I might find a log file...
Here is the part of the perl script that I start printing things to the
browser (see previous message for the html.pm script that contains the
HTML_header and HTML_ender subroutines):
my $header = 'Successful update';
my $msg = h2Your preferences have been updated
successfully.../h2hrbrbrbr;
# Finally, put up a HTML document announcing that the update was successful.
HTML_header($header);
print body\n;
print center\n;
print $msg\n;
print pReturn to the a href=\amtest.pl?uname=$uname\
onMouseover=\window.status='Back to account management'; return true\
onMouseout=\window.status=''; return true\Account Management/a
page/p\n;
print /center\n;
HTML_ender;
Note that I have also tried using print qq| ... | code as well.

I am now getting a CGI error message along the lines of
Cannot find a string terminator '' in ... line ... (the line above starting
with print p... .  I can't find a problem with that line???
Thanks for your help so far guys!  I am losing a bit of sleep on this one :(
Regards,
Mike.
-Original Message-
From: Octavian Rasnita [mailto:[EMAIL PROTECTED]
Sent: Wednesday, 06 August, 2003 2:30 AM
To: Jon Hogue
Cc: Mike Harrison; 'Andrew Brosnan'; [EMAIL PROTECTED]
Subject: Re: Perl line breaks
For troubleshooting a script you can take a look in the server's log file
and you will find there any error.
Teddy,
Teddy's Center: http://teddy.fcc.ro/
Email: [EMAIL PROTECTED]
- Original Message -
From: Jon Hogue [EMAIL PROTECTED]
To: Octavian Rasnita [EMAIL PROTECTED]
Cc: Mike Harrison [EMAIL PROTECTED]; 'Andrew Brosnan'
[EMAIL PROTECTED]; [EMAIL PROTECTED]
Sent: Tuesday, August 05, 2003 4:19 PM
Subject: Re: Perl line breaks


 

...and you don't need to print the HTML header in the BEGIN {} block.
You can just print it at the top of the perl program or in the middle of
   

the
 

program but before anything else is printed.
   

if something is dieing in a module you are loading, you will never know
about it because it will never get to the Content-Type and therefore never
send anything good to your browser. if you use a BEGIN block, you might
catch things that happen in modules you load. i wouldn't recommend doing
that for your normal script, but it is a useful troubleshooting tool.


 



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


Re: Perl line breaks

2003-08-14 Thread Octavian Rasnita
What web server is installed on that computer?
Some web servers need to use non parsed header scripts (NPH) and I heard
that this is the case with MS IIS if this is the web server.

The line break is not very important for perl scripts under Windows. I use
only the Unix end of line (lf) under Windows for my perl scripts and they
work fine.
I don't know if they would be working the same if I will be using Mac end of
lines, but with Unix end of line they work fine.

I guess you should send that script to the list...

Teddy,
Teddy's Center: http://teddy.fcc.ro/
Email: [EMAIL PROTECTED]

- Original Message -
From: Mike Harrison [EMAIL PROTECTED]
To: 'Andrew Brosnan' [EMAIL PROTECTED]; Mike Harrison
[EMAIL PROTECTED]
Cc: [EMAIL PROTECTED]
Sent: Tuesday, August 05, 2003 3:07 AM
Subject: RE: Perl line breaks


Hi Andrew,

1. Yes, I am using the same headers as the perl program that works, so don't
think it is that - I will check that there is a blank line between the
'Content-Type:...' line and the next.

2. My first line in the perl program is: #!perl -w (being a Windows-based
server, it doesn't require the full path.  The -w to warn of errors/mistakes
etc.)

I will need to wait till tonight before sending some of the perl program and
header info...

Cheers,
Mike.


-Original Message-
From: Andrew Brosnan [mailto:[EMAIL PROTECTED]
Sent: Tuesday, 05 August, 2003 10:03 AM
To: Mike Harrison
Cc: [EMAIL PROTECTED]
Subject: Re: Perl line breaks


On 8/5/03 at 9:32 AM, [EMAIL PROTECTED] (Mike Harrison)
wrote:

 Hello all,

 Well, I have spent the last few nights messing around trying to work
 out why one of my PERL programs doesn't work.

s/Perl/PERL/

 With one program, I am getting an error message as follows:

 CGI Error The specified CGI application misbehaved by not returning a
 complete set of HTTP headers. The headers it did return are:

How are you creating your headers? Perhaps you could show that here.


 My question is:  Are line breaks important with PERL programs

With headers they are:
print Content-Type: text/html\n\n #-- blank line required

 does anybody know why I am getting this error?

Maybe Perl does. Did you ask?:
use warnings;



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



Re: Flock and Sleep

2003-08-14 Thread Oliver Schnarchendorf
On Fri, 8 Aug 2003 02:32:05 +0500, Sara wrote:
 open(NUMBER,data.txt);
 flock (NUMBER, 2);
 close (NUMBER);
 closing a file automatically removes the lock??
The answer is yes. When you close files they will automatically 
un-locked.

One thing though, you might want to use the fcntl module which imports 
the following flock constants:

# Importing flock constants:
# (LOCK_SH, LOCK_EX, LOCK_NB and LOCK_UN)
use fcntl ':flock'; 

 My second question is how I can delay the execution of a script (If 
 two users trying to execute the same script) for 30 sec by using 
 sleep function? and If I implement sleep function in my script . 
 Do I really need to use 'flock' in my script or there is no need then.
It depends in which environment you want to run your script. If it only 
needs to run in the *nix world you might want your script to:

(a) check for a file (-e)
(b) if file doesn't exist, create it and write the scripts PID 
(getpid() or $$ or $PID or $PROCESS_ID) into it
(c) if the file is found read the PID and ping the PID for existance 
(sending a signal with kill()) [*]
(d) if PID exists you will wait 30 seconds (sleep()) and go back to 
(c) or wait for the other script to finish (waitpid()).
(e) once your script gets the ok from (a) or (d) you can goto (b).

If you are interested in another solution which will die () if the same 
script is already running, just ping me by email.

thanks
/oliver

[*] You might want to install a signal handler in your script that will 
ignore the send signal though. E.g.:

local $SIG{INT} = 'IGNORE';


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



Re: Regex and Email address.

2003-08-14 Thread Wiggins d'Anconia
Would be interesting to see which is faster, there is that whole regex 
engine thing. Of course to say that there are no letters isn't strictly 
fair because you would need two lines of comments stating what you are 
doing ;-)... depending on the context...

http://danconia.org

Hall, Scott wrote:
Regexes are always more fun :)  How else can you write a program with almost
no letters.
$email =~ s/(?[EMAIL PROTECTED]).*$/.../;

perldoc perlre

search for 'look-behind'

Scott

-Original Message-
From: Wiggins d'Anconia [mailto:[EMAIL PROTECTED]
Sent: Tuesday, August 05, 2003 10:36 PM
To: Sara
Cc: [EMAIL PROTECTED]
Subject: Re: Regex and Email address.
Sara wrote:

Simple Regex problem

How you will convert 

$email = [EMAIL PROTECTED];

TO

$email = [EMAIL PROTECTED];

using Regex.



Well this isn't necessarily a regex issue, TMTOWTDI,

my $email = '[EMAIL PROTECTED]';
$email = substr($email, 0, (index($email,'@')+2));
print Email: $email...\n;
perldoc -f index
perldoc -f substr
...of course having said that you *can* do it with a regex ;-) 

my $email = '[EMAIL PROTECTED]';
$email =~ s/^([EMAIL PROTECTED]).*/$1/;
print Email: $email...\n;
HTH,

http://danconia.org




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


Re: Perl line breaks

2003-08-14 Thread Octavian Rasnita
It depends how is set the web server to execute the programs that will
process the CGI scripts.
By default Apache is set to need the shebang line and it doesn't use the
registry settings, but this can be changed.

...and you don't need to print the HTML header in the BEGIN {} block.
You can just print it at the top of the perl program or in the middle of the
program but before anything else is printed.


Teddy,
Teddy's Center: http://teddy.fcc.ro/
Email: [EMAIL PROTECTED]

- Original Message -
From: Jonathan Hogue [EMAIL PROTECTED]
To: Mike Harrison [EMAIL PROTECTED]; 'Andrew Brosnan'
[EMAIL PROTECTED]; Mike Harrison [EMAIL PROTECTED]
Cc: [EMAIL PROTECTED]
Sent: Tuesday, August 05, 2003 4:21 AM
Subject: RE: Perl line breaks



2. My first line in the perl program is: #!perl -w (being a Windows-based
server, it doesn't require the full path.  The -w to warn of
errors/mistakes
etc.)

I think in Windows, -w isn't enough. The #!perl line is ignored in most
windows installations/configurations , and the file association is used
instead.

Therefore, you should do this explicately.
use warnings;

Also, with some webservers doing the following as your first line in the
script will catch almost all errors. (Works in IPlanet, but not Apache. Not
sure about Windows)
BEGIN { print Content-Type: Text/HTML\n\n; }




--
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: Perl line breaks

2003-08-14 Thread Mike Harrison
I was trying to find a log file to look at.  I guess half the problem is I
am using a hosting service, and it is on a Microsoft IIS server (Windows
NT-based I think, but definitely not UNIX).  I will have to ask the hosting
admin where I might find a log file...

Here is the part of the perl script that I start printing things to the
browser (see previous message for the html.pm script that contains the
HTML_header and HTML_ender subroutines):

my $header = 'Successful update';
my $msg = h2Your preferences have been updated
successfully.../h2hrbrbrbr;

# Finally, put up a HTML document announcing that the update was successful.
HTML_header($header);
print body\n;
print center\n;
print $msg\n;
print pReturn to the a href=\amtest.pl?uname=$uname\
onMouseover=\window.status='Back to account management'; return true\
onMouseout=\window.status=''; return true\Account Management/a
page/p\n;
print /center\n;
HTML_ender;

Note that I have also tried using print qq| ... | code as well.

I am now getting a CGI error message along the lines of
Cannot find a string terminator '' in ... line ... (the line above starting
with print p... .  I can't find a problem with that line???

Thanks for your help so far guys!  I am losing a bit of sleep on this one :(
Regards,
Mike.


-Original Message-
From: Octavian Rasnita [mailto:[EMAIL PROTECTED]
Sent: Wednesday, 06 August, 2003 2:30 AM
To: Jon Hogue
Cc: Mike Harrison; 'Andrew Brosnan'; [EMAIL PROTECTED]
Subject: Re: Perl line breaks


For troubleshooting a script you can take a look in the server's log file
and you will find there any error.

Teddy,
Teddy's Center: http://teddy.fcc.ro/
Email: [EMAIL PROTECTED]

- Original Message -
From: Jon Hogue [EMAIL PROTECTED]
To: Octavian Rasnita [EMAIL PROTECTED]
Cc: Mike Harrison [EMAIL PROTECTED]; 'Andrew Brosnan'
[EMAIL PROTECTED]; [EMAIL PROTECTED]
Sent: Tuesday, August 05, 2003 4:19 PM
Subject: Re: Perl line breaks




...and you don't need to print the HTML header in the BEGIN {} block.
You can just print it at the top of the perl program or in the middle of
the
program but before anything else is printed.

if something is dieing in a module you are loading, you will never know
about it because it will never get to the Content-Type and therefore never
send anything good to your browser. if you use a BEGIN block, you might
catch things that happen in modules you load. i wouldn't recommend doing
that for your normal script, but it is a useful troubleshooting tool.





RE: Urgent Question (Deployed code gone wrong!)

2003-08-14 Thread [EMAIL PROTECTED]
good question. here are some sample scripts which should help... 

the first one asks, how many elements are in a list if they are all undef
#!/usr/local/bin/perl
if ( (undef, undef) == 0 ) { print 'it is 0' }

run this, and you'll see that it prints 'it is 0'.

here's a second one that tests what happens when you get data back. it runs
11 times, and keeps going until it gets only undefs
#!/usr/local/bin/perl
my ($count, $thing, $otherthing);
while( ($thing, $otherthing) = foo ) {
$count++;
}
print the loop ran $count times\n;
sub foo {
return ( 1, 2 );
}

change the routine to this. it runs through the loop 0 times
sub foo {
return;
}

what if only 1 element is returned? it still runs 11 times.
sub foo {
return ( 1 );
}

what if 1 element is undef, but the second element is defined? it still
runs 11 times.
sub foo {
return (undef, 1 );
}

therefore, your code should work like you expect. i would still test it in
a test environment before making changes to prod.


Original Message:
-
From: Greenhalgh David [EMAIL PROTECTED]
Date: Mon, 11 Aug 2003 21:13:39 +0100
To: [EMAIL PROTECTED]
Subject: Urgent Question (Deployed code gone wrong!)


A quick question about a while loop.

I have a simple code that searches database for all entries and puts 
one of the fields into a select box on the output page. However, due to 
a mistake in my untaint routine (which I've fixed) if a visitor entered 
their name in Japanese characters, the entry into the data base is 
blank. That means that my simple while loop:

while ($name=$sth-fetchrow_array()) {
print option$name/option;
}

stops when it hits the blank name. I can also select the ID number..

while (($name, $ID)=$sth-fetchrow_array()) {
print .option$name/option;
}



mail2web - Check your email from the web at
http://mail2web.com/ .



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



perl script as binary

2003-08-14 Thread Sven Bentlage
Hi everyone!

I`m looking for a way to compile a perl script into an executable 
binary for a WIN2000 system (no(!) perl installed).

Is there a way to get this working?

Thanks for your help in advance

Sven

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


Selecting using regular expressions

2003-08-14 Thread Octavian Rasnita
Hi all,

I want to select all the content of a table from a file using regular
expressions (and not a module).
Can you give me some hints about how can I do this?

For example I have the following text:

table ...
tr...td.../tdtd.../td/tr
tr...td.../tdtd.../td/tr
trtd table... /table/tdtd.../td/tr
/table

As you see, I could find more other tables included in this table and I
usually don't know how many are they nor at what level they are included.

Thank you for any hints.

Of course, I am not expecting this selection to be possible with a single
regular expression line, but... who knows.

Teddy,
Teddy's Center: http://teddy.fcc.ro/
Email: [EMAIL PROTECTED]



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



Re: Urgent Question (Deployed code gone wrong!)

2003-08-14 Thread Greenhalgh David
eBay, Thanks.  I learnt something there.

Equally, thanks to Bob, nice solution which I also didn't know.

Dave

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


Re: Why executable?

2003-08-14 Thread fliptop
On Mon, 11 Aug 2003 at 22:36, Octavian Rasnita opined:

[snip]
OR:I've tried chmodding the perl script to 755, and I've tried running it
OR:with:
OR:
OR:$ script.pl
OR:
OR:...but it didn't want to run, telling me that there is no command
OR:script.pl, even though the script has a shebang line in it.

you may want to try it again by specifying './script.pl' because if the 
directory '.' is not in your PATH, it won't find the file.


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



Re: Why executable?

2003-08-14 Thread zentara
On Mon, 11 Aug 2003 11:33:40 +0300, [EMAIL PROTECTED] (Octavian Rasnita)
wrote:

Hi all,

Does anyone know why the perl scripts need to have the execute permission
under Unix?

I am asking this because I've seen that the PHP files don't need this
permission.

Couldn't perl just read a text file (doesn't matter if it has an execute
permission or not), interpret it and execute it just like PHP does with its
programs?

perl scripts can be done the same way

You can take any perl script, and remove the shebang line, chmod it to
644 , and run it like perl scriptname

The way PHP is setup, the PHP interpreter is executable and calls it's
readonly scripts.



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



Re: Regex and Email address.

2003-08-14 Thread Wiggins d'Anconia
Sara wrote:
Simple Regex problem

How you will convert 

$email = [EMAIL PROTECTED];

TO

$email = [EMAIL PROTECTED];

using Regex.

Well this isn't necessarily a regex issue, TMTOWTDI,

my $email = '[EMAIL PROTECTED]';
$email = substr($email, 0, (index($email,'@')+2));
print Email: $email...\n;
perldoc -f index
perldoc -f substr
...of course having said that you *can* do it with a regex ;-) 

my $email = '[EMAIL PROTECTED]';
$email =~ s/^([EMAIL PROTECTED]).*/$1/;
print Email: $email...\n;
HTH,

http://danconia.org

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


Why executable?

2003-08-14 Thread Octavian Rasnita
Hi all,

Does anyone know why the perl scripts need to have the execute permission
under Unix?

I am asking this because I've seen that the PHP files don't need this
permission.

Couldn't perl just read a text file (doesn't matter if it has an execute
permission or not), interpret it and execute it just like PHP does with its
programs?

Teddy,
Teddy's Center: http://teddy.fcc.ro/
Email: [EMAIL PROTECTED]



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



Re: Selecting using regular expressions

2003-08-14 Thread Wiggins d'Anconia
Octavian Rasnita wrote:
Hi all,

I want to select all the content of a table from a file using regular
expressions (and not a module).
Can you give me some hints about how can I do this?
Uh, use a module.

For example I have the following text:

table ...
tr...td.../tdtd.../td/tr
tr...td.../tdtd.../td/tr
trtd table... /table/tdtd.../td/tr
/table
As you see, I could find more other tables included in this table and I
usually don't know how many are they nor at what level they are included.
Thank you for any hints.

Of course, I am not expecting this selection to be possible with a single
regular expression line, but... who knows.
Short of using a module, check the source code for a module as it will 
show you at least how to go about it... but then, you would be using a 
module

I am not trying to be snotty here, but parsing *any* set of 
medium-complex strings is difficult, there are to many factors, but 
something like HTML is incredibly difficult, which is why there are 
robust modules to do it for you.

If you know your data is going to be fairly structured then about the 
simplest would be to grab everythiung that is not between  and .

http://danconia.org

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


Urgent Question (Deployed code gone wrong!)

2003-08-14 Thread Greenhalgh David
A quick question about a while loop.

I have a simple code that searches database for all entries and puts 
one of the fields into a select box on the output page. However, due to 
a mistake in my untaint routine (which I've fixed) if a visitor entered 
their name in Japanese characters, the entry into the data base is 
blank. That means that my simple while loop:

while ($name=$sth-fetchrow_array()) {
print option$name/option;
}
stops when it hits the blank name. I can also select the ID number..

while (($name, $ID)=$sth-fetchrow_array()) {
print .option$name/option;
}
Since this is deployed code, I would like to know if this will work 
before I try it. Will the loop stop when $name is blank, or will it 
keep running because $ID is NOT blank and stop only when both are blank?

Thanks

Dave

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


Re: Why executable?

2003-08-14 Thread Ovid
And as a word of caution, some like to add '.' to their path in order to save typing 
an extra two
letters ('./' in front of the file name).  Don't do this, though, as this is a major 
security
hole.

Using google to search for 'current directory path linux security hole' for many 
examples of this
hole.

Cheers,
Ovid
--- fliptop [EMAIL PROTECTED] wrote:
 On Mon, 11 Aug 2003 at 22:36, Octavian Rasnita opined:
 
 [snip]
 OR:I've tried chmodding the perl script to 755, and I've tried running it
 OR:with:
 OR:
 OR:$ script.pl
 OR:
 OR:...but it didn't want to run, telling me that there is no command
 OR:script.pl, even though the script has a shebang line in it.
 
 you may want to try it again by specifying './script.pl' because if the 
 directory '.' is not in your PATH, it won't find the file.
 
 
 -- 
 To unsubscribe, e-mail: [EMAIL PROTECTED]
 For additional commands, e-mail: [EMAIL PROTECTED]
 


=
Silence is Evilhttp://users.easystreet.com/ovid/philosophy/indexdecency.htm
Ovid   http://www.perlmonks.org/index.pl?node_id=17000
Web Programming with Perl  http://users.easystreet.com/ovid/cgi_course/

__
Do you Yahoo!?
Yahoo! SiteBuilder - Free, easy-to-use web site design software
http://sitebuilder.yahoo.com

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



Re: Why executable?

2003-08-14 Thread Octavian Rasnita
Hmm, are you telling that I can create a perl file and name it file.html,
file.php, or even file.asp, and use a shebang line in it, then it will be
parsed as a perl file?
Or I need to use extensions that are not set in the server's conf file to be
parsed as other types?

Teddy,
Teddy's Center: http://teddy.fcc.ro/
Email: [EMAIL PROTECTED]

- Original Message -
From: Randal L. Schwartz [EMAIL PROTECTED]
To: [EMAIL PROTECTED]; Kristofer Hoch [EMAIL PROTECTED]
Sent: Monday, August 11, 2003 7:35 PM
Subject: Re: Why executable?


 Kristofer == Kristofer Hoch [EMAIL PROTECTED] writes:

Kristofer This is what I do for security on my webserver.  I don't have the
Kristofer shebang line in my scripts.  The webserver has a list of approved
perl
Kristofer script extensions.  When it runs across a file with this
extension, the
Kristofer web server executes it with perl.  Otherwise, it treats the file
as if
Kristofer it is text/html.

And if you are required to include that extension as part of your
URL, you are actually *decreasing* the security of your webserver, not
increasing it.

You should never be able to guess the implementation language by
looking at a URL.  Wrong.  Wrong.

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

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




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



RE: perl / MySql application overview question

2003-08-14 Thread Hughes, Andrew
Thanks for the detailed answer.  I have dealt with JOIN clauses briefly in
the past, but not in this context.  I will have to revisit on my own.  As
far as grabbing the unique id, I am definitely going to use the DBI module
for contacting MySQL.  When I am looking at your piece of code, I had a few
questions though.  Let's say that I use this code to connect and insert data
into table called pageInfo in a database called Project.

pageInfo Table:
id INT UNSIGNED AUTO_INCREMENT NOT NULL PRIMARY KEY
pageName VARCHAR(200)
pageTitle TEXT
pageContent TEXT

my $dbh = WebDB::connecteclub ();
$sth = $dbh-prepare(insert into pageInfo(id, pageName, pageTitle, 
pageContent) values(?,?,?,?)) or die;
$sth-execute(undef, $cgi-param('pageName'), $cgi-param('pageTitle'),
$cgi-param('pageContent')) or die;

How would the suggested code below then grab that generated id from the
record created by the process above?  Also, let's say that there are two
people who submit the form at the same moment.  Will this code be able to
ensure that the correct id is selected to be stored into the cookie?

my $newid = $sth-{'Database'}-{'mysql_insertid'};
unless ($newid) {
# handle error here
}

Thanks,
Andrew

-Original Message-
From: Wiggins d'Anconia [mailto:[EMAIL PROTECTED]
Sent: Sunday, August 10, 2003 7:46 PM
To: Hughes, Andrew
Cc: '[EMAIL PROTECTED]'
Subject: Re: perl / MySql application overview question


Hughes, Andrew wrote:
 I have a multi-table MySQL database that holds different pieces of
 information that will all be displayed on a web page template.  The
general
 principle is that non web people will be able to populate web pages
through
 an admin panel.  The data in all of the MqSQL tables will be entered by
the
 user through forms on the web and bought into a page template using the
 unique id for each page.
 
 The user will login with a username and password.  This information will
 then be stored in a session using Apachee::Session and a cookie.  The
first
 form that the user submits will contain general information about the page
 itself.  All of this information will be stored in one row in the table
and
 a unique id will be generated in MySQL for that webpage.  Subsequent forms
 will request other information for different areas of that one page.  I
plan
 on relating all of the information in the rest of the tables to build that
 one page back to the specific page based on that page's unique id that was
 generated.  I was planning on doing that by somehow getting that generated
 unique id into the cookie immediately after it is generated in the MySQL
 database.  Then, every time information is added to another table that
 relates back to the webpage, I will enter that id from the cookie in the
 MySQL insert statement.
 
 Here are my questions:
 Is this a proper approach?
 If not, what is a better / correct approach?
 If it is, how would I go about it? 
 
 I am not asking for someone to do it for me.  I was just wondering if
there
 were some terms / buzzwords / tutorials that I should follow up on.
 

This sounds like a common approach and certainly a viable one. In 
general you are talking about precisely what an RDBMS is for and the 
tables you refer to are in general called lookup tables.  In other words 
you store the main record in a master table then you lookup into another 
table based on a unique id from the master.

One item you will want to look into is a join clause. A join clause 
allows you to combine fields from multiple tables in a single select 
statement so that you don't have to do multiple independent selects to 
retrieve the same effect, but that is OT for this forum, but have a look 
at the MySQL documentation for JOIN.

As for retrieving the ID generated by an auto increment in MySQL if you 
are using DBI (which I hope you are) then you can using something like 
the following after an insert:

my $newid = $sth-{'Database'}-{'mysql_insertid'};
unless ($newid) {
# handle error here
}

Though this may not be portable to other engines, but it saves you the 
pain of having to do multipe statements in an atomic manner (locking), etc.

You will run into other design problems as you go along, and a lot of 
questions, that really can't be avoided without experience, but overall 
your design is fairly sound for some applications and obviously you have 
given it some or a lot of thought before starting, which is usually the 
critical and first mistake made (aka to dive right in).

Good luck,

http://danconia.org

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



Installing a module from CPAN

2003-08-14 Thread David Granas
Hi,

Im trying to install the Graphics-Simple module from CPAN on ActivePerl but 
can't seem to get it to work.  I ran the PPM install Graphics-Simple which 
worked ok, but then I tried to run the test program gt1.pl and it gave me an 
error about not having the Gtk module.  I then went to CPAN to try to 
install Gtk but I can't get it to work.  The first step in installing it - I 
think - is to type perl Makefile.pl in the directory, but it gives me an 
error about package gtk was needed but not detected and that gtk-config is 
not a command.  So my basic question is whether this is the way to install 
CPAN modules on ActivePerl, and if there are any other things I should try.  
Thanks for any help,

Dave

_
MSN 8 helps eliminate e-mail viruses. Get 2 months FREE*.  
http://join.msn.com/?page=features/virus

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


RE: Perl line breaks

2003-08-14 Thread Jonathan Hogue

2. My first line in the perl program is: #!perl -w (being a Windows-based
server, it doesn't require the full path.  The -w to warn of errors/mistakes
etc.)
I think in Windows, -w isn't enough. The #!perl line is ignored in most 
windows installations/configurations , and the file association is used 
instead.

Therefore, you should do this explicately.
use warnings;
Also, with some webservers doing the following as your first line in the 
script will catch almost all errors. (Works in IPlanet, but not Apache. Not 
sure about Windows)
BEGIN { print Content-Type: Text/HTML\n\n; }



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


RE: Regex and Email address.

2003-08-14 Thread Hall, Scott
Regexes are always more fun :)  How else can you write a program with almost
no letters.

$email =~ s/(?[EMAIL PROTECTED]).*$/.../;

perldoc perlre

search for 'look-behind'

Scott

-Original Message-
From: Wiggins d'Anconia [mailto:[EMAIL PROTECTED]
Sent: Tuesday, August 05, 2003 10:36 PM
To: Sara
Cc: [EMAIL PROTECTED]
Subject: Re: Regex and Email address.


Sara wrote:
 Simple Regex problem
 
 How you will convert 
 
 $email = [EMAIL PROTECTED];
 
 TO
 
 $email = [EMAIL PROTECTED];
 
 using Regex.
 

Well this isn't necessarily a regex issue, TMTOWTDI,

my $email = '[EMAIL PROTECTED]';
$email = substr($email, 0, (index($email,'@')+2));
print Email: $email...\n;

perldoc -f index
perldoc -f substr

...of course having said that you *can* do it with a regex ;-) 

my $email = '[EMAIL PROTECTED]';
$email =~ s/^([EMAIL PROTECTED]).*/$1/;
print Email: $email...\n;

HTH,

http://danconia.org


-- 
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: Perl line breaks

2003-08-14 Thread Jon Hogue

...and you don't need to print the HTML header in the BEGIN {} block.
You can just print it at the top of the perl program or in the middle of the
program but before anything else is printed.
if something is dieing in a module you are loading, you will never know 
about it because it will never get to the Content-Type and therefore never 
send anything good to your browser. if you use a BEGIN block, you might 
catch things that happen in modules you load. i wouldn't recommend doing 
that for your normal script, but it is a useful troubleshooting tool.



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


RE: Regex and Email address.

2003-08-14 Thread Hall, Scott
Comments??  Who needs comments?  My code is 'self-documenting' LOL

Scott

PS:  The regex engine is your friend.

-Original Message-
From: Wiggins d'Anconia [mailto:[EMAIL PROTECTED]
Sent: Wednesday, August 06, 2003 8:08 PM
To: Hall, Scott
Cc: [EMAIL PROTECTED]
Subject: Re: Regex and Email address.


Would be interesting to see which is faster, there is that whole regex 
engine thing. Of course to say that there are no letters isn't strictly 
fair because you would need two lines of comments stating what you are 
doing ;-)... depending on the context...

http://danconia.org

Hall, Scott wrote:
 Regexes are always more fun :)  How else can you write a program with
almost
 no letters.
 
 $email =~ s/(?[EMAIL PROTECTED]).*$/.../;
 
 perldoc perlre
 
 search for 'look-behind'
 
 Scott
 
 -Original Message-
 From: Wiggins d'Anconia [mailto:[EMAIL PROTECTED]
 Sent: Tuesday, August 05, 2003 10:36 PM
 To: Sara
 Cc: [EMAIL PROTECTED]
 Subject: Re: Regex and Email address.
 
 
 Sara wrote:
 
Simple Regex problem

How you will convert 

$email = [EMAIL PROTECTED];

TO

$email = [EMAIL PROTECTED];

using Regex.

 
 
 Well this isn't necessarily a regex issue, TMTOWTDI,
 
 my $email = '[EMAIL PROTECTED]';
 $email = substr($email, 0, (index($email,'@')+2));
 print Email: $email...\n;
 
 perldoc -f index
 perldoc -f substr
 
 ...of course having said that you *can* do it with a regex ;-) 
 
 my $email = '[EMAIL PROTECTED]';
 $email =~ s/^([EMAIL PROTECTED]).*/$1/;
 print Email: $email...\n;
 
 HTH,
 
 http://danconia.org
 
 

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



Re: Why executable?

2003-08-14 Thread Octavian Rasnita
Oh, but I guess this is a little security improvement, not?
But now... another related question.

If the shebang line is not needed by the web server (if I will define an
action to run perl in httpd.conf), is the shebang line used for something
else?

I've tried chmodding the perl script to 755, and I've tried running it with:

$ script.pl

...but it didn't want to run, telling me that there is no command script.pl,
even though the script has a shebang line in it.

Oh, do you know if I can specify the action for running .pl files and .cgi
files with perl in a .htaccess file?

Thanks.

Teddy,
Teddy's Center: http://teddy.fcc.ro/
Email: [EMAIL PROTECTED]

- Original Message -
From: Kristofer Hoch [EMAIL PROTECTED]
To: [EMAIL PROTECTED]
Sent: Monday, August 11, 2003 5:04 PM
Subject: Re: Why executable?


This is what I do for security on my webserver.  I don't have the
shebang line in my scripts.  The webserver has a list of approved perl
script extensions.  When it runs across a file with this extension, the
web server executes it with perl.  Otherwise, it treats the file as if
it is text/html.

Kristofer.
--- zentara [EMAIL PROTECTED] wrote:
 On Mon, 11 Aug 2003 11:33:40 +0300, [EMAIL PROTECTED] (Octavian
 Rasnita)
 wrote:

 Hi all,
 
 Does anyone know why the perl scripts need to have the execute
 permission
 under Unix?
 
 I am asking this because I've seen that the PHP files don't need
 this
 permission.
 
 Couldn't perl just read a text file (doesn't matter if it has an
 execute
 permission or not), interpret it and execute it just like PHP does
 with its
 programs?

 perl scripts can be done the same way

 You can take any perl script, and remove the shebang line, chmod it
 to
 644 , and run it like perl scriptname

 The way PHP is setup, the PHP interpreter is executable and calls
 it's
 readonly scripts.



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



=
-BEGIN GEEK CODE BLOCK-
Version: 3.12
GIT d s+:++ a C++ UL++ US+ P+++ L++
W+++ w PS PE t++ b+ G e r+++ z
--END GEEK CODE BLOCK--

__
Do you Yahoo!?
Yahoo! SiteBuilder - Free, easy-to-use web site design software
http://sitebuilder.yahoo.com

--
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: perl script as binary

2003-08-14 Thread Bob Showalter
Sven Bentlage wrote:
 Hi everyone!
 
 I`m looking for a way to compile a perl script into an executable
 binary for a WIN2000 system (no(!) perl installed).
 
 Is there a way to get this working?

I use ActiveState's PerlApp for this. It's really very nice.
It bundles everything into a single self-contained .exe file 
you can deploy to PC's. No need for Perl to be installed on
them.

http://www.activestate.com/Products/Perl_Dev_Kit/

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



RE: Urgent Question (Deployed code gone wrong!)

2003-08-14 Thread Bob Showalter
Greenhalgh David wrote:
 A quick question about a while loop.
 
 I have a simple code that searches database for all entries and puts
 one of the fields into a select box on the output page. However, due
 to a mistake in my untaint routine (which I've fixed) if a visitor
 entered their name in Japanese characters, the entry into the data
 base is blank. That means that my simple while loop:
 
 while ($name=$sth-fetchrow_array()) {

You have a subtle bug here. It should be:

   while (($name)=$sth-fetchrow_array()) {

This forces the assignment to be in list context. That way, the while()
condtion will be true if fetchrow_array returned any values, or false if it
returned an empty list. That would make the blank value not terminate your
loop.

 print option$name/option;
 }
 
 stops when it hits the blank name. I can also select the ID number..
 
 while (($name, $ID)=$sth-fetchrow_array()) {
 print .option$name/option;
 }
 
 Since this is deployed code, I would like to know if this will work
 before I try it. Will the loop stop when $name is blank, or will it
 keep running because $ID is NOT blank and stop only when both are
 blank? 

The loop will keep running as long as fetchrow_array returns a row, even if
both columns are blank.

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



Re: Why executable?

2003-08-14 Thread Kristofer Hoch
 You should never be able to guess the implementation language by
 looking at a URL.  Wrong.  Wrong.

I couldn't agree more.  None of my scripts are executed directly...IE
there is not script called 'index.pl'.  Alternatly, I use HTML::Mason
for dynamic web content.  The Mason handler calls the scripts and does
something meaningful with the information it gets back.


 -- 
 Randal L. Schwartz - Stonehenge Consulting Services, Inc. - +1 503
 777 0095
 [EMAIL PROTECTED] URL:http://www.stonehenge.com/merlyn/
 Perl/Unix/security consulting, Technical writing, Comedy, etc. etc.
 See PerlTraining.Stonehenge.com for onsite and open-enrollment Perl
 training!
 
 -- 
 To unsubscribe, e-mail: [EMAIL PROTECTED]
 For additional commands, e-mail: [EMAIL PROTECTED]
 


=
-BEGIN GEEK CODE BLOCK-
Version: 3.12
GIT d s+:++ a C++ UL++ US+ P+++ L++ 
W+++ w PS PE t++ b+ G e r+++ z
--END GEEK CODE BLOCK--

__
Do you Yahoo!?
Yahoo! SiteBuilder - Free, easy-to-use web site design software
http://sitebuilder.yahoo.com

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



Re: Why executable?

2003-08-14 Thread Camilo Gonzalez
Okay then, how should scripts be called? Let's say I'm using a form. 
What would the action be?

Kristofer Hoch wrote:

You should never be able to guess the implementation language by
looking at a URL.  Wrong.  Wrong.
   

I couldn't agree more.  None of my scripts are executed directly...IE
there is not script called 'index.pl'.  Alternatly, I use HTML::Mason
for dynamic web content.  The Mason handler calls the scripts and does
something meaningful with the information it gets back.
 

--
Randal L. Schwartz - Stonehenge Consulting Services, Inc. - +1 503
777 0095
[EMAIL PROTECTED] URL:http://www.stonehenge.com/merlyn/
Perl/Unix/security consulting, Technical writing, Comedy, etc. etc.
See PerlTraining.Stonehenge.com for onsite and open-enrollment Perl
training!
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
   



=
-BEGIN GEEK CODE BLOCK-
Version: 3.12
GIT d s+:++ a C++ UL++ US+ P+++ L++ 
W+++ w PS PE t++ b+ G e r+++ z
--END GEEK CODE BLOCK--

__
Do you Yahoo!?
Yahoo! SiteBuilder - Free, easy-to-use web site design software
http://sitebuilder.yahoo.com
 



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


Re: Why executable?

2003-08-14 Thread Randal L. Schwartz
 Octavian == Octavian Rasnita [EMAIL PROTECTED] writes:

Octavian Hmm, are you telling that I can create a perl file and name
Octavian it file.html, file.php, or even file.asp, and use a shebang
Octavian line in it, then it will be parsed as a perl file?

Octavian Or I need to use extensions that are not set in the server's
Octavian conf file to be parsed as other types?

It all depends on the way you configure your server.

For example, with Apache, anything below a ScriptAlias directory is
automatically interpreted with mod_cgi, regardless of the extension.  So,
if I have in my httpd.conf:

ScriptAlias /cgi /some/unix/path

and then put my Perl script register into /some/unix/path/register
with the right shebang line and executable bit set, I can invoke

http://my.host.example.com/cgi/register

and it runs my script.  You can't tell what implements it.  In fact,
you could even make it register.html for all that it matters (none!).

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

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



Premature end of script headers Linux with Fat32 filesystem

2003-08-14 Thread Tim Brom
I dual-boot my computer and I have three partitions, an NTFS partition 
for Windows XP Pro, an ext3 filesystem for Linux (Red Hat Linux 9.0) and 
a Fat32 filesystem for my data (because FAT32 is the only filesystem 
both OS's play nicely with). I keep the data that I want shared stored 
on this FAT32 partition, including all the files for my websites. 
Whenever I try to access a script off of the FAT32 partition, I get a 
'Premature end of script headers' error message. I can copy the script 
verbatim onto the ext3 filesystem and it works fine, and it works fine 
on my web host's server. Does anyone know why I am getting this error 
message only when the file is coming from a FAT32 filesystem? Thanks.

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


perl / MySql application overview question

2003-08-14 Thread Hughes, Andrew
I have a multi-table MySQL database that holds different pieces of
information that will all be displayed on a web page template.  The general
principle is that non web people will be able to populate web pages through
an admin panel.  The data in all of the MqSQL tables will be entered by the
user through forms on the web and bought into a page template using the
unique id for each page.

The user will login with a username and password.  This information will
then be stored in a session using Apachee::Session and a cookie.  The first
form that the user submits will contain general information about the page
itself.  All of this information will be stored in one row in the table and
a unique id will be generated in MySQL for that webpage.  Subsequent forms
will request other information for different areas of that one page.  I plan
on relating all of the information in the rest of the tables to build that
one page back to the specific page based on that page's unique id that was
generated.  I was planning on doing that by somehow getting that generated
unique id into the cookie immediately after it is generated in the MySQL
database.  Then, every time information is added to another table that
relates back to the webpage, I will enter that id from the cookie in the
MySQL insert statement.

Here are my questions:
Is this a proper approach?
If not, what is a better / correct approach?
If it is, how would I go about it? 

I am not asking for someone to do it for me.  I was just wondering if there
were some terms / buzzwords / tutorials that I should follow up on.

Thanks,
Andrew

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



Re: perl script as binary

2003-08-14 Thread Octavian Rasnita
No, you don't need to add any dll files (at least with ActiveState Perl
Developer kit).
The perl interpreter is included in the .exe file by default. If you want
you can choose to not include it and only in that case the perl.dll file
needs to be  used.

Teddy,
Teddy's Center: http://teddy.fcc.ro/
[EMAIL PROTECTED]



- Original Message -
From: Jonathan E. Hogue [EMAIL PROTECTED]
To: 'Sven Bentlage' [EMAIL PROTECTED]; [EMAIL PROTECTED]
Sent: Thursday, August 14, 2003 3:09 PM
Subject: RE: perl script as binary


I've had some luck with perl2exe in the past. If I remember correctly,
you also have to deliver a couple of .dll's with the executable. Can you
turn the app into a web app? You might have more luck with that.
http://www.indigostar.com/perl2exe.htm

-Original Message-
From: Sven Bentlage [mailto:[EMAIL PROTECTED]
Sent: Tuesday, August 12, 2003 8:28 AM
To: [EMAIL PROTECTED]
Subject: perl script as binary



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



Flock and Sleep

2003-08-14 Thread Sara
(sub get_number {
open(NUMBER,data.txt);
flock (NUMBER, 2);

Do blah blah blah

close (NUMBER);

closing a file automatically removes the lock?? or should I have to unlock it by 
placing

flock (NUMBER, 8);
close (NUMBER);

My second question is how I can delay the execution of a script (If two users trying 
to execute the same script) for 30 sec by using sleep function? and If I implement 
sleep function in my script . Do I really need to use 'flock' in my script or 
there is no need then.

Thanks.

 


Regex and Email address.

2003-08-14 Thread Sara
$recipient_email = [EMAIL PROTECTED];

When you send email using yahoo groups, it will show the recpient mail
address after sending mail like this...

Mail successfully sent to [EMAIL PROTECTED]

anybody can help me how to do it? that it will hide the domain except for
showing one character after @.

I know I am poor at Regex (too poor).

Thanks for any input.

Sara.







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



Re: Regex and Email address.

2003-08-14 Thread Sara
Simple Regex problem

How you will convert 

$email = [EMAIL PROTECTED];

TO

$email = [EMAIL PROTECTED];

using Regex.

Thanks,
Sara.

  - Original Message - 
  From: gregg 
  To: Sara 
  Cc: [EMAIL PROTECTED] 
  Sent: Wednesday, August 06, 2003 6:59 AM
  Subject: Re: Regex and Email address.


  I'm not clear on what you're trying to do. I recommend reading Mastering Regular 
Expressions by O'Reilly press. 

  http://www.oreilly.com/catalog/regex/

  I am currently reading it. I am not associated with O'Reilly press, I assure you. ;-)

  Gregg Allen
  Blessed are they who expect nothing, 
  for they shall not be disappointed.
  Nietsche 


  On Wednesday, August 6, 2003, at 09:25 PM, Sara wrote:


$recipient_email = [EMAIL PROTECTED];

When you send email using yahoo groups, it will show the recpient mail
address after sending mail like this...

Mail successfully sent to [EMAIL PROTECTED]

anybody can help me how to do it? that it will hide the domain except for
showing one character after @.

I know I am poor at Regex (too poor).

Thanks for any input.

Sara.

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



Re: cookies

2003-08-14 Thread David Wall
--On Wednesday, August 13, 2003 4:44 PM +0100 Mace, Richard 
[EMAIL PROTECTED] wrote:

I want to start using cookies to store user session information and build
associated privileges on web pages. I'm starting as a complete novice in
this field, has anyone else got off to a flyer using a book or web-site
they can recommend? Any hints gratefully received, thanks, Richard.
I found the code at

http://www.stonehenge.com/merlyn/WebTechniques/col61.html

to be a useful introduction.  (and I just mentioned it yesterday IIRC :-)





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


Re: quick re help

2003-08-14 Thread Janek Schleicher
[EMAIL PROTECTED] wrote at Wed, 13 Aug 2003 15:22:59 -0600:

sub quickWrap {
 my $data = @_[0];

 
 You shouldn't use an array slice where you mean to use a single array
 element.
 
 
 Thanks for catching that, I should have really seen that one.

No, Perl should have seen it for you.
You only have to ask for:

use warnings;



Greetings,
Janek

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



Re: [ADMIN] Re: Download Beginning Perl ebook

2003-08-14 Thread Motherofperls
Yes,  that's where I got it from,  but I have asked a couple of times in the 
forums here and searched for it with search engines with no luck.  So I just 
decided to upload it.

A 
HREF=http://learn.perl.org/library/beginning_perl/;http://learn.perl.org/library/beginning_perl//A

It took a couple hours to load so I will just leave it there unless it 
disturbs someone.

It is free, so I don't see the problem.


CGI::Application

2003-08-14 Thread NYIMI Jose (BMB)
Hello,

I'm wondering why the CGI::Application module is not so popular in Perl's world like 
it is the case for Struts in Java's world.
To me, there are both very similar due to the fact that they are serving the same 
cause : framework to build reusable web applications.

Is that related to TMTOWTDI slogan of Perl ? :)

[CGI::Application link]
http://www.perl.com/pub/a/2001/06/05/cgi.html
[Struts link]
http://jakarta.apache.org/struts/index.html

Thanks in advance for your inputs.

===
José Nyimi Mbambi
Analyst
http://www.proximus.be



 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.



Re: dbm on Install 5.8

2003-08-14 Thread awards
Hi,

just do
$dbm_file=file.db;

tile %dbm, $dbm_file.
you don't need to worry about about the extension, well at least I was luck
and did need to change anything. I just kept file.db and it works just fine

awards



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



Re: Simple question

2003-08-14 Thread David K. Wall
Trevor Morrison [EMAIL PROTECTED] wrote:

I am trying to compare two arrays to find  common numbers in both.  For
the numbers that are not common to both, I want to write them to a file
for my review.
Check the FAQ:

perldoc -q difference of two arrays

How do I compute the difference of two arrays? How do I compute the 
intersection of two arrays?



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


RE: California ballot sort algorithm?

2003-08-14 Thread Marcos . Rebelo
One line???

print join(,map
{tr/ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz/RWQOJMVAHBSGZXNTCIE
KUPDYFLrwqojmvahbsgzxntciekupdyfl/;$_}(sort(map
{tr/RWQOJMVAHBSGZXNTCIEKUPDYFLrwqojmvahbsgzxntciekupdyfl/ABCDEFGHIJKLMNOPQRS
TUVWXYZabcdefghijklmnopqrstuvwxyz/;$_}(DATA;

__DATA__
Bock, Audie E.
Bustamante, Cruz M.
Feinstein, Dan
Flynt, Larry
Kennedy, Edward Thomas
Nave, Paul James
Novello, Donald A.

-Original Message-
From: KEVIN ZEMBOWER [mailto:[EMAIL PROTECTED]
Sent: Thursday, August 14, 2003 3:16 PM
To: [EMAIL PROTECTED]
Subject: California ballot sort algorithm?


Here's a sure sign of someone with too much time on his hands:

I was curious how to implement an algorithm in perl to sort the candidates
in California's recall ballot. According to the news, here's the sort order:
RWQOJMVAHBSGZXNTCIEKUPDYFL

So, for instance, if STDIN is a cat of the file of candidates' names:
Bock, Audie E. 
Bustamante, Cruz M. 
Feinstein, Dan 
Flynt, Larry 
Kennedy, Edward Thomas 
Nave, Paul James 
Novello, Donald A. 

STDOUT would be the sorted list:
Bock, Audie E. # Because O comes before U
Bustamante, Cruz M. 
Novello, Donald A. # Because O comes before A
Nave, Paul James 
Kennedy, Edward Thomas 
Feinstein, Dan # Because E comes before L
Flynt, Larry 

(if I did it correctly).

So, what's the most perl-ish way to write such a beast? Bonus points for a
one-liner.

-Kevin

-
E. Kevin Zembower
Unix Administrator
Johns Hopkins University/Center for Communications Programs
111 Market Place, Suite 310
Baltimore, MD  21202
410-659-6139

-- 
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: California ballot sort algorithm?

2003-08-14 Thread Jenda Krynicky
From: KEVIN ZEMBOWER [EMAIL PROTECTED]
 I was curious how to implement an algorithm in perl to sort the
 candidates in California's recall ballot. According to the news,
 here's the sort order: RWQOJMVAHBSGZXNTCIEKUPDYFL
 
 So, for instance, if STDIN is a cat of the file of candidates' names:
 Bock, Audie E. Bustamante, Cruz M. Feinstein, Dan Flynt, Larry
 Kennedy, Edward Thomas Nave, Paul James Novello, Donald A. 
 
 STDOUT would be the sorted list:
 Bock, Audie E. # Because O comes before U
 Bustamante, Cruz M. 
 Novello, Donald A. # Because O comes before A
 Nave, Paul James 
 Kennedy, Edward Thomas 
 Feinstein, Dan # Because E comes before L
 Flynt, Larry 
 
 (if I did it correctly).

@list = DATA;
chomp for @list;
print join(\n, @list),\n\n;

tr/RWQOJMVAHBSGZXNTCIEKUPDYFLrwqojmvahbsgzxntciekupdyfl/ABCDEFGHIJKLMN
OPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz/ for @list;
print join(\n, @list),\n\n;

tr/ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz/RWQOJMVAHBSGZX
NTCIEKUPDYFLrwqojmvahbsgzxntciekupdyfl/ for sort @list;
print join(\n, @list);

__DATA__
Bock, Audie E.
Bustamante, Cruz M.
Feinstein, Dan
Flynt, Larry
Kennedy, Edward Thomas
Nave, Paul James
Novello, Donald A.


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: counting sorting HTML tags

2003-08-14 Thread James Edward Gray II
On Thursday, August 14, 2003, at 07:56  AM,  
[EMAIL PROTECTED] wrote:

Hi.  I'm still very much a Perl beginner, but I'm reading Mastering
Regular Expressions by Friedl, so I expect to be able to at least  
help the
group out with regexs when I'm a few more chapters in.  ;o)

I've just created a script which, when run like this:

tags.pl filename.html

Produces results like this:

#snipped for brevity
title, 1 occurrances
td, 81 occurrances
/form, 1 occurrances
/tr, 23 occurrances
/font, 10 occurrances
/title, 1 occurrances
/strong, 1 occurrances
applet, 1 occurrances
script, 6 occurrances
hr, 2 occurrances
h3, 1 occurrances
img, 3 occurrances
h1, 1 occurrances
body, 1 occurrances
/td, 81 occurrances
head, 1 occurrances
/option, 10 occurrances


Is there an easy way to have this print out the matching opening and
closing tags on one line:
Example:  td 81, /td 81
Sure.  What about something like:

foreach (sort keys %files) {
	next if substr($_, 0, 1) eq '/';
	if (exists $files{/$_}) {
		print $_ $files{$_} occurrences, /$_ $files{\/$_\}  
occurrences\n;
	}
	else { print $_ $files{$_} occurrences\n; }
}

If not, is there an easy way to sort the hash before printing, so that
either it's sorted by the value ,
(hopefully the td and /td will not be too far apart in the output
then),
foreach (sort { $files{$a} = $files{$b} } keys %files) {
print $_ $files{$_} occurrences\n;
}
or

foreach (sort { $files{$b} = $files{$a} } keys %files) {
print $_ $files{$_} occurrences\n;
}
or sorted by key disregarding the optional /?
my @order = map { substr($_, -1, 1) eq '/' ? '/' . substr($_, 0,  
length($_) - 1) : $_ }
sort map { substr($_, 0, 1) eq '/' ? substr($_, 1) . '/' :  
$_ } keys %files;
print $_ $files{$_} occurrences\n foreach @order;

As always, if my beginner script is functional but less-than-elegant  
in
any regard, please feel free to educate me.

Thank you,
Shawn
tags.pl:
=== 

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

my %files;
my $inFile = $ARGV[0];
my @tags;
open (IN, $inFile) || die It blew up:\n$!\nCould not open file  
$inFile.
\n\n;

while (IN){

   @tags = split();

   foreach (@tags){

  $_ = $_;
  #table tags only
  #$files{lc $1} += 1 if $_ =~ /(\/?t(d|r|able))[^]*/gi;
  #all tags
  $files{lc $1} += 1 if $_ =~ /(\/?\w+)[^]*/gi;
   }
}

my @values = values %files;
my @keys = keys %files;
while (@keys){
   print  . pop(@keys) . ,  , pop(@values),  occurrances\n;
}
=== 


Note:  Any disclaimers below this line are auto-appended by my  
company's
system.  I apologize for the ominous verbage.



**
This e-mail and any files transmitted with it may contain
confidential information and is intended solely for use by
the individual to whom it is addressed.  If you received
this e-mail in error, please notify the sender, do not
disclose its contents to others and delete it from your
system.
**

--
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: AOL and IP Address Changes

2003-08-14 Thread Bob Showalter
Ron Goral wrote:
 ...
 I can figure a way to react to a changed IP, but my curiosity runs
 more toward why this AOL browser is switching IPs during a session. 
 I could understand if the user were to disconnect then reconnect his
 internet, but this is just a change of web pages basically.  Perhaps
 this is just another reason to avoid using AOL, but I'd like to
 discover a reason for this seemingly arbitrary behavior. 

I don't really know the answer, but HTTP is not a session-oriented protocol.
Each request is independent of all other requests (HTTP 1.1 allows reusing
connections to a certain extent, but not for the purposes of maintaining a
session). Between a change of pages, the TCP connection is torn down and
built back up, so the IP is subject to change. AOL may be using a pool of
proxies and handing his requests off to different proxies in a
load-balancing scheme. The point is, you can't reliably use REMOTE_ADDR for
session management. You've got to pass some kind of data back and forth in
the request and response themselves.

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



RE: SOLVED: how do i list the methods connected to a object?

2003-08-14 Thread Jeff 'japhy' Pinyan
On Aug 7, Dan Muey said:

So would this return the methods that the $obj sent to dump_functions
then, only shorter?

sub dump_functions {
use Class::Inspector;
my $r = ref $_[0];
return [ grep /^$r/, @{ Class::Inspector-methods($r,'full','public')} ]
}

Yeah.  The 'return' keyword can even be left out.

-- 
Jeff japhy Pinyan  [EMAIL PROTECTED]  http://www.pobox.com/~japhy/
RPI Acacia brother #734   http://www.perlmonks.org/   http://www.cpan.org/
stu what does y/// stand for?  tenderpuss 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: Read only variabls

2003-08-14 Thread Jenda Krynicky
From: Rob Dixon [EMAIL PROTECTED]
 Jenda Krynicky wrote:
  I don't think Perl4 is a valid reason to call anything in Perl5 an
  afterthought. Unless you call the whole of Perl5 an afterthought.
 
 Not in that sense, but I don't believe Perl would have been designed
 that way from scratch.

Well at least it would not be using 'local' the way it does use it 
now. 'temporary' or something would make more sense. Local versus 
lexical variables are a big source of confusion :-(

On the other hand I do not have any problem whatsoever with 'my' and 
'our' looking the same. (Besides if you don't like 'our' then 'use 
vars' ;-)

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]



Chomping in wrong place...

2003-08-14 Thread Wert, Nathaniel J
 Here is the basis of the script:
 
 #!/usr/bin/perl -w
 
 my $file;
 my $db;
 my $node;
 
 print Prompt user for file name;
 chomp($file = STDIN);
 
 print Prompt user for database;
 chomp($db = STDIN);
 
 open INPUT, $file or die \n\nCan't open file $INPUT: $!\n;
 
 while (INPUT) {
   $node = $_;
   system(script1 -r $db -7 $node -v 9);
 }
 
 close(INPUT);
 --
 
 The problem with the script is that the command script1 -r database -7 nodename 
 -v 9 gets executed as cript -r database -7 node and then the next command is 
 the rest of the previous command -v 9 and then it continues to cycle.  I have 
 found the removing the second chomp produces the command script1 -r database, 
 but it does not complete the rest of the command.  What I really need to know if why 
 is a chomp on a variable effecting its processing in a completely different area of 
 the code and how do I fix it?
 
 Thanks ahead of time to anyone that contributes to my dilemma.


RE: our vs my

2003-08-14 Thread Jeff 'japhy' Pinyan
On Aug 13, Bob Showalter said:

Jeff 'japhy' Pinyan wrote:
 On Aug 12, Dan Muey said:

  Perhaps it'd be better to use my $var = ''; and then export the
  variable on request instead, that way it will work with 5.005_03.

 I don't mean to start up a fire-storm, but it IS technically possible
 to export lexically scoped variables.

You can do it by defining your own sub import, but is there a way using just
Exporter functionality?

Definitely not.  The Exporter functions can't see your module's lexical
scope.  There's talk that Perl 6 will have a %MY:: hash holding the
parent's lexical scope (which would be REALLY WEIRD, but useful in this
case).

-- 
Jeff japhy Pinyan  [EMAIL PROTECTED]  http://www.pobox.com/~japhy/
RPI Acacia brother #734   http://www.perlmonks.org/   http://www.cpan.org/
stu what does y/// stand for?  tenderpuss 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]



Script help

2003-08-14 Thread Keith Olmstead
Hello,

I am neeing some help on a script that I am writing.  Here is what I have so far:

my $startdir = /opt/log/hosts/;
use File::Find;
#use strict;
use warnings;
my @dirlist;
 
@logfile = (cron,messages,maillog,ldap);
foreach $log (@logfile) {
sub eachFile {
 if (-e $_  $_ =~ /$log$/) { push @log, $File::Find::name;}
}
 
 
find (\eachFile, $startdir);
}
foreach $file(@log){
#system(gzip $file);
print $file done!\n;
 
}

It currently looks for @logfile and then gzips them.  What I am needing help with now 
is this.  It gzips all the files, and I only want it to gzip the files from the 
previous day.  Here is an example of what it finds..

/opt/log/hosts/server_ip/2003/08/04/maillog done!
/opt/log/hosts/server_ip/2003/08/03/maillog done!
/opt/log/hosts/server_ip/2003/08/02/maillog done!
/opt/log/hosts/server_ip/2003/08/01/maillog done!
/opt/log/hosts/server_ip/2003/07/31/maillog done!

Whenever the date changes to the next day, then a new dir is created and new log files 
are written to that dir.

An Idea that I had was to check the current date against the date # in the dir, ie 31, 
01, 02.. from above and if the current date does not equal that number then gzip the 
files in it.

How does this sound?  Is there a better way to do this?

Thanks,

Keith

-- 


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



Re: our vs my

2003-08-14 Thread Jeff 'japhy' Pinyan
On Aug 12, Dan Muey said:

Perhaps it'd be better to use my $var = ''; and then export the variable
on request instead, that way it will work with 5.005_03.

I don't mean to start up a fire-storm, but it IS technically possible to
export lexically scoped variables.

-- 
Jeff japhy Pinyan  [EMAIL PROTECTED]  http://www.pobox.com/~japhy/
RPI Acacia brother #734   http://www.perlmonks.org/   http://www.cpan.org/
stu what does y/// stand for?  tenderpuss 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: AOL and IP Address Changes

2003-08-14 Thread Ron Goral
Original -

I am writing a script that relies on retrieving the $ENV{REMOTE_ADDR} from
the user's browser. I'm depending on this for database information retrieval
rather than cookies or some type of javascripting since one cannot depend on
a user having either cookies or javascripting enabled in his browser. I've
run across an issue with an AOL user and am curious if this is a universal
problem with the AOL browser or just this person's particular browser
configurations. My script is handing the user off to a VeriSign secure
server. Sometime between when the user is handed off to the VeriSign server
and he is returned to my unsecured server, his IP address changes. Has
anyone encountered this? If so, what solution can you suggest.

Bob Showalter Replied -

You can't use REMOTE_ADDR for this purpose. His IP is being dynamically
assigned from a pool that any number of users will share over time. If you
don't want to use cookies (easiest approach, IMO), you can use a session ID
in your URL's. Javascript is necessary in either case.

My Reply -

The problem is manifest when I give up control of the user's browser to a
secure VeriSign server.  I cannot use a session ID in the URL since the
VeriSign server redirects to a specific URL and I cannot specify a dynamic
value for the URL.  I would like to do this with cookies, but as I stated
before, I cannot be dependent on the user's allowing cookies to be planted
in his browser.  Way too much paranoia out there.

I can figure a way to react to a changed IP, but my curiosity runs more
toward why this AOL browser is switching IPs during a session.  I could
understand if the user were to disconnect then reconnect his internet, but
this is just a change of web pages basically.  Perhaps this is just another
reason to avoid using AOL, but I'd like to discover a reason for this
seemingly arbitrary behavior.

Peace in Christ -
Ron Goral
[EMAIL PROTECTED]



RE: quick re help

2003-08-14 Thread Jeff 'japhy' Pinyan
On Aug 14, Perry, Alan said:

So, /[\s\S]/ would match a \n, while /./ would not.  The equivalent of
/[\s\S]/, using period notation, would be /[.\n]/

Not so much; the . in a character class matches just itself.

-- 
Jeff japhy Pinyan  [EMAIL PROTECTED]  http://www.pobox.com/~japhy/
RPI Acacia brother #734   http://www.perlmonks.org/   http://www.cpan.org/
stu what does y/// stand for?  tenderpuss 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: Chomping in wrong place...

2003-08-14 Thread Jeff 'japhy' Pinyan
On Aug 14, Wert, Nathaniel J said:

 open INPUT, $file or die \n\nCan't open file $INPUT: $!\n;

That should be $file in your error message.

 while (INPUT) {
   $node = $_;

Why don't you chomp $node here?  It will have a newline at the end.

  while (my $node = INPUT) {
chomp $node;
system script1 -r $db -7 $node -v 9;
  }

-- 
Jeff japhy Pinyan  [EMAIL PROTECTED]  http://www.pobox.com/~japhy/
RPI Acacia brother #734   http://www.perlmonks.org/   http://www.cpan.org/
stu what does y/// stand for?  tenderpuss 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: quick re help

2003-08-14 Thread James Edward Gray II
On Wednesday, August 13, 2003, at 04:22  PM, [EMAIL PROTECTED] 
wrote:

Jeff 'Japhy' Pinyan wrote:
On Aug 13, [EMAIL PROTECTED] said:
  my $wrap_at = @_ ? shift : 75;
I like that.
Just to add my two cents, I like:

my $wrap_at = shift || 75;

James Gray

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


Download Beginning Perl ebook

2003-08-14 Thread Motherofperls
I've posted the ebook Beginning Perl for downloading at:

A 
HREF=http://websiteprogrammin.com/wsp/docs/Beginning_Perl.zip;http://websiteprogrammin.com/wsp/docs/Beginning_Perl.zip/A


Re: AOL and IP Address Changes

2003-08-14 Thread Motherofperls
In a message dated 8/13/03 9:46:29 AM Pacific Daylight Time, 
[EMAIL PROTECTED] writes:

I see,  you have no control of over the redirect.  Use  the IP address first 
and if it returns no match check for cookies. If the cookie returns nothing 
then create an popup input box with javascript.

Yes and no.  What it is for is to locate information in a database that has 
been set 
 prior to being handed off to the VeriSign server.  Since the VeriSign 
 server can only redirect to a specific URL, planting information with JavaScript 
 would be ineffective.  VeriSign redirects the user to A 
 HREF=http://www.mydomain.com/congrats.htm;http://ww
 w.mydomain.com/congrats.htm/A and I cannot add anything dynamic to that.  So to 
 identify the 
 user, I need to either grab the IP (which I now know is not certain), rely on 
 the hope that the person has enabled cookies (not a good bet), or ask the 
 user to manually identify himself upon return to my site if the required IP 
 cannot be located.  Manual identification rather defeats the automated process 
 I'm looking for, but it will probably work for now.
 



RE: Socket

2003-08-14 Thread NYIMI Jose (BMB)
Why not just use FTP (File Transfert Protocol) ?
See Net::FTP module

José.

-Original Message-
From: awards [mailto:[EMAIL PROTECTED] 
Sent: Thursday, August 14, 2003 6:09 PM
To: [EMAIL PROTECTED]
Subject: Socket


Hi,


I would like to know if it is possible to transfer files from one computer to another 
using socket and Perl(obviously). And which module should I look at. Also is there any 
good site to teach socket??

Thank You.
Anthony



-- 
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: Questions of OOP in Perl

2003-08-14 Thread James Edward Gray II
On Wednesday, August 13, 2003, at 12:34  AM, R. Joseph Newton wrote:

Pablo Fischer wrote:

Thanks!

After sending my question I found in a website the topic of 'private' 
methods,
and shows code like this:

my $method_name = sub {
my $this = shift;
_blablabla_
};
And to access it :

$this-$method_name(Arg1);

Now, this it really works for 'private' methods?
This is the standard Perl way to create private methods, yes.  The 
subroutine is only available within the scope of the my variable, 
generally your module.

Perl has no private methods.  Only polite conventions concerning which 
methods
should be called from outside the pm file.
Uh, did you read the question?  :)  That looks like a pretty text book 
perfect private method to me, but please correct me if I'm wrong.

I believe what Joseph meant to say is the Perl doesn't have a 'private' 
keyword, like many OO languages.  However, Perl generally gives you the 
tools to do what needs to be done, just as you show above.  I disagree 
that Perl doesn't have private methods.

The real meat of Joseph's message is that most OO Perl programmers feel 
that what you show above is seldom called for.  While most languages 
give you the tools to lock things down as tight as possible, Perl 
prefers the If you push the big red button marked 'Do Not Touch!', 
don't come crying to us philosophy.  Generally, saying 'Hands Off' 
works in Perl land.  If they mess with it after that, they knew what 
they were getting into and deserve whatever pain they get.

There are even some instances where security hurts users.  By way of 
example, Perl's OO system is known to have a good bit of overhead and 
thus be a little on the slow side of execution.  Accessors, while a 
great OO principal, generally show off this slowdown, in a bad light.  
In Perl though, what you usually have as your object reference is a 
blessed hash.  Is there really a good reason you can do your own hash 
lookup?  For some objects, sure there is, but a lot of the time I think 
read-only hash access of an object's data is fine, especially when 
speed really counts.  Heck, document this in your module and list is as 
a feature, when you can.  Instead of straight jacketing Perl into Good 
OO Behavior, use Perlisms to your advantage.

Of course, just to be thorough I need to say, there are definitely 
times when security IS called for.  Most Perl guys don't think they're 
as often as the Encapsulation Fanatics would have you believe, but they 
definitely exist.  As the programmer, it's your job to determine when 
those situations arise and employ the proper amount of paranoia.  With 
great power comes great responsibility, as they say.  Make good choices.

One way to communicate this is simply to document only public methods 
using the emedded donumentation format, and use standard comments for 
any necessary explanation of internal methods.
Another popular convention is to start any Perl identifier (variable 
name, subroutine name, etc.) with a _ when you want to tell users it's 
important stuff only you need to handle.  Many modules follow this and 
some will even help you enforce it, when you do need the security.

James Gray

Joseph

--
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: quick re help

2003-08-14 Thread [EMAIL PROTECTED]
Jeff 'Japhy' Pinyan wrote:
On Aug 13, [EMAIL PROTECTED] said:

sub quickWrap {
my $data = @_[0];


You shouldn't use an array slice where you mean to use a single array
element.
Thanks for catching that, I should have really seen that one.

$times_to_reread_my_code_before_posting_to_list++;


  my $data = shift;
  my $wrap_at = @_ ? shift : 75;
I like that.



Something tells me you're not sure what a character class does.  A
character class is for CHARACTERS.  Therefore, you don't use | in it.  The
Thanks for the correction character classes *runs to fix about half a 
dozen regexes*

 This regex looks familiar.  I'm going to suggest a big change in a
 bit.
 Oh, and [\s|\S], which could be [\s\S], is kind of awkward.
what is less awkward than [\s|\S] for 'match anything?'


EWW.  DON'T USE $`.  It's terrible.

Okay, is that because it is slow and makes the rest of the regular 
expressions afterwards run slowly? (I saw something about that in the 
perlre document)
Is it as bad to use something like '(match anything)' before the main 
expression, and using $1 in place of $` when it's useful?



Ok, here's my idea:  instead of matching text and putting it in a new
string, why not CHANGE the string we're working on as we match it?  We can
do that using a substitution, the s/// operation.
That is a better approach, I had given up on that when I couldn't 
understand why it was failing, and thought I could follow the logic 
better if I broke it down into a match in a loop.


We want to match UP TO $wrap_at characters, as many as possible, and add a
newline after them, SO LONG as it's in the place of a space.  Here's a
regex I think will do the job for you:
  sub quick_wrap {  # I use the word_word_word style, not wordWordWord
my $str = shift;
my $wrap_at = @_ ? shift : 60;
$str =~ s{(.{1,$wrap_at})\s}{$1\n}g;

return $str;
  }
The regex matches between 1 and $wrap_at characters (trying to match the
most possible) that are followed by a space.  It replaces this with the
text it matched (and captured to $1) followed by a newline.  Let me know
if this does what you expected.
That is exactly what I was trying to do, and that's a far, far more 
elegant way to do it.

I think I'll review all my material again on regexes.  Are there any 
good books you recommend on how to use and think in regexes?

Thanks again for your help, that has really really helped.





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


Re: timing out a system call

2003-08-14 Thread denis

Forgot to mention that most of the guts for this was given to me by some 
of the kind folks on this mailing list..

Just wanted to give credit where credit was due..

Denis

On Thu, 14 Aug 2003 [EMAIL PROTECTED] wrote:

 On Thu, 14 Aug 2003, Niall Flinn wrote:
 
  Hi folks,
  
  I'm writing my first actual useful perl scripts and I've run into the 
  following problem - I'm using the system function to run a command line process 
  (a 3d renderer, as it happens) from within my script. This works fine, except that 
  sometimes the process hangs and leaves my perl script waiting for a return that 
  never comes. How can I make my script carry on and try running the process again? 
  I'm guessing that I need to use the alarm function, but as a newbie, the example 
  shown in the perl docs doesn't make much sense to me :(
  
  Cheers,
  
  Niall
 
 Here's how I'm doing the same this..
 
 while ($line = TESTFILE)
 {
 #   $start=time;
 my $full_line;
 chomp($line);
 #$full_line = join(/,$test_path,$line,$cmd);
 if ($test_path)
 {
 $full_line = $test_path/$line/$cmd;
 }
 else
 {
 $full_line = $line/$cmd;
 }
 print Working on  $full_line\n;
 eval
 {
 local $SIG{ALRM} = sub { die alarm\n }; # NB: \n 
 required
 alarm $timeout;
 my $start = time;
 print LOGFILE 
 *;
 print LOGFILE \n$line;
 system($mpi_run $full_line  logfile.$today);
 my $end = time;
 my $totaltime = $end - $start;
 print LOGFILE \nTime for test: $totaltime 
 sec's\n;
 alarm 0;
 };
 if ($@)
 {
 die unless $@ eq alarm\n;  # propagate 
 unexpected errors
 # timed out
 print LOGFILE \n $full_line TIMED OUT 
 \n;
 print \n$full_line timed out\nKilling job that 
 timed out\n;
 `$killname $killsig mpirun`;
 #sleep 2;
 # kill off jobs on the remote hosts
 my $i;
 for ($i=0; $i =$#kill_num; $i++)
 {
 `rsh $kill_num[$i] $killname 
 $killsig $cmd`;
 }
 next;
 }
 else
 {
 # job didn't time out
 }
 }
 
 
 Sorry for the bad formatting..
 
 HTH
 
 Denis
 
 
 


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



RE: quick re help

2003-08-14 Thread Perry, Alan
Jeff 'japhy' Pinyan wrote:

On Aug 14, Perry, Alan said:

So, /[\s\S]/ would match a \n, while /./ would not.  The equivalent of
/[\s\S]/, using period notation, would be /[.\n]/

Not so much; the . in a character class matches just itself.

You are correct, I forgot about that.  You could use /.|\n/ ... That should
work.

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



RE: cookies

2003-08-14 Thread wiggins


On Wed, 13 Aug 2003 16:44:59 +0100, Mace, Richard [EMAIL PROTECTED] wrote:

 I want to start using cookies to store user session information and build associated 
 privileges on
 web pages. I'm starting as a complete novice in this field, has anyone else got off 
 to a flyer using
 a book or web-site they can recommend? Any hints gratefully received, thanks,

This query may be better addressed to beginners-cgi but not a big deal.

Are you starting fresh in Perl? Or just CGI using Perl? Or just cookies specifically? 

In the latter two cases I would suggest reviewing the docs for the CGI.pm module as it 
will explain how to handle CGI requests, build dynamic pages, and part of that will be 
using and setting cookies.  In the first case I would get a foundation in Perl first, 
then move to CGI specifics by starting with the Learning Perl O'Reilly book.  Also 
check out perldoc perlbook

http://danconia.org

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



Re: regular expresion question.

2003-08-14 Thread James Edward Gray II
On Wednesday, August 13, 2003, at 08:28  AM, Jas Grewal ((DHL UK)) 
wrote:

Hi all,
Howdy.

I am trying to write a regular expresion to get a file path from a 
cron file, I have issolated the required lines, but am having problems 
with extracting just the file path and name.
 
The line is as follows :
 
30 23 * * * /usr/lbin/sa/sa1 600 6
 
I inned to extract just the '/usr/bin/sa/sa1' section.
 
Any guidance would be appreciated.
Not knowing much about your file, I'll assume no entries contain 
whitespace characters.  If this is not true, you'll need to find 
another way.  Given that, if you have a line in $line, try this:

my $path = (split ' ', $line)[5];

That just splits the line on whitespace and chooses the 6th element of 
the resulting list to put in $path.

Hope that helps.

James Gray

Jas
 
 
--
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: array of regular expressions on a string

2003-08-14 Thread Rob Dixon
Ramprasad wrote:

 This was not cut pasted from my actual code. I cannot paste my 250
 line script here so I just wrote a hapazard relevant replica of what
 I did.

Fair enough! An even worse problem is where people's company standards
prohibit decent coding, but I always bear in mind that what's posted
isn't the actual code :)

 Thanks anyway, I do use strict ( not warnings , irritates me when
 perl tells me use of unitialized var when I meants it to be so  )

At the very least you should have

  use warnings;
  no warnings 'uninitialized';

But Perl's smart enough to ignore sensible use of uninitialised variables
so it's far better to explcitly set up variables that otherwise throw up
warnings. For instance

  use warnings;
  my $file;
  push @{$file}, $_ while ;

works fine. As does

  use warnings;
  my $string;
  $string .= $_ foreach qw/A B C D/;

and

  my $i;
  while () {
chomp;
printf %4d: %s\n, ++$i, $_;
  }

In general, Perl's principle is

  I've had nothing yet, Alice replied in an offended tone, so I can't take more.
  You mean you can't take less, said the Hatter: it's very easy to take more than 
nothing.

  Alice's Adventures in Wonderland - Lewis Carroll


 And in my real script I have @array as something more meaningful
 But doesnt work anyway.

 I just have changed the logic. I am using /mi always and put only
 regex in the array and am looping thru the array.

I'm still not sure how, or why. You need to post a sample that is more
representative of your code. Have you tried my example and seen that
it works? How does it differ from what you have?

Cheers,

Rob



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



RE: Read only variabls

2003-08-14 Thread Dan Muey

 It was Wednesday, August 13, 2003 when Dan Muey took the soap 
 box, saying:
 : 
 : If my module exports variables can I make it so they can't 
 be changed?
 
 Yes, but it's very complicated.  You can see my example 
 module ex::constant::vars for a way to do it, but read all 
 the documentation first.  :-)
 
  http://search.cpan.org/author/CTWETEN/ex-constant-vars-0.01/vars.pm

Nice but Oi! it is complicated!

There may be an easier solution.

What I want to do is use the variable within the module itself and export them for the 
user to use if they want.
What I don't want is the user to import a function that uses the variable internally 
and the variable, change it to something evil, and then call the function.

Could I use a my variable intrenall and export the and our variable with the sam data 
then use the my variable internally and export the our version? IE

 my $foo = 02173;
 our $_foo = $foo;

Then they can export and change $_foo all they want but they can't change the my $foo 
so I can use it safley internally.
Using my() in a module won't be a problem right just trying to export a my() variable 
is bad and evil, correct?

 You want to use constant functions in real code.

  Casey West

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



Re: counting sorting HTML tags

2003-08-14 Thread John W . Krahn
On Thursday 14 August 2003 05:56, [EMAIL PROTECTED] wrote:

 Hi.  I'm still very much a Perl beginner, but I'm reading Mastering
 Regular Expressions by Friedl, so I expect to be able to at least
 help the group out with regexs when I'm a few more chapters in.  ;o)

 I've just created a script which, when run like this:

 tags.pl filename.html

 Produces results like this:

 #snipped for brevity
 title, 1 occurrances
 td, 81 occurrances
 /form, 1 occurrances
 /tr, 23 occurrances
 /font, 10 occurrances
 /title, 1 occurrances
 /strong, 1 occurrances
 applet, 1 occurrances
 script, 6 occurrances
 hr, 2 occurrances
 h3, 1 occurrances
 img, 3 occurrances
 h1, 1 occurrances
 body, 1 occurrances
 /td, 81 occurrances
 head, 1 occurrances
 /option, 10 occurrances

 Is there an easy way to have this print out the matching opening and
 closing tags on one line:
 Example:  td 81, /td 81

Yes there is.


use HTML::TokeParser;

my $p = HTML::TokeParser-new( 'index.html' );

my %data;
while ( my $token = $p-get_token() ) {
next unless $token-[ 0 ] =~ /S|E/;
$data{ $token-[ 1 ] }{ $token-[ 0 ] }++;
}

for my $key ( sort keys %data ) {
print $key $data{$key}{S}, /$key $data{$key}{E}\n;
}

__END__


 If not, is there an easy way to sort the hash before printing, so
 that either it's sorted by the value,

Change the line:

for my $key ( sort keys %data ) {

To:

for my $key ( sort { $data{$a}{S} = $data{$b}{S} } keys %data ) {



John
-- 
use Perl;
program
fulfillment


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



Re: timing out a system call

2003-08-14 Thread denis
On Thu, 14 Aug 2003, Niall Flinn wrote:

 Hi folks,
 
 I'm writing my first actual useful perl scripts and I've run into the following 
 problem - I'm using the system function to run a command line process (a 3d 
 renderer, as it happens) from within my script. This works fine, except that 
 sometimes the process hangs and leaves my perl script waiting for a return that 
 never comes. How can I make my script carry on and try running the process again? 
 I'm guessing that I need to use the alarm function, but as a newbie, the example 
 shown in the perl docs doesn't make much sense to me :(
 
 Cheers,
 
 Niall

Here's how I'm doing the same this..

while ($line = TESTFILE)
{
#   $start=time;
my $full_line;
chomp($line);
#$full_line = join(/,$test_path,$line,$cmd);
if ($test_path)
{
$full_line = $test_path/$line/$cmd;
}
else
{
$full_line = $line/$cmd;
}
print Working on  $full_line\n;
eval
{
local $SIG{ALRM} = sub { die alarm\n }; # NB: \n 
required
alarm $timeout;
my $start = time;
print LOGFILE 
*;
print LOGFILE \n$line;
system($mpi_run $full_line  logfile.$today);
my $end = time;
my $totaltime = $end - $start;
print LOGFILE \nTime for test: $totaltime 
sec's\n;
alarm 0;
};
if ($@)
{
die unless $@ eq alarm\n;  # propagate 
unexpected errors
# timed out
print LOGFILE \n $full_line TIMED OUT 
\n;
print \n$full_line timed out\nKilling job that 
timed out\n;
`$killname $killsig mpirun`;
#sleep 2;
# kill off jobs on the remote hosts
my $i;
for ($i=0; $i =$#kill_num; $i++)
{
`rsh $kill_num[$i] $killname 
$killsig $cmd`;
}
next;
}
else
{
# job didn't time out
}
}


Sorry for the bad formatting..

HTH

Denis


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



RE: What is qr for in reg expressions in a a string?

2003-08-14 Thread Perry, Alan
On Wednesday, August 13, 2003 11:42, Rob Dixon wrote:

Alan Perry wrote:
 [EMAIL PROTECTED] wrote:
  I've been reading the previous post and was wondering about what qr
does

[snip]

 For the second array item, the line translates to:
   print found\n if $str =~ '^from: [EMAIL PROTECTED]'mi
 Which could also be written as
   print found\n if $str =~ /^from: [EMAIL PROTECTED]/mi

Except that using the single quote as a delimiter prevents
interpolation within the string.

  qr/^from: [EMAIL PROTECTED]/mi

would try to expand an array called @hotmail and fail, whereas

  qr'^from: [EMAIL PROTECTED]'mi

would be interpreted directly as a regex. Which is why I wrote
it that way.

Of course, you are right...  Got too happy with the copy/paste feature.

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



Re: Download Beginning Perl ebook

2003-08-14 Thread Motherofperls
Sorry for not contacting you first.  I'm still new compared to most with web 
manners and programming in general.

I've searched with search engines and asked in the forums and couldn't find 
the link to the book.  I just gave up and created my own link.

Thankyou for making this book freely available to everyone!

Tricia 



Read only variabls

2003-08-14 Thread Dan Muey

Howdy,

I read in an earlier email that some people put _ in front of variables/function/etc 
to show that they are 
important and should be handled by the program only and it said that some modules 
enforce this

I guess what I'm getting at is:

If my module exports variables can I make it so they can't be changed?

IE

 use MyStuff qw($_joe $_mama); # now they should have $_joe and $_mama exported from 
the module.

 print $_joe $_mama\n; # ok
 my $joe = $_joe;# ok
$joe =~ s/\W//g;   # ok
 $_joe = new value;# bad - not allowed - maybe give warning?
 $_mama =~ s/\W//g;  # bad - not allowed - maybe give warning?

If so hwo do I do it or what module protects its variables in this way so I can look 
at it's code for an example or documentation???

TIA

Dan

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



RE: Read only variabls

2003-08-14 Thread Jenda Krynicky
From: Dan Muey [EMAIL PROTECTED]
  Not sure this is what you are after but ...
  
  *x = \15;
  print \$x=$x\n;
  $x = 16; # = Modification of a read-only value attempted at ...
  print \$x=$x\n;
  
  Jenda
 
 You're a genius! 

No I'm not. I saw this somewhere in the docs.
 
 I'd love to understand further:
  - why using a glob like that makes it readonly
  - why you have to \15 instead 15 to assign it a value(is it to show
  it's a scalar?) - does this work with arrays/hashes/etc of *x? - how
  do assign something besides a nuber to $x? ( *x = \grabdata(); or *x
  = \hi there;) - how do I assign somthign to @x or %x etc...

1)
*y = \$x;
changes $y into an alias to $x. From now it doesn't matter whether 
you assign or read $y or $x, they'll both contain the same value.

2)
\15 
creates a scalar reference to a constant. See:
print '\15 = ', \15, \n;

3)
This means that
*x = \15;
changes $x into an alias of 15.
And just like you can't write
15 = 16;
you can't from now on write
$x = 16;

Now this only works for constants. The only way to set a readonly 
variable based on the return of some function would be using eval:

{ my $value = grabdata(parameters);
  $value =~ s/([\\'])/\\$1/g;
  eval \*const = '$value';
}

And it's not possible to make a constant array or hash this way.
AFAIK.

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: Getting rid of returns

2003-08-14 Thread awards

Hi

I do $string=~ s/\r//g;



Trina Espinoza [EMAIL PROTECTED] wrote in message
news:[EMAIL PROTECTED]
Let me start of with a smaller question. . ..

How do you get rid of returns?
I known chomp gets rid of new lines, but I don't know how to get rid of
returns.
My code accepting data from the user. I just need to start by filtering out
\n's and
\r's

I tried the code (snippet below), but there seems to be 2 problems:
1) my code ignored the if statement
2)If my $line did have a return, I wouldn't know now to remove it.
Could I say something like

if (/\r/) {
$line = grep(/[^\r]/,$line)


EXISTING SNIPPET OF CODE
-
open(SOURCE, $source_file) || die Cannot open \$source_file\: $!;
my $line;
while ($line = SOURCE) {
if(/\n) {
chomp;
if (/\r/) {
print This line has a \\r\n;

 }
}


Thanks!
-T



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



Getting rid of returns

2003-08-14 Thread Trina Espinoza
Let me start of with a smaller question. . ..

How do you get rid of returns? 
I known chomp gets rid of new lines, but I don't know how to get rid of returns.
My code accepting data from the user. I just need to start by filtering out \n's and
\r's

I tried the code (snippet below), but there seems to be 2 problems:
1) my code ignored the if statement 
2)If my $line did have a return, I wouldn't know now to remove it.
Could I say something like

if (/\r/) {  
$line = grep(/[^\r]/,$line) 


EXISTING SNIPPET OF CODE
-
open(SOURCE, $source_file) || die Cannot open \$source_file\: $!;
my $line;
while ($line = SOURCE) {
if(/\n) {
chomp; 
if (/\r/) {
print This line has a \\r\n;

 }
} 


Thanks!
-T

Re: How to replace a long string in a text file?

2003-08-14 Thread zentara
On Tue, 12 Aug 2003 01:29:39 -0400 (EDT), [EMAIL PROTECTED]
(Perlwannabe) wrote:

Here is the little script that I am working with and, obviously, is not
working:

my $filefirst = c:/perl/myfile.txt;
open(FILE,$filefirst) || die Could not open file for reading!  $!;
open(TEMP,$filefirst.tmp) || die Could not open file for writing!  $!;

#are you using windows?
binmode FILE;   #need binmode under windows
binmode TEMP;

# I have used the . . . to show that the entire hex string is really there
my $hextostr = '\x54\x68\x69\x73 . . . \x79\x2E\x22';
while(FILE){
   $_ =~ s/$hextostr/placey/gi;
   print TEMP $_;
}


Perhaps I am attacking this problem wrong by using hex, but it seems
easier to use then text which has carriage returns, tabs, and spaces.

I hope this explains the situation.



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



Re: scheduled tasks - duplicate of background perl programs for'the scheduled task'

2003-08-14 Thread [EMAIL PROTECTED]
sorry, I thought the news program wasn't posting, due to a long delay, 
so I emailed the same question to the list

please reply to

post with subject

background perl programs for 'the scheduled task'

instead, sorry

[EMAIL PROTECTED] wrote:
I need to send an email out to our forum digest readers from a nightly 
scheduled task.

I would like to be able to trigger, check on, and stop the process from 
a webpage script, but the schedule needs to work when no one is visiting 
the site, so it needs to be able to sleep in the background reliably.

I am developing on an XP workstation running Apache/1.3.27, ActivePerl 
5.8.0.806

The App moves to a unix server running Apache 1.3.26 and at least the 
same version of perl

We have ftp access, cgi-bin etc, but I doubt we can install additional 
CPAN modules.

I am at a loss at this time of how to go about tackling this problem, at 
least in a good way.  If anyone can suggest a good starting point, I 
would very much appreciate it.

thanks!




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


RE: Can run through perl, but not alone?

2003-08-14 Thread Paul Archer
11:28am, KEVIN ZEMBOWER wrote:

 Yep, Rob, you're right on the money:
 centernet:/usr/local/httpd/htdocs/cacti8/scripts # head -1 webhits.pl 
 weatherbug.pl|hexdump -c
 000   =   =  w   e   b   h   i   t   s   .   p   l   
 010   =   =  \n   #   !   /   u   s   r   /   l   o   c   a   l   /
 020   b   i   n   /   p   e   r   l  \r  \n  \n   =   =  w
 030   e   a   t   h   e   r   b   u   g   .   p   l  =   =
 040  \n   #   !   /   u   s   r   /   l   o   c   a   l   /   b   i
 050   n   /   p   e   r   l  \n
 058

This is more of a Unix trick than Perl, but worth mentioning (I guess):
An(other) easy way to check for normally unprintable characters is to send
your cat to the vet. cat -vet weatherbug.pl
-v show most non-printing characters
-e show end-of-line characters
-t show tabs as ^I


Paul Archer
Sun Solaris instructor and all-around geek

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



RE: pid-memory usage - Any takers

2003-08-14 Thread Stephen Gilbert
 -Original Message-
 From: Biju Ramachandran [mailto:[EMAIL PROTECTED]
 Sent: Friday, August 08, 2003 8:56 AM
 To: [EMAIL PROTECTED]
 Subject: Re: pid-memory usage - Any takers
 
 
 Please, anybody...
 
 Biju
 
 
 From: Biju Ramachandran [EMAIL PROTECTED]
 To: [EMAIL PROTECTED]
 Subject: pid-memory usage
 Date: Thu, 07 Aug 2003 11:23:33 -0400
 
 Hi there
 
 I just  want to know is there any way to find out the PID 
 ans how much a 
 process is using
 the physical and virtual memory, as it is show by the 
 Windows NT task 
 manager.
 
 Thanks
 
 Biju
 
 _
 MSN 8 helps eliminate e-mail viruses. Get 2 months FREE*.  
 http://join.msn.com/?page=features/virus
 
 
 --
 To unsubscribe, e-mail: [EMAIL PROTECTED]
 For additional commands, e-mail: [EMAIL PROTECTED]
 
 
 _
 MSN 8 helps eliminate e-mail viruses. Get 2 months FREE*.  
 http://join.msn.com/?page=features/virus
 
 
 -- 
 To unsubscribe, e-mail: [EMAIL PROTECTED]
 For additional commands, e-mail: [EMAIL PROTECTED]
 
 
Well your Process id is $$, But I haven't any ideas on retieving the physical/virtual 
mem.

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



RE: SOLVED: how do i list the methods connected to a object?

2003-08-14 Thread Dan Muey

Cool! 1 quick question why do you have @methods?
If it's because you use @{ $methods } then $methods would have to be the string 
'methods' to be a reference to @methods, which doesn't have any data as far as I can 
tell.

Maybe I'm missing something?

Dan

 problem solved:
 
 given an arbitrary object, i can now get a dump of all the 
 functions connected to the object.
 
 print dump_functions( $obj );
 
 sub dump_functions
 {
 use Data::Dumper;
 use Class::Inspector;
 
 my ( $obj ) = @_;
 
 my ( $ref, $methods, @methods );
 
 $ref = ref $obj;
 $methods = Class::Inspector-methods( $ref, 'full', 'public' );
 
 @{ $methods } = grep /$ref/, @{ $methods };
 
 return Dumper( $methods );
 }
 
 
 
 On Tue, Aug 05, 2003 at 12:19:57PM +0200, Martin A. Hansen wrote:
  hi
  
  i wonder how i can list all the methods availible from a 
 given object?
  
  martin
  
  --
  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]
 
 

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



background perl programs for 'the scheduled task'

2003-08-14 Thread [EMAIL PROTECTED]
Hi

I am having a bit of trouble figuring out how to do a fairly generic 
thing:  'the scheduled task', to send out a daily digest for a perl 
forums site.

I am developing on Apache/1.3.27 on Win XP, running ActivePerl 5.8.0.806

The live webserver that it gets uploaded to is running unix, 
Apache/1.3.26 (not sure which perl version, but I am sure it is not lower)

I am thinking I need to exec or fork or something, get some ID to the 
schedule-handling process that can be saved and used to look it up later 
(to ensure it's running, or stop it etc).  If a problem occurs in 
storing the ID, I think I can have the schedule thread check a file 
periodically for a 'I should die' value, to make sure zombies don't 
build up.

I really don't know how to even attempt this, what the best ways are, 
what the pitfalls may be.  I am sure scheduled tasks are no biggy, they 
are fairly common.

I don't think this server will allow us to install new CPAN modules, we 
only have FTP, HTTP, a public and a little cgi-bin dir for the site.

Any help on where to start would be very appreciated thanks!

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


Can't locate object method new error

2003-08-14 Thread gagel
Depending on what I'm installing or runing I'm getting this message,
for example running test MD5 gives:
Can't locate object method new via package MD5 (perhaps you forgot
to load MD5?) at /usr/lib/perl5/5.6.1/CPAN.pm line 4212.

Or in my maillog when SpamAssassin tries to load Razor2 I get:
razor2 check skipped: Can't locate object method new via package
Razor2::Cleint::Agent (perhaps you forgot to load
Razor2::Client::Agent?) at
/usr/lib/perl5/5.6.1/Mail/SpamAssassin/Dns.pm line 382

What has gone wrong with my perl and how do I fix it?
I'm running RedHat 7.3 with perl 5.6.1


Kevin W. Gagel
Network Administrator
(250) 561-5848 local 448
(250) 562-2131 local 448

--
The College of New Caledonia, Visit us at http://www.cnc.bc.ca
Virus scanning is done on all incoming and outgoing email.
--

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



Re: System or Modules?

2003-08-14 Thread Janek Schleicher
Pablo Fischer wrote at Tue, 05 Aug 2003 01:58:35 +:

 I finish a big part of a script. Cause Im working with command to 'cp', 
 'remove', 'move','make directories' Im using certain Modules to do that, 
 however I would like to know whats better in perl, to use the 'system' 
 command or to use modules?

unlink
rename
mkdir
are all Perl builtin functions (read e.g. perldoc -f unlink)
that remove, move or make directories.

To copy, just use the 
File::Copy
module.

 The final project could be running in two years (or maybe never) in Windows or 
 BSD (Im working in Linux)
 
 Yeah, that's my Perl Question :-)
 thanks!
 Pablo


Greetings,
Janek

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



List::Util / arrays

2003-08-14 Thread Jakob Kofoed
Hi,

I am trying to get the maximum number in a file looking like:


1   5001
2   5002
3   5003
4   5004
5   5005
6   5006
7   5007
8   5008
9   5009
10   5010
11   5011
12   5012
13   5013
14   5014
15   5015
16   5016
17   5017
18   5018
19   5019


I had the idea to push the individual line in a row into a array and se
the List::Util module - but I cant get it to work.

Here is what I reached - can you tell me where I go wrong?

Thanks
Jakob



#! /usr/bin/perl -w

use List::Util qw(max min);

open IN, , num2.txt;
my @in = IN;
push @col1, $in[0];

print max @col1;
close IN; 


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



Re: Global variables and a forked process

2003-08-14 Thread Ahmed Moustafa
Steve Grazzini wrote:
On Sat, Aug 09, 2003 at 01:04:26PM -0700, Ahmed Moustafa wrote:

Does a forked process share the memory locations of the global 
variables from the parent process?


Changes made after the fork() won't be visible in the other
process, if that's what you're wondering.
Yes, that's exactly what I am wondering. So, is there a way to assign 
values to the global variables in the parent process?

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


Re: cookies

2003-08-14 Thread Motherofperls
Have you read the ebook beginning perl?
I downloaded it but I don't have the url.  Sorry.  
Try google with 'ebook beginning perl'


RE: Can't locate object method new error

2003-08-14 Thread gagel
Got it, I had to force the install for:
MD5
Digest::MD5
Digest::Nildimsa

The error no longer shows up.


- Original Message Follows -
 I don't know how to set or retrieve the value of @INC, how to
 please?
 
 The Razor2 client files are located at:
 /usr/razor-agents-2.34/lib/Razor2/Client/Agent.pm
 
 The MD5 copy and past from perl is:
 cpan test Digest::MD5
 Running test for module Digest::MD5
 Running make for G/GA/GAAS/Digest-MD5-2.26.tar.gz
   Is already unwrapped into directory
 /root/.cpan/build/Digest-MD5-2.26
   Has already been processed within this session
 Running make test
 PERL_DL_NONLAZY=1 /usr/bin/perl -Iblib/arch -Iblib/lib
 -I/usr/lib/perl5/5.6.1/i386-linux -I/usr/lib/perl5/5.6.1 -e 'use
 Test::Harness qw(runtests $verbose); $verbose=0; runtests @ARGV;'
 t/*.t
 t/align.ok
 t/badfile...ok
 t/clone.ok
 t/files.ok
 t/md5-aaa...ok
 t/utf8..ok
 All tests successful.
 Files=6, Tests=273,  1 wallclock secs ( 0.53 cusr +  0.05 csys = 
 0.58 CPU)
   /usr/bin/make test -- OK
 
 cpan test MD5
 Running test for module MD5
 Running make for G/GA/GAAS/MD5-2.02.tar.gz
 Can't locate object method new via package MD5 (perhaps you
 forgot to load MD5?) at (eval 438) line 4213.
 
 cpan install MD5
 Running install for module MD5
 Running make for G/GA/GAAS/MD5-2.02.tar.gz
 Can't locate object method new via package MD5 (perhaps you
 forgot to load MD5?) at (eval 438) line 4213.
 
 - Original Message Follows -
  
  
  On Wed, 06 Aug 2003 11:58:53 -0800, [EMAIL PROTECTED] wrote:
  
   Depending on what I'm installing or runing I'm getting this
   message, for example running test MD5 gives:
   Can't locate object method new via package MD5 (perhaps you
   forgot to load MD5?) at /usr/lib/perl5/5.6.1/CPAN.pm line
   4212. 
   Or in my maillog when SpamAssassin tries to load Razor2 I get:
   razor2 check skipped: Can't locate object method new via
   package Razor2::Cleint::Agent (perhaps you forgot to load
   Razor2::Client::Agent?) at
   /usr/lib/perl5/5.6.1/Mail/SpamAssassin/Dns.pm line 382
   
   What has gone wrong with my perl and how do I fix it?
   I'm running RedHat 7.3 with perl 5.6.1
   
  
  Well it looks like some module files are missing (or were never
  installed) so I will start at the beginning... Do you have the MD5
  module installed?  Do you have the Razor2::Client::Agent module
  installed? (Please copy and paste don't retype error messages)
  
  In what directories are they installed, and is that directory
  available in @INC?
  
  http://danconia.org
 
 
 Kevin W. Gagel
 Network Administrator
 (250) 561-5848 local 448
 (250) 562-2131 local 448


Kevin W. Gagel
Network Administrator
(250) 561-5848 local 448
(250) 562-2131 local 448

--
The College of New Caledonia, Visit us at http://www.cnc.bc.ca
Virus scanning is done on all incoming and outgoing email.
--

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



Re: Difficulties installing the Tk module

2003-08-14 Thread John Burski
I looked for an appropriate RPM on rpmfind.net, but I couldn't find one.

I decided I'd attempt to install using the interactive CPAN stuff.  

Here's a short history:

I ran perl -MCPAN -e shell to launch the utility.

At the cpan prompt I executed install Bundle::Tk -- and we were off 
to the races.  Things were going pretty well until I encountered the 
following:

snip
cp widget ../blib/script/widget
/usr/bin/perl -MExtUtils::MY -e MY-fixin(shift) ../blib/script/widget
Unrecognized switch: --center (-h will show valid options)
make[1]: *** [manifypods] Error 29
make[1]: Leaving directory '/root/.cpan/build/Tk800.024/demos'
make: *** [subdirs] Error 2
 /usr/bin/make  -- NOT OK
Running make test
 Can't test without successful make
Running make install
 make had returned bad status, install seems impossible
Bundle summary: The following items in Bundle::Tk had installation problems:
  Tk
/snip
Has anyone encountered this before?  I've examined Makefile and it 
seems to me that the error exists either on line 842 or on line 790, but 
I'm not sure which.  Line 842 reads:
FIXIN = $(PERLRUN) -MExtUtils::MY -e MY-fixin(shift)

and line 790 reads
POD2MAN_EXE = $(PERLRUN) -MExtUtils::Command::MM -e pod2man --center 
perl/Tk

What might I do to fix this aberrant behavior?

Thanks.

Ramprasad wrote:

John Burski wrote:

Greetings, All!

I was going to attempt to learn a bit of Perl/Tk, but I've run into a 
bit of trouble installing the Tk module.

Here's some information about my system:  Red Hat 8.0, Perl version 
5.8.0.
I downloaded Tk-800.024.tar.gz from CPAN. I gunzipped and extracted 
everything OK.
The perl Makefile.PL command went off without a hitch.
However, I'm not certain that the make command is completing 
properly. Here's a snippet from the typescript file:
snip

Manifying blib/man1/ptked.1
make[1]: Entering directory `/usr/local/src/Tk/Tk800.024/pod'
Sorry no HTML building yet
make[1]: Leaving directory `/usr/local/src/Tk/Tk800.024/pod'
]0;[EMAIL PROTECTED]:/usr/local/src/Tk/[EMAIL PROTECTED] 
Tk800.024]# [EMAIL PROTECTED] Tk800.024]# [EMAIL PROTECTED] Tk800.024]# 
[EMAIL PROTECTED] Tk800.024]# [EMAIL PROTECTED] Tk800.024]# 
[EMAIL PROTECTED] Tk800.024]# [EMAIL PROTECTED] Tk800.024]# 
[EMAIL PROTECTED] Tk800.024]# [EMAIL PROTECTED] Tk800.024]# 
[EMAIL PROTECTED] Tk800.024]# exit


/snip

I searched through the typescript file, but I didn't find anything 
else that looked suspicious.

Thanks for your help.

If you havent done any fancy thing on your redhat (  like upgrading 
perl  or libc )
get perl-Tk rpms ( from rpmfind.net for eg.) and install them Save 
yourself the bother of compiling

Ram



NETCORE SOLUTIONS *** Ph: +91 22 5662 8000 Fax: +91 22 5662 8134

MailServ: Email, IM, Proxy, Firewall, Anti-Virus, LDAP
Fleximail: Mail Storage, Management and Relaying
http://netcore.co.in
Emergic Freedom: Linux-based Thin Client-Thick Server Computing
http://www.emergic.com
BlogStreet: Top Blogs, Neighborhoods, Search and Utilities
http://www.blogstreet.com
Rajesh Jain's Weblog on Technology: http://www.emergic.org

.

--
John Burski
@HOME S.I.M.U. (Well, sometimes I am :)  )

... and still searching for the cheese!



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


Parsing a mailbox and running each email through a script?

2003-08-14 Thread jc
I have a script that is invoked every time my .procmailrc filter sends it an
email.  This script grabs the email, looks at it and grabs data from it if
applicable and puts the data into a text file.

However, the filter hasn't been working lately, so I have go back to the
mailspool and figure out a way to have the script look at each message in
the mailspool and then do its thing if that email is relevant.

I've looked at the Mail:: CPAN modules.  However, I'm still not sure if it's
the easiest way to go.  Plus that guy that oversees our email server isn't
thrilled about adding a module.

If anyone can be of any help, I thank you in advance.

Joan




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



Pattern search a dir of filenames: Can use a scalar inside grep?

2003-08-14 Thread Alan C.
Hello,

It's my  .*  attempt I don't understand, seek help on.  (seek/need 
ability to either all files in dir opened or pattern search the files in 
dir with only files that meet pattern opened)

(Win32 if that matters Win2k ActiveState 5.61 build 633)  Next line is 
from when the script worked ok.

my @fils = grep /.txt/,readdir FILDIR; # works fine

# but instead of a hard coded search pattern, I wanted use of variable 
to add more flexibility.  So I changed that above line into like next line

my @fils = grep /$filspec/,readdir FILDIR;

With  .*  assigned to $filspec the print line prints all files that are 
in that dir.  But no files get opened.  Instead, an error (see as per 
line 4  5 of next code as well as I took note that the file open line 
is line 18)

#!/perl/bin/perl -w

use strict;
my $pattern = '(?=.*\bmodule\b)';
#my $filspec = '.txt'; # works without error
my $filspec = '.*'; # brings error: permission denied at line 18
my $fildir = '/Programs/NOTETA~2/DOCUME~1';
opendir(FILDIR,$fildir)|| die can't open $fildir $!;
my @fils = grep /$filspec/,readdir FILDIR;

closedir FILDIR;
print @fils;
foreach my $fil (@fils) {
open(FIL,$fildir/$fil)||die can't $!; # line 18
while (FIL) {
if (s/^H=($pattern)/$1/io) {
print $fil:$_ ;
}
}
close FIL;
}
#end
--
Alan.
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]


Re: problem changing filenames

2003-08-14 Thread Jeff 'japhy' Pinyan
On Aug 5, David Smith said:

 I have a couple of problems. I have multiple files on a server that are
all audio files. Some are mp3, some are waves. I need to change there
names because of a new automation system being put in here at the
station. The files are curretly laid out with a series of
numbers+songtitle+artist+time.ext. What I simply need to do is remove
the numbers (except for the 3 in mp3), and change the + to _. I found a
script that will do this with regular expressions. Here is the problem
though. I run the script and it does not loop through the file to take
out all of the numbers unless I run it several times. It also refuses to
take out the +. I'm really really new to perl...in fact I know just
enough to be extremely dangerous :D. If anyone could point me in the
right direction I would appreciate.

You didn't show us how you tried running the program.  I'll show you first
how to change the +'s to _'s.  But I need to know WHICH numbers should be
removed from the filename.  All of them (except for the 3 in mp3), or just
those at the beginning of the filename?

  ./rename 'tr/+/_/' files

or

  ./rename 's/\+/_/g' files

-- 
Jeff japhy Pinyan  [EMAIL PROTECTED]  http://www.pobox.com/~japhy/
RPI Acacia brother #734   http://www.perlmonks.org/   http://www.cpan.org/
stu what does y/// stand for?  tenderpuss 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]



can system() interrupt perl at runtime?

2003-08-14 Thread Martin A. Hansen
Hi

Is there a way to make an exception from an external program run with 

system( program, arg1, arg2, .. );

trigger a perl exception? that is, without explicitly checking $!, $? or $@
after every call ?


Martin

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



Re: combinations

2003-08-14 Thread david
David Byrne [EMAIL PROTECTED] wrote in message
news:[EMAIL PROTECTED]
 I am fairly new to Perl and haven't approached a scipt
 this complex or computation this intensive.  So I
 would certainly appreciate any advice.

 I have successfully created a hash of arrays
 equivalent to a 122 x 6152 matrix that I want to run
 in 'pairwise combinations' and execute the 'sum of the
 difference squares' for each combination.

 In other words:
 columns: y1...y122
 rows:  x1...x6152

 so...
 comb(y1,y2):
 {( y1[x1] - y2[x1] ) ^2 + ( y1[x2] - y2[x2] ) ^2 + ...
 + ( y1[x122] - y2[x122] ) ^2};

 comb(y1,y3):
 {( y1[x1] - y3[x1] ) ^2 + ( y1[x2] - y3[x2] ) ^2 + ...
 + ( y1[x122] - y3[x122] ) ^2};.
 .
 .
 comb(y1,y6152)
 comb(y2,y3)
 .
 .
 comb(y2,y6152)
 comb(y3,y4)
 .
 .
 etc.

 This is going to be very large.  According to the
 combinations formula (nCk, n=6152, k=2), the output
 will be a hash (with, for example, 'y1y2' key and
 'd^2' value) of about 19 million records.

 I think my next step is to create a combinations
 formula, but I'm having problems doing so.

you have an interesting problem (i think) but i don't fully understand what
you are trying to do so the best i can offer is something like:

#!/usr/bin/perl -w

use strict;

my $ahref = [  [ 1 .. 10],
  [11 .. 20],
  [21 .. 30],
  [31 .. 40] ];

my %matrix = ();

sub comb{

 my ($c1,$c2,$ahref) = @_;

 my $total = 0;

 for(@{$ahref}){
  $total += ($_-[$c1] - $_-[$c2]) ** 2;
 }

 return $total;
}

#--
#-- assume data (array) is uniform in size
#--
for(my $c1 = 0; $c1  @{$ahref-[0]}; $c1++){

 for(my $c2 = $c1+1; $c2  @{$ahref-[0]}; $c2++){

  my $k = 'c' . ($c1+1) . ' x ' . 'c' . ($c2+1);

  $matrix{$k} = comb($c1,$c2,$ahref);

  print pack(A10,$k),'= ',$matrix{$k},\n;
 }
}

__END__

prints:

c1 x c2   = 4
c1 x c3   = 16
c1 x c4   = 36
c1 x c5   = 64
c1 x c6   = 100
c1 x c7   = 144
c1 x c8   = 196
c1 x c9   = 256
c1 x c10  = 324
c2 x c3   = 4
c2 x c4   = 16
c2 x c5   = 36

if you explain a bit more, we might be able to offer more help. it might be
helpful to show us the code of how you set up your matrix hash. you mention
yoou have created a hash of array?

david



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



RE: input box

2003-08-14 Thread Dan Muey

 
 Hi 

Howdy

 
 
 I am trying a way to get input from user in GUI mode.. 
 Like Inputbox in Visual Basic.How do i go about?

Have alook at the Tk module at search.cpan.org
It has widgets for that sort of thing.

HTH
Dan

 
 
 with regards
 D.P.S
 

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



RE: :Application

2003-08-14 Thread NYIMI Jose (BMB)
We should avoid re-inventing the wheel as much as we can :)
Yes there are some cases where existing frameworks do not much our requirements
Then in such situation we can go for re-build our own framework (even though this is 
not an easy exercise ;).

Ok, wait and see how the market will grow ...

José.

-Original Message-
From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] 
Sent: Wednesday, August 13, 2003 8:54 PM
To: NYIMI Jose (BMB); [EMAIL PROTECTED]
Subject: RE: :Application




On Wed, 13 Aug 2003 12:33:19 -0500, Charles K. Clarkson [EMAIL PROTECTED] wrote:

 NYIMI Jose (BMB) [EMAIL PROTECTED] wrote:
 :
 : I'm wondering why the CGI::Application module is not
 : so popular in Perl's world like it is the case for
 : Struts in Java's world.
 : To me, there are both very similar due to the fact
 : that they are serving the same cause : framework to
 : build reusable web applications.
 :
 : Is that related to TMTOWTDI slogan of Perl ? :)
 
Perhaps. But the  mailing list for C::A is popular.
 I have about a thousand messages archived since last
 year. Maybe it is just that casual programmers are
 less likely to program in Java. And IMO C::A appeals to serious 
 programmers. I used perl for more than a year as a utility. I didn't 
 do any multiple screen apps until just recently. C::A is also OO and 
 that is a turn off for many.
 

The ironic part to me is that I think C::A applies to the middle of the road. It is 
overly complex to do something simple (or at least has enough of a learning curve to 
avoid it for simple things), but a serious programmer might feel restricted by the 
manner in which it handles things, in other words, they are more likely to grow their 
own object/framework, as I recently have re-written a framework I had previously 
developed, moved from functional Perl 4 to OOP, but didn't start with C::A as a basis, 
though mine works in a similar manner.  On top of that, right now I don't know that 
there is a large middle market, where one needs a decent starting framework to build 
on, but isn't willing to grow their own, or is at the beginner stage where the goals 
don't warrant the learning curve for a couple of dynamic pages or a form that just 
sends a message.

I think this market will grow, and from looking at the docs it appears C::A has 
matured substantially since I last visited it, so I am not against its' usage or 
promoting it, just throwing my two cents in the pot as to why there hasn't been more 
uptake...

http://danconia.org


 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: ifconfig without being root

2003-08-14 Thread Schubert, John [NTWK SVCS]
No.  Adding a network interface is definately something you do not want anyone, except 
root, to be able to perform.  To do otherwise would be opening up an exceedingly huge 
security hole.

John

Message Snipped Since I get this in Digest---  The question is can you add an IP with 
out being root

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



RE: Simple question

2003-08-14 Thread Marcos . Rebelo
I didn't understand your question but 

$line[1] = $line[1]/1000;  

shall work

$line[1] /= 1000; 

must be faster


-Original Message-
From: Sommer, Henrik [mailto:[EMAIL PROTECTED]
Sent: Tuesday, August 05, 2003 5:05 PM
To: [EMAIL PROTECTED]
Subject: Simple question


Hi, 
How do I divide a variable in an array ?
Lets say element one need to be divided by 1000?

$line[1] = $line[1]/1000; 

Thanks, 
Henrik

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



data not pushing to list

2003-08-14 Thread Trina Espinoza
Is there any reason why this doesn't print the @missing?
Ive also tried unless ($myhash{$elem} == 1) { push(@missing, $frame) }
Any insight into what I'm doing wrong would be greatly appreciated.

Thanks!

-T


CODE:

@missing = ;
@framelist= (1, 2, 3, 6, 10);
$startFrame= 001;
$endFrame = 0010;

@fullList = (int $startFrame .. int $endFrame);
print FULL RANGE @fullList\n;
foreach $item(@fullList) {
 $myhash{$item} = 1;
}

foreach $elem(@framelist) {
 print $elem\n;
 if ($myhash{$elem} == 1) {
  print $elem found!\n;
 }else{
  push(@missing, $elem);
 } 
}

print Missing Frames @missing; ##Doesn't print this!
--
OUTPUT :

FULL RANGE 1 2 3 4 5 6 7 8 9 10
1
1 found!
2
2 found!
3
3 found!
6
6 found!
10
10 found!
Missing Frames

Re: Regarding substitution

2003-08-14 Thread Wiggins d'Anconia
Visu wrote:
Hi,
	I have extracted links from a html source using HTML::TokeParser.
I used 'a' as a parameter in get_tag method of HTML::TokeParser.Then I 
want to substitute something for the links that i have extracted.
But the substitution fails for the links in the below lines.

color=#00 face=NEWSa

href=http://www.ani.com/NewsItems.asp?ID=CMK20030808091643amp;Title=Latest+News+Pageamp;lTitle=L%FBP%A3+%F9Nn%A7Lsamp;Topic=0;bigv??Wd
?NnV E??U Cp?XV??: EfN ??Uu\m/big/bigbr
bigbig?V? L?j?R?u; ?olTpX: T.?RmTWm/big/big/abr
/fontbigfont color=#ae face=Verdanastrong./strong/fontfont
color=#00 face=TMNEWSa
href=http://www.ani.com/NewsItems.asp?ID=CMK20030808064834amp;Title=Latest+News+Pageamp;lTitle=L%FBP%A3+%F9Nn%A7Lsamp;Topic=0;big?Tvh
?TdL? YZd?: ?_W?j AW?d? EfN??Uu\m/big/bigbr
bigbig?S?h?v/big/big/abr
/fontbigbiga
href=http://www.ani.com/NewsItems.asp?ID=CMK20030807101744amp;Title=Latest+News+Pageamp;lTitle=L%FBP%A3+%F9Nn%A7Lsamp;Topic=0;/a/bigstrongfont
color=#ae face=Verdana./font/strongfont color=#00 face=TMNEWSa
href=http://www.ani.com/NewsItems.asp?ID=DNL20030808041423amp;Title=Latest+News+Pageamp;lTitle=L%FBP%A3+%F9Nn%A7Lsamp;Topic=0;bigquot;?Tl?,
?L?d ?tT?]d?j ?R?V A[?p R?P':/big/bigbr
bigbigW?UR?v ?L?d?L/big/big/abr

	

Any direction is welcome.
We would need to see the code not the lines themselves. As an aside if 
you are substituting a value for the 'href' attribute you shouldn't use 
a regex. Let the tokeparser do it for you by changing the attribute 
using the token's methods.

http://danconia.org

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


  1   2   3   4   5   >