KevinADC 192 Practically a Posting Shark

i typed a simple perl programme to print the elements of an array in a text file and saved it in the same location like earlier. and tried to compile it via command prompt just like earlier. but i can't get any result. and it's saying can't open perl script and there is no such file or directory.

lets see the code you typed and the commands you typed on the command line

KevinADC 192 Practically a Posting Shark

You have to use the -e switch to execute code from the command line:

perl -e "print \"Hello World\";"

KevinADC 192 Practically a Posting Shark

I understand that you say you have setup Tomcat to run CGI scripts, but it appears you did not set it up correctly. Since this is really a Tomcat configuration issues maybe asking on a Tomcat forum will get you the info you need.

Does Tomcat use the ubiquitous cgi-bin? Are your scripts in the cgi-bin? Have you tried .cgi and .pl?

KevinADC 192 Practically a Posting Shark

http://search.cpan.org/~miyagawa/Email-Find-0.10/lib/Email/Find.pm

You should remove that personal information from your post.

KevinADC 192 Practically a Posting Shark

I was going to suggest a BEGIN{} block too. Perl will compile a BEGIN{} block as soon a possible so it should work.

KevinADC 192 Practically a Posting Shark

On second thought, forget my post. I have no idea why I even bothered to post in this thread, it just seems like such a non-issue that I am surprised anyone would care. But everyone is different, so if the bad rep has you confused or upset, so be it.

I'm out of this thread. Have a good one Christina, and really, don't worry about it or even think about it.

christina>you commented: I know no one cares... but thanks for posting anyway. Have a good day. +18
KevinADC 192 Practically a Posting Shark

Why do you even care? But it seems obvious:

B*tch? Thanks for the good laugh!

Does the above rep from you look familiar?

KevinADC 192 Practically a Posting Shark

You will want to look into WWW::Mechanize if you intend to use perl.

http://search.cpan.org/author/PETDANCE/WWW-Mechanize-1.30/lib/WWW/Mechanize.pm
http://search.cpan.org/author/PETDANCE/WWW-Mechanize-1.30/lib/WWW/Mechanize/Examples.pod
http://search.cpan.org/author/PETDANCE/WWW-Mechanize-1.30/lib/WWW/Mechanize/FAQ.pod


There are also some modules written for gathering stock data.

http://search.cpan.org/~hampton/Finance-Quote-1.13/lib/Finance/Quote.pm

I have never used any of the above modules so I can't really help much more than I already have.

this will most likely be very difficult for you unless you already have solid perl experience and know how to install the modules.

KevinADC 192 Practically a Posting Shark

no:

"When I click the link to go to the second page of code snippets in the perl category"

by that I mean the pages of the thread:

page 1 of 1 1>2>next

But it is working now. 10 snippets on page one, 4 snippets on page two, for a total of 14 snippets.

Dani either fixed it or was working on it or it was just a glitch.

Kevin

KevinADC 192 Practically a Posting Shark

When I click the link to go to the second page of code snippets in the perl category, I get an error message instead of seeing more code snippets:

"No code snippets available with the criteria specified. "

KevinADC 192 Practically a Posting Shark

Please let me know if I am going down the wrong path here.

Honestly, I don't know. system() does fork off a new process, but the parent waits for the child process. So maybe it can initiate multiple instances of the same process. See the system() function docs for details:

http://perldoc.perl.org/functions/system.html

KevinADC 192 Practically a Posting Shark

I'm pretty sure system() waits until the process ends to return to the perl script. So I doubt your loop is running multiple instances of the process, but it could still be bogging down the computer since you run it over and over. How many loops does it run through?

KevinADC 192 Practically a Posting Shark

File::Path and the rmtree function sounds like the way to go if you stick with perl. There isn't much o understand, load the module into your scrip:

use File::Path;

and feed the rmtree() function the name of a directory you wat to wipe out.

rmtree('some_directory');

You can probably feed it a list of directories too.

http://perldoc.perl.org/File/Path.html

KevinADC 192 Practically a Posting Shark

I thought maybe you were unaware of the replies on the other forum and I was just directing you to look there. <deleted - keep it clean>

KevinADC 192 Practically a Posting Shark

You have this question posted on another forum where it has replies.

KevinADC 192 Practically a Posting Shark

OK, sorry, but I have no clue what is causing the problem you are having.

KevinADC 192 Practically a Posting Shark

it will be in the http server error logs but most likely will not help much. But look in the apache folder, find the logs folder and find the error file.

EnderX commented: Thank you. +3
KevinADC 192 Practically a Posting Shark

grasping at straws...... try sleep():

$count = 100;
#print $mech -> content;
for ($count = 100; $count <= 500; $count++)
{
print "$count</br> ";

$purl =

"http://www.website.com/servlet/Servlet?pdf=abc$count.pdf";

$mech->get( $purl, ":content_file" => "d:/Devesh/abc$count.pdf");
print "downloading abc$count.pdf</br>";
[B]sleep(1);[/B]
#print $mech->content;
#print "after......</br>";
#print "save $count done</br>";

}
KevinADC 192 Practically a Posting Shark

try this maybe:

$count = 200;
#print $mech -> content;
for ($count = 200; $count <= 500; $count++)
{

which will start the file download at 200 instead of 100. See what happens.

KevinADC 192 Practically a Posting Shark

my $unc = '\\\\somebox.somehost.com\someshare';

KevinADC 192 Practically a Posting Shark

Can we see the script or is this going to be a guessing game?

KevinADC 192 Practically a Posting Shark

Nearly all FTP applications silently convert the line endings when you upload a file from a local computer to a remote computer. So if you upload from windows to Unix or Linux there should be nothing to worry about. You should upload in ASCII (text) mode though for text files.

Some FTP applications you choose the remote computer type from a list and some do the checking automatically and convert the line endings as needed.

KevinADC 192 Practically a Posting Shark

thats because google does not allow you to do what you are trying to do. If you want to hit google use their API.

KevinADC 192 Practically a Posting Shark

have you tried:

write MAIL;


where MAIL is the currently opened filehandle that prints the email message.

KevinADC 192 Practically a Posting Shark

Start a new thread, it is not polite to ask a new question in a thread another person has started.

KevinADC 192 Practically a Posting Shark

I think you have posted in the wrong forum, this is the perl forum. Post your question in the appropriate shell scripting forum if there is one.

KevinADC 192 Practically a Posting Shark

Didn't like my suggestion?

KevinADC 192 Practically a Posting Shark

I'm going to pass on helping you.

KevinADC 192 Practically a Posting Shark

Is this school work? Do you this question posted on other perl forums? Whats the purpose of including the resID if it's not being used in the output?

KevinADC 192 Practically a Posting Shark

Use a hash to compare the lines.

use strict;
use warnings;

my $f1 = 'E:\upload\new\2.txt';
my $f2 = 'E:\upload\new\a.txt';
my $outfile = 'E:\upload\new\1.txt';
my %results = ();

open FILE1, "$f1" or die "Could not open file: $! \n";
while(my $line = <FILE1>){
   $results{$line}=1;
}
close(FILE1);

open FILE2, "$f2" or die "Could not open file: $! \n";
while(my $line =<FILE2>) {
   $results{$line}++;
}
close(FILE2);


open (OUTFILE, ">$outfile") or die "Cannot open $outfile for writing \n";
foreach my $line (keys %results) {
   print OUTFILE $line if $results{$line} == 1;
}
close OUTFILE;

There are also some perl modules that will compare files, or you can use the operating system commands Salem mentions.

KevinADC 192 Practically a Posting Shark

Don't be confused, @ARGV is just an array, you can also use it like I showed.

KevinADC 192 Practically a Posting Shark

\s+ just means: one or more spaces.

KevinADC 192 Practically a Posting Shark

We haven't seen that.

Is this school work?

KevinADC 192 Practically a Posting Shark

I confused a little...

I don't know these :

local @ARGV = ($file);
local $^I = '.bak';
split(/\s+/) (what's the meaning of \s+???)

We haven't seen that.Can you explain me with seek usage??

Below quoted from: http://perldoc.perl.org/perlvar.html

# ARGV

The special filehandle that iterates over command-line filenames in @ARGV . Usually written as the null filehandle in the angle operator <> . Note that currently ARGV only has its magical effect within the <> operator; elsewhere it is just a plain filehandle corresponding to the last file opened by <> . In particular, passing \*ARGV as a parameter to a function that expects a filehandle may not cause your function to automatically read the contents of all the files in @ARGV .
# $ARGV

contains the name of the current file when reading from <>.
# @ARGV

The array @ARGV contains the command-line arguments intended for the script. $#ARGV is generally the number of arguments minus one, because $ARGV[0] is the first argument, not the program's command name itself. See $0 for the command name.
# ARGVOUT

The special filehandle that points to the currently open output file when doing edit-in-place processing with -i. Useful when you have to do a lot of inserting and don't want to keep modifying $_. See perlrun for the -i switch.

# $INPLACE_EDIT
# $^I

The current value of the inplace-edit extension. Use undef to disable inplace editing. (Mnemonic: …

KevinADC 192 Practically a Posting Shark

It would be simpler to use perls inplace editor for this type of task;

sub edit {
    my $file = 'path/to/file.txt';
    print "Enter the person's name and surname which you'll update the record: ";
    chomp($dest = <STDIN>);
    my ($name, $surname) = split(/\s+/,$dest);
    print "Enter new phone number: ";
    chomp($newNum = <STDIN>);
    local @ARGV = ($file);
    local $^I = '.bak';
    my $found = 0;
    while(<>)
    {
            my @array = split(/\s+/);
            if($name eq $array[0] && $surname eq $array[1]){
               print "$array[0] $array[1] $newNum\n";
               $found = 1;
            }    
            else {
               print;
            }
    }
    unless($found){
       print"Record doesn't exist!!!\n";
    }
}
KevinADC 192 Practically a Posting Shark

in the code I posted, change this line:

print qq~( $long, $lat, time(), $omschrijving, $longneg, $latneg )~;

to:

$sth->execute( $long, $lat, time(), $omschrijving, $longneg, $latneg );
Sulley's Boo commented: ^,^ +3
KevinADC 192 Practically a Posting Shark

I may have figured it out, try this in place of your existing perl script:

#!/usr/bin/perl -wT
#   popchecker.pl


use warnings;
use lib 'd:/www/criens.nl/sailmailscript';
use Mail::POP3Client;
use DBI;
#
$pop3user   = 'mailaddress@criens.nl';
$pop3pass   = 'password';
$pop3host   = "pop.criens.nl";
#
$pop = new Mail::POP3Client( USER => $pop3user, 
              PASSWORD => $pop3pass,
              DEBUG     => 1,
              AUTH_MODE => PASS,
              HOST => $pop3host ) || die "Can't connect";

my $checked = 0;


sub storeurl
{
    my $long          = $_[0];
    my $lat           = $_[1];
    my $omschrijving  = $_[2];
    my $longneg       = $_[3];
    my $latneg        = $_[4];

    my $headers       = shift;
    my $dbhostname    = 'mysql.criens.nl';
    my $dbuser        = 'datebase username';
    my $dbpwd         = 'database password';
    my $dbbase        = 'database name';
    my $dbtabel       = 'longlat';
    my $sql           = "INSERT INTO longlat (longitude, latitude, tijd, omschrijving, longneg, latneg) 
       VALUES (?, ?, ?, ?, ?, ?)";

    my $dbh = DBI->connect( 'dbi:mysql:' . $dbbase, $dbuser,
       $dbpwd, { RaiseError => 1 }) || die
                "Database connection not made: $DBI::errstr";

    my $dbh = DBI->connect ("DBI:mysql:host=mysql.criens.nl;database=name", "name", "password", {PrintError => 0, RaiseError => 1});

    my $sth = $dbh->prepare( $sql );
    print qq~( $long, $lat, time(), $omschrijving, $longneg, $latneg )~;
    $dbh->disconnect();
}

sub main
{
    my $find;
    my $url;
    my $i;
    my $longi;
    my $lati;
    my $longitude;
    my $latitude;
    my $omschrijving;
    my $longneg = 0;
    my $latneg = 0;
    
    
    for ($i = 0 ; $i <= $pop->Count(); $i++) 
     {
         my @FOO = $pop->Body( $i );
         $longi = 0;
         $lati = 0;
         my $blog = 0;
             foreach $line (@FOO)
             {

                 if ($line =~ /\[b\]/){
                     $blog …
KevinADC 192 Practically a Posting Shark

I maybe can help if you can clarify what the problem is in more detail. This makes no sense to me:

Here is where the problem lies. The message "b" in brackets is not taken out of the entire mailmessage and the database field is empty.

KevinADC 192 Practically a Posting Shark

The easiest or the best or a compromise?

The easiest: open the files one at a time and use whatever method works for finding what ever it is you are searching for.

The best: store the data in a database.

A compromise: index the site and search only the index file that would point to the documents where the content can be found.

KevinADC 192 Practically a Posting Shark

That version of perl should support the use of back references.

KevinADC 192 Practically a Posting Shark

Thanks csgal, your edits are correct.

KevinADC 192 Practically a Posting Shark

new snippets appear to be OK, this test can be deleted:

http://www.daniweb.com/code/snippet706.html

KevinADC 192 Practically a Posting Shark

these snippets need to be edited to change all instances of double back-slashes (\\) to single back-slashes (\)

http://www.daniweb.com/code/snippet550.html
http://www.daniweb.com/code/snippet549.html
http://www.daniweb.com/code/snippet541.html

KevinADC 192 Practically a Posting Shark

seems to be OK here though:

my $string = '  Mary had a little lamb.  ';
$string =~ s/^\s+//; #remove leading spaces
$string =~ s/\s+$//; #remove trailing spaces
print $string;
KevinADC 192 Practically a Posting Shark

well it appears to add an extra \:

my $string = ' Mary had a little lamb. ';
$string =~ s/^\\s+//; #remove leading spaces
$string =~ s/\\s+$//; #remove trailing spaces
print $string;

should be (and it was)

my $string = ' Mary had a little lamb. ';
$string =~ s/^\s+//; #remove leading spaces
$string =~ s/\s+$//; #remove trailing spaces
print $string;

KevinADC 192 Practically a Posting Shark

I had a need to read one of the code snippets I posted a while back (perl) and noticed the syntax highlighter has screwed up the code I posted by adding an extra backslash making the snippet no good. I thought I would just try and edit the snippet but there is no longer an edit link like there used to be. What to do?

KevinADC 192 Practically a Posting Shark

If you ask me, zero :) In all seriousness, I am going to sleep on the best way to handle color moving forward while still preserving the time people put into coloring their posts. I have to head off to sleep now though ...

LOL. I think thats a good idea.

KevinADC 192 Practically a Posting Shark

I want everyone to not color things blue, or bright pink, or pale grey, or any other crazy color combination just for the sake of wanting to use the color palette. If there has to be color, I want to be in control of what colors won't negatively affect the work I've put into DaniWeb.

I can gaurantee, you or the only member of this forum that thinks that colored text in posts somehow interfers or negatively affects the design of Daniweb.

Honestly, you're starting to sound a little over caffienated. Go to sleep. Your pillow is calling to you, sleep.....sleeep.......sleeeeeepppppp.........

KevinADC 192 Practically a Posting Shark

My honest opinion is: I don't care one way or the other. So I was unable to vote in your poll.

KevinADC 192 Practically a Posting Shark