File Downlaod issue.

2007-04-19 Thread Sara
I have directory from which users are downloading files directly using FTP 
client (no browser).

If I can run a script or program, which could tell me as which files have been 
downloaded?

File::Stat changes? if they simply download the file from FTP?

Or is there any other way?

Sara.



Can't use string as a subroutine ref while "strict refs"

2006-11-09 Thread Sara
use strict;
use warnings;
use CGI;

my $q = new CGI;

my $do = $q->param('do') || 'main'';

if ($do) {
&$do;
}

sub main {
blah blah
}
=
Trying to call the subroutine main from variable $do but I am gettin' error:
Can't use string ("main") as a subroutine ref while "strict refs.
But somehow I don't want to remove the 'use Strict;'

Any way out?

Sara.




Convert Date to Timestamp.

2006-10-31 Thread Sara
I am getting Month, Day and Year from Drop Downs of a form to convert given 
values to Unix timestamp.
I am able to put values in all the variables below except for $wday & $yday. 
Any ideas as how I can get those with limited user input of month, day and year 
only?

#!/usr/local/bin/perl
use POSIX;

$sec = 1;
$min = 0;
$hour = 0;
$mday = 01;
$mon = 10;
$year = 107;
$wday = ?;
$yday = ?;
$timestamp = mktime($sec,$min,$hour,$mday,$mon,$year,$wday,$yday,-1);
print ($timestamp);


.wav and mp3 length.

2006-10-14 Thread Sara
Need to determine the .wav and mp3 file length not in bits or bytes, but in 
minutes.

It's for a dictation recording service who needs to invoice the clients as per 
the minutes of files uploaded to their servers.

I searched the CPAN but of no help.

Thanks,
Sara.



Getting status of files before copying/moving.

2006-10-02 Thread Sara
I am copying/moving files from an FTP folder to other folders on server. The 
script reads the files and copy/move to separate folders etc. No problem till 
this point.

Now the problem is that users are constantly uploading files to this folder 
using FTP client. The script is invoked using cron after every 10-15 mins, now 
what will be the fate of the files that are in the upload process when the 
script is invoked?

Yes, these files are copied and moved what was uploaded till that point, means 
corrupt files.

How I can avoid it? that script should leave those files which are being 
uploaded at the time it was invoked.

# Start of Subroutine #

sub copy_files {
use File::Copy;
while (glob ("*.mp3")) {
copy("home/uploads/$_", "home/backup/$_");
move("home/uploads/$_", "home/music/$_");
}
}

##

Thanks,
Sara.



Limiting Images Dimensions?

2006-09-02 Thread Sara
I saw in PHP scripts where you can upload avatars within a range of dimensions 
like 100 x 100. If user tries
to upload an image with a size bigger than 100 x 100 it gets a message to 
resize and re-upload.

How it can be achieved in CGI scripts? I have made numerous scripts for 
uploading, limiting upload size, formats, etc
but this problem is encountered first time.

Any help?

Sara.

Regex Help.

2006-06-24 Thread Sara
Need help to remove EVERY thing (non-alphabets, symbols, ASCII codes etc) from 
a string except for a-zAZ, 0-9, dash and underscore.

$string =~ s/??

Thanks,
Sara.



C++ query with mySQL

2006-04-09 Thread Sara
I have been stuck here, SOS call:

Using CGI.pm, I have the script calling certain categories from mySQL table.

my $cat = $q->param('cat');
my $dbh -> prepare ("SELECT * FROM main WHERE CAT='$cat'");

Sample Categories('CAT') are given below:

PHP/Ad_Management/Classifieds
Perl_and_CGI/Ad_Management
C_and_C++/Ad_Management

etc.

Calling the categories starting with PHP and Perl didn't cause any issue, but 
when I called the Categories
starting with C_and_C++, nothing was shown because CGI.pm was removing the 
characters ++.

I replaced the All ++ in the mySQL database with ASCII ++, so now the 
categories are in the DB are:
C_and_C++/Ad_Management

And now when I am calling the script:
http://mysite.com/cgi-bin/index.cgi?cat=C_and_C++/Ad_Management

Since CGI.pm removing ++, so in script I did this:

my $cat =~ s/C_and_C/C_and_C++/gi;

It should have extracted the results from DB containing C_and_C++, BUT NO.

it's printing and calling cat within script as "C_and_C++ /Ad_Managment"

Putting an extra Space after +, so mySQL failed to deliver matching 
categories.

Why an extra white space? or anything more reasonable I can do to call cat with 
"C++" from mySQL.


TIA.







Re: referer throwing Internal Server Error

2006-03-13 Thread Sara

#!/usr/bin/perl

use CGI qw/:standard/;
use CGI::Carp qw(fatalsToBrowser);
use POSIX 'strftime';
use strict;
use warnings;

my $q = new CGI;

my $referer = $ENV{'HTTP_REFERER'} || 'foo.com';

print $q->header();

if ($referer !~ m|^https?://www\.coraconnection\.com|i) {
print "Your not authorized: Bad Referer: $referer \n";
} else {
print "all cool: $referer \n";
}



Sara.

- Original Message - 
From: "David Gilden" <[EMAIL PROTECTED]>

To: 
Sent: Tuesday, March 14, 2006 6:30 AM
Subject: referer throwing Internal Server Error


Greetings from Cow Tow!

Here is my little script and it throwing a Internal Server Error

#!/usr/bin/perl

use CGI qw/:standard/;
use CGI::Carp qw(fatalsToBrowser);
use POSIX 'strftime';
use strict;

my $referer = referer;

   if ($referer !~ m|^https?://www\.coraconnection\.com|i) {
   print "Your not authorized: Bad Referer: $referer \n";
   } else {
   print "all cool: $referer \n";
}


I can not figure out what is wrong here
and how secure is this, can it be spoofed easily??
Thanks.


Dave Gilden
(kora musician / audiophile / webmaster @ www.coraconnection.com  / Ft. 
Worth, TX, USA)


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



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




Electronic Signatures.

2006-03-05 Thread Sara
What is meant by "Electronic Signatrues"?

How these could be implemented using Perl where the documents are being 
generated from forms input,
but these documents need to be electronically signed.

I tried to search, but my concepts are not clear about it. Anyone can help?

Sara.

Matching a string containing '+'

2006-02-07 Thread Sara
Using this query in my Perl Script to find the Category title from the 
database given as:

C_and_C++/Forums
C_and_C++/Codes
C_and_C++/Sites
etc.
my $sql = qq(SELECT CAT_TITLE, FROM categories WHERE CAT_TITLE REGEXP 
'^C_and_C\\+\\+/[a-zA-Z|_]+\$' )


$query = $dbh -> prepare ($sql) or die "Couldn't prepare statement: " . 
$dbh->errstr;


$query->execute();

And when the query is executed, I am gettin' error:
"DBD::mysql::st execute failed: Got error 'repetition-operator operand 
invalid' from regexp"
I am using double \\ in front of + as advised on the link given below but 
still gettin' error, any solution to it?


http://213.136.52.42/bug.php?id=399 



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




Re: Filering a file

2005-12-06 Thread Sara

Here is a small piece of code if it could be helpful.

## START #

#!f:/perl/bin/perl.exe
# set the above to your perl path.

use strict;
use warnings;
use CGI qw(:standard);
use CGI::Carp 'fatalsToBrowser';

my $q = new CGI;

open (DUPF,"dupes.txt"); # name of the file containig dupes to be removed.
open (OUTF,">>dupes_removed.txt"); #new file with dupes removed.
my %saw;
print OUTF grep(!$saw{$_}++,);
close OUTF;
close DUPF;

print $q->header();
print "Duplicate Enteries Removed";

exit;

# End of Code ####

Thanks,

Sara.



- Original Message - 
From: "Adedayo Adeyeye" <[EMAIL PROTECTED]>
To: "'David Dorward'" <[EMAIL PROTECTED]>; "'Perl Beginners - CGI List'" 


Sent: Tuesday, December 06, 2005 12:14 PM
Subject: RE: Filering a file



Hello David,

I'm able to open the file, read the contents and output the results of my
initial filtering to a new file.

The problem is that my new file has duplicate entries, and cleaning up
duplicates is where I'm stuck.

Kind regards

Dayo

-Original Message-
From: David Dorward,,, [mailto:[EMAIL PROTECTED] On Behalf Of David 
Dorward

Sent: Monday, December 05, 2005 2:35 PM
To: 'Perl Beginners - CGI List'
Subject: Re: Filering a file

On Mon, Dec 05, 2005 at 02:20:33PM +0100, Adedayo Adeyeye wrote:

   How do I write a script to parse through this file and just return the
   unique names. Ie I want the repetitions ignored.


What have you tried?  Where are you stuck? (Opening the file? Reading
the contents? The actual filtering?). Nothing in your question is CGI
related, have you got this working as a command line script but are
having trouble converting it to work under CGI? What code have you got
so far?


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


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





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





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




Tracking/Blocking IPs.

2005-11-01 Thread Sara
I have been running a public forum (no registration required) with over 50,000 
visits per day. Lot of Trolls and bad  / advertising posts etc from other sites 
and individuals.

-> It was small initially and I used to track the IPs and ban them manually to 
put them within a database and Posting script checked the IP ban list before 
anyone can post.

-> By the time, it grew and I started monitoring {HTTP:Forwarded-For} and 
{HTTP:X-Forwarded-For}as well to filter out trolls.

-> later I also tried mod_rewrite,
# Ban anonymous proxy requests 
RewriteCond %{HTTP:Via} !^$ [OR] 
RewriteCond %{HTTP_FORWARDED} !^$ [OR] 
RewriteCond %{HTTP:X-Forwarded} !^$ 
RewriteCond %{HTTP:Client-IP} ^$ 
RewriteCond %{HTTP:Forwarded-For} ^$ 
RewriteCond %{HTTP:X-Forwarded-For} ^$ 
RewriteRule .* /cgi-local/not_allowed.pl [L]

Now the problem is that Trolls are STILL coming through, I track those IPs and 
matched a couple of those as "Elite Proxies" (http://www.samair.ru/proxy/). 
Elite Proxy -> HTTP Servers of this type do not send HTTP_X_FORWARDED_FOR, 
HTTP_VIA and HTTP_PROXY_CONNECTION variables. Host doesn't even know you are 
using proxy server an of course it doesn't know your IP address.  

Now the question is how to get these Elite Proxies filtered out? Another thing 
that I want to ask is that when I used these Elite Proxies myself to access 
Yahoo or Google, they immediately tracked it and gave the error "405 - Resource 
Not Allowed". It means that there is some way to detect it or it's because of 
https? If SSL can deal with this issue I am ready to go for it but just need to 
confirm or alternative solution to it before I make my move.

Thanks for any help.

Sara.



Re: uninitialized variable

2005-11-01 Thread Sara

my $action = param('form_action') || 'any_default_value';

HTH,
Sara.


- Original Message - 
From: "Chris Devers" <[EMAIL PROTECTED]>

To: "Adedayo Adeyeye" <[EMAIL PROTECTED]>
Cc: 
Sent: Tuesday, November 01, 2005 8:42 PM
Subject: Re: uninitialized variable



On Tue, 1 Nov 2005, Adedayo Adeyeye wrote:


my $action = param('form_action');


Try setting a default value when 'form_action' isn't specified:

   my $action = param('form_action') or '';

Or set it to 0, or 'do nothing' or undef, or whatever is appropriate.


--
Chris Devers

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




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




Re: Taking Multiple Values for The Same Form Field.

2005-10-28 Thread Sara
Thanks for the quick respons, just need a bit more help. Now I need to write 
these values in a text file (I am fully aware of writing to files) but where 
I am gettin' confused is that : I told you that Name is a required field, 
but Email is optional. so what if :


my @name = ('Sara', 'John', 'Doe'); # 3 names coming from form.
my @email = ('[EMAIL PROTECTED]'); # coming from form as Email Optional field is 
ONLY filled for John.


The problem is $name[0] does not corresponds with $email[0] and so on 
Otherwise I would have used while or foreach for @name and @email to write 
it to file like it:


### TEXT FILE TO WRITE ###
Sara |
John | [EMAIL PROTECTED]
Doe |
##

Thanks again for your help.

Sara.



- Original Message - 
From: "Ovid" <[EMAIL PROTECTED]>

To: 
Sent: Saturday, October 29, 2005 9:14 AM
Subject: Re: Taking Multiple Values for The Same Form Field.



--- Sara <[EMAIL PROTECTED]> wrote:



use CGI;
my $q = new CGI;

my $name = $q->param('name');

Now What as multiple name values will be coming.??


Use list context:

 my @names = $q->param('name');

Cheers,
Ovid

--
If this message is a response to a question on a mailing list, please send
follow up questions to the list.

Web Programming with Perl -- http://users.easystreet.com/ovid/cgi_course/

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





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




Taking Multiple Values for The Same Form Field.

2005-10-28 Thread Sara
Never thought of it before, but now I need help as how to pass multiple values 
of a form field with a single submit to script.

** example **























use CGI;
my $q = new CGI;

my $name = $q->param('name');

Now What as multiple name values will be coming.??


Thanks for any help.

Sara.

Fast CGI.

2005-10-09 Thread Sara
I am a new dedicated server where: FastCGI: Enabled

I am at a loss as what I need in my scripts to run them with Fast CGI? .fcgi 
extension? and what else.

Thanks for any help.

Sara.




Re: Forcing a "save as' dialogue box to come up on left click

2005-09-20 Thread Sara
Hi all,

Did you read it?

Content-Disposition -> "do not enclose filenames in quotes"

http://support.microsoft.com/kb/q182315/

Thanks,
Sara.


Re: Forcing a "save as' dialogue box to come up on left click

2005-09-20 Thread Sara

Hi all,

Did you read it?

Content-Disposition -> "do not enclose filenames in quotes"

http://support.microsoft.com/kb/q182315/

Thanks,
Sara.




- Original Message - 
From: "Wiggins d'Anconia" <[EMAIL PROTECTED]>

To: "Tony Frasketi" <[EMAIL PROTECTED]>
Cc: 
Sent: Tuesday, September 20, 2005 5:22 AM
Subject: Re: Forcing a "save as' dialogue box to come up on left click



Tony Frasketi wrote:



What I was intending was to call the cgi script and rather than it
printing the normal text/html header it would print the header directly,
that way you are guaranteed to be operating the way you intended.


Hi Wiggins
Thanks for this suggestion... I've tried the following bit of CGI script
with three different file types (.txt, .cgi, .dat) and in each case *DO*
get the 'Save as...' dialogue box to come up and when I select 'Save to
disk' and click ok, It appears as if a transfer occurs but only a
zero-length file is saved to my local hard disk directory.  The code is
as follows...


Ok, so almost there let's back up a step and understand the whole
thing. The HTTProtocol is very similar to other common net protocols
where there is a header section and a data (or payload) section. The two
are separated by a blank line. So right now you are providing the header
(apparently correctly). The client reads that information and based on
what it knows how to handle it decides on a way to use the payload. In
this case we are giving the browser less than optimal descriptors of the
payload. Basically we are telling it that there is something coming and
that neither I nor you know what it is. So it does the only thing it
can, "Save as...". The only hint you are providing it a suggestion about
what to call that thing. So right now you are providing a header, but
not a payload, let's add it




#!/usr/local/bin/perl -w

# testoctetstream_1.cgi

# My base directory and base directory URL
my($basedir) = "";
my($baseurl) = "";

# Location of the file to be downloaded
$fileloc = "$basedir/cgi-bin/test/xxx.txt";
#$fileloc = "$basedir/cgi-bin/test/testdu1.cgi";
#$fileloc = "$baseurl/cgi-bin/test/testdu.dat";

# Name of file to be downloaded
$filename = "xxx.txt";
#$filename = "testdu1.cgi";
#$filename = "testdu.dat";

# NOTE: Uncomment the desired $filename and $fileloc above

# Set The headers
print "Content-Type: application/octet-stream;\n";
print "Content-Disposition: attachment; filename=\"$filename\"\n";

# ---
# Note: Can't figure out what to put in here to actually download
# the darn file!!!
# ---



This is the simple part, and probably looks a little like.

open file...
read in file...
print file back to browser...
close file

There are simpler ways to do this, but what I have come to use looks like:

my $READHANDLE;
unless (open $READHANDLE, $file) {
   # error handling...
}
binmode $READHANDLE;

$| = 1;

while ( my $length = sysread $READHANDLE, my $buffer, $block_size ) {
   next unless defined $length;

   my $offset = 0;
   while ( $length ) {
   my $written  = syswrite STDOUT, $buffer, $length, $offset;
   $length -= $written;
   $offset += $written;
   }
}

close $READHANDLE;


print "\n";


You will want to remove this as it will be an addition to the actual
data which can break some formats.


exit;


The above cod was tested in both Mozilla and IE browers with the same
results.


It appears I'm missing some statement that should follow the
Content-Disposition
statement.



Does this hit the mark?

http://danconia.org

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





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




Re: cookies as hidden files

2005-09-16 Thread Sara

1. Are we setting up the proper headers?

use CGI;
my $q = new CGI;

print $q->header(-cookie=>$cookie);

2. I am unable to see the

-domain => 'foo.com';

3. On which machine, you are testing? Your Windows (localhost) or a real web 
server?. I have always experienced problems locating cookies for my 
localhost (Windows XP, Apache). But when I ran the scripts on my *nix Web 
Server, those worked fine.


4. When dealing with cookies and calling the scripts within your browser, 
don't hit your refresh button while testing the script, always call the 
script in a new window for fresh headers.


I have never experienced HIDDEN cookies, new phenomenon for me atleast.

HTH,
Sara.

- Original Message - 
From: "Denzil Kruse" <[EMAIL PROTECTED]>

To: 
Sent: Friday, September 16, 2005 9:08 AM
Subject: cookies as hidden files



Hi all,

I read through the docs for CGI::Cookie and learned
how to set a cookie.  I do it with line:

my $cookie = new CGI::Cookie(-name=>'name',
-value=>"$name",
-expires=>'+6M');

But, I've found out that when IE creates the cookie,
it creates it as a hidden file, so when I come around
and fetch it, it can't find the cookie and hangs.

But, I saw some cookies that weren't hidden.  The list
just got bigger once I told windows to how hidden
files.

So, my question is, how can I create the cookie in
such a way that it isn't hidden?  I couldn't find it
in the docs I looked through.

thanks,
Denzil



__
Do You Yahoo!?
Tired of spam?  Yahoo! Mail has the best spam protection around
http://mail.yahoo.com

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





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




Re: Exact matching using GREP.

2005-09-08 Thread Sara

No, it's not working, probably you didnt' get my question.

Anyways, thanks for a prompt reply.

Sara.

- Original Message - 
From: "Ovid" <[EMAIL PROTECTED]>

To: 
Sent: Friday, September 09, 2005 12:01 AM
Subject: Re: Exact matching using GREP.



--- Sara <[EMAIL PROTECTED]> wrote:


while (my $row = $sth->fetchrow_hashref)
{
  if (grep /$row->{CAT_TITLE}/, @present) {
  #matching title with @present elements
  print "$row->{CAT_TITLE}";
}

Question is how to do EXACT matching using GREP? because the above
code prints every element from array for 'php' if the
$row->{CAT_TITLE} is 'php' it prints php/counters, php/forums and
every element containing php.


Assuming I understood your question correctly:

 if (grep { $_ eq $row->{CAT_TITLE} } @present) {
   # do something
 }

Cheers,
Ovid

--
If this message is a response to a question on a mailing list, please send
follow up questions to the list.

Web Programming with Perl -- http://users.easystreet.com/ovid/cgi_course/

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





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




Exact matching using GREP.

2005-09-08 Thread Sara
my @present = ('perl', 'perl/chat', 'php', 'php/forums', 'php/counters', 
'perl/search/scripts', 'php');

# Getting Results for mySQL query in hashref.

while (my $row = $sth->fetchrow_hashref) 
{  
if (grep /$row->{CAT_TITLE}/, @present) {
#matching title with @present elements
print "$row->{CAT_TITLE}";
}

Question is how to do EXACT matching using GREP? because the above code prints 
every element from array for 'php' if the $row->{CAT_TITLE} is 'php' it prints 
php/counters, php/forums and every element containing php.

How I am supposed to do Exact matching that if $row->{CAT_TITLE} is 'perl/chat' 
it should pick only 'perl/chat' from @present.

I saw the Unix man pages and did other searches and found '-x' switch to use 
for exact matching with GREP and '-e' switch for pattern matching but dont' 
know how to incorporate it within my code.

TIA, 
Sara



Re: Regex Problem.

2005-08-18 Thread Sara

That's worked like a charm, You ALL are great.

Thanks everyone for help.

Sara.


- Original Message - 
From: <[EMAIL PROTECTED]>

To: "'Sara'" <[EMAIL PROTECTED]>
Sent: Thursday, August 18, 2005 10:50 PM
Subject: RE: Regex Problem.



Hi Sara,

what is about somthing like
$string = 'blood';
for($i=0; $i<=length($string)-3;$i++) {

check(substr($string,$i,3));
}



Mit freundlichen Grüssen
   Ihr echtwahr.Webmaster


http://www.echtwahr.de
http://www.echtwahr.com

-Original Message-
From: Sara [mailto:[EMAIL PROTECTED]
Sent: Thursday, August 18, 2005 5:48 PM
To: beginners-cgi@perl.org
Subject: Regex Problem.

I am at a loss here to generate REGEX for my problem.

I have an input query coming to my cgi script, containg a word (with or
without spaces e.g. "blood" "Globin Test" etc).
What I am trying to do is to split this word (maximum of 3 characters) 
and

find the BEST possible matching words within mySQL database. For example
if the word is "blood"

I want to get results using regex:

for "blood": &check(blo) then &check(loo)  &check(ood)
for "Globin Test": &check(Glo) then &check(lob)  &check(obi)
&check(bin) &check(Tes) &check(est)

TIA.

Sara.

sub check {
my $check = $dbh -> prepare("SELECT * FROM medical WHERE def LIKE
'%$query%' ");
$check->execute();
while (my @row = $check -> fetchrow_array()) {
print "blah blah blah\n";
}
}







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




Regex Problem.

2005-08-18 Thread Sara
I am at a loss here to generate REGEX for my problem.

I have an input query coming to my cgi script, containg a word (with or without 
spaces e.g. "blood" "Globin Test" etc).
What I am trying to do is to split this word (maximum of 3 characters) and find 
the BEST possible matching words within mySQL database. For example if the word 
is "blood"

I want to get results using regex: 

for "blood": &check(blo) then &check(loo)  &check(ood)
for "Globin Test": &check(Glo) then &check(lob)  &check(obi) &check(bin) 
&check(Tes) &check(est)

TIA.

Sara.

sub check {
my $check = $dbh -> prepare("SELECT * FROM medical WHERE def LIKE '%$query%' ");
$check->execute();
while (my @row = $check -> fetchrow_array()) {
print "blah blah blah\n";
}
}


Script execution time.

2005-08-03 Thread Sara
I have to test/optimize a script on a shared server. The script contains a 
couple of mySQL queries etc.

Is there a way that I can see the query execution time (like in phymyAdmin) and 
total script execution time, plus memory & CPU usage? There are a lot of ways 
doing it in PHP but nothing in PERL/CGI? 

I searched CPAN but failed to find my desired requirements. Are there any 
system commands that can be executed within the script to get these values.

TIA.

Sara.



Re: export to text file

2005-06-08 Thread Sara
I always used 'phpmyAdmin' for such tasks. Give it a try.

Thanks,
Sara.

- Original Message - 
From: "Glauco Magnelli" <[EMAIL PROTECTED]>
To: 
Sent: Wednesday, June 08, 2005 10:55 AM
Subject: export to text file


> I do a query to mysql table and view the result in
> html table. At this point I want export query result
> in a text file (comma separated fields), doing to
> choose (to user) file name and destination on your
> filesystem.
> Can you help me?
> 
> Thanks
> magnellig 
> 
> 
> 
> ___ 
> Yahoo! Messenger: chiamate gratuite in tutto il mondo 
> http://it.beta.messenger.yahoo.com
> 
> -- 
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
> <http://learn.perl.org/> <http://learn.perl.org/first-response>
> 
> 


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




CGI::Cookie Reading.

2005-03-29 Thread Sara
## SET-COOKIE.cgi ##

#!/usr/bin/perl
use CGI qw/:standard/;
use CGI::Cookie;
use CGI::Carp qw(fatalsToBrowser);
use strict;
use warnings;

my $c = new CGI::Cookie(-name => 'ID',
-value => '987654321',
-domain => '.domain.com',
-expires => '+3M',
-path => '/'
);

my $q = new CGI;

print $q->header(-cookie=>$c);

print "ID cookie is set for 3 months";

##

The above code is working fine and sets up the cookie as required.

I have problems reading the cookie as follows:

## READ-COOKIE.CGI ###

#!/usr/bin/perl
use CGI;
use CGI::Cookie;
use CGI::Carp qw(fatalsToBrowser);
use strict;
use warnings;

my %cookies = fetch CGI::Cookie;
my $cookies;
my $id = $cookies{'ID'}->value;

my $q = new CGI;

print $q->header(-cookie=>$cookies);

print "Cookie ID = $id";
print "Thanks\n";


IF the cookie already exists the script reads the value perfectly, but if 
cookie doesn't exist or I mean for the first time visitor, it gives error: 
"Can't call method "value" on an undefined value"

I tried to do something like it: if ($id) {do blah} else {do blah} but that's 
not working either.

It's my first time using CGI::Cookie, how can I overcome this problem

Thanks for any input,

Sara.






removing dupes from fetchrow_array()?

2005-03-23 Thread Sara
Following is the code used in my CGI script. 

my $query = $dbh -> prepare("SELECT * FROM invoices WHERE ID = '$ID'"); 
$query -> execute(); 
while (my @row = $query -> fetchrow_array()){ 
print "$row[1] - $row[2] - $row[3]"; 
} 

What If I want to remove dupes from @row? like if $row[2] is similar in 
multiple records, only one entry should be showed, the duplicates should not 
appear in the print. 

I am aware of grep, but unable to implement it here in While loop. 

@row = grep {++$count{$_} < 2} @row; 

I am also aware that Unique keys can be added within mySQL database, but that's 
un-do-able due to some reasons. I want to remove dupes within the script.


Any ideas? 


Addendum: Content_Length.

2005-02-03 Thread Sara
Why the length is not coming out? Any ideas?

#

my @aho = ("fgfgfgf", "fgfgfgfgf", "fgfgfgfg");

my $length += length($_) for @aho;

print "Content-type: text/plain\n\n";
print "$length";

#

Thanks,
Sara.





Content_Length

2005-02-03 Thread Sara
I have like 20 variable coming from a form, using CGI.pm in my script.

I am at a loss as how to get $ENV{'Content_lenght'} for all of those 
collectively. Is there anything in CGI.pm for it?. I am trying to count every 
keystroke that user inputs to form.

Thanks,
Sara.


Extracting links.

2005-01-16 Thread Sara
I am trying to extract links along with HTML tags  from a list, 
but it's not working on my XP machine with Active State Perl 5.0.6
Kindly help.

# CODE START 

my @array = qq|
http://www.mydomain.com";>http://www.mydomain.com/images/logo2.gif";>
|;
#extract LINKS (no image links) only http://www.mydomain.com";>

my @get = grep {//} @array;
print "@get\n"

### CODE END ###

Thanks,

Sara.






Reducing load on server.

2004-11-19 Thread Sara
I am writing a Cgi script to retrieve records and split it into pages.

my $limit = $q->param('limit') || '0';
my $results_per_page = 50;

my $query = $dbh -> prepare("SELECT * FROM $table WHERE reply=0 ORDER BY msg
DESC LIMIT $limit, $results_per_page");
$query->execute();
while (my @row = $query -> fetchrow_array()) {
print "$row[1]$row[2]$row[3] blah blah blah.";
}
$query->finish();
&print_number_of_pages;
--

The table holds about 50,000 rows of records, The script is supposed to be
accessed 100,000 times a day by web users. After reading manual for LIMIT, I
came to know that LIMIT works after getting the whole matrix of records, so
it's not going to reduce any load on server, so I am using it only for
splitting records on to pages.

--
My Questions:

1 - Is it safe to load such huge data 100,000 times a day? Or there is a way
that I can load only those records which are going to be printed on each
page?

2 - How much data in terms of size (MB) can be holded safely by my @row =
$query -> fetchrow_array())

3- What else can I do to reduce load on mySQL, PERL and server? Should I use
CGI::Fast?

4- Anyother possible query?

Thanks,
Sara.



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




Re: untainting data

2004-11-10 Thread Sara
No I don't know, can you please explain.

How it can be spoofed, I am interested in details.


- Original Message - 
From: "Bob Showalter" <[EMAIL PROTECTED]>
To: "'Sara'" <[EMAIL PROTECTED]>
Cc: <[EMAIL PROTECTED]>
Sent: Thursday, November 11, 2004 3:17 AM
Subject: RE: untainting data


> Sara wrote:
> > > > > bad guys can always create their own form
> > 
> > I can't say how others do it but almost my every script starts with:
> > 
> > if ($ENV{'HTTP_REFREER'} !~ /yourdomain.com/) {
> > exit;
> > }
> > 
> > it helps eliminating of Bad Guys forms & shoving of data (no remote
> > postings allowed).
> 
> You do know that the Referer header can be trivially spoofed?


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




Re: untainting data

2004-11-10 Thread Sara
>>> bad guys can always create their own form

I can't say how others do it but almost my every script starts with:

if ($ENV{'HTTP_REFREER'} !~ /yourdomain.com/) {
exit;
}

it helps eliminating of Bad Guys forms & shoving of data (no remote postings
allowed).

Sara.




- Original Message -
From: "B McKee" <[EMAIL PROTECTED]>
To: "Sara" <[EMAIL PROTECTED]>
Cc: <[EMAIL PROTECTED]>
Sent: Thursday, November 11, 2004 2:13 AM
Subject: Re: untainting data


>
> On Wednesday, November 10, 2004, at 04:02  PM, Sara wrote:
>
> > If the 'name' is coming from a Form, try limiting it within the form
> > tags,
> > it's always a better idea.
>
> I thought (correct me if I'm wrong here - I'm no expert)
> that you want to do this at both ends
> because the bad guys can always create their own form
> (or whatever) and shove bad data at the web server.
>
> Brian
>



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




Re: untainting data

2004-11-10 Thread Sara
If the 'name' is coming from a Form, try limiting it within the form tags,
it's always a better idea.



OR if you insist to do it within script; use 'substr' function.

my $name = param('name');

my $limited_name = substr($name, 0, 40);

Thanks,
Sara.




- Original Message -
From: "David Gilden" <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Sent: Wednesday, November 10, 2004 11:49 PM
Subject: untainting data


Hello,


Is the following all I need to untaint data?


#!/usr/bin/perl

use CGI qw/:standard/;

my $name = param('name');

$name =~ s/(\w+)/$1/;

What can I do limit string length to 40 characters?

Thanks,

Dave

(kora musician / audiophile / webmaster @ www.coraconnection.com  / Ft.
Worth, TX, USA)

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




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




PPM problem.

2004-10-17 Thread Sara
I am trying to install DBI module for my perl installation on XP machine.
Everything was working fine, I installed a lot of modules before using the
same PPM, but now it has started giving this error (as shown below).

I have searched, but failed to find anything. I installed a fresh version of
Perl, but it's still the same.

Any ideas?

-
C:\Perl\bin>ppm
PPM - Programmer's Package Manager version 3.1.
Copyright (c) 2001 ActiveState SRL. All Rights Reserved.

Entering interactive shell. Using Term::ReadLine::Stub as readline
library.

Type 'help' to get started.

ppm> search DBI
Searching in Active Repositories
Error: No valid repositories: Error: 500 Can't connect to
ppm.ActiveState.com:80 (Bad protocol 'tcp') Error: 500 Can't connect to
ppm-ia.ActiveState.com:80 (Bad protocol 'tcp')
ppm>



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




Apache::Session Error Handling.

2004-09-22 Thread Sara
Wondering how I can show custom error message if session file doesn' exist.

http://search.cpan.org/~cwest/Apache-Session/Session/File.pm

If session file doesn't exist:

using CGI::Carp qw(fatalsToBrowser);

Software error:
Object does not exist in the data store at 
/usr/share/perl5/Apache/Session/Store/File.pm line 90.Is there a way that I can use:|| 
die "Sorry, your session has expired $!";if yes, where I can use it in the code? or 
should I validate file existance separately? (-f, 
$id)?use Apache::Session::File;
 
 tie %hash, 'Apache::Session::File', $id, {
Directory => '/tmp/sessions',
LockDirectory   => '/var/lock/sessions',
 };###Thanks for any input.Sara.

Re: CPU load/server resources.

2004-07-14 Thread Sara
First of all thanks Wiggins and Alex,

For some reasons, I don't want to post the script.

Long story short, I was reading a big file using While statement that was
overloading the server. I used grep to solve this issue.

I am intent to make more changes within the script and would like to know
CPU usage/load on each step of modifying it.

Further, I think, the newbies like us should know CPU usage/load for their
developed scripts as it will help us to program better.

Okay, now again, I am on shared hosting of Ipowerweb.com. Do I have access
to /proc? Nope.

Any further help?

Any CPAN module for it? I tried to search but failed to find.

Once again thanks for your help.

Sara.



- Original Message -
From: "Wiggins d Anconia" <[EMAIL PROTECTED]>
To: "Alexander Blüm" <[EMAIL PROTECTED]>; "Sara" <[EMAIL PROTECTED]>;
<[EMAIL PROTECTED]>
Sent: Wednesday, July 14, 2004 6:41 PM
Subject: Re: CPU load/server resources.


> > On Tue, 13 Jul 2004 15:30:36 -0600
> > "Wiggins d Anconia" <[EMAIL PROTECTED]> wrote:
> >
> > > >
> > > > I had a script for which my previous host cancelled my account
> > > > saying
> > > it's a resource hog and using more than 50% resources of the server
> > > (shared hosting).
> > > >
> > > > Yep, there were some faults in the script. I modified it and they
> > > restored the account.
> > > >
> > > > But now I am looking for some script/subroutine within the script
> > > > that
> > > can give me the CPU/resource usage when the script runs?
> > > >
> > > > I have NO idea about it.
> > > >
> > > > Can anyone help me with it?
> > >
> > > This tends to be a very system dependent thing.   I find it odd that
> > > you would need to run a script in such an environment, isn't that what
> > > the hoster does?  Or are you talking about the resource usage of the
> > > script specifically?
> > >
> > > In any case, give us more information about your platform.  If it is
> > > Unix can you read from /proc?
> >
> > yes, use:
> >
> > **
> > open (F, " > # $$ is current PID
> > @content = split /\s+/, ;
> > close F;
> > print join("\n",@content), "\n";
> > **
>
> That's going to be pretty ineffective on Windows I suspect, or on a
> system either without /proc or where /proc has not been mounted.
>
> >
> > all YOU need to find out now is what what each element means... and
> > share your wisdom with us. well, I'd like to know. ;)
> >
>
> man proc
>
> http://danconia.org
>



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




CPU load/server resources.

2004-07-13 Thread Sara
I had a script for which my previous host cancelled my account saying it's a resource 
hog and using more than 50% resources of the server (shared hosting).

Yep, there were some faults in the script. I modified it and they restored the account.

But now I am looking for some script/subroutine within the script that can give me the 
CPU/resource usage when the script runs?

I have NO idea about it.

Can anyone help me with it?

Thanks in advance.

Sara.




CGI and mySQL book, any recommendation.

2004-05-28 Thread Sara
Looking to buy a comprehsive book on CGI and SQL, any recommendations.

Thanks,
Sara.



Regex Help!

2004-03-21 Thread Sara
I am looking for a regex which would extract the intials from a
string i.e.

str = "Doe, John L.L.M";

$str =~ /(^(\w)).*?((\s)(\w)).*?((\s)(\w))/;

$initial = $1.$2.$3;

print "$initial";

The above code is not serving my purpose.

String constants: There would be always 3 words (obvioulsy with 2
spaces in between) in the string however string may contain periods
(.) and (,) in it. I am looking to extract.

1. First Character of the string.
2. Next two Characters after space in the String.

Doe, John L.L.M should be "DJL"
Simth, G. M.D. should be "SGM"

Any help, please?

Thanks,
Sara.


MIME::Lite

2004-03-08 Thread Sara
 Is MIME::Lite only capable of sending email attachments present on your server?

What If I want the users to give ability to attach files from their hard drives from a 
form input.

Is there any other module for it?

Thanks,
Sara.



Comparing text text::diff

2004-03-06 Thread Sara
I asked a question a couple of days back on perl beginners at Yahoo groups as well on 
other forums.
to compare two text files/strings and to print the results if both are different and 
was advised to use Text::Diff.

Actually, I am working on project of transcription, where typist types the $text1 and 
save it. Then the QA (Quality Control) person logs in and make appropriate corrections 
to file and save it again as $text2. Now I have to compare $text1 with $text2 for the 
feedback of typist, so that he can view the changes QA made to the file and should not 
repeat the same in the next files.

So far so good, I used the Text::Diff and it solved my problem, when I tested it for 
small text containing  3 - 4 lines paragraph. Now the problem arises again. I tested 
it for 3-4 lines paragraph, but when script went live, the text strings were quite big 
like some contained 20 lines in a single paragraph. Text::Diff matches until \n || \r 
is inserted. Okay, the module is doing it's job well I have no problems with it. Now 
the problem is if only QA changes 'is' to 'was' or removes any white space character 
in 20 lines. Text::Diff prints the whole 20 lines because the changes were made. So 
sometime typist reads whole 20 lines and found nothing in it except for removal of 
white space which obviously he is unable to see or sometime only 'is' to 'was' change 
(if the file contains no other big mistakes). So instead of helping the typist to 
review the feedback from QA, it becomes a time waster.

Now, I am looking for a way where I can highlight (by enclosing changes with 
tags) the changes (if the $text2 is different from $text1) either within the 
output of Text::Diff or separately from it. 

TIA,

Sara.


-
#!/usr/bin/perl


use Text::Diff;
use strict;
use warnings;
use CGI::Carp qw(fatalsToBrowser);
use CGI;
my $q = new CGI;

my $text1 = $q->param('text1') || 'this is text line and it contains the ___ line';
my $text2 = $q->param('text2') || 'this is text line and it contains no blank line';


print $q->header();


my @output;

my $diff = diff \$text1, \$text2, { STYLE => "Context",
OUTPUT => [EMAIL PROTECTED],
CONTEXT => 0,
};

print "@output";




encrypting email address (to prevent spam)

2003-12-17 Thread Sara
Hi everyone,

I am looking for a way to encrypt & decrypt an email addy to prevent spam while 
posting a message to discussion board.

I tried to split email address;
1- 

($id,$host) = split(/\@/, "$email");

so, split it into $id and $host and later retrieve it by joining both.

But still its visible, and visitors can guess it seeing the source code or while it 
posted to script.

2-

Writing it to a pipe delimited text or db file with time of posting and email and 
later retriving it by passing the
$time to script and matching corresponding email is the second option.

$email|$time

Don't want to use this option, because the db file can get quite big, since its a high 
traffic site and one message is posted
approx every minute.

What I am looking for a way to compelety change the email addy layout by replacing it 
with unguessable alphabets and numbers or either of those and vice versa. eg.

$email = [EMAIL PROTECTED]";

using some search and replace/translate function ?

$email = "blah..3b92a98ualwetwe334...blah";

and then translating it back to email when needed.

Thanks for any input.

Sara.

Re: Bad referrer!

2003-12-07 Thread Sara
>> What are you *really* trying to do? If you are trying to add a security
>> mechanism to a set of scripts this is definitely NOT the way to do it.

Yep, I want to add the security mechanism and want to protect my work from
the vultures who
are eating up my band width.

Can you please steer me in the right direction?

Thanks for your help.

Sara.





- Original Message -
From: "Wiggins d'Anconia" <[EMAIL PROTECTED]>
To: "Sara" <[EMAIL PROTECTED]>; "beginperl" <[EMAIL PROTECTED]>
Sent: Sunday, December 07, 2003 3:20 AM
Subject: Re: Bad referrer!


> Sara wrote:
>
> > There was a script which people were using remotely, so I have to add
this
> > simple subroutine
> > to check referrers. Currently, the site is getting approx. 20,000 hits
per
> > day.
> >
>
> I don't think you are using the correct ENV variable. The referer tells
> you what page the user was linking from when they made the submission,
> which among other things is very spoofable so really shouldn't be used
> for much of anything, especially supposed security.  It can allow you
> assuming someone isn't messing with you to track a users path through a
> site, etc. but beyond that is pretty much worthless.
>
> > NO one, not even a single person claimed that they have experienced any
> > problem after
> > implementing this change, except for the owner of the site. I am
webmaster
> > for the site.
> > And now she is pushing to undo this change immediately because she is
> > constantly
> > getting &error(bad_referrer) and unable to use this script and we both
know
> > she is the only one
> > experiencing this problem.
> >
>
> Sounds like it is bookmarked or she is typing it in directly in
> whichcase there will be no referer (at least for most clients (browsers)).
>
> > Is there something wrong below? If yes, then why others are not getting
any
> > bad referrer error.
> > If no, what could be the possible reasons that owner is the only person
> > getting bad referrer error?
> >
>
> What are you *really* trying to do? If you are trying to add a security
> mechanism to a set of scripts this is definitely NOT the way to do it.
>
> > TIA,
> > Sara.
> >
> > 
> >
> >
> > @referers = ('http://www.foo.com', 'http://foo.com');
> >
>
> The above is not scoped, which means you are still not using 'strict'
> and 'warnings' which you have been warned of.
>
> > sub check_url {
> > local($check_referer) = 0;
>
> This is a misuse of 'local'.
>
> >
> > if ($ENV{'HTTP_REFERER'}) {
> > foreach $referer (@referers) {
> > if ($ENV{'HTTP_REFERER'} =~ m|$referer|i) {
> > $check_referer = 1;
> > last;
> > }
> > }
> > }
> > if ($check_referer != 1) { &error('bad_referer') }
> > }
> >
> >
> >
>
> http://danconia.org
>
> --
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
> <http://learn.perl.org/> <http://learn.perl.org/first-response>
>
>



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




Bad referrer!

2003-12-06 Thread Sara
There was a script which people were using remotely, so I have to add this
simple subroutine
to check referrers. Currently, the site is getting approx. 20,000 hits per
day.

NO one, not even a single person claimed that they have experienced any
problem after
implementing this change, except for the owner of the site. I am webmaster
for the site.
And now she is pushing to undo this change immediately because she is
constantly
getting &error(bad_referrer) and unable to use this script and we both know
she is the only one
experiencing this problem.

Is there something wrong below? If yes, then why others are not getting any
bad referrer error.
If no, what could be the possible reasons that owner is the only person
getting bad referrer error?

TIA,
Sara.




@referers = ('http://www.foo.com', 'http://foo.com');

sub check_url {
local($check_referer) = 0;

if ($ENV{'HTTP_REFERER'}) {
foreach $referer (@referers) {
if ($ENV{'HTTP_REFERER'} =~ m|$referer|i) {
$check_referer = 1;
last;
}
}
}
if ($check_referer != 1) { &error('bad_referer') }
}



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




extracting email addys.

2003-11-19 Thread Sara
$text = qq| 
This is text and it contains a couple of e-mail addresses, like [EMAIL PROTECTED] and 
[EMAIL PROTECTED]
what If I want to search for these [EMAIL PROTECTED] etc etc addresses in the text and 
perform search and replace function on those. 
|; 


Any idea as how to extract all the E-mails from the text above and performing s/@/#/; 
on all addresses at the same time?

Just want to extract email addys and want to replace @ with something un-readable by 
spam bots.

Thanks for any Regex help.

Sara.

Re: HTTP::Request

2003-11-06 Thread Sara
#!/usr/bin/perl
use CGI;
use LWP::UserAgent;

my $q = new CGI;

my $query = $q->param('query') || 'LWP';

use LWP::UserAgent;

my $ua = LWP::UserAgent->new;

my $response = $ua->get("http://search.cpan.org/search?query=$query";);

if ($response->is_success) {

my $server_response = $response->content;

print $server_response;

}





- Original Message -
From: "Tobias Fink" <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Sent: Friday, November 07, 2003 4:12 AM
Subject: HTTP::Request


> Hi,
>
> why doesn't
>
> my $ua = LWP::UserAgent->new;
> my $res = $ua->request(GET 'http://www.google.de/search', q  => 'asdasd');
> if ($res->is_success) {
>  my  $server_response = $res->content;
>  print $server_response;
> }
>
> print the html-source of http://www.google.de/search?q=asdasd ?
>
>
> Regards,
>
> Tobias
>
> --
> 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]



Delete/Archive older enteries.

2003-11-06 Thread Sara
I am trying to modify an already existing piece of code. This piece of
code -> opens a db file -> split the records (one of which is date when the
record was added) -> compare the dates with current date -> and remove all
the records if those are old enteries (as specified to remove e.g 7 days old
enteries). So the database gets updated automatically and all the old
enteries are deleted.

Now what I am trying to do is to append deleted enteries to another file
too. In case, If I need to access older enteries I can access that archived
file.

Any ideas?

Thanks for you help.

Sara.


# DB FILE #

John|06-Nov-2003
Doe|05-Nov-2003
Smith|04-Nov-2003
Sara|03-Oct-2003
Deiley|02-Oct-2003

#

#!/usr/bin/perl

use strict;
use warnings;
use CGI::Carp 'fatalsToBrowser';

use CGI;

my $q = new CGI;


my $db_file_name = 'test.txt';

my $remove = 3; # Number of days old.

my $today = &date_to_delete(&get_delete_date);

my $removeby = $today - ($remove * 86400);

open (READ, "$db_file_name") || die "unable to open DB FILE $!";

my @lines = ;

close (READ);

print $q->header();


open (DB, ">$db_file_name") || die "can't open the file again $!";

foreach my $line(@lines) {
chomp $line;
my ($name, $id);
($name, $id) = split (/\|/, $line);
if ($removeby > &date_to_delete($id)){next;}
print DB "$line\n";
}
close DB;

print "Data Updated - Old Enteries Deleted!";


sub get_delete_date {
# 
# Returns the date in the format "dd-mmm-yy".
# Warning: If you change the default format, you must also modify the
&date_to_unix
# subroutine below which converts your date format into a unix time in
seconds for sorting
# purposes.

my ($sec, $min, $hour, $day, $mon, $year, $dweek, $dyear, $daylight) =
localtime(time());
my (@months) = qw!Jan Feb Mar Apr May Jun Jul Aug Sep Oct Nov Dec!;
($day < 10) and ($day = "0$day");
$year = $year + 1900;

return "$day-$months[$mon]-$year";
}

sub date_to_delete {
# 
# This routine must take your date format and return the time a la UNIX
time().
# Some things to be careful about..
# int your values just in case to remove spaces, etc.
# catch the fatal error timelocal will generate if you have a bad date..
# don't forget that the month is indexed from 0!
#
my ($date) = $_[0];
my (%months) = ("Jan" => 0, "Feb" => 1, "Mar" => 2, "Apr" => 3, "May" => 4,
"Jun" => 5,
"Jul" => 6, "Aug" => 7, "Sep" => 8, "Oct" => 9, "Nov" => 10,"Dec" => 11);
my ($time);
my ($day, $mon, $year) = split(/-/, $_[0]);
unless ($day and $mon and $year) { return undef; }
unless (defined($months{$mon})) { return undef; }

use Time::Local;
eval {
$day = int($day); $year = int($year) - 1900;
$time = timelocal(0,0,0,$day, $months{$mon}, $year);
};
if ($@) { return undef; } # Could return 0 if you want.
return ($time);
}

##

P.S. The above two sub-routines are taken from: DBMan -
http://www.gossamer-threads.com/

#



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



Content-Length and printing

2003-11-03 Thread Sara
I am facing a problem here.

I am writing a script which will produce HTML output for printing.

I want to introduce "page-break" after a specified "Content-Length" and then it 
continues printing the remaining input.

Lets suppose after every 130 characters (supposing a 65 character line, after every 2 
lines), how can I insert



and then continue printing the remaining part?

I tried to use 'while' statement but could not think of any good solution.

Thanks in advance for any help.

Sara.

### CODE ###

$text = qq|
This is line no 1 and then it continues . and then a line break
This is line no 2 and then it continues . and then a line break
This is line no 3 and this is a long line and then it continues . and then a line 
break
This is line no 4 and then it continues . and then a line break
|;

$length = length ($text);

print qq|





$text





|;

Re: unlink help.

2003-10-29 Thread Sara
Thanks,

Thats the point, I wanted to confirm.

Sara.


- Original Message -
From: "Wiggins d Anconia" <[EMAIL PROTECTED]>
To: "Sara" <[EMAIL PROTECTED]>; "beginners-cgi"
<[EMAIL PROTECTED]>; <[EMAIL PROTECTED]>
Sent: Thursday, October 30, 2003 2:03 AM
Subject: Re: unlink help.


>
>
> >
> > unlink <*.bak>;
> >
> > how I am supposed to specify directory above?
> >
> > for example I have to apply above unlink command to delete all backup
> files in the Specified directory.
> >
> > $dir = /home/path/to/dir
> >
> > is it right?
> >
> > unlink <$dir/*.bak>;
> >
> > ??
> >
> > Any ideas?
> >
>
> The <> operator has two purposes one as a IO handle readline function
> the other as a file globber.  You are using it in the second case. You
> can read more in:
>
> perldoc perlop
>
> Specifically in the section on the <> operator and file globbing, which
> is part of the "I/O Operators" subsection.
>
> Essentially it recommends you use an explicit 'glob' in this case, so
> something like:
>
> unlink glob("$dir/*.bak");
>
> Should do the trick.  Don't forget to check for success, yada yada yada...
>
> perldoc -f glob
>
> http://danconia.org
>
>



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



unlink help.

2003-10-29 Thread Sara
unlink <*.bak>;

how I am supposed to specify directory above?

for example I have to apply above unlink command to delete all backup files in the 
Specified directory.

$dir = /home/path/to/dir

is it right?

unlink <$dir/*.bak>;

??

Any ideas?

Thanks,

Sara.



Re: quotes problem (solved).

2003-10-20 Thread Sara
:) its solved, sorry I was making a mistake.

Thank you all for prompt help.

Sara.


- Original Message -
From: "Hanson, Rob" <[EMAIL PROTECTED]>
To: "'Sara'" <[EMAIL PROTECTED]>; "beginners-cgi"
<[EMAIL PROTECTED]>
Sent: Tuesday, October 21, 2003 4:05 AM
Subject: RE: quotes problem


> I'm not sure if John or Greg from the previous answers understand the
> question... or maybe it is me that is misunderstanding it.
>
> You are receiving a string from the query string that includes quotes, but
> it isn't printing the whole value.  Correct?
>
> If that is the case, I am not sure I know where the problem is, even
though
> you say you do.
>
> For example, this works fine:
>
> my $x = 'This is the string "which" contains the quotes';
> print $x, "\n";
> print qq|
> $x
> |;
>
> Once the quote is inside the variable you don't need to do anything
special
> to print it.
>
> If you could give us an example of the query string, maybe that would
help.
> My guess would be that the query string is malformed.
>
> Rob
>
>
> -Original Message-
> From: Sara [mailto:[EMAIL PROTECTED]
> Sent: Sunday, October 19, 2003 6:56 PM
> To: beginners-cgi
> Subject: quotes problem
>
>
> ##
> use CGI;
>
> $q = new CGI;
>
> my $field = $q->param('field');
>
> print qq|
> $field
> |;
> #
>
> # Lets Suppose the form Input contains the quotes in the string e.g.
>
> $field = "This is the string "which" contains the quotes";
>
> The script stops printing everything after first quote ("), I KNOW where
the
> problem is but at a loss to prevent it as I have tried all the options
>
> Any help!!!.
>
> thanks,
>
> Sara.



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



Re: quotes problem

2003-10-20 Thread Sara
I am getting the input from a form.

Sorry but, If I Single quote the string, everything is then literal, it
Won't work if there's a variable in the string.

any other suggestion for the given below query string:

http://foo.com/test.cgi?field=this%20is%20"My"%20test%20field

Sara.


- Original Message -
From: "Hanson, Rob" <[EMAIL PROTECTED]>
To: "'Sara'" <[EMAIL PROTECTED]>; "beginners-cgi"
<[EMAIL PROTECTED]>
Sent: Tuesday, October 21, 2003 4:05 AM
Subject: RE: quotes problem


> I'm not sure if John or Greg from the previous answers understand the
> question... or maybe it is me that is misunderstanding it.
>
> You are receiving a string from the query string that includes quotes, but
> it isn't printing the whole value.  Correct?
>
> If that is the case, I am not sure I know where the problem is, even
though
> you say you do.
>
> For example, this works fine:
>
> my $x = 'This is the string "which" contains the quotes';
> print $x, "\n";
> print qq|
> $x
> |;
>
> Once the quote is inside the variable you don't need to do anything
special
> to print it.
>
> If you could give us an example of the query string, maybe that would
help.
> My guess would be that the query string is malformed.
>
> Rob
>
>
> -Original Message-
> From: Sara [mailto:[EMAIL PROTECTED]
> Sent: Sunday, October 19, 2003 6:56 PM
> To: beginners-cgi
> Subject: quotes problem
>
>
> ##
> use CGI;
>
> $q = new CGI;
>
> my $field = $q->param('field');
>
> print qq|
> $field
> |;
> #
>
> # Lets Suppose the form Input contains the quotes in the string e.g.
>
> $field = "This is the string "which" contains the quotes";
>
> The script stops printing everything after first quote ("), I KNOW where
the
> problem is but at a loss to prevent it as I have tried all the options
>
> Any help!!!.
>
> thanks,
>
> Sara.



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



quotes problem

2003-10-20 Thread Sara
##
use CGI;

$q = new CGI;

my $field = $q->param('field');

print qq|
$field
|;
#

# Lets Suppose the form Input contains the quotes in the string e.g.

$field = "This is the string "which" contains the quotes";

The script stops printing everything after first quote ("), I KNOW where the problem 
is but at a loss to prevent it as I have tried all the options

Any help!!!.

thanks,

Sara.


Truncate questions.

2003-09-13 Thread Sara
open (DB, "+

Re: Perl/Linux problem.

2003-09-11 Thread Sara
Yep, I did that, tried every single option to remove this premature end of
script headers.

Do you think it has to do something with 'gedit' text editor? because I am
scripting in this editor for the very first time.
The scripts copied from Window XP machine have no problems at all, runing
smoothly, only those are producing error which I am writing in the Linux
machine. Why?

use CGI qw(&header);
use CGI::Carp qw(fatalsToBrowser);


print &header;
print "Hello world";


-

with CGI.pm

$q->print($q->header( type => 'text/html')

--

and simply

print "Content-Type: text/html\n";

print "Hello World\n";

--


Thanks,



Sara.





- Original Message -
From: "drieux" <[EMAIL PROTECTED]>
To: "cgi cgi-list" <[EMAIL PROTECTED]>
Sent: Friday, September 12, 2003 4:31 AM
Subject: Re: Perl/Linux problem.


:
: Sara,
:
: Wiggins is right, one of the questions is what exactly
: did the Apache Error Log say was it's chief complaint.
:
: The 'premature end of script headers' suggest that your
: output does not have a content-type or there is
:  separating them.
:
: eg:
: [jeeves: 45:] test_cgi GET simple.cgi
: Content-Type: text/plain
: hello World
: [jeeves: 46:]
:
: which is not a separation from the header and the body:
:
: [jeeves: 47:] test_cgi GET simple.cgi
: Content-Type: text/plain
:
: hello World
: [jeeves: 48:]
:
: The script for that is at the end.
:
: Excuse me while I help adjust Wiggins Hair
:
: On Thursday, Sep 11, 2003, at 15:45 US/Pacific, Wiggins d'Anconia wrote:
: [..]
: >
: > Without that all the claims you make to checking everything are
: > suspect
:
: bad hair day there wiggins?
:
: THWACK! THWACK! THWACK
:
: did that help loosen up the dandruf.
:
: ciao
: drieux
:
: ---
: the simple code:
: ### #!/usr/bin/perl -w
: ### use strict;
: ###
: ### our $CRLF = "\015\012";   # "\r\n" is not portable
: ### my $type = "text/plain";
: ### print "Content-Type: $type" . $CRLF . $CRLF . "hello World"
:
:
:
: --
: 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/Linux problem.

2003-09-11 Thread Sara
Apache Error Log: "premature end of script headers"


Thanks,

Sara.

- Original Message -
From: "Wiggins d'Anconia" <[EMAIL PROTECTED]>
To: "Sara" <[EMAIL PROTECTED]>; "beginperl" <[EMAIL PROTECTED]>
Sent: Friday, September 12, 2003 3:45 AM
Subject: RE: Perl/Linux problem.


:
: ----
: On Thu, 11 Sep 2003 15:37:05 +0500, "Sara" <[EMAIL PROTECTED]> wrote:
:
: > I recently installed RH 9.0 on my machine with pre-configured Apache and
Perl.
: >
: > I made a simple script "HELLO WORLD" to check the Perl and it gave me a
continuous error for "500 Internal Server Error" and "Premature End of
Script Headers".
: >
: > I double checked the perl path, permissions, httpd.conf etc, everything
looks fine, ran the script in terminal (perl -wc)  and it produced desired
output, verified the syntax is ok and there is no problem with this 3 line
script, but in the browser it again failed to run.
: >
: > I thought another way of testing it, Using LAN (and samba) I copied a
simple script from my Windows machine to Apache and ran that script and
amazingly it ran without any problem (both in terminal and mozilla)
: >
: > So, what I have assumed that there must be some problem with scripts
that I am writing in the Linux environment. I am using text editor of Linux
(gedit) for saving the scripts. I am at a loss now as what I am doing wrong.
The simple scripts like 'Hello world' written in gedit failed to run (in
browser only) but a bit complex script imported from Windows XP is runing
smoothly?
: >
: > Do I need to change the text editor for Linux, if yes, what are the
recommendations?
: >
: > Thanks for any input.
: >
:
: What does the Apache error log have in it?  Usually that is the best way
to tell exactly waht the error is.
:
: Without that all the claims you make to checking everything are
suspect
:
: http://danconia.org


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



Perl/Linux problem.

2003-09-11 Thread Sara
I recently installed RH 9.0 on my machine with pre-configured Apache and Perl.

I made a simple script "HELLO WORLD" to check the Perl and it gave me a continuous 
error for "500 Internal Server Error" and "Premature End of Script Headers".

I double checked the perl path, permissions, httpd.conf etc, everything looks fine, 
ran the script in terminal (perl -wc)  and it produced desired output, verified the 
syntax is ok and there is no problem with this 3 line script, but in the browser it 
again failed to run.

I thought another way of testing it, Using LAN (and samba) I copied a simple script 
from my Windows machine to Apache and ran that script and amazingly it ran without any 
problem (both in terminal and mozilla)

So, what I have assumed that there must be some problem with scripts that I am writing 
in the Linux environment. I am using text editor of Linux (gedit) for saving the 
scripts. I am at a loss now as what I am doing wrong. The simple scripts like 'Hello 
world' written in gedit failed to run (in browser only) but a bit complex script 
imported from Windows XP is runing smoothly?

Do I need to change the text editor for Linux, if yes, what are the recommendations?

Thanks for any input.

Sara.




[Addendum] Stripping HTML from a text file.

2003-09-04 Thread Sara
Okay, when I finally implemented this, again its not working ... any ideas?
simple regex like s///g; is working but not this one?


#!/usr/bin/perl

use LWP::Simple;

print "Content-type: text/html\n\n";

$url = 'http://yahoo.com';

$html = get($url);

@html = split(/\n/,$html);

foreach $line(@html) {

chomp ($line);

$line =~ s|.*?<\/head>||s;

print "$line\n";

}
#



Thanks for any input.

Sara.



- Original Message -
From: "Sara" <[EMAIL PROTECTED]>
To: "Hanson, Rob" <[EMAIL PROTECTED]>; "'Wiggins d'Anconia'"
<[EMAIL PROTECTED]>
Cc: "beginperl" <[EMAIL PROTECTED]>
Sent: Wednesday, September 03, 2003 4:34 PM
Subject: Re: Stripping HTML from a text file.


: Thanks a lot Hanson,
:
: It worked for me.
:
: Yep, you are right "The regex way is good for quick and dirty HTML work."
:
: and especially for the newbies like me :))
:
: Sara.
:
:
: - Original Message -
: From: "Hanson, Rob" <[EMAIL PROTECTED]>
: To: "'Wiggins d'Anconia'" <[EMAIL PROTECTED]>; "'Sara'"
: <[EMAIL PROTECTED]>
: Cc: "beginperl" <[EMAIL PROTECTED]>
: Sent: Friday, September 05, 2003 5:55 AM
: Subject: RE: Stripping HTML from a text file.
:
:
: : > Or maybe I misunderstood the question
: :
: : Or maybe I did :)
: :
: : > HTML::TokeParser::Simple
: :
: : I agree... but only if you are looking for a strong permanant solution.
: The
: : regex way is good for quick and dirty HTML work.
: :
: : Sara, if you need to keep the  tags, then you could use this
: modified
: : version...
: :
: : # untested
: : $text = "...";
: : $text =~ s|().*?()|$1$2|s;
: :
: : ...Or if you wanted to keep the  tag...
: :
: : # untested
: : $text = "...";
: : $text =~ s|().*?.*?.*?()|$1$2$3|s;
: :
: : Rob
: :
: : -Original Message-
: : From: Wiggins d'Anconia [mailto:[EMAIL PROTECTED]
: : Sent: Thursday, September 04, 2003 8:48 PM
: : To: 'Sara'
: : Cc: beginperl
: : Subject: Re: Stripping HTML from a text file.
: :
: :
: : Won't this remove *everything* between the given tags? Or maybe I
: : misunderstood the question, I thought she wanted to remove the "code"
: : from all of the contents between two tags?
: :
: : Because of the complexity and variety of HTML code, the number of
: : different tags, etc. I would suggest using an HTML parsing module for
: : this task. HTML::TokeParser::Simple has worked very well for me in the
: : past.  There are a number of examples available. If this is what you
: : want and you get stuck on the module then come back with questions.
: : There are also the base modules such as HTML::Parser, etc. that the one
: : previously mentioned builds on, among others check CPAN.
: :
: : http://danconia.org
: :
: : Hanson, Rob wrote:
: : > A simple regex will do the trick...
: : >
: : > # untested
: : > $text = "...";
: : > $text =~ s|.*?||s;
: : >
: : > Or something more generic...
: : >
: : > # untested
: : > $tag = "head";
: : > $text =~ s|<$tag[^>]*?>.*?||s;
: : >
: : > This second one also allows for possible attributes in the start tag.
: You
: : > may need more than this if the HTML isn't well formed, or if there are
: : extra
: : > spaces in your tags.
: : >
: : > If you want something for the command line you could do this...
: : >
: : > (Note: for *nix, needs modification for Win [untested])
: : > perl -e '$x=join("",<>);$x=~s|.*?||s' myfile.html >
: : > newfile.html
: : >
: : > Rob
: : >
: : >
: : > -Original Message-
: : > From: Sara [mailto:[EMAIL PROTECTED]
: : > Sent: Wednesday, September 03, 2003 6:32 AM
: : > To: beginperl
: : > Subject: Stripping HTML from a text file.
: : >
: : >
: : > I have a couple of text files with html code in them.. e.g.
: : >
: : > -- Text File --
: : > 
: : > 
: : > This is Test File
: : > 
: : > 
: : > This is the test file contents
: : > 
: : > blah blah blah.
: : > 
: : > 
: : >
: : > -
: : >
: : > What I want to do is to remove/delete HTML code from the text file
from
: a
: : > certain tag upto certain tag.
: : >
: : > For example; I want to delete the code completely that comes in
between
: : >  and  (including any style tags and embedded javascripts
: etc)
: : >
: : > Any ideas?
: : >
: : > Thanks in advance.
: : >
: : > Sara.
: : >
: :
: :
: : --
: : 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]



Re: Stripping HTML from a text file.

2003-09-04 Thread Sara
Thanks a lot Hanson,

It worked for me.

Yep, you are right "The regex way is good for quick and dirty HTML work."

and especially for the newbies like me :))

Sara.


- Original Message -
From: "Hanson, Rob" <[EMAIL PROTECTED]>
To: "'Wiggins d'Anconia'" <[EMAIL PROTECTED]>; "'Sara'"
<[EMAIL PROTECTED]>
Cc: "beginperl" <[EMAIL PROTECTED]>
Sent: Friday, September 05, 2003 5:55 AM
Subject: RE: Stripping HTML from a text file.


: > Or maybe I misunderstood the question
:
: Or maybe I did :)
:
: > HTML::TokeParser::Simple
:
: I agree... but only if you are looking for a strong permanant solution.
The
: regex way is good for quick and dirty HTML work.
:
: Sara, if you need to keep the  tags, then you could use this
modified
: version...
:
: # untested
: $text = "...";
: $text =~ s|().*?()|$1$2|s;
:
: ...Or if you wanted to keep the  tag...
:
: # untested
: $text = "...";
: $text =~ s|().*?.*?.*?()|$1$2$3|s;
:
: Rob
:
: -Original Message-
: From: Wiggins d'Anconia [mailto:[EMAIL PROTECTED]
: Sent: Thursday, September 04, 2003 8:48 PM
: To: 'Sara'
: Cc: beginperl
: Subject: Re: Stripping HTML from a text file.
:
:
: Won't this remove *everything* between the given tags? Or maybe I
: misunderstood the question, I thought she wanted to remove the "code"
: from all of the contents between two tags?
:
: Because of the complexity and variety of HTML code, the number of
: different tags, etc. I would suggest using an HTML parsing module for
: this task. HTML::TokeParser::Simple has worked very well for me in the
: past.  There are a number of examples available. If this is what you
: want and you get stuck on the module then come back with questions.
: There are also the base modules such as HTML::Parser, etc. that the one
: previously mentioned builds on, among others check CPAN.
:
: http://danconia.org
:
: Hanson, Rob wrote:
: > A simple regex will do the trick...
: >
: > # untested
: > $text = "...";
: > $text =~ s|.*?||s;
: >
: > Or something more generic...
: >
: > # untested
: > $tag = "head";
: > $text =~ s|<$tag[^>]*?>.*?||s;
: >
: > This second one also allows for possible attributes in the start tag.
You
: > may need more than this if the HTML isn't well formed, or if there are
: extra
: > spaces in your tags.
: >
: > If you want something for the command line you could do this...
: >
: > (Note: for *nix, needs modification for Win [untested])
: > perl -e '$x=join("",<>);$x=~s|.*?||s' myfile.html >
: > newfile.html
: >
: > Rob
: >
: >
: > -Original Message-
: > From: Sara [mailto:[EMAIL PROTECTED]
: > Sent: Wednesday, September 03, 2003 6:32 AM
: > To: beginperl
: > Subject: Stripping HTML from a text file.
: >
: >
: > I have a couple of text files with html code in them.. e.g.
: >
: > -- Text File --
: > 
: > 
: > This is Test File
: > 
: > 
: > This is the test file contents
: > 
: > blah blah blah.
: > 
: > 
: >
: > -----
: >
: > What I want to do is to remove/delete HTML code from the text file from
a
: > certain tag upto certain tag.
: >
: > For example; I want to delete the code completely that comes in between
: >  and  (including any style tags and embedded javascripts
etc)
: >
: > Any ideas?
: >
: > Thanks in advance.
: >
: > Sara.
: >
:
:
: --
: 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]



Stripping HTML from a text file.

2003-09-04 Thread Sara
I have a couple of text files with html code in them.. e.g.

-- Text File --


This is Test File


This is the test file contents

blah blah blah.



-

What I want to do is to remove/delete HTML code from the text file from a certain tag 
upto certain tag.

For example; I want to delete the code completely that comes in between  and 
 (including any style tags and embedded javascripts etc)

Any ideas?

Thanks in advance.

Sara.

Defining Return-path.....

2003-09-02 Thread Sara
Hi to all

I am using a simple form script in which users can send mail to other users using 
"FROM" and "TO" mail addresses.
But when a TO address is invalid the failure delivery goes by default to 'Return-path' 
owner of the cgi ([EMAIL PROTECTED])

Is there a way that we can define Return-path from the script or any other 
alternatives that failure deliveries should go to
'FROM' or anyother specified address (preferably defining something within the script)

I tried to this, but no results. 

print MAIL "Return-path: <$email>\n";
print MAIL "To: $recip\n";
print MAIL "Reply-to: $email\n";
print MAIL "From: $email\n";

Thanks in advance,

Sara.




Defining Return-path ...

2003-09-02 Thread Sara
Hi to all

I am using a simple form script in which users can send mail to other users using 
"FROM" and "TO" mail addresses.
But when a TO address is invalid the failure delivery goes by default to 'Return-path' 
owner of the cgi ([EMAIL PROTECTED])

Is there a way that we can define Return-path from the script or any other 
alternatives that failure deliveries should go to
'FROM' or anyother specified address (preferably defining something within the script)

I tried to this, but no results. 

print MAIL "Return-path: <$email>\n";
print MAIL "To: $recip\n";
print MAIL "Reply-to: $email\n";
print MAIL "From: $email\n";

Thanks in advance,

Sara.




Formatting integer input

2003-08-21 Thread Sara
$one = 2.5;
$two = 2;
$three = $one + $two;

print "$three"; # prints 4.5

I want 4.5 in proper format as 04.05

Any ideas?

Thanks,
Sara.

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]



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]



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.

 


Flock Test...

2003-07-31 Thread Sara
What could be the simplest test to check 'flock' working on your server or not?

except for writing to support team of host ::))

Thanks for any input.

Sara.

Re: .htaccess

2003-07-26 Thread Sara
Use HTTP_REFREER in your scripts which you want to prevent from other
domains.

It will check the input coming from which domain. Allow selected domains and
disallow all others.

Alternatively, there are a lot of javascripts for this purpose also. One I
used was ... hm, go to:

http://javascript.internet.com

and put "Must Come From" in the search box there, and hopefully it will come
up with the script.

Thanks,

Sara.


- Original Message -
From: awarsd <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Sent: Thursday, July 24, 2003 4:27 PM
Subject: .htaccess


> Hello,
>
> I'm curious i read somewhere with .htaccess we can block user to do
hotlinks
> in both ways etc...
> But my question is a bit different it is possible with .htaccess to forbid
> forms that comes from a different domain? so no hacking
>
>
> Thank You
>
>
>
> --
> 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]



Another Regex question.

2003-07-23 Thread Sara
$TS = "THIS INPUT IS IN ALL CAPS";

$TS_cont = lc $TS;

$TS now prints out "this input is in all caps"

What If I want first letter in caps for every word in string? which should be "This 
Input Is In All Caps"

TIA,

Sara.







Bolding and Underlining.

2003-07-21 Thread Sara
I have an input coming from scrolling textbox eg.

$description = qq~
This is my description. Here goes a couple of headings in it
Heading abc: 
this is the heading one and needs to bold and underlined
Heading xyz: 
needs to bold and underlined too.
description continues here
~;

I am producing HTML files from input. I need to underline and make bold these headings 
when the output is 
generated. Any ideas how to extract and make the changes in headings only for output?

The two definate markers for these headings are there is always a line break before 
and after the heading and it always contains the colon at the end :

Thanks for any input

Sara.




Regex problem

2003-07-20 Thread Sara
$name = "SARA DEILEY";

how its possible to grasp only initials for First and Last name i.e $name ="SD"??

thanks.


Comparing two text files.

2003-07-12 Thread Sara
## 

open (DATA, "data.txt") || die "Cannot open file. Reason: $!"; 
@data = ; 
close(DATA); 

open (LIST, "list.txt") || die "Cannot open list.txt. Reason: $!"; 
while () { 
$found = 0; 

foreach $line (@data) { 
chomp $line; 
if ($line eq $_) { $found = 1; last; } 
$found = 0; 
} 

if ($found) { 
print "Entry \"$_\" was found in data.txt "; 
} 
else 
{ 
print "Entry \"$_\" was NOT found in data.txt "; 
} 
} 

# 

list.txt (contains 3 enteries) 
## 
file1.html 
file3.html 
file2.html 
## 

data.txt (contains 2 enteries) 
## 
file3.html 
file1.html 
## 


The script is generating the following output

Entry "file1.html " was NOT found in data.txt 
Entry "file3.html " was NOT found in data.txt 
Entry "file2.html " was NOT found in data.txt 

though, file1.html and file2.html exists in data.txt 

Any ideas what I m doing wrong?

I want to compare both text files and the script should produce that this. i.e after 
comparing the file nos. it should report which file is found and which is not found.

file1.html was found in the data.txt
file2.html was NOT found in the data.txt
file3.html was foundi in the data.txt

TIA,

Sara.



Net::FTP

2003-07-10 Thread Sara
#!/usr/bin/perl -w

use strict;
use warnings;
use CGI::Carp 'fatalsToBrowser';
use CGI qw/:standard/;
use Net::FTP;



my $ftp = Net::FTP->new("ftp.yourserver.com", Debug => 0)
or die "Cannot connect to some.host.name: $@";

$ftp->login("username",'password')
or die "Cannot login ", $ftp->message;

$ftp->cwd("/")
or die "Cannot change working directory ", $ftp->message;

my @Directory = $ftp->dir("/path/to/directory");
print "@Directory";

$ftp->quit;


I am using the following to login to remote FTP;
and its working fine and I am getting the list of files from remote FTP from my 
desired directory but;

- The script is working fine in my Window IDE and giving an Internal Server Error 
(without any error message) while on my Host.

- its returning @Directory in long format 
"-rw-r--r-- 1 username username 8654 Jul 5 18:20 test.html"
Is it possible to get file names only like test.html


and how to provide $Directory in the script given below because above is an array 
context @Directory?

because after getting the list of files from the directory above I want to 
match/compare the file names with a text list on my server, see below.

###
$my Directory = ".";

if ( open( NO, 'data.txt' ) )
{
while (  )
{
chomp;
# Optional: Add check for blank/incomplete lines.

if ( -f "$Directory/$_" )
{
print "File '$_' exists in '$Directory'.\n";
# Optional: Add file to 'exists' list for later reporting.
}
else
{
print "File '$_' does NOT exist in '$Directory'.\n";
# Optional: Add file to 'not exists' list for later reporting.
}
}
close( NO );
}
else
{
print "ERROR: Unable to open file: $!\n";
}



Thanks,

SARA.






Re: split function problem.

2003-07-09 Thread Sara
I am extremely thankful to you for your help.

I always loved your way of teaching and explaining the code bit by bit.

One more question I searched the google for "HTH" abbreviation but didn't
find anything.

Can you tell me what does it mean?

Thanks,

Sara, :))


- Original Message -
From: Charles K. Clarkson <[EMAIL PROTECTED]>
To: 'Sara' <[EMAIL PROTECTED]>; 'org' <[EMAIL PROTECTED]>
Sent: Wednesday, July 09, 2003 6:30 AM
Subject: RE: split function problem.


> Sara <[EMAIL PROTECTED]> wrote:
> :
> : An input string like;
> :
> : $name_with_id = "Deiley, Sara Jr., 1234";
> :
> : another example could be
> :
> : $name_with_id = "DEILEY SARA, Jr,. 123";
> :
> : Two things are for sure in it always.
> :
> : 1- First part contains the alphabets (caps or small) with any
> : number of commas and periods (full stops) in between or at the end.
> :
> : and then always a white space, followed by:
> :
> : 2- the last part contains the digit/number which could be 2 -
> : 5 digits long.
>
>
> : I am trying this;
> :
> : $name_with_id = "Deiley, Sara Jr., 1234";
> :
> : split (/[^\d]+/, $name_with_id) = ($name,$id);
>
> [^\d]+ will match anything that is *not* a
> digit. and appears more that one time in the
> search string. In our example string, it splits
> on: "Deiley, Sara Jr., ". All of which is not a
> digit.
>
> To find the last part we could use: \d{2,5}
> William of Occam gave pretty good advice:
> "Entities should not be multiplied unnecessarily."
>
>
> : print "name: $name and ID: $id";
> :
> : Error: Can't modify split in scalar assignment at line 3;
>
> Unlike 'substr', split can only be on the right
> side of an equation. If you set split equal to
> something, you'll get the error above. So this
> would seem more logical:
>
> my ($name,$id) = split (/\d{2,5}/, $name_with_id);
>
> The problem is that split discards the
> part we're looking for: \d{2,5} unless we
> place it in parenthesis.
>
> my( $name, $id ) = split / (\d{2,5})/, $name_with_id;
>
> This should throw away the space and keep the
> digits:
>
> use strict;
> use warnings;
> use Data::Dumper;
>
> my $name_with_id = "Deiley, Sara Jr., 1234";
>
> print Dumper [ split / (\d{2,5})$/, $name_with_id ];
>
> __END__
>
> HTH,
>
> Charles K. Clarkson
> --
> Head Bottle Washer,
> Clarkson Energy Homes, Inc.
> Mobile Home Specialists
> 254 968-8328
>
>
>
>
>



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



Reading and comparing files from a directory

2003-07-09 Thread Sara
I m trying to read the files in a directory and match them with a same file names in 
text list.

Below given are the couple of lines, but I am unable to get the results, rather 
getting the same line repeated

This fileno1 does NOT found in directory but its in the list
This fileno2 does NOT found in directory but its in the list
This fileno3 does NOT found in directory but its in the list


and so on

So its matching the file names but not giving the desired results?

Any idea?

###

open (NO, "list.txt");# A list that contains the file numbers in a txt file, 
one per line
@temp = ;
foreach $lines(@temp){
chomp $lines;
}

$dir = "Test";#Directory we are opening to match the files in the directory 
with the above given list.

opendir (DH, $dir) || die ("could not open directory $dir\n");
foreach $file (sort readdir (DH))
{
if ($file eq $lines) {

print "This $file exists and found in the list too $lines";

}

else {
print "This $file does NOT found in directory but its in the list";
}


}
close (DH);

###




Re: split function problem.

2003-07-09 Thread Sara
First of all thanks for your prompt reply.

its not just the comma separated list, it contains sometimes comma in the
middle of name and sometime

at the end of name.

I am looking for some Regex in the split function to separate both fields.

thanks,

Sara.


- Original Message -
From: frbn <[EMAIL PROTECTED]>
To: Sara <[EMAIL PROTECTED]>
Cc: org <[EMAIL PROTECTED]>
Sent: Tuesday, July 08, 2003 11:49 PM
Subject: Re: split function problem.


> hi,
> $name_with_id looks like a comma separated list
> you can simply *not tested*:
>
> ($name,$id) = split (/,/, $name_with_id)
>
> --
>
> franck
>
>
> Sara wrote:
> > An input string like;
> >
> > $name_with_id = "Deiley, Sara Jr., 1234";
> >
> > another example could be
> >
> > $name_with_id = "DEILEY SARA, Jr,. 123";
> >
> > Two things are for sure in it always.
> >
> > 1- First part contains the alphabets (caps or small) with any number of
commas and periods (full stops) in between or at the end.
> >
> > and then always a white space, followed by:
> >
> > 2- the last part contains the digit/number which could be 2 - 5 digits
long.
> >
> > What I am trying to do is to split this string in two parts
> > first part with alphatbets and second part with digits separately
> >
> > and assign them to two new variables i.e $name and $id.
> >
> > I am trying this;
> >
> > $name_with_id = "Deiley, Sara Jr., 1234";
> >
> > split (/[^\d]+/, $name_with_id) = ($name,$id);
> >
> > print "name: $name and ID: $id";
> >
> > Error: Can't modify split in scalar assignment at line 3;
> >
> > Any help or alternative way to do this.
> >
> > Thanks,
> >
> > Sara.
> >
> >
> >
> >
> >
> >
>
>
>
>
> --
> 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]



split function problem.

2003-07-08 Thread Sara
An input string like;

$name_with_id = "Deiley, Sara Jr., 1234";

another example could be

$name_with_id = "DEILEY SARA, Jr,. 123";

Two things are for sure in it always.

1- First part contains the alphabets (caps or small) with any number of commas and 
periods (full stops) in between or at the end.

and then always a white space, followed by:

2- the last part contains the digit/number which could be 2 - 5 digits long.

What I am trying to do is to split this string in two parts
first part with alphatbets and second part with digits separately

and assign them to two new variables i.e $name and $id.

I am trying this;

$name_with_id = "Deiley, Sara Jr., 1234";

split (/[^\d]+/, $name_with_id) = ($name,$id);

print "name: $name and ID: $id";

Error: Can't modify split in scalar assignment at line 3;

Any help or alternative way to do this.

Thanks,

Sara.

 





Counting the characters..

2003-07-06 Thread Sara
There is a form field 'description' which is the input for CGI script.

$description = "This is my description and it contains numerous __ double underscore 
marks and __ these marks some special area in the field"

What I want to do is to count/extract the amount of times these double underscore 
marks are used. Like in the above example it should show that 2 marks are found.


$description =~ m/__/;

whats next???





Regex question.

2003-06-30 Thread Sara
I have a database with the following fields.

lname fnam M acct# mrmbirth Postdate  Post#   drln 
drfn m disch
DOE,JOHN,R,00037839842,207337,02151956,04072003,01980,LastName,FirstName,L,04102003

I have a very simple script which splits the delimiter , and shows the result in the 
same format as in database.
I want to do following things using regex, but I have tried my options to my level 
best, ::) no results yet,

1- Remove all the leading 000 from any field like acct# = 00037839842 should be 
37939842 and Post# should be 1980

2- Want to format dates like birth = 02151956 should be 02/15/1956

Any help??

Thanks,

Sara.



require "config.txt"

2003-06-01 Thread Sara
How to call the variables from the config file using CGI. pm?

#!/usr/bin/perl

use CGI;
my $q = new CGI;

require "config.txt";

print "Variables_from_the_config_file"; 

???

Thanks,

Sara.




Looking for form mail attachment script.

2003-05-31 Thread Sara


I am looking for a pre-written CGI Form script, which is capable of sending mails with 
attachment from my desktop etc.

I have seen an example of this script sometimes back in the group.

Any ideas?

TIA,

Sara.


Looking for form mail attachment script.

2003-05-31 Thread Sara
I am looking for a pre-written CGI Form script, which is capable of sending mails with 
attachment from my desktop etc.

I have seen an example of this script sometimes back in the group.

Any ideas?

TIA,

Sara.


Final IP ban subroutine.

2003-05-27 Thread Sara
ed Forum IP check subroutine ##

open IP, '/home/ipban.txt';

 foreach $line () {
  chomp($line);
($ipban,$subject) = split(/\|/,$line);
next unless $ipban eq $current_ip;
  &error(bad_ip);
last;
  }
####

SECOND:
I have just started using CGI.pm, its probably my second or third 
script using CGI.pm and I have no idea how to split the IPban.txt 
and put the variables IPs and Subject line like this:


$ipban | $subject

Currently I am getting the output like this:
$ipban

see the make_form; subroutine above.

Thanks for any input, for integrating the subject line in already 
existing script for banning IPs of BBS.


Thanks,

Sara.