try this:
my $dir = <STDIN>;
chomp $dir;#<-- remove the end of line character(s)
and change "else if" to "elsif".
try this:
my $dir = <STDIN>;
chomp $dir;#<-- remove the end of line character(s)
and change "else if" to "elsif".
I sounds possible. Good luck.
OK... what have you tried so far?
Thanks for being so polite about it.... not.
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.
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'],
)
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.
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.
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).
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. :)
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:
$decVal = <STDIN>;
chomp($decVal);#<--- you need this
use split instead:
my $var = 'abcdefghijklmnop';
my @chars = split(//,$var);
foreach my $char (@chars) {
#do something with $char
}
Thanks for the speech.... I guess.
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
Assuming you are using NET::FTP, look at the ls() or dir() functions and see if one of them will work.
get the name of the directory after you login, see the documentation for the FTP module you are using for details.
CGI::Pretty comes with perl. I leave it up to you to read the documentation.
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
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'}));
I don't know, you can try www.perlmonks.com or ask on the dbi modules mailing list (see the DBI module for details)
You need to print the header first, not second:
print $cgi->start_html(), $cgi->header();
should be:
print $cgi->header(), $cgi->start_html();
#!/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";
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.
Cool... note I removed the capturing parentheses because when you use the "g" option they are not necessary.
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
see your post on devshed
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}
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";
}
}
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.
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.
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.
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.
found this on CPAN:
but thats is as much help as I can give you on this topic.
That's not how rand works:
Hes just not applying it correctly to this particular problem.
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";
PayPall has all sorts of APIs, the PayPal site is where they can be found.
Maybe someone else will have a suggestion. I think I have offered all I can at this point.
Good luck
There are also a number of paypal modules on CPAN.
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.
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.
its like this:
$pointer->()
but I don't think thats his question.
ditto everything Comatose said.
Sorry, I have no experience with installing either of those.
look up ord()
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
It should work. It works for me.
It appears that you need to install DBD::mysql
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.