KevinADC 192 Practically a Posting Shark

This wouldn't be a problem with the script since it runs fine from the command but a misconfiguration of apache or whatever webserver you are using.

I missed your post somehow so I realize this is a late reply. The problem could very well be the script. If run as a CGI it needs to print an http header before trying to print anything else. This is not a problem from the command line and will work, but will error out with a 500 ISE if initiated as a CGI script from a browser.

KevinADC 192 Practically a Posting Shark

Maybe some trick involving frames or an iframe?

KevinADC 192 Practically a Posting Shark

I think the problem with this line:

require Oogaboogoo::date;

is that the :: is a directory path, which is why you get the error message:

Can't locate Oogaboogoo/date.pm

rename the module to 'date.pm' and put it in the Oogaboogoo directory and I think it will work.

KevinADC 192 Practically a Posting Shark

in the code snippets perl syntax highlighter, this regexp:

$string =~ s/^\s+//;

the first 's' after the '=~' operator is correctly linked to the perldoc page concerning the 's' function, the second 's' however is also linked to the same page, which is not correct since it is the meta character for a white space.

Also, the links should probably really go to:

http://perldoc.perl.org/

and not:

http://www.perldoc.com/

perldoc.com never seems to be online anymore.

This is of course nothing very important, just thought I would bring it to your attention.

KevinADC 192 Practically a Posting Shark

I would at least try using an FTP client to eliminate if XP FTP is the problem or not.

KevinADC 192 Practically a Posting Shark

make sure you are uploading the file in ASCII (text) format and not binary format.

KevinADC 192 Practically a Posting Shark

It's not working because the question mark '?' is a quantifier in a perl regular expression, it means one or zero. You have to escape the ? to treat it as a literal ? instead of a quantifier. You can use the quotemeta option with the regexp:

$cr = '???';
$decrypted ="Something";
$decrypted =~ s/\Q$cr\E/\r/g;
print "Content-type: text/html\n\n";
print $decrypted;
KevinADC 192 Practically a Posting Shark

You need to print an http header when running scripts in a CGI environment:

1: #!/usr/bin/perl
2:
3: $cr = '???';
4: $decrypted ="Something";
5: $decrypted =~ s/$cr/\r/g;
6: print "Content-type: text/html\n\n";
7: print $decrypted;

use a better subject line in the future. "Please Help Me!!! P E R L!!!" is not appropriate.

KevinADC 192 Practically a Posting Shark

your post is really much too long, probably nobody is going to read all that. My questiojn to you is have you tried the code? Did it work or not? Any error messages if it did not work?

KevinADC 192 Practically a Posting Shark

None of this has anything to do with vBulletin, I'm afraid. It was all coded by me. I am rather suspicious that the problem lies in my code cache and not in the highlighter at all. However, thank you very much for pointing out it happens when the \ character is within quotes. That could help me debug my code which I haven't looked at in 5 months :)

OK, well, it's easy enough to just add the extra back-slash when entering code. Maybe you could post a note in the snippet forum letting potential contributors know about this "bug" and informing them of what to do.

KevinADC 192 Practically a Posting Shark

I'm really stumped with the backslash problem. I cannot reproduce the error in other code snippets. The display of \ and / characters seem to work fine in other code snippets?? Do you have any idea why it wouldn't work in just this one spot, and yet \n works just fine in the same code snippet? Please note that DaniWeb was written in PHP and the \ character is the escaping character in PHP.

back-slashes are getting removed by the high-lighter unless they are inside single-quotes or inside double-quotes. You have to escape a back-slash with a back-slash if it's not inside single or double quoted strings (which is why \n works, it's inside of quotes) . It's probably because php is interpreting the back-slash as the escape character unless inside quotes.

The high-lighter needs to add the escaping back-slash automatically to back-slashes in code to avoid this unecessary interpolation of the escape character. Maybe vbulletin has some known recommendations about how to appropriately fix this small bug in the high-lighter.

KevinADC 192 Practically a Posting Shark

this line parses a little oddly too in the same perl snippet:

use File::Basename;

but it's no big deal, the code is correct, just looks funny.

KevinADC 192 Practically a Posting Shark

the snippet in question is the only code snippet posted under perl. Here is the link:

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

It looks OK now because I added the second backslash as noted previously, otherwise the single backslash is removed from the display. This is a problem with the highlighter code, not the regular code tags.

Seems to be the same in the php syntax highlighter:

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

note there is no \ in this section of code: qr{..*}); but I did enter a backslash: qr{\..*});

(snippet536.html should be deleted after you take a look. )

Looks the same in Mozilla 1.5 and IE 6 so most likely not a browser problem.

KevinADC 192 Practically a Posting Shark

the Perl syntax highlighter is mangling some perl code, for example, this line:

my(undef, undef, $ftype) = fileparse($file,qr{\..*});

using the perl syntax highlighter (which I guess does not work in this forum) the backslash in qr{\..*} is removed, and becomes qr{..*} which is no longer the correct code for the regexp.

Adding two backslashes overcomes the problem: qr{\\..*} but that means a person has to know they need to write bad code so it displays as good code, and there might be other problems that I have not spotted yet.

Regards,
Kevin

KevinADC 192 Practically a Posting Shark

I would like to display .html files in green, .jpg files in blue and so on..

Building on the last example, I will use a hash table to store the color associated with the extension and the File::Basename module to get the extension and apply the color.

use File::Basename;
$dir = '/home/username/public_html/';
$DirName = 'images';
my %colors = (
   '.html' => 'green',
   '.jpg' => 'blue',
   '.gif' => 'blue', 
   '.txt' => 'red',
);
doit();
sub doit {
   opendir(DIRHANDLE,"$dir$DirName") or die "Can't open $dir$DirName: $!";
   @filenames = sort readdir(DIRHANDLE);
   close(DIRHANDLE);
   foreach $dirfile (@filenames) {
      my(undef, undef, $ftype) = fileparse($dirfile,qr{\..*});
      [B]my $color = $colors{lc($ftype)} || 'black';[/B]
      print qq~<span style="color:$color">$dirfile</span><br>\n~;
   }
}

** apply your own HTML code to the output that gets printed, mine is just for the purpose of the

KevinADC 192 Practically a Posting Shark

2. Get perl to recognize the different file extensions.

There are a variety of ways to determine the file extension, you could use a regexp, or split(), or substr(), and probably more. But there is a core module for this purpose: File::Basename

using your existing code as an example:

[B]use File::Basename;[/B]
$dir = '/home/username/public_html/';
$DirName = 'images';
doit();
sub doit {
   opendir(DIRHANDLE,"$dir$DirName") or die "Can't open $dir$DirName: $!";
   @filenames = sort readdir(DIRHANDLE);
   close(DIRHANDLE);
   foreach $dirfile (@filenames) {
      [B]my(undef, undef, $ftype) = fileparse($dirfile,qr{\..*});[/B]
      print "$ftype<br>";
   }
}
KevinADC 192 Practically a Posting Shark

1. Get perl to recognize the difference between a file and a sub-directory

File test operators are your friend:

http://perldoc.perl.org/functions/-X.html

KevinADC 192 Practically a Posting Shark

Hi,
How to convert excel to html in shell prompt
Is there any unix command to do this ? so that I can use that in excel
Vinay

Why are you asking this question in the perl forum? You should ask in a shell scripting/unix forum.

KevinADC 192 Practically a Posting Shark

Because I want to implement this in perl

The reasons to use xml with perl is the same reason to use xml for any reason. Are you saying you don't know why to use xml in general? If so, maybe you should ask in the XML/SOAP forum, someone there is probably going to be better at explaining what the value and purpose of xml is.

KevinADC 192 Practically a Posting Shark

hmmm xml and perl, how's you going to implement xml in perl, you should at least use a javascript interface between platforms. :mrgreen:

Why do you need to use javascript as an interface between xml and perl? Maybe you were just joking?

KevinADC 192 Practically a Posting Shark

No, yesterday there was a large advertisement for someones site selling all sorts of scripts. Seemingly it has now been removed (either by a moderator or the individual who posted it).

Sure there was. :rolleyes:


hehehe... just kidding, makes sense. I hate spammers too so if I see this creep I'll make sure to let them know spammers are the lowest form of life on earth, just below child-molesters and rappists. :mad:

KevinADC 192 Practically a Posting Shark

Who's Spamming?

I think masijade has been smoking something:

http://www.daniweb.com/techtalkforums/thread49624.html

KevinADC 192 Practically a Posting Shark

does excel have a native command for "save as csv"?

KevinADC 192 Practically a Posting Shark

why are you asking this in the perl forum?

KevinADC 192 Practically a Posting Shark

mkdir()

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

although using File::Path does have advantages and it's a core module so nothing to install:

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

KevinADC 192 Practically a Posting Shark

I have personally never installed it but here is the link to the FTS site on sourceforge:

http://openfts.sourceforge.net/

KevinADC 192 Practically a Posting Shark

Yes, the CGI module is your friend:

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

KevinADC 192 Practically a Posting Shark

please start a new thread.

KevinADC 192 Practically a Posting Shark

That's correct, but you can also assign a list of scalars to the split:

my ($name,$address,$phone,$zip,$other) = split(/,/,$line);

then just use the appropriate scalar, or just use the array index, there really is no need to assign the array index to another scalar unless you really wanted to:

@list = split(/,/,$line);
if ($list[0] eq 'foo') {
....
}
KevinADC 192 Practically a Posting Shark

you can probably do what you want without splitting the data into fields but whats the problem with splitting it? Thats the whole idea behind having delimited data in the first place, so you can work with the specific fields of data. Your altrernative is probably to use regexps or maybe substr().

KevinADC 192 Practically a Posting Shark

There is a perl module for handling csv files:

Text::CSV

but it's not a core module so would maybe would need to be installed. It's pretty common to have it installed since dealing with csv file is pretty common. Ask tech support if you are unsure.

KevinADC 192 Practically a Posting Shark

This so smells of class work. You need to put some effort into it if you want help with class work, that means writing some code.

KevinADC 192 Practically a Posting Shark

You may want to post on another forum where there could be more members that have experience with this type of thing you are trying. Try perlmonks or devshed.

KevinADC 192 Practically a Posting Shark

I believe the error codes are specific to the operating system, so you may have to try and determine what 255 means for your operating system, personally I don't know. Maybe someone else can shed some light on this problem for you.

KevinADC 192 Practically a Posting Shark

To run any system application with perl you use:

system()
backtiks: ` `
qx/ /
exec()

but exec exits the perl program. Whcih you use depends on what you are doing.

KevinADC 192 Practically a Posting Shark

Look up the substitution operator. s//.

You can replace the data like so:

$myvar = "hello|world|yes!";
$myvar =~ s/|/\t/gi;
print "$myvar";

I'm wondering if you or the OP ran the code you suggested, I think you will find the results not what is expected if the code is left as-is.

Usually you don't want to do a substitution on field delimiters but I guess you could if you wanted to. You split the string on the delimiters then munge the data, I had already suggested using join for this (on another forum):

print join("\t",split(/\|/,$var));

Nit-pik: There is also no need to use the "i" option to substitute non alpha characters as there is no case involved.

KevinADC 192 Practically a Posting Shark

search the cisco website? Search using google?

KevinADC 192 Practically a Posting Shark

This isn't homework is it? Next time please post the code you have been trying. Here is one way, assumes you only want to find if there is one match (the first one). If you want to find multiple matches just remove the line that has "last;"

chomp(my $input = <STDIN>);
open(FH,'yourfile.txt') or die "$!";
my $match = 0;
while (my $line = <FH>) {
   my ($digits) = $line =~ /^(\d+),/;
   if ($input == $digits) {
      print $line;
      $match = 1; 
      last;
   }
}
close(FH);
unless ($match) {
   print "The four digits were not found in the file$/";
}
KevinADC 192 Practically a Posting Shark

what have you tried so far? You could do this a number of ways, but what I would probably do is build a hash from the text file first. Then check the entered number against the hash using the exists() function. If the exists() function returns true then the number is already in the file.

KevinADC 192 Practically a Posting Shark

If you want to use a batch file (or even telnet) why are you asking in the perl/cgi forum?

KevinADC 192 Practically a Posting Shark

You will have to use whatver zipping tool is installed on the remote machine if you want to zip the file while it still resides on the remote machine.

KevinADC 192 Practically a Posting Shark

I would assume c would be faster than perl, but I have no experience with the database you are using. There is a module for it though:

http://search.cpan.org/~reden/Db-Ctree-1.1/Ctree.pm

KevinADC 192 Practically a Posting Shark

Did you try any of my suggestions? I assume you mean you are using apache on a local server where notepad is installed. If so it should work.

KevinADC 192 Practically a Posting Shark

the problem with this is that your perl script will continue running in the background. Maybe that's not a problem for your application though. You can use system() or exec() or qx// or backtiks ``. Anyone of thses will open a notepad window. Since windows is almost always (or maybe is always) in the command path you can just do this:

system('notepad.exe');

or even:

system('notepad');

KevinADC 192 Practically a Posting Shark

Probably there is a module on CPAN as there are many DNA related modules.

KevinADC 192 Practically a Posting Shark

are we supposed to understand the question? If you want help it might be best to explain what a "promoter region in Eukaryots" is.

KevinADC 192 Practically a Posting Shark

Just a short intro, I'll be posting in the perl forum 99.9999% of the time so don't expect to see too much of me, but I wanted to say hi and compliment ya'll on what looks like a good forum that is growing and I hope continues to grow.

Kevin

KevinADC 192 Practically a Posting Shark

The answer is on the other forum