Search Results

Search found 19539 results on 782 pages for 'pretty print'.

Page 72/782 | < Previous Page | 68 69 70 71 72 73 74 75 76 77 78 79  | Next Page >

  • How can I send an html email with perl?

    - by alexBrand
    I am trying to send an HTML email using perl. open(MAIL,"|/usr/sbin/sendmail -t"); ## Mail Header print MAIL "To: $to\n"; print MAIL "From: $from\n"; print MAIL "Subject: $subject\n\n"; ## Mail Body print MAIL "Content-Type: text/html; charset=ISO-8859-1\n\n<html><head></head><body>@emailBody"; close(MAIL) Is that the correct way of doing it? It is not working for some reason. Thanks for your help.

    Read the article

  • Fortran severe (40) Error... Help?!

    - by Taka
    I can compile but when I run I get this error "forrtl: severe (40): recursive I/O operation, unit -1, file unknown" if I set n = 29 or more... Can anyone help with where I might have gone wrong? Thanks. PROGRAM SOLUTION IMPLICIT NONE ! Variable Declaration INTEGER :: i REAL :: dt DOUBLE PRECISION :: st(0:9) DOUBLE PRECISION :: stmean(0:9) DOUBLE PRECISION :: first_argument DOUBLE PRECISION :: second_argument DOUBLE PRECISION :: lci, uci, mean REAL :: exp1, n REAL :: r, segma ! Get inputs WRITE(*,*) 'Please enter number of trials: ' READ(*,*) n WRITE(*,*) dt=1.0 segma=0.2 r=0.1 ! For n Trials st(0)=35.0 stmean(0)=35.0 mean = stmean(0) PRINT *, 'For ', n ,' Trials' PRINT *,' 1 ',st(0) ! Calculate results DO i=0, n-2 first_argument = r-(1/2*(segma*segma))*dt exp1 = -(1/2)*(i*i) second_argument = segma*sqrt(dt)*((1/sqrt(2*3.1416))*exp(exp1)) st(i+1) = st(i) * exp(first_argument+second_argument) IF(st(i+1)<=20) THEN stmean(i+1) = 0.0 st(i+1) = st(i) else stmean(i+1) = st(i+1) ENDIF PRINT *,i+2,' ',stmean(i+1) mean = mean+stmean(i+1) END DO ! Output results uci = mean+(1.96*(segma/sqrt(n))) lci = mean-(1.96*(segma/sqrt(n))) PRINT *,'95% Confidence Interval for ', n, ' trials is between ', lci, ' and ', uci PRINT *,'' END PROGRAM SOLUTION

    Read the article

  • PHP: variable not working inside of function?

    - by mathiregister
    hi guys, echo $path; //working function createList($retval) { echo $path; //not working print "<form method='POST' action='' enctype='multipart/form-data'>"; foreach ($retval as $value) { print "<input type='checkbox' name='deletefiles[]' id='$value' value='$value'>$value<br>"; } print "<input class='submit' name='deleteBtn' type='submit' value='Datei(en) löschen'>"; print "</form>"; } what am I doing wrong? why is $path printed corretly outside of the createlist function, but it's not inside of the function?

    Read the article

  • Instantiating a class within a class

    - by Ink-Jet
    Hello. I'm trying to instantiate a class within a class, so that the outer class contains the inner class. This is my code: #include <iostream> #include <string> class Inner { private: std::string message; public: Inner(std::string m); void print() const; }; Inner::Inner(std::string m) { message = m; } void Inner::print() const { std::cout << message << std::endl; std::cout << message << std::endl; } class Outer { private: std::string message; Inner in; public: Outer(std::string m); void print() const; }; Outer::Outer(std::string m) { message = m; } void Outer::print() const { std::cout << message << std::endl; } int main() { Outer out("Hello world."); out.print(); return 0; } "Inner in", is my attempt at containing the inner within the outer, however, when I compile, i get an error that there is no matching function for call to Inner::Inner(). What have I done wrong? Thanks.

    Read the article

  • What is the '@(' doing in this Perl code?

    - by Anthony Veckey
    In this code snippet: use strict; use warnings; use Data::Dumper; my $r = [qw(testing this thing)]; print Dumper($r); foreach my $row (@({$r}) { print "$row\n"; $row .= 'mod'; } print Dumper($r); print Dumper(@({$r}); I figured out that the '(' after the '@' in the foreach is causing this not to loop correctly. I have no idea why this code even works as there is no ending parenthesis. What is this doing? It looks to be creating a new variable on the fly, but shouldn't 'use strict' have fired or something? Please help explain what that '@(' is doing and why it still runs without an ending parenthesis.

    Read the article

  • regular expression not behaving as expected - Python

    - by philippe
    I have the following function which is supposed to read a .html file and search for <input> tags, and inject a <input type='hidden' > tag into the string to be shown into the page. However, that condition is never met:( e.g the if statement is never executed. ) What's wrong with my regex? def print_choose( params, name ): filename = path + name f = open( filename, 'r' ) records = f.readlines() print "Content-Type: text/html" print page = "" flag = True for record in records: if re.match( '<input*', str(record) ) != None: print record page += record page += "<input type='hidden' name='pagename' value='psychology' />" else: page += record print page Thank you

    Read the article

  • How can I enable a debugging mode via a command-line switch for my Perl program?

    - by Michael Mao
    I am learning Perl in a "head-first" manner. I am absolutely a newbie in this language: I am trying to have a debug_mode switch from CLI which can be used to control how my script works, by switching certain subroutines "on and off". And below is what I've got so far: #!/usr/bin/perl -s -w # purpose : make subroutine execution optional, # which is depending on a CLI switch flag use strict; use warnings; use constant DEBUG_VERBOSE => "v"; use constant DEBUG_SUPPRESS_ERROR_MSGS => "s"; use constant DEBUG_IGNORE_VALIDATION => "i"; use constant DEBUG_SETPPING_COMPUTATION => "c"; our ($debug_mode); mainMethod(); sub mainMethod # () { if(!$debug_mode) { print "debug_mode is OFF\n"; } elsif($debug_mode) { print "debug_mode is ON\n"; } else { print "OMG!\n"; exit -1; } checkArgv(); printErrorMsg("Error_Code_123", "Parsing Error at..."); verbose(); } sub checkArgv #() { print ("Number of ARGV : ".(1 + $#ARGV)."\n"); } sub printErrorMsg # ($error_code, $error_msg, ..) { if(defined($debug_mode) && !($debug_mode =~ DEBUG_SUPPRESS_ERROR_MSGS)) { print "You can only see me if -debug_mode is NOT set". " to DEBUG_SUPPRESS_ERROR_MSGS\n"; die("terminated prematurely...\n") and exit -1; } } sub verbose # () { if(defined($debug_mode) && ($debug_mode =~ DEBUG_VERBOSE)) { print "Blah blah blah...\n"; } } So far as I can tell, at least it works...: the -debug_mode switch doesn't interfere with normal ARGV the following commandlines work: ./optional.pl ./optional.pl -debug_mode ./optional.pl -debug_mode=v ./optional.pl -debug_mode=s However, I am puzzled when multiple debug_modes are "mixed", such as: ./optional.pl -debug_mode=sv ./optional.pl -debug_mode=vs I don't understand why the above lines of code "magically works". I see both of the "DEBUG_VERBOS" and "DEBUG_SUPPRESS_ERROR_MSGS" apply to the script, which is fine in this case. However, if there are some "conflicting" debug modes, I am not sure how to set the "precedence of debug_modes"? Also, I am not certain if my approach is good enough to Perlists and I hope I am getting my feet in the right direction. One biggest problem is that I now put if statements inside most of my subroutines for controlling their behavior under different modes. Is this okay? Is there a more elegant way? I know there must be a debug module from CPAN or elsewhere, but I want a real minimal solution that doesn't depend on any other module than the "default". And I cannot have any control on the environment where this script will be executed...

    Read the article

  • SFINAE and detecting if a C++ function object returns void.

    - by Tom Swirly
    I've read the various authorities on this, include Dewhurst and yet haven't managed to get anywhere with this seemingly simple question. What I want to do is to call a C++ function object, (basically, anything you can call, a pure function or a class with ()), and return its value, if that is not void, or "true" otherwise. #include <stdio.h> struct Foo { void operator()() {} }; struct Bar { bool operator()() { return false; } }; Foo foo; Bar bar; bool baz() { return false; } void bang() {} const char* print(bool b) { printf(b ? "true, " : "false, "); } template <typename Functor> bool magicCallFunction(Functor f) { return true; // lots of template magic occurs here... } int main(int argc, char** argv) { print(magicCallFunction(foo)); print(magicCallFunction(bar)); print(magicCallFunction(baz)); print(magicCallFunction(bang)); printf("\n"); }

    Read the article

  • Reading a series of input / output in Python

    - by PulpFiction
    Hello everyone. For my app, I need to print out a series of outputs and then accepts inputs from the user. What would be the best way of doing this? Like: print '1' x = raw_input() print '2' y = raw_input() Something like this, but it would go on for at least 10 times. My only concern with doing the above is that it would make up for poor code readability. How should I do it? Should I create a function like this: def printOut(string): print string Or is there a better way?

    Read the article

  • OnClientClick event for keeping track of prints?

    - by Ram
    Hello, I am trying to keep track of prints that are made for a page. The page has Print this page link. And the code for it is like below: This is written in .cs file as there are many conditions for displaying this. And i am appending here using String Builder. sbOutput.AppendFormat("<td align=\"right\" valign=\"bottom\"><div style =\"float:right;text-align:right; valign:bottom;width:200px\"class=\"print_button notPrinted\"><a class=\"notPrinted\" href=\"#\" onclick=\"window.print();\">PRINT THIS COUPON </a><img src=\"images/print-icon-34x34.gif\" class=\"notPrinted\" align=\"absmiddle\" /></div> </td></tr></table>", couponid, Userid, locationid); Do i have to use onclientclick or something else?? Thanks so much in advance.

    Read the article

  • MySQLDB query not returning all rows

    - by RBK
    I am trying to do a simple fetch using MySQLDB in Python. I have 2 tables(Accounts & Products). I have to look up Accounts table, get acc_id from it & query the Products table using it. The Products tables has more than 10 rows. But when I run this code it randomly returns between 0 & 6 rows each time I run it. Here's the code snippet: # Set up connection con = mdb.connect('db.xxxxx.com', 'user', 'password', 'mydb') # Create cursor cur = con.cursor() # Execute query cur.execute("SELECT acc_id FROM Accounts WHERE ext_acc = '%s'" % account_num ) # account_num is alpha-numberic and is got from preceding part of the program # A tuple is returned, so get the 0th item from it acc_id = cur.fetchone()[0] print "account_id = ", acc_id # Close the cursor - I was not sure if I can reuse it cur.close() # Reopen the cursor cur = con.cursor() # Second query cur.execute("SELECT * FROM Products WHERE account_id = %d" % acc_id) keys = cur.fetchall() print cur.rowcount # This prints incorrect row count for key in keys: # Does not print all rows. Tried to directly print keys instead of iterating - same result :( print key # Closing the cursor & connection cur.close() con.close() The weird part is, I tried to step through the code using a debugger(PyDev on Eclipse) and it correctly gets all rows(both the value stored in the variable 'keys' as well as console output are correct). I am sure my DB has correct data since I ran the same SQL on MySQL console & got the correct result. Just to be sure I was not improperly closing the connection, I tried using with con instead of manually closing the connection and it's the same result. I did RTFM but I couldn't find much in it to help me with this issue. Where am I going wrong? Thank you. EDIT: I noticed another weird thing now. In the line cur.execute("SELECT * FROM Products WHERE account_id = %d" % acc_id), I hard-coded the acc_id value, i.e made it cur.execute("SELECT * FROM Products WHERE account_id = %d" % 322) and it returns all rows

    Read the article

  • Does dict.update affect a function's argspec?

    - by sbox32
    import inspect class Test: def test(self, p, d={}): d.update(p) return d print inspect.getargspec(getattr(Test, 'test'))[3] print Test().test({'1':True}) print inspect.getargspec(getattr(Test, 'test'))[3] I would expect the argspec for Test.test not to change but because of dict.update it does. Why?

    Read the article

  • How can I use Awk inside a Perl script?

    - by papoyan
    I'm having trouble using the following code inside my Perl script, any advise is really appreciated, how to correct the syntax? # If I execute in bash, it's working just fine bash$ whois google.com | egrep "\w+([._-]\w)*@\w+([._-]\w)*\.\w{2,4}" |awk ' {for (i=1;i<=NF;i++) {if ( $i ~ /[[:alpha:]]@[[:alpha:]]/ ) { print $i}}}'|head -n1 [email protected] #----------------------------------- #but this doesn't work bash$ ./email.pl google.com awk: {for (i=1;i<=NF;i++) {if ( ~ /[[:alpha:]]@[[:alpha:]]/ ) { print }}} awk: ^ syntax error # Here is my script bash$ cat email.pl ####\#!/usr/bin/perl $input = lc shift @ARGV; $host = $input; my $email = `whois $host | egrep "\w+([._-]\w)*@\w+([._-]\w)*\.\w{2,4}" |awk ' {for (i=1;i<=NF;i++) {if ( $i ~ /[[:alpha:]]@[[:alpha:]]/ ) { print $i}}}'|head -1`; print my $email; bash$

    Read the article

  • I can I separate multiple logical pages in a text file I create in Perl?

    - by Micah
    So far, I've been successful with generating output to individual files by opening a file for output as part of outer loop and closing it after all output is written. I had used a counting variable ($x) and appended .txt onto it to create a filename, and had written it to the same directory as my perl script. I want to step the code up a bit, prompt for a file name from the user, open that file once and only once, and write my output one "printed letter" per page. Is this possible in plain text? From what I understand, chr(12) is an ascii line feed character and will get me close to what I want, but is there a better way? Thanks in advance, guys. :) sub PersonalizeLetters{ print "\n\n Beginning finalization of letters..."; print "\n\n I need a filename to save these letters to."; print "\n Filename > "; $OutFileName = <stdin>; chomp ($OutFileName); open(OutFile, ">$OutFileName"); for ($x=0; $x<$NumRecords; $x++){ $xIndex = (6 * $x); $clTitle = @ClientAoA[$xIndex]; $clName = @ClientAoA[$xIndex+1]; #I use this 6x multiplier because my records have 6 elements. #For this routine I'm only interested in name and title. #Reset OutLetter array #Midletter has other merged fields that aren't specific to who's receiving the letter. @OutLetter = @MiddleLetter; for ($y=0; $y<=$ifLength; $y++){ #Step through line by line and insert the name. $WorkLine = @OutLetter[$y]; $WorkLine =~ s/\[ClientTitle\]/$clTitle/; $WorkLine =~ s/\[ClientName\]/$clName/; @OutLetter[$y] = $WorkLine; } print OutFile "@OutLetter"; #Will chr(12) work here, or is there something better? print OutFile chr(12); $StatusX = $x+1; print "Writing output $StatusX of $NumRecords... \n\n"; } close(OutFile); }

    Read the article

  • PHP object help -> unexpected T_OBJECT_OPERATOR

    - by php-b-grader
    Please help me understand: print gettype(new CustomerObject()) prints: "object" (so it is an object) BUT print gettype((new CustomerObject())->get_customer()); prints: unexpected T_OBJECT_OPERATOR If I do it over two lines it works fine $object = new Customer($order->customer_id); print gettype($object); prints: object $customer = $object->get_customer(); print gettype($customer); prints: array It appears that the lines cannot be joined into a single call. Is this correct? and what is the logic behind that?

    Read the article

  • Concatenate, sort and swap array in Java

    - by sblck
    I am trying to concatenate two arrays into new array, sort in order, and swap two values of index. I'm kind of new to java and only use C before so having a hard time handling an Object. In main method it declares two object arrays IntVector vector = new IntVector(3); and IntVector vector2 = new IntVector(3); I can only do this if the types are int[], but I want to use as an object How should I code the concat, sort, and swap method? public class IntVector { private int[] items_; private int itemCount_; private IntVector(int[] data, int n) { items_ = data.clone(); itemCount_ = n; } public IntVector(int itemSize) { itemCount_ =0; if(itemSize<1) itemSize =10; items_ = new int[itemSize]; } public void push(int value) { if(itemCount_ + 1 >= items_.length) overflow(); items_[itemCount_++] = value; } public void log() { for (int i=0 ; i<itemCount_; ++i) { System.out.print(items_[i]); if(i<itemCount_ -1) System.out.println(); } } public void overflow() { int[] newItems = new int[items_.length * 2]; for(int i=0 ; i<itemCount_; ++i) { newItems[i] = items_[i]; } items_=newItems; } public int getValue(int index) { if(index < 0 || index >= itemCount_) { System.out.println("[error][IntVector][setValue] Incorrect index=" + index); return 0; } return items_[index]; } public void setValue(int index, int value) { if(index < 0 || index >= itemCount_) { System.out.println("[error][IntVector][setValue] Incorrect index=" + index); return ; } items_[index] = value; } public IntVector clone() { return new IntVector(items_, itemCount_); } public IntVector concat() { return null; } public IntVector sort() { return null; } public IntVector swap() { return null; } public static void main(String[] args) { IntVector vector = new IntVector(3); IntVector vector2 = new IntVector(3); vector.push(8); vector.push(200); vector.push(3); vector.push(41); IntVector cloneVector = vector.clone(); vector2.push(110); vector2.push(12); vector2.push(7); vector2.push(141); vector2.push(-32); IntVector concatResult = vector.concat(vector2); IntVector sortResult = concatResult.sort(); IntVector swapResult = sortResult.clone(); //swapResult.swap(1,5); System.out.print("vector : "); vector.log(); System.out.print("\n\ncloneVector : "); cloneVector.log(); System.out.print("\n\nvector2 : "); vector2.log(); System.out.print("\n\nconcatvector : "); concatResult.log(); System.out.print("vector : "); vector.log(); System.out.print("vector : "); vector.log(); } }

    Read the article

  • Sleeping a thread blocking stdin

    - by Sid
    Hey, I'm running a function which evaluates commands passed in using stdin and another function which runs a bunch of jobs. I need to make the latter function sleep at regular intervals but that seems to be blocking the stdin. Any advice on how to resolve this would be appreciated. The source code for the functions is def runJobs(comps, jobQueue, numRunning, limit, lock): while len(jobQueue) >= 0: print(len(jobQueue)); if len(jobQueue) > 0: comp, tasks = find_computer(comps, 0); #do something time.sleep(5); def manageStdin(): print "Global Stdin Begins Now" for line in fileinput.input(): try: print(eval(line)); except Exception, e: print e; --Thanks

    Read the article

  • Error compiling basic java code

    - by Michael Younani
    New to java. Practicing coding by following a book. Heres my code: class Motorcycle { //Three instance variables - make and color are strings. while a boolean refers to TRUE OR FLASE(in this case off or on) String make; String color; boolean engineState; void startEngine() { if (engineState == true) System.out.print("The engine is already on."); else { engineState = true; System.out.print("The engine is now on."); } void showAtts() { System.out.print("This motorcycle is a " + color + " " + make); if (engineState ==true) System.out.print("The engine is on."); else System.out.print("The engine is off."); } } } When I compile I get 2 errors: 1) illegal start of expression 2) ; expected I can't pin point the problem. If anyone can direct me or hint me please do.

    Read the article

  • Login with Google OAuth api and return url with variable

    - by user2833721
    I am using the Google API for login in my site and I appending my variable with URL and I want that variable in the return URL of OAuth API because of update purpose can I return back that variable For example: <a href="<?php echo($authUrl); ?>&kicker"> I append the kicker in $authUrl and when I return back from Oauth api print $me['displayName']; print $user['email']; print $me['gender']; print $me['id']; with this output I also want my variable "kicker" how can I get it

    Read the article

  • Python lxml - returns null list

    - by Chris Finlayson
    I cannot figure out what is wrong with the XPATH when trying to extract a value from a webpage table. The method seems correct as I can extract the page title and other attributes, but I cannot extract the third value, it always returns an empty list? from lxml import html import requests test_url = 'SC312226' page = ('https://www.opencompany.co.uk/company/'+test_url) print 'Now searching URL: '+page data = requests.get(page) tree = html.fromstring(data.text) print tree.xpath('//title/text()') # Get page title print tree.xpath('//a/@href') # Get href attribute of all links print tree.xpath('//*[@id="financial"]/table/tbody/tr/td[1]/table/tbody/tr[2]/td[1]/div[2]/text()') Unless i'm missing something, it would appear the XPATH is correct: Chrome screenshot I checked Chrome console, appears ok! So i'm at a loss $x ('//*[@id="financial"]/table/tbody/tr/td[1]/table/tbody/tr[2]/td[1]/div[2]/text()') [ "£432,272" ]

    Read the article

  • Find all occurrences of a substring in Python

    - by cru3l
    Python has string.find() and string.rfind() to get the index of a substring in string. I wonder, maybe there is something like string.find_all() which can return all founded indexes (not only first from beginning or first from end)? For example: string = "test test test test" print string.find('test') # 0 print string.rfind('test') # 15 #that's the goal print string.find_all('test') # [0,5,10,15]

    Read the article

< Previous Page | 68 69 70 71 72 73 74 75 76 77 78 79  | Next Page >