196 Posted Topics

Member Avatar for abhik1368

Hi, Since you know hash 2 keys relate with hash 1 values, you can just say, print hash 1 key, when hash 1 value equals hash 2 key. Bingo!!! You are done. Like so: use warnings; use strict; my %hash1 = ( a => 1, b => 2, c => …

Member Avatar for 2teez
0
114
Member Avatar for yksrmc

Hello yksrmc, This can easily be done by going through your data a line at a time. Since it's only the last number that is changing there is no need comparing it with the pervious figure before it. Just take the number you wanted and check the condition you specify, …

Member Avatar for 2teez
0
170
Member Avatar for yksrmc

Hello yksrmc, This can easily be done by going through your data a line at a time. Since it's only the last number that is changing there is no need comparing it with the pervious figure before it. Just take the number you wanted and check the condition you specify, …

Member Avatar for 2teez
0
145
Member Avatar for 2teez

I wanted a graphical representation of the listing of my files and folders from the command line interface, just like what the CLI **tree** would give on linux system, I really don't like how the same command is displayed on windows. So, I called on ma 'Cherie' Perl do it …

0
294
Member Avatar for nicetapo

Hi, You can simlpily do like so: use warnings; use strict; my $str = 'cat/dog/cat'; $str=~s{dog/cat$}{tiger/deer}; print $str; #cat/tiger/deer #OR You can run the following from Command Line Interface: `perl -we '$_=q[cat/dog/cat];s{cat/dog/cat$}{print qq[cat/tiger/deer\n]}e;'` You don't need the modifier `g`. If you are reading the string from a file you might …

Member Avatar for nicetapo
0
221
Member Avatar for magaji ahmed
Member Avatar for jg1405

You didn't show how you use the module Win32::OLE, so really one might not know how and where you are having issues with your code. There are several part of the code you need to upgrade. Like, why use 2 while loop?

Member Avatar for doubi
0
325
Member Avatar for anglaissam

Please check this Perl module [WWW::Mechanize::Firefox](https://metacpan.org/module/WWW::Mechanize::Firefox) from METACPAN, it should help, with this kind of stuff you want to do.

Member Avatar for doubi
0
207
Member Avatar for 2teez

I really got bored and tired of trying to find or remember some codes usage in so many files saved on my system, when it was needed. So, I called 'Monsieur' perl for help, hacking together some codes which works great for me and solve my problem of boredom. You …

Member Avatar for rsprice
0
243
Member Avatar for rajesrmbioinfo

Hi rajesrmbioinfo, I know there are more than one way to do it in Perl, but so many ways are not efficient and effective. Am glad you have your coding working fine, but there are some things I believe you should also put in place. 1. Your open function should …

Member Avatar for 2teez
0
171
Member Avatar for yksrmc

Hi, You can do this: #!/usr/bin/perl use warnings; use strict; my %count_variable_converted; chomp( my $title = <DATA> ); print $title,$/; while (<DATA>) { next if /^$/; s/\s$//g; my @data = split /\s+?/, $_, 5; $count_variable_converted{'A/T'}{'A/A'}++ if ( $data[3] eq 'A/T' and $data[4] eq 'A/A' ); $count_variable_converted{'G/C'}{'C/C'}++ if ( $data[3] eq …

Member Avatar for yksrmc
0
2K
Member Avatar for tony75

Hi Tony75, Could you run your compile program on system on which perl is not installed? If Yes, I think you are cool. Sorry, not on Window OS presently [ I suppose that program will run on one], so I can't say authoritatively.

Member Avatar for tony75
0
221
Member Avatar for sandeepbajjuri
Re: perl

Hi sandeepbajjuri, It seem to me you are looking for Perl function backtick written as `` or `qx`. You might also want to look at Perl function `system`. From within your perl script you just do like so: `system("generator.exe");` your code then runs as if you are on a CLI. …

Member Avatar for 2teez
0
184
Member Avatar for tony75

Hi tony75, To parse HTML in Perl, you might have to know how to use some Perl modules. HTML being what it is, can really be best parsed not with regex. That been said, there are a number of module on [CPAN](http://www.cpan.org) and [meta::cpan](http://www.metacpan.org) which can be used to parse …

Member Avatar for tony75
0
289
Member Avatar for tony75

Hi tony75, There are more than one way to achieve your aim. Of course, using the function `opendir` and reading all your filename like you did should work, but why not use one of the CORE module to go through the file for you save the filename and other requirement …

Member Avatar for tony75
0
4K
Member Avatar for hero19760

Hi hero19760, >Can you please help me No! Because, I don't know what your text file looks like. Moreover, in Perl Programming there is more than one way to do a thing. So, show how your data look likes or give an idea of what it is, then we can …

Member Avatar for 2teez
0
229
Member Avatar for hero19760

Hi hero19760, We can't magic know how the webpage you wanted to parse look like do we? Moreover, what have to tried on your own that you want a help for? I believe this is how to get help anywhere as soon as possible. Hope this helps

Member Avatar for 2teez
0
61
Member Avatar for rajesh9042

Hi rajesh9042, There are several things not right with your script namely: 1. Please start your script with use warnings and use strict pragmas, though I know many people may not like these. But believe me, those are your best friend programming in Perl, 2. What do you have in …

Member Avatar for DoRight
0
297
Member Avatar for tony75
Member Avatar for tony75

Hi tony75, 1.What error message are you getting. 2.Check your filehandle "IN" you used. You can't be reading FROM and writing TO the same filehandle, like you are doing. 3.Also use a 3-arugment for open function. like open my $fh,'<',$file_to_read or die "can't open file: $!"; while(<$fh>){ ... } close …

Member Avatar for tony75
0
211
Member Avatar for vivek.vivek

Hi vivek.vivek, Using hash in perl takes care of all issues you have in this your post. Please, check the solution below and feel free to ask any question. #!/usr/bin/perl use warnings; use strict; my %seen; while (<DATA>) { chomp; my @data_filter = split; if ( defined $data_filter[2] and !exists …

Member Avatar for 2teez
0
197
Member Avatar for FelineHazard

Hi FelineHazard: The following modules from [CPAN](http://www.cpan.org) could be of help: [URI](http://search.cpan.org/~gaas/URI-1.60/URI.pm) with [URI::Escape](http://search.cpan.org/~gaas/URI-1.60/URI/Escape.pm). Or [Data::Validate::URI](http://search.cpan.org/~sonnen/Data-Validate-URI/lib/Data/Validate/URI.pm) However, I could only have one question; why validate if the URL doesn't exists? Hope this helps. Enjoy.

Member Avatar for FelineHazard
0
760
Member Avatar for voidyman

Hi voidyman, There is a better way of writing the perl code you showned. 1. Use a 3 agrument open function like `open my $fh,'<',$filename or die "can't open file: $!";` 2. Don't use a bareword for filehandles like FILE_OUT etc Instead use a lexical filehandles as showned in (1.) …

Member Avatar for voidyman
0
137
Member Avatar for mshefa

Hi mshefa, I will advise that you use 3 argument open function as demonstrated below. Moreover, please check the proper usage of split function... The following code show how to get desired result: #!/usr/bin/perl use warnings; use strict; my $parameter = qr/\.|"|,/; my @words; open my $fh, '<', "test.txt" or …

Member Avatar for mshefa
0
191
Member Avatar for ashiiiish

Hi ashiiiish, Consider using these modules from [CPAN](www.cpan.org) namely: 1. Text::CSV_XS 2. Spreadsheet::WriteExcel From the directory read each of the CSV using Text::CSV_XS or Text::CSV, then write to a new Excel Sheet created by Spreadsheet::WriteExcel. Check examples these modules except you have sample of what to share here. Hope this …

Member Avatar for 2teez
0
190
Member Avatar for bharathG

Hi Taywin, >If there are duplicated lines in file2, I am not sure it would print all the duplicated line numbers? Despite, its functionality may already satisfy what the OP wants. Nice observation, and that was my initial thought too until I read again the OP's last comments * It …

Member Avatar for 2teez
0
346
Member Avatar for pjrey

Hi wickedxter, Though your script compile, but will produce no output, because there is no match in your regex. Since each of the value read into the array variable `@Blocked_Words` has a trailing "\n". check this using `use re qw(debug);` in your script. However, doing `chomp(my @Blocked_Words = <DATA>);` resolves …

Member Avatar for Taywin
0
482
Member Avatar for erezz

Hi erezz, You can achieve what you wanted using perl inbuilt functions. Atleast that is one way to go about it. For example, if your file has a fixed length that the you posted above, one can do like so: use warnings; use strict; use constant ZERO => 0; use …

Member Avatar for 2teez
0
307
Member Avatar for rogerg

Hi rogerg, This problem could be easily solved using map and grep in Perl like so: use warnings; use strict; my $splitter = qr/[^a-zA-Zàâäéèêëîïôöùûüç]/; # split on the following my %word_freq; ## hash variable my @chains = ( "just trying to figure this out,", "cant figure how to do it…", …

Member Avatar for 2teez
0
458
Member Avatar for mtr1amit

Hi, You didn't tell us that this was also cross-posted in perlmonks [Merge columns from two different files](http://www.perlmonks.org/?node_id=1008972) and stackoverflow.

Member Avatar for 2teez
0
159
Member Avatar for nakshi

Hi nakshi, Here is one. #!/usr/bin/perl use warnings; use strict; my @data_array; push @data_array, join " " => @{ [split] }[ 4, 1 ] while <DATA>; local $" = "\n"; print "@data_array[0,$#data_array]"; __DATA__ HETATM 7749 C1 NFG A1001 -31.772 -7.604 -23.847 0.80 61.71 C HETATM 7750 O1 NFG A1001 -30.806 …

Member Avatar for 2teez
0
322
Member Avatar for dsplayer14

hello dsplayer14, First of, Line 23, is NOT just a convinience measure. The chomp function removes the trailing "\n" from your input from STDIN. Commet out line 23, and see the error message, you get. Secondly, it would be goood if your script is kept in a loop, like a …

Member Avatar for dsplayer14
0
164
Member Avatar for laksraju

Hi laksraju, Please could you show what you have done so far. The area of the code where you are having problems. Writing the code for you would not help you in the long run. Secondly,you might look into the archieve of this forum. This kind of problem has been …

Member Avatar for 2teez
0
153
Member Avatar for vassi
Re: perl

Hi vassi, Please show some example of what you have be able to do so far. With input, codes and desire results and possibly error messages. So that we can help.

Member Avatar for 2teez
0
155
Member Avatar for James79

Hi James 79, First of, I will advice that you use the following in your code: `use warnings;` and `use strict;`. These two pragma, will save you a lot of headaches. Secondly, It is a lot better if your codes are divided into different parts using subroutine instead of lumpping …

Member Avatar for James79
0
258
Member Avatar for voidyman

James 79, You are posting a new question under a solved trend. There is a every chance that your question would not be attended to. Because the trend already has a Solved mark. So, Please start a new disussion instead. Thank you.

Member Avatar for 2teez
0
394
Member Avatar for arishy

Hi, for your codes line numbered 7-11, replace with this: #open the file that contains the body of the email open(FH,'<','body.txt') or die "file does not exists $!"; my $body=do{ local $/ = undef;<FH>}; close(FH); then code line numbered 19-21 then do this: `body => $body,` it should work.

Member Avatar for arishy
0
331
Member Avatar for Wade_1

Hi Wade_1, How are you reading the text file from with your Perl script? What are the text copied into the text file? Obviously, these will be a UTF8 charater set issue. Moreover, you don't need to copy from a webpage into a text file, before opening and reading the …

Member Avatar for 2teez
0
253
Member Avatar for anilak

Hi, First of, there is nothing like PERL,because perl is not an acronym. The language is Perl ( with capital letter ) and the interpreter is called perl ( with small letter ). [What's the difference between "perl" and "Perl"?](http://perldoc.perl.org/perlfaq1.html#What%27s-the-difference-between-%22perl%22-and-%22Perl%22?) That been said OOP in perl is a whole book, …

Member Avatar for 2teez
0
165
Member Avatar for axn

Hi, What you have are checkboxes, which are table data of a table row. So changing the both table attributes and the row attributes could help. See a modification of your code below, and please tell us know if it works. use warnings; use strict; use CGI qw(:standard); my $q …

Member Avatar for 2teez
0
155
Member Avatar for arishy

Something like this: my $str='TGCTCCGGAGCGGTTGACCGACGAATCATGGTTTCGTCTACATCCCGTCTAGTTTCTAG'; while($str=~m/(TC)/g){ print $1,$/ } OR something like this (**UPDATE**): my $str = do{local $/;<DATA>}; for(split/\n/,$str){ print $_,$/ if(/It followed/ .. /till Mary/); # using range operator } __DATA__ Mary had a little lamb, whose fleece was white as snow. And everywhere that Mary went, the …

Member Avatar for arishy
0
327
Member Avatar for arishy

Hello arishy, To start with NEVER use regex to parse an html file(s). It might work for a line or two, but not a file. 2. Modern Perl Mastering encourages the use of tested and used modules in the cpan or other cpan mirrors. Why will you want to re-create …

Member Avatar for 2teez
0
2K
Member Avatar for jjoseph8008

Hi jjoseph8008, You are welcome to learning this great Programming language. I think it will help a bit if you show some codes you have written to solve this problem and where you are having difficultes. As you will not learn much if codes where just written and you don't …

Member Avatar for 2teez
0
230
Member Avatar for iacosar

Hi, It will be better if you can share more codes here, so that we can see what you are really comparing. However, there are several things wrong with the code you have shown so far. Do you intend to use `&&` as against `&` and `||` as against `|`. …

Member Avatar for d5e5
0
175
Member Avatar for siddkh

The code below should solve this quiet easily. #!/usr/bin/perl use warnings; use strict; my %lump_has; while (<DATA>) { chomp; my ( $title, $value ) = split; push @{ $lump_has{$title} }, $value; } print join ' ', $_, @{ $lump_has{$_} }, $/ for keys %lump_has; __DATA__ AH 1106 AH 11989 AH …

Member Avatar for 2teez
0
83
Member Avatar for Aditya_MUHAHA

It would have been wonderful if you show what you have tired. So that we can tell you where you are going wrong. However, this will do: Instead of writing the open function twice, I wrote just once in a subroutine. And used it to call and perform different operation …

Member Avatar for 2teez
0
198
Member Avatar for ronnel09_1

Hi, use int for main() and return 0. Then you could try if and else to break up a long print out like so: #include<stdio.h> #include<conio.h> int main() { int a [20], i; int count = 0; //clrscr (); printf("enter 20 numbers:"); for ( i = 0 ; i < …

Member Avatar for Adak
0
227
Member Avatar for hemalatha.nambisan

Hi, The code below solves the problem. Take this as a guide. Test, verify and ask if you still have some other questions. #!/usr/bin/perl use warnings; use strict; my $data; while (<DATA>) { chomp; my $value = substr $_, 4; # you can use regex instead push @{$data}, [ split …

Member Avatar for 2teez
0
126
Member Avatar for Aditya_MUHAHA

Hi d5e5, Long time. Nice solutions. It worked just as you intended. Tested it on Window OS using both ActivePerl and StrawberryPerl. Hi replic, Nice work but I didn't get your point here. >However not escaping the ''s when using '"' seems to cause a lot of problems. Try escaping …

Member Avatar for 2teez
0
203
Member Avatar for abulut

Or, write the for loop like so: for my $i(0..$#sessions){ ... ... ( $sessions[$i]) ... }

Member Avatar for wickedxter
0
178

The End.