KevinADC 192 Practically a Posting Shark

There are other ways, but here is one:

my $string = 'address=no+3%2C+oxford+street';
(my $key,$value) = split(/=/,$string);
$value =~ tr/+/ /;
$value =~ s/%([a-fA-F0-9][a-fA-F0-9])/pack("C", hex($1))/eg; 
print $value;
KevinADC 192 Practically a Posting Shark

The standard way is to use the CGI modeule that comes with perl.

http://perldoc.perl.org/CGI.html

KevinADC 192 Practically a Posting Shark

Some input data would also be nice.

KevinADC 192 Practically a Posting Shark

Yes, with perl this should not be a problem although it does help to properly declare variables within the intended scope of their use using "my", "our", or "local" when and where appropriate.

As ithelp has said, in perl they are called references. They are mostly used to create complex data strucutes, like a multi-dimensional array or hash, but can be used for other things.

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

KevinADC 192 Practically a Posting Shark

Sorry, I have no idea how to do that.

KevinADC 192 Practically a Posting Shark

Thank you.

KevinADC 192 Practically a Posting Shark

Daniweb....

please remove all the stupid comments posted by sultan6928 in this code snippet:

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

Thanks

KevinADC 192 Practically a Posting Shark

My vote for: Most confusing question of the year award.

KevinADC 192 Practically a Posting Shark

open(IN, "/path/to/file");
open(OUT,">",'path/to/outfile');
print OUT reverse <IN>;
close(IN);
close(OUT);

The only problem is that if there is not a newline at the end of the last line of the IN file, the reversed OUT file will have the first and second lines appended together.

KevinADC 192 Practically a Posting Shark

Maybe it will work if you remove "strict"

KevinADC 192 Practically a Posting Shark

When you use print, you should quote strings.

print reverse <>, "history.txt > history_rev.txt\n";

On the other hand, if you are expecting perl to know those are input and output files you must not have been awake in perl class. ;)

KevinADC 192 Practically a Posting Shark

I think we all struggled at first installing modules, so welcome to the club. :)

Regards,
Kevin

KevinADC 192 Practically a Posting Shark

1. I can't get a stable and full version of Perl.

2. Need help in developping an FTP application and INVOICING application under PERL.
Tx.

You can get perl from many sources, there is no reason to not be able to get a working distribution of perl.

If you need help with a perl program or have perl questions you have to post them. Nobody here can guess what the problems you are having with your code. If you are hoping to find someone to write your code for you this is the wrong place.

KevinADC 192 Practically a Posting Shark

You need to install DBI and DBD::mysql.

Open the activestate/activeperl folder that was created on the hard drive when you install activeperl and open the documentation. Read the PPM directions which is what you use to install and manage modules with activeperl.

Then see this thread on another forum:

http://bytes.com/forum/thread840298-install+dbd%3A%3Amysql.html

KevinADC 192 Practically a Posting Shark

Kelicula,

the thread is over a year old.....

PS: i added a comment to both of your recent code snippets if you are interested.

KevinADC 192 Practically a Posting Shark

"it doesn't work" is too vague. Any error messages? What does it do? Is Mail::Sendmail installed?

Use code tags to post code.

KevinADC 192 Practically a Posting Shark

with a CGI script it often means you tried to print something to the screen or perl tried to print something to the screen, like an error message, before the http header was printed.

See your other thread, that is probably where the error is occuring. You had the shebang line messed up. When the shebang line is bad perl and the http server can't do anything except return the error message you see.

Its always good to add this line to perl based CGI scripts:

use CGI::Carp qw/fatalsToBrowser/;

although in the case of a bad shebang line it doesn't help since perl can't even be started.

KevinADC 192 Practically a Posting Shark

as far as I know there should be no quotes on the shebang line:

#!c:\xampp\perl\bin\perl.exe

but you're better off using forward slashes, which Windows fully supports:

#!c:/xampp/perl/bin/perl.exe

backslashes in perl code create escape sequences, not on the shebang line which is a special line in a perl program, but its a good habit to use forward slashes in file/directory paths whenever possible to avoid the problem intirely. Note that DOS does not support forward slashes so if you ever do something in DOS you will have to use backslahes in directory paths.

KevinADC 192 Practically a Posting Shark

Link worked for me.....

KevinADC 192 Practically a Posting Shark

See you other thread mruane.

KevinADC 192 Practically a Posting Shark

Activeperl is perl, it is the compiler. The biggest difference, I guess, is that Windows does not use the shebang line to find perl.

You open a text editor and write some perl code and save it to your hard drive. To run it open a DOS windows and at the DOS prompt:

c:\>perl nameofscript.pl

assumes perl is in the command path which I think Activeperl does by default. You may need to add the path to the file if its not in the current directory.

You can download a free perl IDE for windows:

www.perl-express.com

That way you can write perl code and run it directly in the IDE which does make life easier.

KevinADC 192 Practically a Posting Shark

print the values of $type and $temp to the screen and see if they are correct. Thats the only thing that would cause the script to fall through to the "else error" condition.

KevinADC 192 Practically a Posting Shark

Well, I'm not sure what to tell you. The day range must fall between 1 and 31, if it doesn't you get the error that you are getting. Your script with your sample data works fine for me.

KevinADC 192 Practically a Posting Shark

Works for me. But you do have to subtract 1 (one) from the month because Time::Local and the timexxxx() functions uses 0-11 for the months of the year the same as localtime() does.

use warnings;
#use Text::ParseWords;
use Time::Local;
use strict;

my $r = get_unix_timestamp('06.10.2008','06:28:32');
print scalar localtime($r);

sub get_unix_timestamp {
my ($date,$time) = @_;

my $mday = substr($date,0,2);
my $mon = substr($date,3,2);
my $year = substr($date,6,4);

my $hours = substr($time,0,2);
my $min = substr($time,3,2);
my $sec = substr($time,6,2);

my $time_stamp = timegm ($sec, $min, $hours, $mday, $mon-1, $year);
return $time_stamp;
}

I suggest you print out the values in the sub routine as you run the code to see whats going on.

KevinADC 192 Practically a Posting Shark

This is wrong:

<FORM ACTION="http://cgi-bin/xxxx.cgi" method=POST>

probably should be:

<FORM ACTION="cgi-bin/xxxx.cgi" method=POST>

You also need a </select> tag:

<SELECT NAME="Type">
<OPTION VALUE="c_fah">Convert from Celsius to Fahrenheit<BR/>
<OPTION VALUE="f_cel">Convert from Fahrenheit to Celsius<BR/>
</SELECT>


besides that it looks like the script should work.

KevinADC 192 Practically a Posting Shark

What data do you pass into the function? Which module are you using that imports the timegm() function?

KevinADC 192 Practically a Posting Shark

Your words "not" clear. Personally I have no idea what you are asking so I can't help. Maybe someone else will understand your question.

Regards,
Kevin

KevinADC 192 Practically a Posting Shark

This is the perl forum mate. Post in the shell scripting forum.

KevinADC 192 Practically a Posting Shark

The short answer is no. Perl has no builtin function that checks if a character is an alpha character.

KevinADC 192 Practically a Posting Shark

You have this same incomprehensible question on several perl forums. I assume English is not your native language, but you still have to ask a question that we can understand. Besides telling you to read the CGI.pm documentation like you have been told on two forums, there is no way to help you because your question does not make any sense. It is incomprehensible.

KevinADC 192 Practically a Posting Shark

And the same person on tek-tips, and perlguru, and daniweb, and ??

KevinADC 192 Practically a Posting Shark

You have this posted on too many forums for me to want to help you. You should also try and do your own school work.

KevinADC 192 Practically a Posting Shark

If you're using Windows you would use activestate activeperl (see Salems post above), its the easiest way to get perl on your windows computer. If you want to do CGI script you may also want to install an HTTP server. Apache is free (www.apache.org) or you can try using your Windows based HTTP server if it has one.

You may also want to install mySQL which is the most popular internet database software.

If you are not using windows, perl comes with many other operating system so you may already have it installed.

KevinADC 192 Practically a Posting Shark
opendir (DIR, "path/name of directory") or die "$!";
while(my $file = readdir(DIR)) {
   next if ($file eq '.' || $file eq '..');
   open (my $FH, "path/name of directory/$file") or print "$!\n";
   while (my $line = <$FH>) {
      do something with $line
   }
   close $FH;
   }
}
closedir DIR;
KevinADC 192 Practically a Posting Shark

Hello,
Please tell me the form of Perl.

high on the ends, low in the middle.

KevinADC 192 Practically a Posting Shark

I am sure it is possible, but it would not be too easy. Your question is considerably beyond the scope of a typical question posted on a forum.

You would need a program that monitors incoming emails, seaches for a certain subject line or an email address and opens the email and extracts the data out of the email. It would need to run checks on the data to make sure its what the script expects.

The script would then do whatever the update is that you need done on the website. The easiest would be to put the data from the email in a file or database then have a script that reads in the data and generates the webpage dynamically, just like this forum does.

This would all have to be custom written for your specifc requirements.

Maybe its time to hire a programmer? Sites like eLance.com and oDesk.com have many programmers from around the world that will bid on your job.

KevinADC 192 Practically a Posting Shark

Yes, it sounds possible if I understand your question. A programing language would be useless if it were unable to read/write to files.

KevinADC 192 Practically a Posting Shark

I suggest you look into existing programs on script archives such as www.hotscripts.com and see if you can find something that does what you want or comes close to doing it.

KevinADC 192 Practically a Posting Shark

@branch is an array of arrays in the perl code. It is a global variable in the above code, but global only to that perl script. Its a lexical variable that is scoped to the entire script so in essence it is global, but still only global to that script. It is not a method, it is just an array. I can't help you with translation to JAVA because I don't know any JAVA.

KevinADC 192 Practically a Posting Shark
KevinADC 192 Practically a Posting Shark

Don't bother, they have been given the answer on another forum:

http://www.perlguru.com/gforum.cgi?post=32920

KevinADC 192 Practically a Posting Shark
open (IN, "filename.pdb") or die "$!";
while (my $line = <IN>) {
   chomp($line);
   my @array = (split(/\s+/,$line))[6,7,8];
   print "@array\n";
}
close (IN);

Look into perls math operators for the distance calculations. The above just shows an example of how to get the last three columns from a line with 9 columns of varying length data seperated by spaces.

KevinADC 192 Practically a Posting Shark

Sorry, I have never used them.

KevinADC 192 Practically a Posting Shark

Have you looked at Net::SFTP or Net::SFTP::Util ?

KevinADC 192 Practically a Posting Shark

Like everyone already told you on the other forum, nobody knows what Far Manager is. I"ve never heard of it either.

KevinADC 192 Practically a Posting Shark
KevinADC 192 Practically a Posting Shark

grep is OK in this situation because you have to search the entire file. grep uses "$_ =~ m/pattern/" internally to search for the pattern.

When you say search for multiple things in the file, how does the user input those multiple things? You have to tell the user something like:

Enter multiple search terms seperated by a space:

then your script gets the search terms and uses split() to create a list of those search terms and searches for them sequentially, or you could actually compile a regexp or a search pattern from the input after split()ing it into the serperate search terms.

KevinADC 192 Practically a Posting Shark

this is the perl forum, not the php forum.

KevinADC 192 Practically a Posting Shark

Is there more than one line with "free disk space" in the file?

KevinADC 192 Practically a Posting Shark

You could try using a reference to a function.

sub some_function {
   print "foo";
}

my $some_function = \&some_function;

You can pass $some_function like any other scalar, but you need to use the arrow operator to run the function.

$some_function->()

Assuming you pass references to functions to your sub rotuine:

sub function_runner {
   my @exit_functions = @_;
   my $counter = 1;
   foreach my $function (@exit_functions) {
      print "Performing exit function $counter:\n";
      $counter++;
      $function->();
   }
   print "\nAll exit functions completed.\n";
}
klactose commented: His post was very helpful +1