Perl Sub Questions and Answers



Resolved Question: why wont this code work?

!perl use Tk; my $mw= new MainWindow; my $text= $mw -> Label(-text=>"Enter the equation you would like solved in the box below.\n To keep the number in the box for your next equation press the \'M\' button.\n Then use the letter \'m\' in place of that number in another equation.\n") -> pack(); my $entry = $mw -> Entry() -> pack(); my $submit=$mw->Button(-text=>"Enter")->pack(); my $memory=$mw->Button(-text=>"M", -command=>\&memory)->pack(); $answer=eval($equation=$entry->get); $equation -> delete(0,'end'); $equation -> insert(0,"$answer"); $equation =~ s/m/$m/; MainLoop; sub memory{ $m=$entry->get(); } i have isolated it it to the the two lines that are pushed out. wen i remove them the program runs when it doesnt the window doesnt even pop up. thanks sorry forgot to push them out the lines that say $equation->insert and $equation->delete  more

Resolved Question: How do you pass (and dereference) an array of hashes to a Perl subroutine?

I though the code below would work but I think it is not dereferencing the array: #!/usr/bin/perl # ARRAY OF HASHES $val[0]{'CELL1'} = "0cell1"; $val[0]{'CELL2'} = "0cell2"; $val[1]{'CELL1'} = "1cell1"; $val[1]{'CELL2'} = "1cell2"; for my $i (0..$#val) { print "$val[$i]{'CELL1'} $val[$i]{'CELL2'}\n"; } $res = &mysub(\@val); print "RESULT: $res\n"; sub mysub { my $ref = shift ; # $ref is a reference to an array of HASHES my @valIN=@{$ref}; # try to dereference it for my $i (0..$#valIN) { print "$valIN[$i]{'CELL1'} $valIN[$i]{'CELL2'}\n"; } return "DONE"; }  more

Voting Question: how to Monitor folder for new files using bash shell script ?

how to Monitor folder for new files using bash shell script ? I'm doing a project using smsserver tools 3. i have used a perl script to handle incoming messages. the content of each message must be directed to a java program. this program generates the answer to reply to the user so we need to call the java program from the perl code. this is my perl code //****************************************************************************************************************************************** #!/usr/bin/perl -w use strict; use File::Monitor; use File::Monitor::Object; my $number = ''; my $msgFrom = ''; my $outgoing = "/home/T/Documents/run/outgoing/"; my $extract ="/home/T/Documents/run/extract part/"; my $temp = '/var/spool/sms/incoming'; my $monitor = File::Monitor->new(); my $newline = 0; $monitor->watch( { name => "$temp", recurse => 1, callback => \&Test, } ); $monitor->scan; for (my $i=0; $i < 100; $i++) { my @changes = $monitor->scan; sleep 5; } sub Test { my ($name, $event, $change) = @_; my @adds = $change->files_created; my @dels = $change->files_deleted; if(@adds){ print "Added: ".join("\nAdded: ", $adds[0])."\n"; # if @adds; my $filename = $adds[0]; open (INFILE, $filename); # if @adds; while (my $line = <INFILE>) { chomp $line; $line = lc($line); if ($newline == 1) { $msgFrom = $msgFrom.$line; printf "*************".$msgFrom; } if ($line =~ /^from: (.*)/) { $number = $1; } elsif (length($line) == 0) { $newline = 1; } } close INFILE; open(OUTFILE1 , ">".$number.".txt"); print OUTFILE1 ("hi gfdg"); close OUTFILE1; open(OUTFILE, ">".$outgoing."sms".$number."-".int(rand(100000))); #open for write, overwrite print OUTFILE ("To: ",$number); #write text without newline print OUTFILE "\n\n"; print OUTFILE join(',','hi is this working '); #write text print OUTFILE "\n"; #write newline close OUTFILE; } } //****************************************************************************************************************************************** I'm new to perl and if there any way to run java program inside the perl its ok.if not can anyone help me to write this perl code in shell script  more

Voting Question: shuffling an array sub routine in perl?

Okay, so iam writing this code (in PERL) that needs to shuffle an array. But here's the problem: i need to randomly pick a number between 20 and 40 (which i have done) , then i need to randomly shuffle my array(sequence) that many number of times. I have to do all this in a subroutine but somehow i cant get my code to work as it wont shuffle. Any help will be appreciated.Thanks.  more

Resolved Question: XML-RPC Java/Perl Problem, Help Please?

I am having problem with a Java program that calls a Perl/CGI Script, creates a hash and returns. A simple example looks like this: Perl Script: ------------------------------------------------------------------------------------ sub createHash{ %hashTable = (); $hashTable{"first"} = 1; # inserts a new hash table entry with key="first" and value=1 $hashTable{"second"} = 2; # new entry with key="second" and value=2 return %hashTable; }#end createHash Java Program ------------------------------------------------------------------------------------ public void getHash(){ HashMap hashmap=new HashMap(); Vector params = new Vector(); //Create Variables try { XmlRpcClient xmlrpc = new XmlRpcClient(SERVER_URL); //Set Strings String methodName = "MyProgram.createHash"; System.out.println(xmlrpc.execute( methodName, params)); //The line below is commented out because it throws an error //hashmap=(HashMap) xmlrpc.execute( methodName, params); } catch (MalformedURLException e) { // TODO Auto-generated catch block e.printStackTrace(); } catch (XmlRpcException e) { // TODO Auto-generated catch block e.printStackTrace(); } catch (IOException e) { // TODO Auto-generated catch block e.printStackTrace(); } }//end class The problems are this, when, I System.out.print the return hash created in Perl, is only prints out the last value. When I cast the return value to a Java Hash, it throws a string execption. So how do I return a hash table or multiple values from a perl program?  more

Resolved Question: Perl Variable Problem?

Hi, what I'm attempting in Perl is pretty simple.. I've tried looking for the answer but nothing out there gives a straightforward or seemingly relevant answer to what I need to know (and what I've tried so far doesn't work) I've declared a variable like so.. $userid; This variable lives outside of all functions on the code text.. because of this, I assumed that'd make it global to the file but it doesn't seem to work that way I change the value of this variable in a subroutine sub changeuserid { $userid = "fred"; } Then I try.. print "user id is $userid"; and all I get is "user id is " I've tried using "our $userid;", and applying "use strict", and both.. so far nothing is working Quite simply.. how do I make this variable global to this file? Thanks  more

Resolved Question: can anyone explain this perl source code to me?

can anyone explain this source code in perl programming? as in everything, heheh.. thanks in advence the output is: A: a b c d B: c d e f union: a b c d e f intersection: c d #!/usr/bin/perl @ArrayA = (a, b, c, d); @ArrayB = (c, d, e, f); my ($union_ref, $isec_ref) = ArrayFunctions(\@ArrayA, \@ArrayB); @$union_ref = sort(@$union_ref); @$isec_ref = sort(@$isec_ref); print "A: @ArrayA\n"; print "B: @ArrayB\n\n"; print "Union: @$union_ref\n"; print "Intersection: @$isec_ref\n"; sub ArrayFunctions { my $a_ref = shift; my @a = @$a_ref; my $b_ref = shift; my @b = @$b_ref; @isec = @union = (); foreach $e (@a, @b) { $count{$e}++ } foreach $e (keys %count) { push(@union, $e); if ($count{$e} == 2) { push @isec, $e; } } return (\@union, \@isec); }  more

Voting Question: whats wrong with this perl script?

!perl use Tk; $mw=new MainWindow; $mw->Label(-text=>"Please enter the equation you would like to evaluate. The symbols are as follows: \nplus+\nminus-\nmultiply*\ndivide/\nmodulus%\nexponent**\n")->pack(); $in=$mw->Entry(-width=>"20")->pack(-padx=>30); $mw->Label(-text=>"The answer to the equation is $ans.\n")->pack(); $mw->Button(-text => 'Evaluate this equation', -command => sub{calc()} )->pack(-side => 'left', -padx => 30); $mw->Button(-text=>'Exit', -command=>sub{exit})->pack(-side=>'right', -padx=>30); MainLoop; sub calc{ $equ=$in->get; $ans=eval($equ); $mw->update; } im trying to get the screen to refresh after calculating the answer but it wont.i know its calculating the number because if a i add a print statement it prints on the command prompt but the tk gui doesnt update thnx in advance im on windows so the path is fine and missing # found it had to change text using configure()  more

Voting Question: I have several errors in my program and have no idea how to fix them after surfing the web.?

!/usr/bin/perl use strict; use warnings; ###################### #Homework 3 #The Service Engine #Athur: Brad Duhon #Due November 9th 09 ###################### ###################### #OPEN ###################### open (LOG, '>>$/tmp/bckgnd_log.txt'); select ( ( select ( LOG ), $| = 1 ) [ 0 ] ); open FILE, '>/tmp/bckgnd_run.txt'; print FILE "$$"; close FILE; my $sig_vars = { USR1 => 0, QUIT => 0 }; my @array_ref; my $jobs; my $count = 0; ###################### #PRINT ###################### sub Print{ chomp($array_ref[$count][0]); chomp($array_ref[$count][1]); chomp($array_ref[$count][2]); print LOG "submit $array_ref[$count][0] $array_ref[$count][1] $array_ref[$count][2] \n"; $count++; } ###################### #CATCH ###################### sub catch { my ($signame) = @_; if ( exists( $sig_vars->{ $signame } ) ) { $sig_vars->{ $signame } = 1; } } ###################### #INT_CATCHER ###################### sub INT_catch { open (JOB, '/tmp/bckgnd_sub.txt')or print "Cannot open"; my @temp = <JOB>; if(@temp == 3 || $temp[0] =~ /[1-10]/){ push(@array_ref,[@temp]); } else{ print LOG "SUBMISSION FILE ERROR.\n"; } @array_ref = sort{ $a->[0] <=> $b->[0]; }@array_ref; print @array_ref; close(JOB); unlink("/tmp/bckgnd_sub.txt"); Print(); } ###################### #QUIT ###################### sub QUIT_doer { close LOG; exit; } ###################### #USR1 ###################### sub usr1{ open(DUMP, ">/tmp/bckgnd_dump.txt") or die "Couldn't Complete Action."; if(@array_ref > 0){ for(my $z = 0; $z < @array_ref; $z++){ chomp($array_ref[$z][0]); chomp($array_ref[$z][1]); chomp($array_ref[$z][2]); print DUMP "job dumped: $array_ref[$z][0] $array_ref[$z][1] $array_ref[$z][2] \n"; } } else { print DUMP "No Jobs Found."; } close(DUMP); } ###################### #ACTIONS ###################### $SIG{ INT } = \&INT_catch; $SIG{ USR1 } = \&catch; $SIG{ QUIT } = \&catch; ###################### #MAIN LOOP ###################### while(1) { if(@array_ref > 0){ #open(PIPE, "$array_ref[2] |"); #open(OUTFILE, 'array_ref[2]'); #while(<PIPE>){ #print LOG "RUN CMD array_ref[1] OUT array_ref[2]"; #} } else{ sleep(1000); if ( $sig_vars->{ USR1 } ) { USR1_doer() }; if ( $sig_vars->{ QUIT } ) { QUIT_doer() }; } } I have "Use of uninitialized value in scalar chomp" for lines 30-32 "Use of uninitialized value in concatenation(.) or string print() on closed file handle" line 33 readline() on closed filehandle JOB line 51 use of uninitialized value in pattern match (m//) line 52 And I have no idea what these are for I have tried fixing them over and over... the overall program is suppose to run in the background... and take info from a file, store it into an array of arrays, sort them by priority (found in the first line of every 'job' sent to it). then write out everything that happens to a log.  more

Voting Question: Unmetered Specialist Hosting on CV. Software Technology ?

Visit : http://www.st.co.id ORDER HERE : http://www.st.co.id/client Unmetered Linux Reseller Unlimited Diskspace, Unlimited Bandwitdh, Unlimited Hosting, Unlimited Domain, Unlimited Sub Domain, Unlimited FTP, Unlimited Email, Unlimited MySQL. Cpanel, Fantastico, Free Domain (.com/.net). Free Installation billing cP Creator. Bulanan : Rp. 50.000 | Tahunan : Rp. 500.000 Monthly Cost: 5.00 USD Annual Cost: 50.00 USD Unmetered Linux Master Reseller Unlimited Reseller, Unlimited Shared Hosting, Unlimited Diskspace, Unlimited Bandwitdh, Unlimited Hosting, Unlimited Domain, Unlimited Sub Domain, Unlimited FTP, Unlimited Email, Unlimited MySQL. CPanel, Fantastico, WHM Reseller, Free Domain (.com/.net). Free Installation billing cP Creator. Bulanan : Rp. 100.000 | Tahunan : Rp. 1.000.000 Monthly Cost: 10.00 USD Annual Cost: 100.00 USD Unmetered Windows Reseller Windows 2003 Server, Unlimited Diskspace, Multilingual Support (Helm Control Panel), PHP, ASP, ASP.Net, Perl ColdFusion, ODBC, Unlimited Bandwitdh, Unlimited Hosting, Unlimited Domain, Unlimited Sub Domain, Unlimited FTP, Unlimited Email, Unlimited Microsoft Access, Unlimited SQL, Unlimited MySQL. Free Domain (.com/.net). Detail and Fitur Windows Server : http://st.co.id/windows.reseller.php Bulanan : Rp. 300.000 | Tahunan : Rp. 3.000.000 Monthly Cost: 30.00 USD Annual Cost: 300.00 USD Unmetered Super Master Reseller Unlimited Master Reseller, Unlimited Reseller, Unlimited Shared Hosting, Unlimited Diskspace, Unlimited Bandwitdh, Unlimited Hosting, Unlimited Domain, Unlimited Sub Domain, Unlimited FTP, Unlimited Email, Unlimited MySQL. Cpanel,Fantastico,WHM Master Reseller, Free Domain (.com/.net). Free Installation billing cP Creator. Bulanan : Rp. 300.000 | Tahunan : Rp. 3.000.000 Monthly Cost: 30 USD Annual Cost: 300 USD  more

Resolved Question: Convert it to turbo c?

$ $ cat -n triangle.pl 1 $seed=$ARGV[0]; 2 $size=$ARGV[1]; 3 for ($j=$size; $j>=1; $j--){ 4 oneline($j); 5 } 6 sub oneline { 7 ($i) = @_; 8 for ($k=1; $k<=$i; $k++){ 9 printf("%s",$seed%10); 10 $seed++; 11 } 12 print "\n"; 13 } $ $ perl triangle.pl 5 4 5678 901 23 4 $ $ perl triangle.pl 9 9 901234567 89012345 6789012 345678 90123 4567 890 12 3 $ $ please help..  more

Voting Question: Can anyone help me solve a Perl Problem?

I don't understand why my toString method, in the code below does not work. Any help would be great thanks! package person; use strict; use warnings; sub new { my $self = {}; my ($className,$id, $name, $password) = @_; $self -> {CLASSNAME} = $className; $self -> {ID} = $id; $self -> {NAME} = $name; $self -> {PASSWORD} = $password; bless($self); } sub id { my $self = shift; if (@_) {$self -> {ID} = shift} return $self -> {ID}; } sub name { my $self = shift; if (@_) {$self -> {NAME} = shift} return $self -> {NAME}; } sub password { my $self = shift; if (@_) {$self -> {PASSWORD} = shift} return $self -> {PASSWORD}; } sub toString { my $id = &id; my $name = &id; my $password = &password; return $id . $name . $password; } my $user1 = person -> new("45", "Jack", "Yack"); print $user1 -> toString; 1;  more

Resolved Question: Please enhance this small program?

Hi.. I am bigenner in perl. And I wrote a small program, so i want to know that whther its correct coding procedure. Please enhance this script in more efficient way. I am just displaying the array which contains Hashes and each hashes contain an array reference. -----Code---- sub DisplayHashesOfArray(){ my ($ArrayRef) = @_; for($i=0;$i<scalar(@$ArrayRef);$i++){ $BabyRefHash = $ArrayRef->[$i]; foreach(keys(%$BabyRefHash)){ $BabyRefArray = $BabyRefHash->{$_}; print("\n$_\n"); for($k=0;$k<scalar(@$BabyRefArray);$k++){ print("$BabyRefArray->[$k]"); } } } } sub HashesOfArray(){ my (%Name,%Address,%Office); my @Addr; $Name{'FIRST_NAME'} = ['ABC','','CDF']; $Name{'FATHER_NAME'} = ['XYZ','VXS']; $Address{'HOME_CITY'} = ['DELHI',47667]; $Address{'HOME_COUNTRY'} = ['INDIA','WORLD']; $Office{'OFFICE_CITY'} = ['BANGALORE',560029]; $Office{'OFFICE_COUNTRY'} = ['AMERICA','WORLD']; @Addr = (\%Name,\%Address,\%Office); &DisplayHashesOfArray(\@Addr); } &HashesOfArray(); -------Code Complete---- Please enhance it.  more

Resolved Question: whats best website package?

Domain registration, website designing and hosting @ 40 USD flat (2000 Indian rupees) Choose from Windows or Linux server Choose from servers based at India or UK or the USA Unlimited bandwidth, unlimited sub domains HTML, DHTML, XHTML, CSS, XML, FLASH, PHP, Java, javascript, MySQL, Oracle, Perl support Dynamic web content, designing in dynamic flash content available Free 100 MB sppace for My SQL database Free multiple mail IDs with huge inbox space visitor stat, auto backup, full control panel and FTP control no hidden taxes or additionaql charges domain registered under 30 minutes, website delivered within 48 hours flat 24 hour email and telephone tech support Call Imran 91 9270343817 email admin@downloadfork.com Lol, Im NOT inquiring. I sell this stuff.  more

Resolved Question: Putting car type subs on a home theater?

I'm not real experienced with speakers and all, so any help would be great. I have one of these. http://esupport.sony.com/US/perl/model-documents.pl?mdl=DAVDX255 and I was wondering if I could somehow replace the stock sub with some 12's or 15's that you would normally put in a car. Could I run the sub output from the home theater to another amp and then to the speakers or would that be messy. I think the stock sub is 1.5 ohms. It says on the link when you go to specs. The reason I'm asking is because eventually I was going to put them in my car that I won't have for a year or so, so I was going to get them and stick them in my dorm(and keep it low to not have the entire hall out to get me) until I got my car back, but if it would be difficult and not sound so great then I'll just wait.  more

Resolved Question: What code can I add so that when the form is submitted a confirmation email will be sent 2 the form user?

What code can I add to this so that when the form is submitted a confirmation email will be sent to the person who filled ot the form? #!/usr/bin/perl -wT # # mail-form cgi # Quick and dirty Web form processing script. Emails the data # to the recipient. # # You should change any variable that has "CONFIGURE" in the # comment. #### modules (these don't need changing) # # be strict, define all variables use strict; # use CGI.pm for parsing form data and printing headers/footers use CGI; # redirect errors to the browser window use CGI::Carp qw(warningsToBrowser fatalsToBrowser); # create an instance of CGI.pm: my($cgi) = CGI->new; # CONFIGURE: change this to the proper location of sendmail on your system: my($mailprog) = '/usr/sbin/sendmail'; # Set the path, so taint mode won't complain. This should be the path # that sendmail lives in! (If you're using /usr/lib/sendmail, then # the path had better be /usr/lib here.) $ENV{PATH} = "/usr/sbin"; # CONFIGURE: change this to the e-mail address you want to receive the # mailed form data my($recipient) = 'webmaster@email.com'; # CONFIGURE: change this to your URL: my($homepage) = "http://mywebsite.com"; # CONFIGURE: change this to the subject you want the e-mail to have # WARNING: Do NOT Let the form specify the subject line, or your # program can be hijacked by spammers!!! my($subj) = "Info Request"; # everything below this shouldn't need changing, except possibly the # "thank you" page at the end. # Print out a content-type header print $cgi->header; # CGI.pm automatically parses the data, and you can retrieve it using # $cgi->param("fieldname") # Now send mail to $recipient open (MAIL, "|$mailprog -t") || &dienice("Can't open $mailprog!\n"); print MAIL "To: $recipient\n"; print MAIL "From: $recipient\n"; print MAIL "Subject: $subj\n\n"; # print all of the form fields: foreach my $i ($cgi->param()) { print MAIL $i . ": " . $cgi->param($i) . "\n"; } print MAIL "\n\n"; # print some extra info: print MAIL "Server protocol: $ENV{'SERVER_PROTOCOL'}\n"; print MAIL "HTTP From: $ENV{'HTTP_FROM'}\n"; print MAIL "Remote host: $ENV{'REMOTE_HOST'}\n"; print MAIL "Remote IP address: $ENV{'REMOTE_ADDR'}\n"; close (MAIL); # CGI.pm prints the HTML header print $cgi->start_html(-title=>"Thank You", -bgcolor=>"#ffffff", -text=>"#000000"); # CONFIGURE: # Print a thank-you page - you can customize this however you wish. # Be sure to use proper HTML, and escape any $-signs or @-signs with a # backslash, e.g.: \$25.00, nullbox\@cgi101.com print <<EndHTML; <meta http-equiv="refresh" content="1;url=http://mysite.com/thanks.html"> EndHTML # CGI.pm prints the HTML footer print $cgi->end_html; # error handler sub dienice { my($msg) = @_; print $cgi->start_html(-title=>"Error"); print qq(<h2>Error</h2>\n); print $msg; print $cgi->end_html; exit; } # the end.  more

Voting Question: How to extract a specific line from hashes in Perl?

I've a file which contains several records and I have categorized them using hashes. But besides the categories which I already managed to extract, I also wish to extract a specific line from each of the records. So, how should I be extracting it within the hashes? my program script are as follow: #!/usr/bin/perl use strict; use warnings; #Introduction print "\nASSIGNMENT 2: CREATING A LIST OF MULTIDOMAIN PROTEINS\n\n"; #Declare and initialize variables my $record = ''; my $x = ''; my $y = ''; my $pfam = ''; #Get Swissprot file print "\nPlease key in the file name for this query:\t"; $x=<>; chomp $x; open (MYFILE,"<", $x) or die "Invaild file name"; print "\n\nRESULTS TO QUERY:\n\n\n"; #Set input separator to termination line $/ = "//\n"; #Define line_types sub get_line_types{ my ($record) = @_; my %line_types_hash = (); my @records = split(/\n/,$record); foreach my $line (@records){ my $line_type = substr($line,0,2); (defined $line_types_hash{$line_type}) ?($line_types_hash{$line_type} .= $line) :($line_types_hash{$line_type} = $line); } return %line_types_hash; } #Extract ID, Pfam and DE information from data while ($record = <MYFILE>){ my %line_types = get_line_types($record); defined $line_types{'ID'} or next; #Get Id of this record my $id = $line_types{'ID'}; $id =~ s/^ID\s*//; #Get Pfam of this record my $pfam = $line_types{'DR'}; #Get DE of this record my $DE = $line_types{'DE'}; $DE =~ s/DE //g; #Print outcome of query print "Protein:\t $id\n"; print "DR Pfam:\t $pfam\n"; print "Description:\t $DE\n\n\n"; } print "Press 'Q' to quit\t"; while ($y = <STDIN>){ chomp $y; if ($y =~ /^\s*Q/){ last; } } RL Science 309:131-133(2005). CC -!- SUBCELLULAR LOCATION: Cell membrane; lipid-anchor; GPI-anchor CC (Potential). In microneme/rhoptry complexes (By similarity). CC ----------------------------------------------------------------------- CC Copyrighted by the UniProt Consortium, see http://www.uniprot.org/terms CC Distributed under the Creative Commons Attribution-NoDerivs License CC ----------------------------------------------------------------------- DR EMBL; CR940353; CAI76474.1; -; Genomic_DNA. DR InterPro; IPR007480; DUF529. DR Pfam; PF04385; FAINT; 4. KW Complete proteome; GPI-anchor; Lipoprotein; Membrane; Repeat; Signal; KW Sporozoite. The above is part of the sample data which I had try with.  more

Resolved Question: Best cheap web hosting company in india?

Ruby Plan Details Disk Space500MB Monthly Bandwidth2GB FTP Accounts1 Sub Domains5 Email Accounts2 MySQL Databases1 PHP,MySQL,Ruby,Rail,ROR,perl,python yes 1 Year Plan$2.99/mon 2 Years Plan$1.99/mon Visit : www.host4websites.com sales@host4websites.com  more

Resolved Question: Perl Script Problems?

What is wrong with this script? #!/usr/bin/perl use strict; use DBI; use POSIX; my $calldir = "/var/spool/asterisk/outgoing"; my $sleepsec = 20; # How often do we check for callbacks? my $outchan = "SIP/PSTN"; # What channel do we call our customers back on? my $dbhost = "localh"; my $dbuser = "REMOVED"; my $dbpass = "REMOVED"; my $dbname = "REMOVED"; $| = 1; # Flush stdout print "Daemonizing...\n"; &daemonize; my $dbh = DBI->connect("dbi:mysql:$dbname:$dbhost","$dbuser","$dbpass") or die $DBI::errstr; my $qql = "SELECT queuename FROM queuename"; my $aryRef = $dbh->selectall_arrayref($qql); my @queuename = map { $aryRef->$_0} 0..$#{$aryRef}; while (1) { # begin main loop sleep($sleepsec); foreach my $queue (@queuename ) { # check each queue my $q1 = "SELECT uniqueid,callbacknum,queueid FROM callers WHERE queuename='".$queue."' ". "ORDER BY uniqueid LIMIT 1"; my $row = $dbh->selectrow_hashref( $q1 ); if (!$row->{callbacknum}) { next; } open CALLFILE, "+>>/tmp/cb$row->{uniqueid}.call"; print CALLFILE "Channel: $outchan/$row->{callbacknum}\n"; print CALLFILE "MaxRetries: 3\n"; print CALLFILE "RetryTime: 60\n"; print CALLFILE "WaitTime: 30\n"; print CALLFILE "Context: callback\n"; print CALLFILE "Extension: s\n"; print CALLFILE "Priority: 1\n"; print CALLFILE "Set: queueid=$row->{queueid}\n"; close CALLFILE; $dbh->do("DELETE FROM callers WHERE uniqueid=$row->{uniqueid}"); rename("/tmp/cb$row->{uniqueid}.call", "$calldir/$row->{uniqueid}.call"); } } # end main loop sub daemonize { chdir '/' or die "Can't chdir to /: $!"; open STDIN, '/dev/null' or die "Can't read /dev/null: $!"; open STDOUT, '>>/dev/null' or die "Can't write to /dev/null: $!"; open STDERR, '>>/dev/null' or die "Can't write to /dev/null: $!"; defined(my $pid = fork) or die "Can't fork: $!"; exit if $pid; setsid or die "Can't start a new session: $!"; umask 0; } It keeps giving me an error of: Global symbol "$_0" requires explicit package name at acd.pl line 25. Execution of acd.pl aborted due to compilation errors.  more

Resolved Question: ANY FREE WEBHOST WITHOUT ADS or POP UPS?

Iam learning scripts & stuff.. So Iam looking for a web hosting free with the following, please help. I need something that has these, doesnt have to be unlimited but atleast 1 or some. But must include all of the folowing. Unlimited Sub-Domains Unlimited MySQL Databases Unlimited FTP Accounts Unlimited POP3 Emails Unlimited E-Mail Aliases Unlimited Auto-Responders Spam Assasin Webmail Anonymous FTP Password Protection Perl 5.8.1 PHP 4.3.3 MySQL 4.0.15 Sendmail Support Frontpage Extensions POP3/SMTP Server File Manager Control Panel CPanel 8.5.3 Custom Error Pages Backup Manager Domain Parking Search Engine Submit Chat Room Discussion Board Shopping Cart Hotlink Protection CGI Center Add-On Scripts Thanks in advance!!!!!!!!!!!!!!!!!  more

Resolved Question: Perl Programming Help Please!?

I have a menu and I need the user to select an option. So for example: 1) add 2) subtract 3) multiply 4) divide 5) exit ($num=<stdin>;) How do I have this break up into groups for more detail without doing: if ($num=1); { stuff } elsif ($num=2) { other stuff } etc... I need to do this using Functions. How is this done? I was trying with the "sub" function but couldn't figure it out. Best answer will receive 10 points!  more

Resolved Question: Make directories and sub-directories with Perl?

Hello all. I'm new to making Perl scripts and I need to make a directory in my home folder, create 26 sub-directories in that folder labeled A through Z, then create 5 files in each sub-directory labled A.1 through A.7, B.1 through B.7, and so on. I'm looking for the best and most efficient way to do this with a bit of an explanation. Correction. The files should be labeled A.1 through A.5, B.1 through B.5, .......  more

Resolved Question: yesterday i have found this site?

www.webrotraffic.info - Free Cpanel Hosting with no ads Space (MB) : 350 Bandwidth : 1.5 GB Max FTP Accounts : 3 Max Email Accounts : 3 Max Email Lists : 3 Max Databases : 3 Max Sub Domains : 3 Max Parked Domains : 3 Max Addon Domains : 3 Account / Website Features Included * Web Browser Control Panel - cPanel * Fantastico Script Installer * POP3 Accounts * Forwarders * Auto-Responders * Mailing Lists * Mail Blocking * Sub-Domains * Email Aliases * FTP Accounts * Web Based Email Access * CGI, Perl, PHP * MS Frontpage™ Extensions * MySQL Databases * PhpMyAdmin Support * Cron Jobs * Web Based Statistics * Password Protected Files * SMTP Mail Server * Real Audio/Video * MX Record Changes * Anonymous FTP * Shopping Cart * Custom Error Pages * CGI Chat Room * Zend * Ion Cube * Mod_rewrite * register_globals off * .htaccess allowed i want to know more about this thing (free cpanel hosting ) . Can be something good ?  more

Resolved Question: How to cancel out of waiting for <STDIN> in Perl?

On one line i have $c = <STDIN>; I also have $SIG{INT} = \&ctrlc; and later on sub ctrlc { ... } How can i continue the script and skip the STDIN if Ctrl+C is hit?  more

Resolved Question: unix programming sub shells suggestions?

I recently wrote a script in perl to take care of a repetitive problem. It gathers information and formats the commands that need to be run in the shell. If i was to do each of these in the terminal myself i would do one press enter open a new terminal window do a different one let that run and so on, opening a new terminal window for each one. Each process can take up to thirty minutes to complete, but when i do it manually they can all run together. In my perl program i use the system command and the entire script works but to my disappointment the system operator waits for the bash shell to return before executing the next command. Any suggestions to get multiple processes running?  more

Resolved Question: I want names of World Masterpiece Theater Anime completely subbed?

I want names of complete sub Anime that has world classic story or what is called "World Masterpiece Theater". I want just Anime names that you have watched, I can search for them myself. I want one that complete English subbed because most of these Anime are not subbed of only few episodes subbed. Examples of such Anime Emily of the new moon Allison to Lillia Patapata Hikousen no Bouken this list of other ones but I don't which of them are completely subbed : http://anidb.net/perl-bin/animedb.pl?tagid=111&show=animelist&orderby.name=1.1&orderby.enddate=0.2&orderbar=0&noalias=1 I don't want websites but Anime names that is completely subbed. the examples gives idea of what I am looking for. Most Anime give you japanese feeling or culture but those in the list are like world classic Novels -Emily of the new moon : Canadian novel -based on the Jules Verne novels Facing the Flag and City in the Sahara so basically I am looking for Anime adapted from world novel or it might be from japanese novelist but it doesn't seem so since it cover about different country. like Monster, and Alison and Allison & Lillia  more

Resolved Question: help with perl, Subroutines, need by Monday night (before 9 pm EST if possible)?

ok I have 1 more problem to go but I can't seem to figure it out on what to do. so can anyone help me. here is the problem Copy rectangle04.pl to rectangle05.pl. Add code within the subroutine to separately check the values of length and width to be sure they are greater than zero. If either value is zero or less than zero print an informative message and stop the program. All checks should be done in the getArea subroutine. HERE IS RECTANGLE04.pl #!/usr/bin/perl -w # # ================= Subroutines =================== # # -------------------------------------------------- # SUBROUTINE: max # OBJECTIVE: Return the maximum value of two numbers. # # SAMPLE USAGE: # $maxValue = &max($firstValue,$secondValue) ; # # KNOWN BUGS: No error checking. # -------------------------------------------------- sub max { if($_[0] > $_[1]) { $_[0] ; # return first value. } else { $_[1] ; # return second value. } ; } # -------------------------------------------------- # SUBROUTINE: min # OBJECTIVE: Return the minimum value of two numbers. # # SAMPLE USAGE: # $minValue = &min($firstValue,$secondValue) ; # # KNOWN BUGS: No error checking. # -------------------------------------------------- sub min { if($_[0] < $_[1]) { $_[0] ; # return first value. } else { $_[1] ; # return second value. } ; } #-------------------------------------------------- # SUBROUTINE: getArea # OBJECTIVE: Return the area of a rectangle from the # two input numbers. # # SAMPLE USAGE: # $area = getArea($length,$width) ; # # KNOWN BUGS: No error checking. # -------------------------------------------------- sub getArea { my $length = $_[0] ; my $width = $_[1] ; my $area = $length * $width ; return $area ; } # ================= main program =================== print "Enter the first value:" ; $firstValue = <STDIN> ; chomp $firstValue ; print "Enter the second value:" ; $secondValue = <STDIN> ; chomp $secondValue ; $maxValue = &max($firstValue,$secondValue) ; print "The maximum value is $maxValue\n" ; $minValue = &min($firstValue,$secondValue) ; print "The minimum value is $minValue\n" ; $getArea = &getArea ($firstValue,$secondValue) ; print "the area is $getArea\n" ; if you need to know more about what im doing here is the pages http://cset.stcc.edu/~edbigos/courses/2008fa/cset-111/hw/hw10.pdf if you need to know more about what im doing here is the pages http://cset.stcc.edu/~edbigos/courses/2008fa/cset-111/hw/hw10.pdf  more

Resolved Question: who can provde the web hosting ?

I want to take a new shared web hosting server... my requirements are as follows 1. shared hosting... on good speed server 2. php 5 + mysql 5 + python + perl etc 3. multiple IPs ( if needed ) 4. atleast 100 domains , 10 ips 5. unlimited space , band width unlimited 6. ssh root access.. 7. good control panel for managing domains, sub domains, dns., etc... 8. good webstats /awstats 9. price should be from 1000rs - 2000rs monthly 10. server should be in india / very good ping reachble in india... and pls suggest... thank you...  more

Voting Question: I need help with perl coding!?

I'm looking for a way to shorten this code (use less lines), and also to get it to work, because it keeps bringing up this error: Can't modify constant item in scalar assignment at perlcode.pl line 1, near "2;" Execution of perlcode.pl aborted due to compilation errors. The code is: $m=10; $mm=-2; threshold=-2; sub maximal_local{ my $qstart = index($_[0], $_[2]); my $qend = $qstart + length($_[2])-1; my $tstart = index($_[1], $_[2]); my $tend = $tstart + length($_[2])-1; my $curr_score = length($kmer) * $m; my $prev_score = 0; while ($curr_score - $prev_score>$_[3]){ $prev_score = $curr_score; $qstart--; $qend++; $tstart--; $tend++; my $qs = substring($_[0], $qstart, 1); my $qe = substring($_[0], $qend, 1); my $ts = substring($_[1], $tstart, 1); my $te = substring($_[1], $tend, 1); if ($qs eq $ts){$curr_score += $m;} else {$curr_score += $mm;} if ($qe eq $te){curr_score += $m;} else {$curr_score += $mm;} } $qstart++; $qend--; $tstart++; $tend--; my $qseg = substring($_[0], $qstart, $qend-$qstart+1); my $tseg = substring($_[1], $tstart, $tend-$tstart+1); return ($qseg, $tseg); } &maximal_local ($q, $t, $kmer, $threshold); Please Help. Thank you. so i made some changes to the code, but i want the program to take the input from a file called input.txt. the new code is: $m=10; $mm=-2; $threshold=-2; sub maximal_local{ my $qstart = index($_[0], $_[2]); my $qend = $qstart + length($_[2])-1; my $tstart = index($_[1], $_[2]); my $tend = $tstart + length($_[2])-1; my $curr_score = length($kmer) * $m; my $prev_score = 0; while ($curr_score - $prev_score>$_[3]){ $prev_score = $curr_score; $qstart--; $qend++; $tstart--; $tend++; my $qs = substr($_[0], $qstart, 1); my $qe = substr($_[0], $qend, 1); my $ts = substr($_[1], $tstart, 1); my $te = substr($_[1], $tend, 1); if ($qs eq $ts){$curr_score += $m;} else {$curr_score += $mm;} if ($qe eq $te){$curr_score += $m;} else {$curr_score += $mm;} } $qstart++; $qend--; $tstart++; $tend--; my $qseg = substr($_[0], $qstart, $qend-$qstart+1); my $tseg = substr($_[1], $tstart, $tend-$tstart+1); return ($qseg, $tseg); } &maximal_local ($q, $t, $kmer, $threshold); the code should compute the maximal aligned segment of two sequences. Then, it should extend the sequence both forward and backward provided that the score of the forward and backward extension is greater than the threshold. If the score of an extension is less than the threshold, it stops the extension. an example input is $t: ACCTGTAGG $q: ATGTC $kmer="TGT" if the maximum alignment is extended, it becomes: CTGTA ATGTC this extension has a score of -4 which is less than the threshold -2, so the output is: TGT TGT note that match score is 10 and mismatch score is -2.  more

Resolved Question: I Need Perl Programming Help!?

the question is: Write a Perl program that scores an alignment using the scoring matrix in the file "matrix.txt". Assume that the alignment is stored in FASTA format in the file "dna.fasta". The program should print the alignment score as output. The file matrix.txt contains this input: 10 -1 2 1 -1 9 1 2 2 1 11 -1 1 2 -1 12 The file dna.fasta contains this input: >human ACCGTTAAG >mouse --CGTTCA- (the dashes '-' represents blanks or spaces) I think what they are basically asking is to I use the following input in matrix.txt: A C G T A 10 -1 2 1 C -1 9 1 2 G 2 1 11 -1 T 1 2 -1 12 to score the input in dna.fasta, and then print out the alignment score. Also, they want these done in a subroutine. I have the main code and the subroutine, but they seem to be combined all wrong and so cant perform the whole task. @matrix=(); &getmatrix("matrix.txt",\@matrix); @sequences=(); @names=(); &get_dna_score("dna.fasta", \@sequences, \@names); $score=$score(\@sequences, \@matrix); print $score; @matrix= ( ); &getmatrix ("matrix.txt",\@matrix ); for(my$i=0; $i<4; $i++) { for (my$j=0; $j<4; $j++) { print $matrix[$i][$j] ." "; } print "\n"; } sub getmatrix { open (IN, $_[0]); my $ref=$_[1]; $i=0; while(<IN>) { @s=split(/\s+/, $_); for (my$j=0; $j<@s; $j++) { $$ref[$i][$j]=$s[$j]; } $i++; } close(IN); return; } use strict; use warnings; open(IN, "dna.fasta"); my @file1=<IN>; chomp($file1[1]); chomp($file1[3]); close IN; sub get_dna_score { my @first_arr = split //, shift; my @second_arr = split //, shift; my $match = shift; my $miss = shift; my $gap = shift; my $score = 0; my ($i, $len); if (scalar @first_arr != scalar @second_arr) { die "Can't compare strings with different length!\n"; } for ($i = 0, $len = scalar @first_arr; $i < $len; ++$i) { if ($first_arr[$i] eq $second_arr[$i]) { $score += $match; } elsif ($first_arr[$i] eq " " || $second_arr[$i] eq " ") { $score += $gap; } else { $score += $miss; } } return $score; } print get_dna_score($file1[1], $file1[3], 2, -1, -2), "\n"; Please Help!!!  more

Resolved Question: How to simulate rolling a dice 6000 times with PERL?

I'm trying to do an assignment about Subroutines in PERL. I need to simulate rolling a dice 6000 times using the srand() and tally the results in a tabular format. Here is an excerpt of the code I produced: #Generates rolling a dice and counts the occurences which number shows up &roll_dice my @whichnum = qw(1 2 3 4 5 6 3 4 5 5 2 2 4 4 6); my %count; #####random generating rolling a die 6000 times, and trying to run the program once#### foreach($count) { if ($roll == 1 && <>6000) { foreach (@whichnum) { if (exists $count ($_)++; else { $count{$_} = 1; } } } } #counts the number of occurences which number shows up from #rolling a die foreach (@whichnum) { if (exists $count ($_)++; else { $count{$_} = 1; } } #counts how many occurences and shows result on tabular format foreach (keys %count) { print "$_ \t $count{$_} \n"; foreach( sub roll_dice { $roll = &roll_dice } I am just doing 1 side of rolling the die to see if this program works. However, I may miss some logic and trying to get this program to go to the right direction for this particular assignment. Any help is appreciated before Wednesday, October 15,2008.  more

Resolved Question: How to run a perl program in linux command line?

I'm having trouble running a perl program in the console. I'm on Ubuntu 8.04. The program I want to run is a hash collision. my $goal = '37a36dd7607832abdb366774b88a787f'; # hash to find my @chars = ( a..z, 0..9 ); # characters to use my $minlen = 1; # minimum length of string my $maxlen = 8; # maximum length of string for ( $minlen..$maxlen ) { print 'Length: ', $_, "\n"; &checkStrings($_); } sub checkStrings { my ( $n, $s ) = ( (shift) - 1, shift ); for ( @chars ) { if ( $n ) { checkStrings($n, $s . $_ ); } else { print $s, $_, "\n" if md4_hex( $s . $_ ) eq $goal; } } } If you can include the output of this program that would be greatly appreciated!! Thanks for all responses!  more

Resolved Question: Perl Tk GUI Design Question?

I'm looking for a way to use a bmp or gif as the background of a window. I can't quite figure how I would do that, but I assume it should be possible. Any help? use Tk; use strict; my $mw = MainWindow->new; $mw->geometry("400x100"); $mw->title("Main Window"); #$mw->Photo('imgbmp',-file=>"F:\\matrix.gif"); #$mw->Label('-image'=>'imgbmp')->pack; my $info_frame1 = $mw->Frame()->pack(-side => "top"); my $message1; $message1 = $info_frame1->Entry()->pack(-side => "right"); $message1->focus; $info_frame1->Label(-text => "Enter Username:")->pack(-side => "right"); my $button1 = $mw->Button(-text => "Open chat window", -command => \&button1_sub)->pack(-side => "top"); $button1->bind('Tk::Entry','<Return>', \&button1_sub); $mw->bind('Tk::Entry','<Key-Escape>', sub{exit}); $mw->Button(-text => "Exit", -command => sub{exit})->pack(); my $message;  more

Resolved Question: Perl Question-- How would i make a moving average?

sub moving_average($) { my $increment = shift; # Increment for average my $index; # Current item for average my @result; # Averaged data for ($index = 0; $index <= $#raw_data - $increment; $index++) { my $total = sum(@raw_data[$index..$index + $increment -1]); push (@result, $total / $increment); } return(@result); } My mentor gave me that scvripts Im not sure how to format the input any help appreciated  more

Resolved Question: Dear perl expert, I got an odd line of string, "HASH(0x225518)|HASH(0x225440)|HASH(0x15300fc)|HASH

I got this odd line of string in my file which I used in for my output of my program. The program I wrote just uses this statement: sub writetofile { open(PROFAIL, ">$profail"); print PROFAIL $_[0]; close(PROFAIL); } where this sub, named writetofile takes 1 argument and use it as the input string to be written into the file. One last time I ran it, it went through the string exactly in my file, but one time(this time), it show me this line on top of the exact string, where the rest is still ok. This is just like a header of the file, but I haven't done anything like that. All I've just done is just the sub, then the string passed to it is just consisted of a plain user data, like name, password, and so on in line-by-line basis. It went out ok before, but not this time. If you need to see what the inputs are, I can send it to you later. Thanks.  more

Resolved Question: Help me decide between 2 webhosts?

I'm currently stuck deciding between 2 great free hosts! Here's the breakdown: Host # 1: - short subdomain (about 3 char. long) - cPanel w/fantastico - PHP and Perl Support - Unlimited Sub-domains, E-mail, & MySQL Databases - Somewhat inactive owner - somewhat active hostees - very slow response (I posted a question at the forum and I only got a reply from the owner 10 days later) - not responsible for back-ups - owner has to review apps first - reseller at surpasshosting HOST # 2: - long subdomain (about 14 char. long) - No cPanel but has Webmin control panel instead - Unlimited space and bandwidth - Up to 2 subdomains (more upon request) and up to 5 websites - PHP 5.2, Ruby on Rails 1.2, MySql 5.0, phpMyAdmin, etc. - regular offsite back-ups - Very active owner (I sent 2 questions through email to him already and responded less than 30 minutes!) - Somewhat inactive hostees - very selective when it comes to hostees (But I fit) - own server I'm not linking to the sites because I don't want to attract applications from noobs and abusers if you know what I mean... The site I'm planning to make is a personal site and portfolio/fanlisting collective. I might buy a domain name and my own hosting account next year when I get my online payment stuff set-up. But for now, free-hosting will do. What do you guys think? Any opinion is much appreciated.  more

Resolved Question: How to resolve Perl error "Prototype mismatch: sub main::prompt ($;$) vs none at inc/Module/Install.pm line" ?

 more

Resolved Question: How to searh all .txt files under the specified path using Perl.?

I wanna to searh all .txt files under the path I specified(including sub folder). I don't know how to use that, could you give me a example?  more

Resolved Question: Simple code but wierd Perl behavior. Why does this happen?

Hello. I have a very simple subroutine that opens a file and reads the lines into an array, then prints out the array text. (I'm experimenting with arrays - not planning to print out all the lines directly so please don't tell me how to do that). sub printFile{ my ($file) = @_; open(HANDLE, "< $file") || die("Failed to open file!"); while(@line = <HANDLE>){ chomp(@line); print @line; } close(HANDLE); } So when I run the code it shows only one line of it that changes as it prints out the text and then it finishes with the last line shown. I would have expected it to fill the whole console window with text, but all it does is update a single line.  more

Resolved Question: Lets try to agree on something?

Ok, so I want everyone here to agree, and I want to see how many people can agree. Now, please read this with an OPEN MIND, forgetting your prejudices and thinking scientifically. S: (n) scientific theory (a theory that explains scientific observations) "scientific theories must be falsifiable" That is Princeton’s definition. http://wordnet.princeton.edu/perl/webwn?s=scientific+theory&sub=Search+WordNet&o2=&o0=1&o7=&o5=&o1=1&o6=&o4=&o3=&h=0 As used in science, a theory is an explanation or model based on observation, experimentation, and reasoning, especially one that has been tested and confirmed as a general principle helping to explain and predict natural phenomena. http://home.comcast.net/~fsteiger/theory.htm That is the definition and Atheist uses, on his website. Now based on these definitions, can we at least say that both creation and evolution ARE theories? Given that there is evidence, regardless of whether you believe the evidence, that creation is true. Now there is alot of evidence on this site, for creation, and everyone has already heard the evidence on evolution. www.creationevidence.org Now since were being open minded I will admit that evolution is a theory, a very nice theory, but has some problems. I will also admit that creation is a very nice theory, and some people have problems with it (there may be problems with creation). Both are theories on how we got here. Both have the possibility of being true. Both have evidence for and against them. Can we all agree? The Fossil Record...Evolutionists have constructed the Geologic Column in order to illustrate the supposed progression of "primitive" life forms to "more complex" systems we observe today. Yet, "since only a small percentage of the earth's surface obeys even a portion of the geologic column the claim of their having taken place to form a continuum of rock/life/time over the earth is therefore a fantastic and imaginative contrivance.1" "[T]he lack of transitional series cannot be explained as being due to the scarcity of material. The deficiencies are real, they will never be filled."2 This supposed column is actually saturated with "polystrate fossils" (fossils extending from one geologic layer to another) that tie all the layers to one time-frame. "[T]o the unprejudiced, the fossil record of plants is in favor of special creation." Man-made artifacts - such as the hammer in Cretaceous rock, a human sandal print with trilobite in Cambrian rock, human footprints www.creationevidence.org WOULD ANYONE please please please read the evidence before answering my question or are you all going on your predispositions? And to the big m or whoever you are, the evidence I'm stating is NOT at all evidence from the Bible, I am not usuing the Bible to prove the Bible I'm using fossil records to prove the Bible, this proves you didn't look at the evidence I'm using. PLEASE, NO MORE ANSWERS WITHOUT HAVING LOOKED AT THE WEBSITE AND INFORMATION ON THE WEBSITE!!!!!!!!!!!!! http://www.creationevidence.org/scientific_evid/evidencefor/evidencefor.html The problems with evolution: there are alot, most I couldn't even name. I have to say personaly I have a HUGE issue with being told that I came from nothing, then nothing turned into a dot, then that dot started spinning for no appearant reason, then the spinning continued and suddenly there was dirt, OUT OF NOTHING, and the dirt came into the dot, and the dot exploded and planets formed with mostly hydrogen, and the hydrogen became all chemicals. Which became people. Ok, how about, we would have proof that apes did NOT turn into human beings, which we have (were still missing that missing link) and we would see absolutly no evidence for any kind of evolution other than micro evolution which happens and have been proven. Also we would see that the earth has certain aspects, like more chemicals than hydrogen, its hard to fuse past iron. And we would see that there are planets spinning the wrong way which would disprove evolution but would prove that someone must have designed it that way. To prove evolution we would see people still evolving, and we don't see that. Does that meet your requirments? I liked your statement. Ok, again, thanks for what you said. What I meant about the rotation of planets was to disprove evolution, but I threw that in there for fun, it also works with creation, if we had a creator who intelligently said the planets would work best spinning like this we would see that, if evolution is true we would see all the planets spinning the same way because they all came from a spinning dot. If creation is true we would see: very complex structures all living things (even trees) sharing alot of DNA the smallest known organism being amazingly complex all 'kinds' staying within kind (no macro evolution being shown as if we always were in this 'kind' admittedly no one is sure where kind lays but it lays somewhere just above species in the taxa in my opinion - NOTE: not species) intelligent thought (as man was made in the image of God who was the intelligent designer) lots of different elements, elements that interact and such, as if they were always this way not changing  more

Resolved Question: What causes a "Bareword 'Module' not allowed while strict subs" error in Perl?

For example, if I run a program with a module called NetCDF::No_Write independently, it works fine. But when I stick it into a subroutine and within a foreach loop (so that it will do it for every element in an array that's passed into the subroutine) I get a "Bareword NetCDF::No_Write not allowed while strict subs at line ###" error. Just curious what kind of things I might want to look for.  more

Resolved Question: Perl Subroutine Question Involving Arrays...?

I can't seem to figure out why the subroutine is only returning the 3 values for the last element in the array I am passing to it in the foreach statement. The array @juliandate contains two elements, so I'd like to perform the calculation for both elements. Can anyone enlighten me as to where I'm going wrong? Thanks! sub Jul2Greg { use integer; my ($a, $g, $dg, $c, $dc, $b, $db, $da, $y); my ($m, $d, $sgregyear, $sgregmonth, $sgregday, $i); foreach $i(@juliandate) { #Other parts of algorithm omitted. $sgregyear = $y - 4800 + ($m + 2)/12; $sgregmonth = (($m + 2)%12)+1; $sgregday = $d + 1; } return($sgregmonth, $sgregday, $sgregyear); }  more

Resolved Question: Perl Subroutine Question?

I know that Perl saves things a subroutine does into the array @_, but is there a way to specify another place to send this? For example, in the following subroutine, I'd like to be able to use the values the subroutine computers ($GregYear, $GregMonth, $GregDay) elsewhere in the program. Is there an easy way to implement this? Thanks! --- sub Jul2Greg { use integer; my ($a, $g, $dg, $c, $dc, $b, $db, $da, $y); my ($m, $d, $GregYear, $GregMonth, $GregDay, $juliandate); $juliandate = 2454371; $a = $juliandate + 32044; $g = $a / 146097; $dg = $a % 146097; $c = (($dg / 36524)+1)*3/4; $dc = $dg - $c * 36534; $b = $dc / 1461; $db = $dc % 1461; $a = (($db/365)+1)*3/4; $da = $db - $a*365; $y = $g * 400 + $c * 100 + $b * 4 + $a; $m = ((($da * 5)+308)/153)-2; $d = $da - ((($m + 4) * 153)/5) + 122; $GregYear = $y - 4800 + ($m + 2)/12; $GregMonth = (($m + 2)%12)+1; $GregDay = $d + 1; }  more

Resolved Question: Need help about PERL?

I am writing a perl based test. For example, A.pl . In A.pl, I would like to call a sub routine that is defined in another file, say..B.pl. How do I do that?  more

Resolved Question: Perl Code question about 'exists' keyword?

This code returns an error: 'script produced no output'. Can anyone tell me why? print "Content-type: text/html\n\n"; if (exists &page_test) { &page_test; } sub page_test { print "test"; } Note: this is on an IIS server, and yes other code works, but I just cant get code with 'exists' to work.  more

Resolved Question: How do I pass a list/array of nubmers to the the 2 subroutines (add and multiply) as a reference in perl prgrm

An example I was given was $aref = \@array; # $aref now holds a reference to @array; So like if I had $xy = $aref; $xy now holds a reference to @array How do I put that in a program like this: # If first argument is add, run add function; if multiply, run multiply # function, otherwise warn user and end script $cmd = shift @ARGV; if ($cmd =~ /add|multiply/) { $rtn = &$cmd(@ARGV); print "The result is: $rtn\n"; } else { print "\nInvalid request, please use \"add\" or \"multiply\"\n"; print "followed by some numbers.\n"; } # Subroutine definitions # sub add { my $sum = 0; $sum += $_ foreach @_; return $sum; } sub multiply { my $prod = 1; $prod *= $_ foreach @_; return $prod; }  more

Resolved Question: How do you pass an array of numbers to a subroutine as a referecence in Perl.?

And in particular how would you do in it with this program for the add and multiply subroutine ? my ($rtn, $len); $len = @ARGV; # If first argument is add, run add function; if multiply, run multiply # function, otherwise warn user and end script if ($ARGV[0] =~ /add/) { $rtn = &add(@ARGV); print "The sum is: $rtn\n"; } elsif ($ARGV[0] =~ /multiply/) { $rtn = &multiply(@ARGV); print "The product is: $rtn\n"; } else { print "\nInvalid request, please use \"add\" or \"multiply\"\n"; print "followed by some numbers.\n"; } # Subroutine definitions # sub add { my ($sum, $i); $sum = 0; for ($i = 1; $i <= $len; $i++) { $sum += $_[$i]; } $sum; } sub multiply { my ($product, $i); $product = 1; for ($i = 1; $i < $len; $i++) { $product *= $_[$i]; } $product; }  more

Resolved Question: Does the following PERL program pass a list/array of numbers to the add an multiply subroutine as a referecenc

Does the following PERL program pass a list/array of numbers to the add and multiply subroutine as a referecence or does it not? And if doesn't how can make it do this. my ($rtn, $len); $len = @ARGV; # If first argument is add, run add function; if multiply, run multiply # function, otherwise warn user and end script if ($ARGV[0] =~ /add/) { $rtn = &add(@ARGV); print "The sum is: $rtn\n"; } elsif ($ARGV[0] =~ /multiply/) { $rtn = &multiply(@ARGV); print "The product is: $rtn\n"; } else { print "\nInvalid request, please use \"add\" or \"multiply\"\n"; print "followed by some numbers.\n"; } # Subroutine definitions # sub add { my ($sum, $i); $sum = 0; for ($i = 1; $i <= $len; $i++) { $sum += $_[$i]; } $sum; } sub multiply { my ($product, $i); $product = 1; for ($i = 1; $i < $len; $i++) { $product *= $_[$i]; } $product; }  more

Resolved Question: FREE Windows Hosting with Perl enabled?

Note: Please don't write telling me how paid hosting is better than free hosting. That is not the question. Can anyone tell me where I can find a FREE Windows Hosting with sub domain or ip address. It must support PERL. My Perl script will not run on a *nix machine. Thanks a bunch, Eric  more

Resolved Question: Using a multiply subroutine in Perl?

Using Perl, I can get the add subroutine to work perfectly with the same code but with switching every instance of $product to $sum and using "+=" instead of "*=" , but I am having trouble with the multiply subroutine. So far I have tried: sub multiply {$product=0; for($i=$#ARGV; $i>=0; $i--) {$product *= $ARGV[$i];} print "The product is: $product\n";} and sub multiply {my $product = 0; map { $product *= $_ } @ARGV;} print "The product is: $product\n";} It will compile without any errors, but I am getting 0 for every answer. To those who say I am multiplying by zero: I previously had changed $product to '1', '2', and '4'. It still does not work. When it prints out the $product, it prints out whatever it was initialized to first; (i.e. '1', '2', or '4').  more

Perl Sub News

Read more


Perl Sub Links


Fatal error: Call to undefined method baseParserClass::baseParserClassWithExtensions() in /home/battlegr/public_html/scripts/gaat/FeedForAll_XMLParser.inc.php on line 1693