415 Posted Topics

Member Avatar for PhoenixInsilico

Consider using Tie::File. [QUOTE]Tie::File represents a regular text file as a Perl array. Each element in the array corresponds to a record in the file. The first line of the file is element 0 of the array; the second line is element 1, and so on. The file is not …

Member Avatar for d5e5
0
73
Member Avatar for terabyte

[QUOTE=terabyte;1620213]I've been programming a web crawler for a while, I'm almost done, it works perfectly but when it crawls vbulletin forums i get weird urls example: forum/index.php?phpsessid=oed7fqnm9ikhqq9jvbt23lo8e4 index.php/topic,5583.0.html?phpsessid=93f6a28f192c8cc8b035688cf8b5e06d obviously this is being causes by php session IDs what can I do to stop this? I tried using cookies with HTTP::Cookies …

Member Avatar for maninaction
0
205
Member Avatar for grazinggoat

I don't know what you mean by "there can actually be many files for each record" but I think you want an array of hash references. See [URL="http://perldoc.perl.org/perldsc.html"]http://perldoc.perl.org/perldsc.html[/URL][CODE]#!/usr/bin/perl; use strict; use warnings; use Data::Dumper; my @AoH;#Array of hash references while(my $line = <DATA>){ chomp($line); my ($id, $filename, $size) = split/\s+/, …

Member Avatar for d5e5
0
1K
Member Avatar for blacknred

[CODE]#!/usr/bin/perl; use strict; use warnings; while (<DATA>){ my @whitespacegroups = m/\w(\s+)\w/g; foreach my $whitespacegroup(@whitespacegroups){ my $count = length $whitespacegroup; print "$count spaces\t"; } print "\n"; } __DATA__ I wake up in the morning What time? Always wakeup at 6am.[/CODE]Output is: [ICODE]1 spaces 5 spaces 1 spaces 10 spaces 32 spaces …

Member Avatar for k_manimuthu
0
281
Member Avatar for blacknred

We need to know what delimiter character you use to separate the columns in your file. When you post the data without wrapping it in [noparse][CODE][/CODE][/noparse] tags all duplicate spaces or tabs become single spaces so we can't see some of the delimiters. If you put only one single space …

Member Avatar for blacknred
0
161
Member Avatar for senthilamp4

[CODE]#!/usr/bin/perl use strict; use warnings; my (@array, $foundvar1, $foundvar2); while (<DATA>){ chomp; if (m/Var1 data:/){ $foundvar1 = 1; } elsif (m/Var2 data:/){ $foundvar1 = 0; $foundvar2 = 1; } else { if ($foundvar1){ my @rec = split /,/, $_; push @{$array[0]}, join ',', @rec; } if ($foundvar2){ my @rec = …

Member Avatar for d5e5
0
98
Member Avatar for newbie21

[CODE]#!/usr/bin/perl use strict; use warnings; use File::Basename; my %hash; open my $fh, '<', '2.txt'; while (<$fh>){ chomp; my @flds = split; my $fullname = $flds[0]; my $name = fileparse($fullname,qw(.fit .vcor)); #Remove the file extension $hash{$name} = join ' ', @flds[2..$#flds]; } close $fh; open $fh, '<', '1.txt'; while (<$fh>){ chomp; …

Member Avatar for d5e5
0
257
Member Avatar for hari kishan

[QUOTE=hari kishan;1615059]Hi, This is my first post in the forum. I got a situation where i have to find a file in a folder based on its extension and there by use the file name and contents of the file. Thanks for the reply.[/QUOTE] If the extension of the files …

Member Avatar for d5e5
0
144
Member Avatar for blah32

Please show us an example of a negative bitstring. I think that since you say "big-endian" you have generated your bitstring according to the 2's Complement method but I'm not sure about that. [URL="http://simple.wikipedia.org/wiki/Negative_binary_numbers"][QUOTE]There are two methods for storing negative binary numbers, they are Sign and Magnitude and 2's Complement.[/QUOTE][/URL]

Member Avatar for d5e5
0
613
Member Avatar for alenD

If you want to save the results of a query in a table have a look at [URL="http://dev.mysql.com/doc/refman/5.1/en/create-table-select.html"]create table select[/URL].

Member Avatar for b89smith
0
105
Member Avatar for ghosh22

The [URL="http://perldoc.perl.org/Tie/File.html"]Tie::File[/URL] module lets you treat a file like an array so you can repeatedly loop through it and push new records into it.[CODE]#!/usr/bin/perl #tie_file.pl; use strict; use warnings; use Tie::File; my $filename = '/home/david/Programming/data/new1.txt'; tie my @array, 'Tie::File', $filename or die "Unable to Tie $filename: $!"; my ($input, $input1); …

Member Avatar for ghosh22
0
431
Member Avatar for Xokzin

I don't have your kind of database and am not familiar with awk so I don't understand your script. To create an output file whose name is the current date you can do the following:[CODE]#!/usr/bin/perl use strict; use warnings; my ($day, $month, $year) = (localtime)[3,4,5]; my $filename = sprintf("%04d-%02d-%02d\n", $year+1900, …

Member Avatar for d5e5
0
257
Member Avatar for ghosh22

Try creating a table having the same column names whose columns are all VARCHAR and import your data into that. That should work as long as your VARCHAR columns are big enough. Then you can write a query that reads the data from this all-VARCHAR table and INSERTs into the …

Member Avatar for ghosh22
0
5K
Member Avatar for choboja621

I think the map name must correspond to what you refer to in usemap. In your example, [icode]usemap="#bearface"[/icode] but [icode]<map name="bear">[/icode]

Member Avatar for Airshow
0
134
Member Avatar for senthilamp4

[QUOTE=senthilamp4;1567588]Dear Experts, Here i am written code for convert the text to CSV file conversion. i am facing a problem in while compare the two array to print the values row wise. below i have mentioned my code,input and output format. input : "OC192-11,OC192:CVS,0,COMPL,NEND,RCV,1-DAY,02-11,00-00,1" "OC192-11,OC192:ESS,0,COMPL,NEND,RCV,1-DAY,02-11,00-00,1" "OC192-11,OC192:SESS,0,COMPL,NEND,RCV,1-DAY,02-11,00-00,1" "OC192-11,OC192:SEFSS,0,COMPL,NEND,RCV,1-DAY,02-11,00-00,1" "OC192-11,OC192:CVL,0,COMPL,NEND,RCV,1-DAY,02-11,00-00,1" "OC192-11,OC192:ESL,0,COMPL,NEND,RCV,1-DAY,02-11,00-00,1" "OC192-11,OC192:SESL,0,COMPL,NEND,RCV,1-DAY,02-11,00-00,1" …

Member Avatar for poorrich
0
195
Member Avatar for JukesK

Current Turn Around Time does not belong in your table. Make it a calculated column in the query that selects from your table. The following shows an item that came in 12 days ago and hasn't gone out yet so date_out is NULL. [CODE]CREATE TABLE IF NOT EXISTS `test`( `id` …

Member Avatar for d5e5
0
177
Member Avatar for terabyte

[QUOTE]Undefined subroutine &main::start called at getwords.pl line 27.[/QUOTE] The error message says it can't find your [ICODE]start[/ICODE] function. It doesn't mention a function named 'parse', you need to define a function or subroutine named 'start' in your main package. For example, if you have an html file in your current …

Member Avatar for d5e5
0
277
Member Avatar for nibalan

If you don't test whether each of your open statements succeeded by adding [iCODE]or die $![/iCODE] you won't know which one of them fails. See the simple examples at the beginning of [URL="http://perldoc.perl.org/functions/open.html"]perldoc -f open[/URL]. Also every script should [ICODE]use strict; use warnings;[/ICODE]

Member Avatar for roswell1329
0
209
Member Avatar for Diwakar Gana

[QUOTE=Diwakar Gana;1581363]Dear All, Can anybody tell me how to autoincrement the Hexa decimal value. For Ex: I am having the value FF0B in Result array and want increment it to FF0C. Now Result array should contain two values.[/QUOTE](I assume you mean 'increment' because I think 'autoincrement' refers to database table …

Member Avatar for Diwakar Gana
0
693
Member Avatar for terabyte

You have declared $baz with the [ICODE]my[/ICODE] function which limits the scope of $baz to the block in which it is declared thus making it impossible to obtain its value from outside that block. [URL="http://perldoc.perl.org/perlmod.html"]A my declares the listed variables to be local (lexically) to the enclosing block[/URL]... In the …

Member Avatar for d5e5
0
108
Member Avatar for nonshatter

[iCODE]<form name="login" action="$cgidir?action=verify_login" method="POST">[/iCODE] The above doesn't look right to me. To get it to work I put it in an html document like the following:[CODE=html]<html> <header> <title>Post form example</title> </header> <body> <form name="login" action="/cgi-bin/verify_login" method="POST"> <input type="text" name="user"> <input type="password" name="pass"> <input type="submit" name="login" value="Login"> </form> </body> </html>[/CODE]Then your …

Member Avatar for nonshatter
0
477
Member Avatar for bio-grad

[QUOTE=bio-grad;1573911]sample data was copied and pasted - in gedit there are tabs between columns, but here it appears as spaces.[/QUOTE] If you click the "Manage Attachments" button you can attach your input file so that it preserves all the data correctly. You may need to add an acceptable file extension …

Member Avatar for d5e5
0
234
Member Avatar for tejaminnu

You are opening a file without testing if the open was successful. Add an 'or die..' and error message to your open statement so you will know if your open statement failed and have some clue why it didn't work. Also, you are assuming your file contains only one line …

Member Avatar for d5e5
0
241
Member Avatar for jonhylever

Nobody who hasn't already died can know for sure what it's like, so I can't really fear death -- only my idea of what death might be like. Most of the time I don't fear my idea of death nearly so much as I fear some of the events or …

Member Avatar for Ene Uran
-2
358
Member Avatar for diafol

Rather than struggle to compose one regex that does all the substitution I would use two regexes. I find it easier to understand and change if necessary.[CODE]#!/usr/bin/perl use strict; use warnings; my @words = qw(iodine Thiodi number dix Iodic iodide); foreach my $word(@words){ $word =~ s/(?<!io)di/deu/i;#Replace di with deu unless …

Member Avatar for diafol
0
158
Member Avatar for anraevlus18

Looks like your loop is calling alarm multiple times. [URL="http://perldoc.perl.org/functions/alarm.html"]Only one timer may be counting at once. Each call disables the previous timer...[/URL]

Member Avatar for d5e5
0
92
Member Avatar for BioJavaPhobic

Remove the following line from inside your foreach loop and put it before the beginning of the loop starts. [iCODE]open OUTFILE, ">$file" or die "unable to open $file $!";[/iCODE] Opening a file for output multiple times results in overwriting the existing file each time so that only the last thing …

Member Avatar for roswell1329
0
182
Member Avatar for ajmcello

I haven't used fork and don't know much about it, but doesn't a return value of 0 mean this is a child process? So why does your script [iCODE]print "parent\n";[/iCODE] when the $pid == 0? How about using an environmental variable to pass each array element to a child, so …

Member Avatar for d5e5
0
150
Member Avatar for ssdeep

The semicolon is optional for the last statement in a block of Perl statements. I think that explains your seeing a one-liner ending in a print command not terminated with a semicolon.

Member Avatar for roswell1329
0
313
Member Avatar for smandape

You need to show us more than one line of code. Also "application/xml; charset=UTF-8" doesn't look like an error message to me. The utf8 module allows you to use accented characters as values or variable names in your script source code, but that's all it does, so maybe you need …

Member Avatar for d5e5
0
180
Member Avatar for yashsaxena

I bought and read [URL="http://www.perl.org/books/beginning-perl/"]Beginning Perl by Simon Cozens[/URL] and have since downloaded it and reread much of it so that's the one I would recommend. You can [URL="http://www.perl.org/books/beginning-perl/"]download it for free[/URL] now.

Member Avatar for roswell1329
0
134
Member Avatar for bioinfo90

[QUOTE=bioinfo90;1565029]i NEED A PERL SCRIPT TO CREATE NAME_DIRECTORY FOR ALL TRAJECTORIES. i've trajectory files like this, rep2.tra3M.bz2 rep2.tra4M.bz2 rep2.tra5M.bz2 rep2.tra6M.bz2 rep2.tra7M.bz2 i want a scipt to list all replicas,copy zipped replicas and unzip all replicas and create a file with list of replicas and call make_pdb.pl for all trajectories.[/QUOTE] What …

Member Avatar for d5e5
0
191
Member Avatar for extemer

I would start by writing a query that gives the information needed for the report. Print the results of the query. Call it a report.:) If the report required must have a specific layout such as headers, details, subtotals, groups, footers, page numbers, etc. then you'll need to look for …

Member Avatar for smantscheff
0
91
Member Avatar for senthilamp4

[CODE]#!/usr/bin/perl use strict; use warnings; print "ESS\tSESS\tSEFSS\tCVL\n"; while(<DATA>){ s/"//g;#Remove all double quotes my @fields = m/(.+?,)/g; print chr(34), @fields[0..2], chr(34), "\t"; } __DATA__ "OC192-11,OC192:ESS,0,COMPL,NEND,RCV,1-DAY,02-11,00-00,1" "OC192-11,OC192:SESS,0,COMPL,NEND,RCV,1-DAY,02-11,00-00,1" "OC192-11,OC192:SEFSS,0,COMPL,NEND,RCV,1-DAY,02-11,00-00,1" "OC192-11,OC192:CVL,0,COMPL,NEND,RCV,1-DAY,02-11,00-00,1"[/CODE]Running the above prints the following to STDOUT[CODE=text]ESS SESS SEFSS CVL "OC192-11,OC192:ESS,0," "OC192-11,OC192:SESS,0," "OC192-11,OC192:SEFSS,0," "OC192-11,OC192:CVL,0," [/CODE]

Member Avatar for d5e5
0
285
Member Avatar for bioinfo90

Please attach data from your rep.tra1 file to your post so somebody can test your script. In what way does the output of your script not meet your expectations?

Member Avatar for d5e5
0
108
Member Avatar for realoneomer

One way of finding the first Saturday of each month for a given year:[CODE]#!/usr/bin/perl use strict; use warnings; use 5.010; use Date::Simple; my $year = 2011; my @month_names = qw(January February March April May June July August September October November December); foreach('01'..'12'){ my $dt = first_saturday($_); my $mth = $month_names[$_ …

Member Avatar for d5e5
0
187
Member Avatar for amithlaxman

Another way, if you don't mind using a module:[CODE]#!/usr/bin/perl use strict; use warnings; use File::Basename; my $string ="datafiles/source/main_data_files/content.csv"; my $filename = fileparse($string); print "\nThe file name is $filename\n";[/CODE]

Member Avatar for d5e5
0
90
Member Avatar for jacksantho

What happens when you type [iCODE]c:/xampp/htdocs/test.php?emp=$id [/iCODE] into the URL area of your browser? I bet your browser can't read that as a valid URL. Your browser needs a valid URL that looks like [iCODE]http://HOSTNAME/test.php?emp=$id[/iCODE] where you replace HOSTNAME with the real host name (try [iCODE]http://localhost/test.php?emp=$id[/iCODE]).

Member Avatar for jacksantho
0
219
Member Avatar for extemer

[QUOTE=extemer;1554049]hi guys i want to set password to mysql database please help me out[/QUOTE] For which user do you want to set a password. If you haven't created any user accounts yet I guess you mean you want to set a password for the root user. What platform does your …

Member Avatar for b1izzard
0
134
Member Avatar for tcollins412

[QUOTE=tcollins412;1542257]what if thats not the only cookie?[/QUOTE] If the name of the cookie you created is 'sessionid' you can read the value of the cookie into a variable as follows:[CODE]use CGI qw(:standard -debug); use CGI::Carp qw(fatalsToBrowser); #Create a new CGI object my $cgi = new CGI; my $value=$cgi->cookie('sessionid');[/CODE]If no cookie …

Member Avatar for d5e5
0
181
Member Avatar for Tango2010

[QUOTE=Tango2010;1538358]Hi, I am attempting to read in a CSV file, modify certain arrays and output it into a new file. It works fine on a mac, however on Windows it does not do anything. Any ideas what im doing wrong? Code posted below; [CODE] open(FILE,"file.csv") or die $!; open(TARGET,"> newfile.csv") …

Member Avatar for d5e5
0
345
Member Avatar for extemer

[CODE]mysql> select curdate(); +------------+ | curdate() | +------------+ | 2011-05-01 | +------------+ 1 row in set (0.00 sec) mysql> select MONTH(CURDATE()); +------------------+ | MONTH(CURDATE()) | +------------------+ | 5 | +------------------+ 1 row in set (0.00 sec) [/CODE]

Member Avatar for d5e5
0
76
Member Avatar for amithlaxman

Why can't you use modules? [URL="http://www.perlmonks.org/?node_id=693828"]Yes, even you can use CPAN[/URL]

Member Avatar for d5e5
0
3K
Member Avatar for OneDreamCloser

I don't know about threads and my perl is not built for threads but I can illustrate the problem by the following: [CODE]#!/usr/bin/perl use strict; use warnings; use 5.010; #When you follow the sub name with arguments in parentheses #the sub runs first and returns a scalar value, #which the …

Member Avatar for erezschatz
1
447
Member Avatar for realoneomer

[CODE]#!/usr/bin/perl use strict; use warnings; use constant {SECONDS_IN_DAY => 86400}; use HTTP::Date qw(time2str str2time parse_date); my $today_YMD = epoch2YMD(time); my $today_epoch = str2time($today_YMD); my $today_minus_3_epoch = $today_epoch - 3 * SECONDS_IN_DAY; my $today_minus_3_YMD = epoch2YMD($today_minus_3_epoch); my (@completed, @not_completed); my $filename = 'omar.txt'; open my $fh, '<', $filename or die "Failed …

Member Avatar for realoneomer
0
160
Member Avatar for terabyte

[QUOTE=terabyte;1542689]what is this variable: [CODE]$/[/CODE][/QUOTE] "The input record separator, newline by default. This influences Perl's idea of what a 'line' is." from [URL="http://perldoc.perl.org/perlvar.html"]http://perldoc.perl.org/perlvar.html[/URL]

Member Avatar for d5e5
0
353
Member Avatar for debasishgang7

[QUOTE=debasishgang7;1522063]its not working ....[/QUOTE] If you wanted to retrieve the highest score you would use offset of 0 (not 1). And so to retrieve the 6th highest score you need an offset of 5.[CODE]SELECT id FROM members ORDER BY score desc LIMIT 5, 1;[/CODE]In English I think the above says …

Member Avatar for debasishgang7
0
134
Member Avatar for Gaspacho

The input record separator (see [URL="http://perldoc.perl.org/perlvar.html"]perlvar[/URL]) determines how much input to read for each input record. It is newline by default. Change it to semicolon followed by newline and each time perl reads the file it will read up to the next semicolon followed by newline, which is what you …

Member Avatar for d5e5
0
82
Member Avatar for stepamil

[QUOTE=stepamil;1517331]...I'm getting this warning message: could not find ParserDetails.ini in /usr/lib/perl5/site_perl/5.8.8/XML/SAX Is this related?[/QUOTE] Maybe not. [URL="http://perl-xml.sourceforge.net/faq/"]The Perl-XML FAQ[/URL] suggests it may have to do with how XML::SAX was installed on your computer. I don't know about this but the FAQ suggests re-installing XML::SAX and "if you are asked whether …

Member Avatar for d5e5
0
217
Member Avatar for tomrock_shi

I recommend installing the DBI and SQLite modules for perl and inserting your data into a database table as follows:[CODE]#!/usr/bin/perl use strict; use warnings; use DBI; # Connection to DB file created before my $dbh = DBI->connect("dbi:SQLite:dbname=demo.db","",""); $dbh->do("CREATE TABLE payments (eid,date,amount)"); my $sth = $dbh->prepare("insert into `payments` (eid,date,amount) values (?, …

Member Avatar for d5e5
0
95

The End.