415 Posted Topics

Member Avatar for jatri

Tell us what you mean by not working. Do you get a syntax or runtime error, or does it print too many lines or nothing at all? Give us an example that's easy to test. You don't want to have to type the name of the file every time you …

Member Avatar for jatri
0
1K
Member Avatar for 54uydf

[QUOTE=54uydf;1513655]but this makes me think that that's why I SHOULD use english..it's gonna be easier to write SQL queries where most of the command is gonna be in 1 language, I don't see why there should be a conflict.. :?:[/QUOTE] I would say definitely avoid using SQL reserved words to …

Member Avatar for smantscheff
0
125
Member Avatar for perlnoob

[CODE]#!/usr/bin/perl use strict; use warnings; my $pp_replaced = 0;#Indicates no occurrence of PP has been replaced yet while(<DATA>){ if (m/^PP:/ and $pp_replaced == 0){ s/PP:/HL:/; $pp_replaced++;#Add 1 } print; } __DATA__ PP: Happy Sunday! PP: It's a good weather. PP: Have a blessed Sunday everyone.[/CODE]

Member Avatar for d5e5
0
120
Member Avatar for Perl_enthusiast

I don't think I know how to help you without more information. Can you give us examples of these booking reference numbers? Do you want to look up one booking reference at a time, or match a range or pattern of them with one query? Give us an example of …

Member Avatar for Perl_enthusiast
0
961
Member Avatar for Acute

[CODE]select count(*) from (select 1 from t1 UNION ALL select 1 from t2) as both_tables;[/CODE]

Member Avatar for Acute
0
78
Member Avatar for aPPmaSTer
Member Avatar for aPPmaSTer
0
79
Member Avatar for PhoenixInsilico

Comparing this line [iCODE]my ($ref_numbers,$ref_exceptions,$number,$n) = @_;[/iCODE] with [iCODE]if($i != $$ref_execptions[$number])[/iCODE] It looks like a typo in $$ref_[COLOR="Red"]execp[/COLOR]tions.

Member Avatar for Taywin
0
149
Member Avatar for pragati_2010

Assuming an input file such as example.csv (contains no accented or non-ascii characters)[CODE=text]fname,lname bugs,bunny donald,duck betty,boop[/CODE] You could use [URL="http://search.cpan.org/~isterin/XML-CSV-0.15/CSV.pm"]XML::CSV[/URL] in a script such as the following:[CODE]#!/usr/bin/perl use strict; use warnings; use 5.010; use XML::CSV; my $csv_obj = XML::CSV->new(); $csv_obj->parse_doc("example.csv", {headings => 1});#file starts with header row $csv_obj->print_xml("output.xml", {format => …

Member Avatar for d5e5
0
141
Member Avatar for boshu

[QUOTE=k_manimuthu;1486057][CODE] do { unlink if ( !/20110225104849|20110225104833|20110225104848/ ) } for @your_files; [/CODE][/QUOTE] I like Muthu's answer and it works, but BE CAREFUL when testing it that you glob the desired directory into your array. You don't want to delete all the files in whatever your current working directory happens to …

Member Avatar for boshu
0
173
Member Avatar for jacksantho

[CODE]#!/usr/bin/perl use strict; use warnings; use CGI qw(:all); #Create a new CGI object my $cgi = new CGI; my $this_url = $cgi->url(); #Save this script's url my $first = $cgi->param('first_name'); my $last = $cgi->param('last_name'); print "Content-type:text/html\n\n"; print <<EndOfHTML; <html><head><title>Generating Self-Referential URLs</title></head> <body> <FORM action="$this_url" method="POST"> First Name: <input type="text" name="first_name"> …

Member Avatar for d5e5
0
2K
Member Avatar for deolalkar_pooja

[QUOTE=deolalkar_pooja;1484482]Hi to all, i created following table in SQL. =================================== create table employee(name varchar(20), dob date) =================================== But, when i ran the query, i got the massage that 'SQL can not find data type 'date''. How should i include 'date' in to table definition.[/QUOTE] [ICODE]create table employee(name varchar(20), dob date)[/ICODE] …

Member Avatar for d5e5
0
123
Member Avatar for boshu

[CODE]#!/usr/bin/perl use strict; use warnings; while (<DATA>){ my ($fruit,$end)=split(/\_ #Match an underscore (?!.*\_) #Negative lookahead. #Match only if not followed by characters #followed by another underscore /x); #x means allow multi-line regex with comments print "My fruit = $fruit\n"; print "My end = $end\n"; } __DATA__ apple_india_20110218091255.txt apple_india_20110221112444.txt apple_india_20110301112444.txt[/CODE][URL="http://www.regular-expressions.info/lookaround.html"]http://www.regular-expressions.info/lookaround.html[/URL]

Member Avatar for boshu
1
155
Member Avatar for GrimJack

I'm not a gamer, rarely use Vista and don't have Strawberry Perl so maybe that's why I don't understand the question. To clarify, are you saying you have downloaded Strawberry Perl (source? or binary?) and need instructions how to install it in Windows Vista? You ask how to compile and …

Member Avatar for d5e5
0
349
Member Avatar for <LDJ>

Instead of taking filename from alt take it from the end of the src URL.[CODE]# Obtains all individual comic data sub getComicData { my $siteData = get("$sitePrefix$current/"); my @data = split /\n/, $siteData; foreach (@data) { if (/http:\/\/xkcd.com\/(\d+)\//) { $current = $1; } #Instead of taking filename from alt #take …

Member Avatar for d5e5
0
376
Member Avatar for rmh000

After creating and populating the @printarray, connecting to MySQL, selecting a database etc. the following snippet seems to work OK. The trick is to prepare your query with placeholders and letting DBI worry about what characters need escaping.[CODE] $sth=$dbh->prepare ("INSERT INTO test (id, html_string) VALUES (? , ?)"); my ($id, …

Member Avatar for d5e5
0
272
Member Avatar for rajeesh_rsn

It is confusing to name a column 'date' because DATE is a datatype. The creator of the table should have created a DATE type column with a better name. If you have no choice but to try and sort this table without altering the design, try the following:[CODE]mysql> select * …

Member Avatar for d5e5
0
113
Member Avatar for vaibhav1983

[QUOTE=mitchems;1470500]It sets scope: [CODE] my $var1="world"; { my $var1="hello"; print "$var1 "; } print "$var1\n"; [/CODE] Output: [CODE] hello world [/CODE][/QUOTE] Good answer. If you want to read more I strongly recommend [URL="http://perl.plover.com/FAQs/Namespaces.html"]Coping With Scoping[/URL] which explains in simple language with examples the difference between variables declared with my and …

Member Avatar for d5e5
0
338
Member Avatar for boshu

Read about [URL="http://docstore.mik.ua/orelly/perl/cookbook/ch07_10.htm"]edit-in-place[/URL]. I don't have time right now to customise but here is an old example I've used before for editing a file, saving a backup, and the edited file automatically replaces the original.[CODE]#!/usr/bin/perl use strict; use warnings; my $filename = '/home/david/Programming/Perl/data/var.txt'; #So you can use diamond operator and …

Member Avatar for k_manimuthu
0
1K
Member Avatar for realoneomer

[QUOTE=realoneomer;1465308]Hi Shibblez, Thanks for your response... i have used Spreadsheet::WriteExcel but it is giving me an error that WriteExcel.pm does not exist @INC more over i cannot install any additional software or patch on Linux Machine...Well i first i want to generate an excel file on linux after that i …

Member Avatar for d5e5
0
586
Member Avatar for indr

You must select the database that contains the objects to which the rest of the SQL statements refer. For example, if the statements in your company_data.sql refer to objects in a database called 'db1' you need to either run the following statement [CODE]USE db1;[/CODE] before running source from the company_data.sql …

Member Avatar for d5e5
0
115
Member Avatar for jddigitalchaos

Since the docs don't say you have to have any specific extension for your file name, I guess you can have any that you want. Why not try it with a simple example? I haven't used Storable and am not an expert, but I see that the docs give simple …

Member Avatar for jddigitalchaos
0
137
Member Avatar for archana amith

I don't see a connect statement in your script. The following works for me.[CODE]#!/usr/bin/perl use strict; use warnings; use 5.012; use DBI; my ($dbh, $sql, $sth, $msg); $dbh=DBI->connect('dbi:mysql:daniweb','david','dogfood') || die "Error opening database: $DBI::errstr\n"; my $create_procedure = qq{ CREATE PROCEDURE simpleproc () BEGIN SELECT 'helloworld' As Messgae; END }; $dbh->do($create_procedure); …

Member Avatar for d5e5
0
2K
Member Avatar for jordan0420

> (also how do i properly wrap my code in the [code] as this is my first post with a code snippet [CODE]#First line of code . . . . #Last line of code[/CODE]

Member Avatar for jordan0420
0
6K
Member Avatar for lewashby

[QUOTE=Garrett85;1452120]I was told that there are four python string delimiters but I can only think of three, ', ", & """. What is that last one? I searched google but with no luck.[/QUOTE] [LIST=1] [*]single quote ' [*]double quote " [*]triple double quote """ [*]triple single quote ''' [/LIST][URL="http://docs.python.org/release/1.5.1p1/tut/strings.html"]http://docs.python.org/release/1.5.1p1/tut/strings.html[/URL]

Member Avatar for richieking
0
171
Member Avatar for boshu

I don't know how to do it with a one-liner. The "add only if not already present" requirement is much more easily done by building a hash instead of an array.[CODE]#!/usr/bin/perl use strict; use warnings; use 5.010; my %emails = ('sam@email.com' => undef, 'john@email.com' => undef, 'jenifer@email.com' => undef);#Hash of …

Member Avatar for boshu
0
176
Member Avatar for rmsagar

This works for me in a Linux environment:[CODE]perl -n -i.bak -e '$r=1 if m/<process-type="Remote">/;$m=1 if $r && m/<\/module-data>/;print;if ($r and $m){print "blah\n" x 7;($r,$m)=(0,0);}' file.txt [/CODE]file.txt now contains:[CODE=text]--------------------------FILE------------------------------------------ <process-type="Local"> <module-data> </module-data> <process-type="Remote"> <module-data> </module-data> blah blah blah blah blah blah blah --------------------------FILE------------------------------------------[/CODE]

Member Avatar for rmsagar
0
106
Member Avatar for winky

An example of a query that returns only one row consisting of one column:[CODE]#!/usr/bin/perl use strict; use warnings; use 5.010; use warnings; use strict; use DBI; my $pwd = 'dogfood'; my ($dbh, $sth); $dbh=DBI->connect('dbi:mysql:daniweb','david',$pwd) || die "Error opening database: $DBI::errstr\n"; #The following query should return only one row containing one …

Member Avatar for d5e5
0
2K
Member Avatar for ColMatrix

Sorry, I probably can't help you because my platform is Linux and I don't have Excel, etc. so can't test your script. I really don't see anything wrong with line 84 of your script. Can you recreate the error in a simpler script without all the presumably irrelevant (irrelevant to …

Member Avatar for erezschatz
1
285
Member Avatar for j111c222

[QUOTE=erezschatz;1442305]substr takes an expression (here $str), an offset (index of starting character) and length. You need to keep in mind that offset is zero based. In your example, you take the first 3 characters ("Jan"), then concatenate that with the characters at index 4 and 5 (" "), which you …

Member Avatar for erezschatz
1
170
Member Avatar for boshu

[CODE]#!/usr/bin/perl use strict; use warnings; use XML::Simple; my $fr = 'fruit.txt'; open (my $fh, '<', $fr) or die "Unable to open $fr: $!"; my @fruits = <$fh>; chomp @fruits; my $status = 'status.txt'; my $hashref = XMLin($status); foreach(@fruits){ $hashref->{$_}->{'In_Stock'} = 'true'; } print "<data>\n"; foreach (keys %{$hashref}){ print "\t<$_>\n\t\t<In_Stock>\n\t\t\t$hashref->{$_}->{'In_Stock'}\n\t\t</In_Stock>\n\t</$_>\n"; } …

Member Avatar for boshu
0
405
Member Avatar for mrhankey

The following works for me[CODE]CREATE TABLE tasks( TaskID INT AUTO_INCREMENT , TaskDueDate DATETIME, Completed TEXT( 3 ) , PRIMARY KEY ( TaskID ) ) INSERT INTO `tasks` ( `TaskID` , `TaskDueDate` , `Completed` ) VALUES ( NULL , NOW( ) , 'No' ); SELECT count( TaskID ) AS DueToday FROM …

Member Avatar for d5e5
0
174
Member Avatar for realoneomer

[CODE]#!/usr/bin/perl use strict; use warnings; use Data::Dumper; my $fa = 'a.txt'; my $fb = 'b.txt'; my %h; #Hash to store file 'a' data # First, open and read file 'a' into a hash open (my $fha, '<', $fa) or die "Unable to open $fa"; while (<$fha>){ next unless m/\d+/; #Skip …

Member Avatar for realoneomer
0
1K
Member Avatar for archik123

[CODE]<html> <body> <?php $contents = 'john||mk||mlm||klm||lkm||lkm||lmlk||mkl||female||January||9||2004||ljnbjknjlnln||Expert||'; $chunks = explode('||', $contents); foreach($chunks as $chunk){ print $chunk . '<br />'; } ?> </body> </html>[/CODE]Sure you can also put it in tabular format. I don't know how many columns you want.

Member Avatar for archik123
0
196
Member Avatar for qingmui

[QUOTE=tonyjv;1374225]And OP must add the recursion? To only check if things are palindrome is by the way enough to: [code]def ispalindrome(x): return x == x[::-1][/code] (The recursive version can be written with same amount of lines)[/QUOTE] I like that. It's much shorter than what I was thinking of. However the …

Member Avatar for vegaseat
0
780
Member Avatar for jazzyb

[QUOTE=smantscheff;1430456]Please explain the difference between LEFT JOIN and LEFT OUTER JOIN in MySQL. To the best of my knowledge there isn't any.[/QUOTE] I can't find a clear explanation to this in docs but [URL="http://stackoverflow.com/questions/2809594/basic-question-left-outer-join-vs-left-join"]this question[/URL] was asked on StackOverflow and the accepted answer was that it makes no difference which …

Member Avatar for drjohn
0
11K
Member Avatar for daviddoria

First you could create an SQLite database with one table into which you will insert all the data. (Later you may want to normalise the data by creating other tables and copying data into them from your first table.) Then you could use a programming language such as perl or …

Member Avatar for d5e5
0
113
Member Avatar for kjanardhanam

What is the value of $file_path when you pass it as an argument to mkpath? To find out, insert the following statement in your code immediately before the statement that calls mkpath. [iCODE]print "Here is the path name to pass to mkpath:\n$path_name\n";#For debugging only[/iCODE] Also I recommend that you include …

Member Avatar for d5e5
0
230
Member Avatar for gutchi

The pending method gives you the number of items in the queue, so you can peek at each of them in a loop.[CODE]#!/usr/bin/perl use strict; use warnings; use Thread::Queue; my $q = new Thread::Queue; $q->enqueue('item1', 'item2', 'item3'); my $count = $q->pending; my @queued_items; push @queued_items, $q->peek($_) foreach(0 .. $count-1); print …

Member Avatar for d5e5
0
250
Member Avatar for anraevlus18

[QUOTE=anraevlus18;1418567]Hi Manimuthu, Thanks for your reply..But this logic even i have tried. I wanted to use one single grep command for both operations. Is there a way to do this?[/QUOTE] [CODE]#!/usr/bin/perl use strict; use warnings; my @file_list= qw(aaa ddd bbb/aaa ccc ddd kkk/ddd hhh); my %exist=(); #To remove duplicate elements. …

Member Avatar for d5e5
0
264
Member Avatar for tones1986

I don't have any experience with Telnet and can't reproduce your 'Alarm Clock'. Have you tried adding a print statement to print the $telnet->errmsg() when there is one?[CODE]# Get any errors my $error = $telnet->errmsg; if ($telnet->errmsg) { # continue with telnet stuff, else ignore device print $telnet->errmsg();# Add this …

Member Avatar for d5e5
0
270
Member Avatar for ColMatrix

Please post the file "FROM_ISODRAW.txt" as an attachment. That should give us a file with the original encoding preserved so we can reproduce the problem. Click the "Manage Attachments" button to attach your text file.

Member Avatar for d5e5
0
379
Member Avatar for choosenalpha

What happened when you tested it? I can't test your script because I don't have all your modules and don't have your l2cgi.cfg file. Try to access your script on your web server, then open /var/log/apache2/error.log or whatever file your server uses to report errors and see what errors you …

Member Avatar for choosenalpha
0
305
Member Avatar for ghosh22

k_manimuthu's answers should work fine. Here is a slightly different way to do the same thing.[CODE]#!/usr/bin/perl use strict; use warnings; my $input_file = 'blast.txt'; open my $fh, '<', $input_file or die "Cannot Open the $input_file : $!"; my $sequence; while (<$fh>){ chomp; $sequence .= $_ unless m/^>/;#Skip the line that …

Member Avatar for ghosh22
0
122
Member Avatar for terabyte

[QUOTE=k_manimuthu;1416466][CODE] push @matches, $1 while ($source=~ m{(PATTERN)}g); [/CODE] Is this you want ?[/QUOTE] That looks good. Alternatively, you can assign the result of a global match to an array directly, without a loop.[CODE]#!/usr/bin/perl use strict; use warnings; my $source = '1 door and only 1 and yet its sides are …

Member Avatar for mitchems
0
168
Member Avatar for vishalkhialani

[CODE]SELECT * FROM details WHERE BRAND IN('bmw', 'audi')[/CODE] Alternatively you can say [ICODE]WHERE BRAND = 'bmw' OR BRAND = 'audi'[/ICODE]

Member Avatar for vishalkhialani
0
100
Member Avatar for NevadaSam

Instead of [iCODE]perl -pi.int -e 's/\|/,/g;' fileName.ext [/iCODE] try using double quotes instead of the single quotes. [iCODE]perl -pi.int -e "s/\|/,/g;" fileName.ext[/iCODE] [URL="http://stackoverflow.com/questions/660624/why-doesnt-my-perl-one-liner-work-on-windows"]http://stackoverflow.com/questions/660624/why-doesnt-my-perl-one-liner-work-on-windows[/URL]

Member Avatar for d5e5
0
384
Member Avatar for terabyte

[QUOTE=terabyte;1406122]Which is the best way to make a plataform-independent perl app, I tried Perl Packer but it seems it wont work on windows, I don't want to use activestate? what are my alternatives?[/QUOTE] If all your users have access to the web then you could develop it as a web …

Member Avatar for terabyte
0
153
Member Avatar for killerpopiller

When you talk about the [I]names[/I] of your [I]rows[/I] you confuse me. Do you mean you have a table named energielog having three columns named sernr, peak and kwh?

Member Avatar for killerpopiller
0
243
Member Avatar for koushikG

[QUOTE=koushikG;1406166]I can't resolve a question.write a stucture in html that can call a perl script.please help.[/QUOTE] [CODE=html]<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> <html lang="en"> <head> <title>Run temp.cgi</title> </head> <body> <a href='../cgi-bin/temp.cgi'> Click here to run a perl script called temp.cgi </a> </body> </html> [/CODE]

Member Avatar for d5e5
0
194
Member Avatar for Anthony Cameron

I really don't know the bioinformatics subject matter involved here. I tried changing the regex and adding a chomp statement because including the newline \n in my regex caused it to fail on my computer for some reason. Here is what I changed:[CODE]# Now separate the annotation from the sequence …

Member Avatar for Anthony Cameron
0
330

The End.