KevinADC 192 Practically a Posting Shark

try this:

my $dir = <STDIN>;
chomp $dir;#<-- remove the end of line character(s)

and change "else if" to "elsif".

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

I sounds possible. Good luck.

KevinADC 192 Practically a Posting Shark

OK... what have you tried so far?

KevinADC 192 Practically a Posting Shark

Thanks for being so polite about it.... not.

KevinADC 192 Practically a Posting Shark

You're not supposed to post school work on the forum unless you have demonstrated effort to solve the requirements first, which you have not done yet.

KevinADC 192 Practically a Posting Shark

Here is an example of your data as a hash of hashes:

my %hash = ( 
  SectionOne => {Entry1 => 15, Entry2 => 'hello there'},
  SectionTwo => {Entry1 => 19, Entry2 => 'hello there'},
)

or a hash of arrays:

my %hash = ( 
  SectionOne => [15, 'hello there'],
  SectionTwo => [19, 'hello there'],
)
KevinADC 192 Practically a Posting Shark

My guess is you are using the wrong type of data struture for whatever it is you are doing. A hash might work better or an even more complex data set like an array of arrays or array of hashes. A hash of arrays would make deleting "sections" easy, if the sections are unique and can be used as hash keys.

KevinADC 192 Practically a Posting Shark

just ran into 2nd problem as I was coding other parts. one of the things I must do is delete everything between occurences of the word "section". I got this fine, but what if it is the last section in the array? How would I get the program to know this and delete the correct number of elements?

pop() removes the last element of an array. Maybe an example of what you are doing will help.

KevinADC 192 Practically a Posting Shark

splice can be used to add elements to an array.

@array = qw(1 2 4 5);
splice(@array,2,0,3);
print "$_\n" for @array;

In the above code:

2 - is the place in the array you are splicing (its the index value, not the element value)

0 - is the number of elements in the array to replace (we are not replacing any, only adding to the array, so use 0)

3 - is the replacement list (just one element in this case).

KevinADC 192 Practically a Posting Shark

If a person has some programming background then they might pick perl up pretty quickly, but don't underestimate CGI script programming. CGI is a very insecure environment to run programs in and writing secure CGI code is something most amatuers really should not be doing. If a person has no programming background at all, and html code does not count as programming, they will be in for a bit of culture shock. Nuff said, all opinions respected. :)

KevinADC 192 Practically a Posting Shark

Learing perl will take a big investment in your time and possibly energy. Its not a simple tool like html code, its a full blown programming language. You can start learning some basics but programming a site that is interactive using CGI scripts is not something will accomplish in the near future unless you are a really quick learner or have lots of time to dedicate to it.

You can start here:

http://www.perlmonks.com/index.pl?node=Tutorials

KevinADC 192 Practically a Posting Shark
$decVal = <STDIN>;
chomp($decVal);#<--- you need this
KevinADC 192 Practically a Posting Shark

use split instead:

my $var = 'abcdefghijklmnop';
my @chars = split(//,$var);
foreach my $char (@chars) {
   #do something with $char
}
KevinADC 192 Practically a Posting Shark

Thanks for the speech.... I guess.

KevinADC 192 Practically a Posting Shark

Use the open() function to open a file in the CGI script to print data to the file. Something like:

open(my $IN, ">>", "path/to/vfx.txt") or die "$!";
print $IN "some data\n";
close ($IN);

>> = creates or appends to file
> = creates or overwrites file

See the open functions manpage or perlopen

KevinADC 192 Practically a Posting Shark

Assuming you are using NET::FTP, look at the ls() or dir() functions and see if one of them will work.

KevinADC 192 Practically a Posting Shark

get the name of the directory after you login, see the documentation for the FTP module you are using for details.

KevinADC 192 Practically a Posting Shark

CGI::Pretty comes with perl. I leave it up to you to read the documentation.

KevinADC 192 Practically a Posting Shark

Use capturing parentheses, this is covered in any basic regexp tutorial. One example:

$content = 'this is a test';
$content =~ m/(test)/;
$match = $1;
print $match;

Of course that is silly because you already know you are looking for "test" so there is no need to capture it and assign it to a scalar. All you need to know is if the regexp is true then you can assign "test" to a scalar. But maybe you are really looking for a pattern of unknown value you want to capture, something like:

$var = 'test 3456';
if ($var =~ /(\d+)/) {
   print $1;
}

which will print 3456

KevinADC 192 Practically a Posting Shark

Ok, I got it to work:

print $cgi->start_html(-title => 'Siddharth\'s Search Engine', -head => "<META HTTP-EQUIV=\"Pragma\" CONTENT=\"no cache\" />"), "\n";

Although, I would still like it more if there was a better way to do it.

Its covered in the CGI modules documentation, you were pretty close actually:

use CGI;
my $cgi = CGI->new;
print $cgi->start_html(-title => 'Meta Test',
                       -head=>$cgi->meta({-http_equiv => 'Pragma',
                                          -content    => 'no-cache'}));
KevinADC 192 Practically a Posting Shark

I don't know, you can try www.perlmonks.com or ask on the dbi modules mailing list (see the DBI module for details)

KevinADC 192 Practically a Posting Shark

You need to print the header first, not second:

print $cgi->start_html(), $cgi->header();


should be:

print $cgi->header(), $cgi->start_html();

Comatose commented: :) +12
sid78669 commented: Rightt on time! +1
KevinADC 192 Practically a Posting Shark
#!/usr/local/bin/perl
use English;

$string = "This is my string this is it.  I want to tie my string";

$count = 0;

while ($string =~ m/string/gi)
{
  $count=$count+1;
}

$string =~ /string/; 
print "$count strings\n";
print "\n Match: $MATCH\n";
print "\n PreMatch: $PREMATCH\n";
print "\n PostMatch: $POSTMATCH";
KevinADC 192 Practically a Posting Shark

If you literally want to find "string" you can't put it in square brackets. That makes a character class and order of the characters is ignored.

KevinADC 192 Practically a Posting Shark

Cool... note I removed the capturing parentheses because when you use the "g" option they are not necessary.

KevinADC 192 Practically a Posting Shark

use the "g" option:

$string = 'abc 123 def 456 ghi 789';
@numbers = $string =~ /\d+/g;
print "$_\n" for @numbers;

Note I changed the quantifier * to + because * will match zero or more digits so it will match anything that is not a digit although it will just be an empty match.

That should be covered in any regexp tutorial

KevinADC 192 Practically a Posting Shark

see your post on devshed

KevinADC 192 Practically a Posting Shark

try like this:

sub show {
        my $self = shift;
        foreach my $key (keys %{ $self->{items} }) {
                print $key, " ", $self->{items}->{$key}->[0], " ", $self->{items}->{$key}->[1] , "\n";
        }
}

note the extra -> in the print command between {items} and {$key}

KevinADC 192 Practically a Posting Shark

You don't need the %{} brackets to dereference individual parts of the hash of array. See if this does it:

sub show {
        my $self = shift;
        foreach my $key (keys %{ $self->{items} }) {
                print $key, " ", $self->{items}{$key}->[0], " ", $self->{items}{$key}->[1] , "\n";
        }
}
KevinADC 192 Practically a Posting Shark

line 6 above should be probably be written like this:

%{ $self->{items} {$key }} =  @values;

When you declare your new object initially you don't need the [] brackets in there:

my $self = { name => $name, items => {} };

It may or may not be a problem to have them in there, I'm not sure without testing code, but I am sure you can safely remove them.

KevinADC 192 Practically a Posting Shark

There you go. Its a place to start. Nobody here can help with that part besides telling you to try and figure out what the problem is. Check that the directory does exist, the file does exist, etc etc etc.

KevinADC 192 Practically a Posting Shark

Chnage this line:

open(OUT, "+>", "$target") || die("Couldn't open file OUT $target");

change to:

open(OUT, "+>", "$target") || die("Couldn't open file OUT $target: $!");

and see what $! reports. I suspect file paths need to be adjusted for the computer the script does not run on correctly.

KevinADC 192 Practically a Posting Shark

Are you using activeperl? Try installing the module using the PPM application which makes the process a bit easier. See the PPM documentation for details.

KevinADC 192 Practically a Posting Shark

found this on CPAN:

http://search.cpan.org/~mrdvt/Win32-OLE-CrystalRuntime-Application-0.08/lib/Win32/OLE/CrystalRuntime/Application.pm

but thats is as much help as I can give you on this topic.

KevinADC 192 Practically a Posting Shark

That's not how rand works:

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

Hes just not applying it correctly to this particular problem.

KevinADC 192 Practically a Posting Shark

The problem is you are generating a random number based on the length of the array, not the values of the elements of the array. Here is what you want to do:

my @numbers = (48..57, 65..90, 97..112);
my $num = $numbers[int rand @numbers];
print $num,"\n";
KevinADC 192 Practically a Posting Shark

PayPall has all sorts of APIs, the PayPal site is where they can be found.

KevinADC 192 Practically a Posting Shark

Maybe someone else will have a suggestion. I think I have offered all I can at this point.

Good luck

KevinADC 192 Practically a Posting Shark

There are also a number of paypal modules on CPAN.

KevinADC 192 Practically a Posting Shark

You can't get the data sent to redirect.pl parsed by showdata.pl the way you are trying.

You have to recieve the data in your redirect.pl script and save it to disk and have showdata.pl open the file and get the data from a file or send the data to showdata.pl the same way the html form does, using POST or GET methods. You can use a module like LWP::UserAgent to send data from one CGI script to another. But if both scripts run on the same server you probably want to look into CGI::Sessions or maybe there are newer modules by now.

Comatose commented: Great Answer! +12
KevinADC 192 Practically a Posting Shark

That does call the function. But as I said, I don't think it applies to your question. Your function is not a perl function.

KevinADC 192 Practically a Posting Shark

its like this:

$pointer->()

but I don't think thats his question.

KevinADC 192 Practically a Posting Shark

ditto everything Comatose said.

KevinADC 192 Practically a Posting Shark

Sorry, I have no experience with installing either of those.

KevinADC 192 Practically a Posting Shark

look up ord()

KevinADC 192 Practically a Posting Shark

You can find DBD::mysql here:

http://theoryx5.uwinnipeg.ca/ppms/

add that to your repository list or install it directly from there. See the PPM help files if necessary

KevinADC 192 Practically a Posting Shark

It should work. It works for me.

KevinADC 192 Practically a Posting Shark

It appears that you need to install DBD::mysql

KevinADC 192 Practically a Posting Shark

I guess when we say Windows we should be more specific. Windows operating systems based on NT are different than older operating systems. The older ones support both slashes at the kernel level where NT does not. NT based systems do a conversion before the kernel level (in the APIs apparently). I had a link that explained all this on the MS website but the link now returns a "not found" page.