Search Results

Search found 1147 results on 46 pages for 'strict'.

Page 26/46 | < Previous Page | 22 23 24 25 26 27 28 29 30 31 32 33  | Next Page >

  • How can I create a custom cleanup mode for git?

    - by Danny
    Git's default cleanup of strip removes all lines starting with a # character. Unfortunately, the Trac engine's wiki formatter uses hashes in the beginning of a code block to denote the syntax type. Additionally any code added verbatim might include hashes as they are a common comment prefix; Perl comes to mind. In the following example the comments all get destroyed by git's cleanup mode. Example: {{{ #!/usr/bin/perl use strict; # say hi to the user. print "hello world\n"; }}} I'd like to use a custom filter that removes all lines beginning with a hash from the bottom of the file upwards. Leaving those lines that being with a hash that are embedded in the commit message I wrote alone. Where or how can I specify this in git? Note, creating a sed or perl script to perform the operation is not a problem, just knowing where to hook it into git is the question.

    Read the article

  • At the download of a file: does it make sense to check the filesize?

    - by sid_com
    Does the test of the file-size make sense here? I tried to cut the connection while downloading, but it looks like the size-test is never reached. #!/usr/bin/env perl use warnings; use strict; use 5.012; use LWP::Simple; my $file_size = '2342'; my $response = getstore( 'url', 'filename' ); if ( is_success $response ) { if ( $file_size == -s 'filename' ) { say "OK"; } }

    Read the article

  • Problem of import DBI module - Complication Failed in require

    - by Winnie
    Hi All, I have a problem when I use the DBI module in scritp .pm. please help thanks you package CC; use DBI; use strict; use Alias; my $dbFile = 'XXXXXXXX.db'; my $db = DBI-connect("dbi:SQLite:$dbFile","","", {RaiseError =1, AutoCommit = 1})or "Unable to connect: $DBI::errstr\n"; use Alias qw(attr); our ($CURRENTOFFSET,@LANGUAGE); sub new { my $that = shift; my $class = ref($that)|| $that; my $self = { CURRENTOFFSET= undef, LANGUAGE = [] }; bless($self, $class); return $self; }

    Read the article

  • How to run system-commands in the background?

    - by sid_com
    #!/usr/bin/env perl use warnings; use strict; use 5.012; use IPC::System::Simple qw(system); system( 'xterm', '-geometry', '80x25-5-5', '-bg', 'green', '&' ); say "Hello"; say "World"; I tried this to run the xterm-command in the background, but it doesn't work: No absolute path found for shell: & What would be the right way to make it work?

    Read the article

  • File::Find and $_ in nested subroutines.

    - by zedoo
    When running the following code, the filenames of all files below C:\Test are printed. Why doesn't it print just Hello (n times, depending on how many files are processed)? Does this imply that I cannot rely on shift to reliably assign to $_? Imagine a coworker implements the wtf function and doesn't know that it's called from a File::Find wanted sub. I run this code with Strawberry Perl 5.12 use strict; use warnings; use File::Find; find(\&wanted, "C:\\test"); sub wanted{ wtf("Hello"); } sub wtf { shift; print; #expecting Hello }

    Read the article

  • Insert A Line At The Beginnig Of A File

    - by thebourneid
    I'm trying to insert/add a line 'COMMENT DUMMY' at the beginnig of a file as a first row if /PATTERN/ not found. I know how to do this with OPEN CLOSE function. Probably after reading the file it should look something like this: open F, ">", $fn or die "could not open file: $!"; ; print F "COMMENT DUMMY\n", @array; close F; But I have a need to implement this with the use of the Tie::File function and don't know how. use strict; use warnings; use Tie::File; my $fn = 'test.txt'; tie my @lines, 'Tie::File', $fn or die "could not tie file: $!"; untie @lines;

    Read the article

  • why doesn't perl sort the hash key in numeric order ?

    - by Haiyuan Zhang
    #!/usr/bin/perl use strict; use warnings; my %hash; foreach ( 1 .. 10 ) { $hash{$_} = $_; } foreach ( sort(keys %hash) ) { print $_ . ": " . "$hash{$_}" . "\n" ; } execute the above code, the result is as below : 1: 1 10: 10 2: 2 3: 3 4: 4 5: 5 6: 6 7: 7 8: 8 9: 9 Yes, I expect "10: 10" to be the last one taht is printed . So I just need someone to explain why perl give me surprise in this case.

    Read the article

  • Excel Worksheet assignment in VB.Net doesn't compile

    - by Brian Hooper
    I'm converting a VB6 application into VB.Net and having trouble with the basics. I start off with:- Dim xl As Excel.Application Dim xlsheet As Excel.Worksheet Dim xlwbook As Excel.Workbook xl = New Excel.Application xlwbook = xl.Workbooks.Open(my_data.file_name) xlsheet = xlwbook.Sheets(1) but the last line doesn't compile; it reports Option Strict On disallows implicit conversion from 'Object' to 'Microsoft.Office.Interop.Excel.Worksheet' I can make this go away by replacing the line with xlsheet = CType(xlwbook.Sheets(1), Excel.Worksheet) but that does't look like the right thing to do to me. If the assignment is correct, I would have thought the object should naturally have the correct type. So: does anyone know what the correct thing I should be doing here?

    Read the article

  • Is a safe accumulator really this complicated?

    - by Martin
    I'm trying to write an accumulator that is well behaved given unconstrained inputs. This seems to not be trivial and requires some pretty strict planning. Is it really this hard? int naive_accumulator(unsigned int max, unsigned int *accumulator, unsigned int amount) { if(*accumulator + amount >= max) return 1; // could overflow *accumulator += max; // could overflow return 0; } int safe_accumulator(unsigned int max, unsigned int *accumulator, unsigned int amount) { // if amount >= max, then certainly *accumulator + amount >= max if(amount >= max) { return 1; } // based on the comparison above, max - amount is defined // but *accumulator + amount might not be if(*accumulator >= max - amount) { return 1; } // based on the comparison above, *accumulator + amount is defined // and *accumulator + amount < max *accumulator += amount; return 0; }

    Read the article

  • Best practice question

    - by sid_com
    Hello! Which version would you prefer? #!/usr/bin/env perl use warnings; use strict; use 5.010; my $p = 7; # 33 my $prompt = ' : '; my $key = 'very important text'; my $value = 'Hello, World!'; my $length = length $key . $prompt; $p -= $length; Option 1: $key = $key . ' ' x $p . $prompt; Option 2: if ( $p > 0 ) { $key = $key . ' ' x $p . $prompt; } else { $key = $key . $prompt; } say "$key$value"

    Read the article

  • Change all instances of object to iframe for IE using Jquery

    - by geckomist
    I was wondering if it would be possible to use jquery to change all object tags on a site automatically to iframe for IE 8 and below. I would like this so that it can be xhtml 1.1 valid and not have to be double coded all the time and you would not have to focus on non-standard browsers. The data attribute would have to be changed to src, I would like frameborder="0" to be inserted, and all styles set to the object tag also set to the iframe tag. I don't want this to turn into a debate on iframes vs objects, I just thing this would be a huge time saver and would encourage proper strict xhtml coding. Thanks for any input!

    Read the article

  • Does Core Data automatically validate new values when they are set?

    - by mystify
    In this question, someone asked how to write a validation method for Core Data. I did that, and it looks cool. But one thing doesn't happen: The validation. I can easily set any "bad" value and this method doesn't get called automatically. What's the concept behind this? Must I always first call the validation method before setting any value? So would I write setter methods which call the appropriate validation method first? And if yes, what's the point of following a strict convention in how to write the validation method signature? I guess there's also some automatic way of validation, then. How to activate this?

    Read the article

  • How do I split Chinese characters one by one?

    - by Nano HE
    If there is no special character(such as white space, : etc) between firstname and lastname. Then how to split the Chinese characters below. use strict; use warnings; use Data::Dumper; my $fh = \*DATA; my $fname; # ??; my $lname; # ? ; while(my $name = <$fh>) { $name =~ ??? ; print $fname"/n"; print $lname; } __DATA__ ??? Output ?? ?

    Read the article

  • How to add header, footer with images using PDF::API2::Lite ?

    - by Space
    Is it possible to add header(with image) and footer (with page number) with images. I wrote below code to create a PDF document which shows png images. If this can be done easily with any other module, please suggest.Really appreciate response with sample code. use strict; use PDF::API2::Lite; use Getopt::Long; my $outfile; my $path; my $options = GetOptions( "outfile=s" => \$outfile, "images=s" => \$path,); my @images = sort glob("$path") or die "No Files\n"; my $pdf = PDF::API2::Lite->new(); for my $png ( sort @images ) { my $image = $pdf->image_png( "$png" ); $pdf->page(1150,450); $pdf->image($image, 10, 10); } $pdf->saveas( $outfile );

    Read the article

  • Listing C/C++ functions (Code analysis in Unix)

    - by Jond
    Whether we're maintaining unfamiliar code or checking out the implementation details of an Apache module it can help if we can quickly traverse the code and build up an overview of what we're looking at. Grep serves most of my daily needs but there are some cases where it just wont do. Here's a common example of how it can help. To find the definition of a PHP function I'm interested in I can type this at the command line: grep -r "function myfunc" . This could be adapted very quickly to C or C++ if we know the return type, but things become more complicated if, say, I want to list every method that my class provides: grep "function " ./src/mine.class.php Since there's no single keyword that denotes a function or method in C++ and because it's generally more complex syntax, I think I'd need some kind of static code analysis tool, smart use of the C Preprocessor or blind faith the coder followed strict code guidelines (# of whitespace, position of curlies etc) to get these sorts of results. What would you recommend? p.s. be nice, this is my first post ;-) :p

    Read the article

  • How can I insert a line at the beginning of a file with Perl's Tie::File?

    - by thebourneid
    I'm trying to insert/add a line 'COMMENT DUMMY' at the beginnig of a file as a first row if /PATTERN/ not found. I know how to do this with OPEN CLOSE function. Probably after reading the file it should look something like this: open F, ">", $fn or die "could not open file: $!"; ; print F "COMMENT DUMMY\n", @array; close F; But I have a need to implement this with the use of the Tie::File function and don't know how. use strict; use warnings; use Tie::File; my $fn = 'test.txt'; tie my @lines, 'Tie::File', $fn or die "could not tie file: $!"; untie @lines;

    Read the article

  • Why does Term::Size seem to mess up Perl's output encoding?

    - by sid_com
    Hello! The Term::Size-module jumbles up the encoding. How can I fix this? #!/usr/bin/env perl use warnings; use strict; use 5.010; use utf8; binmode STDOUT, ':encoding(UTF-8)'; use Term::Size; my $string = 'Hällö'; say $string; my $columns = ( Term::Size::chars *STDOUT{IO} )[0]; say $columns; say $string; Output: Hällö 140 H?ll?

    Read the article

  • More HTTP verbs with AS3?

    - by tedw4rd
    I'm developing a social game in Flash with a team of developers. Our server-side guy has developed a really slick RESTful API for the Flash client to talk to. A lot of the client-server interactions involve adding and removing objects from a persistent world, so the API makes extensive use of the PUT and DELETE verbs. The problem is, the URLRequest object in AS3 only supports the GET and POST verbs. We're on a strict schedule, and we'd really rather not have to rewrite the whole API to just use GET and POST. Has anyone come up with a good way to get Flash to send other verbs?

    Read the article

  • Calling a method on a Object says "disallows late binding"

    - by Maury Markowitz
    I have a calls called DtaDate that stores an integer "key", a string name, a string for the date, and a Date object that is created from that string. I have some code that needs to accept a date-like object. I'd like the user to be able to pass in anything date like - a Date object which I'll extract the information from, another DtaDate, a string with the date in it, or even the key, which I'll use to look up the DtaDate from a collection. So I have this: Friend Sub New(NameIn As String, DateFormulaIn As String, Optional FromDateIn As Object = Nothing) [stuff that works] [check that we got a FromDateIn...] If TypeOf FromDateIn Is DtaDate Then fdk = FromDateIn.Key Ans.FromDate = fdk VB tells me that "Option Strict On disallows late binding". The other cases, where a string or integer is the TypeOf, I use CInt or CStr. But this is the first time I've actually run into a case where the casting is a non-base type. What's the trick?

    Read the article

  • When is (true == x) === !!x false?

    - by Paul S.
    JavaScript has different equality comparison operators Equal == Strict equal === It also has a logical NOT ! and I've tended to think of using a double logical NOT, !!x, as basically the same as true == x. However I know this is not always the case, e.g. x = [] because [] is truthy for ! but falsy for ==. So, for which xs would (true == x) === !!x give false? Alternatively, what is falsy by == but not !! (or vice versa)?

    Read the article

  • Which code snipplets in PHP can create a input form, which creates a new set of data in my mysql dat

    - by smiyazaki
    I am using the Google Maps API with parts in javascript and others in PHP. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> Google Maps AJAX + mySQL/PHP Example // var iconBlue = new GIcon(); iconBlue.image = 'icon.png'; iconBlue.shadow = ''; iconBlue.iconSize = new GSize(19, 19); iconBlue.shadowSize = new GSize(22, 20); iconBlue.iconAnchor = new GPoint(6, 20); iconBlue.infoWindowAnchor = new GPoint(5, 1); var iconRed = new GIcon(); iconRed.image = 'icon.png'; iconRed.shadow = ''; iconRed.iconSize = new GSize(19, 19); iconRed.shadowSize = new GSize(22, 20); iconRed.iconAnchor = new GPoint(6, 20); iconRed.infoWindowAnchor = new GPoint(5, 1); var customIcons = []; customIcons["restaurant"] = iconBlue; customIcons["bar"] = iconRed; function load() { if (GBrowserIsCompatible()) { var map = new GMap2(document.getElementById("map")); map.setMapType(G_SATELLITE_MAP); map.addControl(new GSmallMapControl()); map.addControl(new GMapTypeControl()); map.setCenter(new GLatLng(47.614495, -122.341861), 13); // Change this depending on the name of your PHP file GDownloadUrl("phpsqlajax_genxml.php", function(data) { var xml = GXml.parse(data); var markers = xml.documentElement.getElementsByTagName("marker"); for (var i = 0; i < markers.length; i++) { var name = markers[i].getAttribute("name"); var address = markers[i].getAttribute("address"); var type = markers[i].getAttribute("type"); var point = new GLatLng(parseFloat(markers[i].getAttribute("lat")), parseFloat(markers[i].getAttribute("lng"))); var marker = createMarker(point, name, address, type); map.addOverlay(marker); } }); } } function createMarker(point, name, address, type) { var marker = new GMarker(point, customIcons[type]); var html = "<b>" + name + "</b> <br/>" + address; GEvent.addListener(marker, 'click', function() { marker.openInfoWindowHtml(html); }); return marker; } //]]> (I suppose the php will be called by "GDownloadUrl("phpsqlajax_genxml.php", function(data) { ..." in the javascript part of the sourcecode of phpsqlajax_map.htm) Now I need another php file and the code snipplets for it, which creates an input form where I can add some new locations to the google map. Following code is used to create the xml file here: http://detektors.de/maptest/phpsqlajax_genxml.php The next step would be, trying to make an plugin for wordpress that I could easily post a blog entry with a new location on the same map, which displays already some other locations stored in the mysql database. thanks! <?php require("phpsqlajax_dbinfo.php"); function parseToXML($htmlStr) { $xmlStr=str_replace('<','<',$htmlStr); $xmlStr=str_replace('','>',$xmlStr); $xmlStr=str_replace('"','"',$xmlStr); $xmlStr=str_replace("'",''',$xmlStr); $xmlStr=str_replace("&",'&',$xmlStr); return $xmlStr; } // Opens a connection to a MySQL server $connection=mysql_connect ($host, $username, $password); if (!$connection) { die('Not connected : ' . mysql_error()); } // Set the active MySQL database $db_selected = mysql_select_db($database, $connection); if (!$db_selected) { die ('Can\'t use db : ' . mysql_error()); } // Select all the rows in the markers table $query = "SELECT * FROM markers WHERE 1"; $result = mysql_query($query); if (!$result) { die('Invalid query: ' . mysql_error()); } header("Content-type: text/xml"); // Start XML file, echo parent node echo ''; // Iterate through the rows, printing XML nodes for each while ($row = @mysql_fetch_assoc($result)){ // ADD TO XML DOCUMENT NODE echo ''; } // End XML file echo ''; ?

    Read the article

  • Encoding regarding Term::Size

    - by sid_com
    Hello! The Term::Size-module jumbles up the encoding. How can I fix this? #!/usr/bin/env perl use warnings; use strict; use 5.010; use utf8; binmode STDOUT, ':encoding(UTF-8)'; use Term::Size; my $string = 'Hällö'; say $string; my $columns = ( Term::Size::chars *STDOUT{IO} )[0]; say $columns; say $string; Output: Hällö 140 H?ll?

    Read the article

  • Make content 100% height with scrollbar

    - by Ben Sinclair
    I am using CKEditor (http://ckeditor.com) and I've created my own custom file browser... Problem is, when you open the filebrowser, it opens it in a new popup window and has no scrollbars. I submitted a support ticket 2 weeks ago to find out how to add the scrollbars and no answer. I can't find what to edit in the code either... So what I plan to do is make it scroll using CSS... I found this post about making the body 100% (http://stackoverflow.com/questions/886809/css-quirks-html-4-01-strict-100-body-height-and-scrollbars) but it doesn't add scrollbars. Any ideas how I can force scrollbars using CSS?

    Read the article

  • Reading another packages symbol table in Perl

    - by justintime
    I am trying to read a global symbol from another package. I have the package name as a string. I am using qualify_to_ref from Symbol module my $ref = qualify_to_ref ( 'myarray', 'Mypackage' ) ; my @array = @$ref ; gives me Not an ARRAY reference at ...... I presume I am getting the format of the dereference wrong. Here is a complete example program. use strict; use Symbol ; package Mypackage ; our @myarray = qw/a b/ ; package main ; my $ref = qualify_to_ref ( 'myarray', 'Mypackage' ) ; my @array = @$ref ;

    Read the article

  • Can Perl detect arrays?

    - by Sandra Schlichting
    I have this script #!/usr/bin/perl use warnings; use strict; use Data::Dumper; my %x1 = (); $x1{"a"} = "e"; my %x2 = (); $x2{"a"} = ["b","c"]; p(\%x1); p(\%x2); sub p { my $x = shift @_; print $x->{a}; print "\n"; } which outputs e ARRAY(0x2603fa0) The problem is I don't know when the input is an array or a scalar, and when it is an array I would like to print those values as well. Can p be modified to do this?

    Read the article

< Previous Page | 22 23 24 25 26 27 28 29 30 31 32 33  | Next Page >