460 Posted Topics
Re: I assume you are shelling out because you don't know who to write it all in perl. Here is one way: [code] #!/usr/bin/perl -w #for folders 41..60 open (my $OUT, ">>", "path/to/output1") or die "$!"; for my $k (41..61){ opendir(my $DIR, "Users/scripts/$k") or die "$!"; my @files = grep {/^ms_stem/} … | |
Re: typically you would use the CPAN shell to install modules with Linux. This part of the perl documentation should help you: [url]http://perldoc.perl.org/perlmodinstall.html[/url] Note it is written for perl 5.10 which might differ from earlier version of perl. | |
Re: or using a loop: [code] use LWP::UserAgent; my $ua = LWP::UserAgent->new; my $success = 1; for (1..5) { my $req = $ua->get( 'http://some.web.site'); if ($req->is_success) { print $req->content; $sucess = 0; last; } } unless ($sucess) { print "Failed all 5 tries to get content\n"; }[/code] | |
Re: You never said what error you were getting but I am assuming you were getting a warning and not an array. Scalar value @array[$marker] better written as $array[$marker] at script line 9 . When accessing individual elements of an array you use the scalar data type symbol $ and not … | |
Re: Perl has no such inbuilt functions/operators try and catch. | |
Re: I'm going to suggest you ask this question on [url]www.unix.com[/url] in the shell scripting forum: [url]http://www.unix.com/shell-programming-scripting/[/url] | |
Re: anywhere you are opening a file in the script: [CODE]open(USERLIST, "./User Lists/$infile.csv");\[/CODE] change to: [CODE]open(USERLIST, "./User Lists/$infile.csv") or die "Can't open ./User Lists/$infile.csv: $!";[/CODE] just make sure to put the name of the file in the die part that corresponds with the actual file being opened. Rerun the script and … ![]() | |
Re: WWW::Mechanize does not come with perl it has to be installed. You can see a listing of all perls core modules here: [url]http://perldoc.perl.org/index-modules-A.html[/url] | |
Re: You need to use a file test operator -M or the stat() function to get the date and the sort() function to sort them. But I bet a Google search would find plenty of examples of code already written, so search yourself: [url]http://www.google.com/search?q=perl+sort+files+by+date[/url] ![]() | |
Re: considering that a .bin file is a compressed and encoded file its no wonder you can't just open it like a text file. | |
Re: Well, the first thing is to properly construct your regexp: [CODE]if($data =~ /$user_input/){then do something;}[/CODE] assuming $data is the number like 1008 and 800, etc, and $user_input is the number 8 then it would match any string that has the number 8 in it anywhere. You can easily test that: … ![]() | |
Re: There is no pearl language but there is perl. Is it the easiest? No. There are plenty of perl books, you want "Learning Perl" the newest edition. Search for it on amazon.com The easiest language to learn might be BASIC, but I have no idea what you would use it … | |
Re: [QUOTE=Salem;902710]Well the 'my' exists inside a { } scope, so I guess it goes out of scope when the block exits.[/QUOTE] Yep, thats probably the reason. [CODE]my @contents = (); if (-e $path_to_file) { open (FILE, $path_to_file) or die "$!"; @contents=<FILE>; close(FILE); } print "$_\n" for @contents;[/CODE] | |
Re: OK, now the easy way...... [CODE]open(LISTFILE, $filename); @filearray = <LISTFILE>; close LISTFILE; print "$_\n" for reverse @filearray;[/CODE] | |
Re: [QUOTE=kummetha;899974]How to print the duplicates in a text file. Also the line number where the duplicate text has been found needs to be printed. pls help KZ[/QUOTE] What have you tried? Where are you stuck? | |
Re: You need to clarify your requirements better. Right now you are looping through num.txt and populating a hash with the lines of the file and the count of how many times each line is seen in the file. From there what do you want to do? See if the same … ![]() | |
Re: [url]http://www.perlguru.com/gforum.cgi?post=39010;[/url] | |
Re: click on the "flag bad post" link in the threads you want deleted and ask that they be deleted. Provide a good reason though. | |
Re: The accepted protocol is that first you try and solve your own programming requirements and post the code you wrote. Then when you are stuck you ask a question. But what is not acceptable is just asking people to do your work (school or otherwsie) for you. Asking a question … | |
Re: Be more specific, what part do you need help with? It looks like you have the general idea of how to do the assignment although there might be better ways to code it, that is not important right now. Learning is incremental, you will learn better methods as you go. … | |
Re: Two easy choices activeperl from [url]http://www.activestate.com[/url] or strawberryperl from [url]http://www.strawberryperl.com[/url] they come with installation instructions. | |
Re: $name is being used for no good reason that I can see: [code] open (INP, "input.txt") or die "Can't open input: $!\n"; open (OUT, ">>output.txt") or die "Can't open output: $!\n"; while ($line = <INP>) { chomp ($line); @field = split (/\s+/, $line); print OUT "($field[0])\t$field[1]\n"; } close INP; close … | |
Re: Maybe: [url]http://search.cpan.org/~leakin/File-Rsync-0.42/Rsync.pm[/url] search CPAN for rsync | |
Re: [QUOTE=Salem;882656][url]http://forums.devshed.com/perl-programming-6/regular-expression-to-get-multi-line-comment-615434.html[/url] Getting kinda bored with your approach.[/QUOTE] Amen | |
Re: The perl documentation would have explained all of your errors. But I'll short-cut it for you. First, $a and $b are variables used by perl for sorting and should not be used by you except for that purpose. Since they are global package variables you don't have to declare them … | |
Re: I didn't look at all your code but this line: [code] $content = get('http://www.ncbi.nlm.nih.gov/sviewer/viewer.fcgi?db=protein&sendto=t&dopt=fasta&list_uids=$protacc_arr[$i]'); [/code] Needs double-quotes so that the variables are interpolated: [code] $content = get("http://www.ncbi.nlm.nih.gov/sviewer/viewer.fcgi?db=protein&sendto=t&dopt=fasta&list_uids=$protacc_arr[$i]"); [/code] Change that and see if it helps. | |
Re: [QUOTE=redmaverick;873228]does anybody know a good forum to go to. I know that daniweb is good for java and c++ thanks![/QUOTE] Whats wrong with this forum? You didn't get a reply fast enough? This is a help forum with volunteer members, not tech support. Be patient. | |
Re: Try perlmonks.com if you get no replies here. I can't help with your question. | |
Re: if useradd is an external application you probably want to use sytemt() to run it: [code] #!/usr/bin/perl $uName=$ARGV[0]; $uNumStart=$ARGV[1]; $uNumEnd=$ARGV[2]; for($i=$uNumStart; $i<=uNumEnd; $i++) { system(qq{useradd "$uName.$i" -g 999}); } [/code] | |
Re: [URL="http://www.google.com/search?client=opera&rls=en&q=perl+send+email&sourceid=opera&ie=utf-8&oe=utf-8"]http://www.google.com/search?q=perl+send+email[/URL] | |
Re: You should be able to do both in one header because the cookie is not a content-type entity. I am not real experienced with cookies but maybe if you post your code I can help, or maybe someone else can. | |
![]() | Re: The code you posted will work to append the string to the end of whatever value $values[10] has. If its not working the problem is elsewhere. |
Re: try: my ($d) = $s =~ m/<head>(.*?)<\/head>/is; | |
Re: The question is probably best asked on a forum dedicated to http servers and not a CGI forum dedicated to CGI scripts. | |
Re: "do" is not really a loop but if you use "until" or "while" with it you can get it to act like a loop. The problem with your code is that $start never has a chance to equal zero so the "do" block just keeps getting repeated over and over. … | |
Re: try this: [CODE]my $dir = <STDIN>; chomp $dir;#<-- remove the end of line character(s)[/CODE] and change "else if" to "elsif". | |
Re: use split instead: [code] my $var = 'abcdefghijklmnop'; my @chars = split(//,$var); foreach my $char (@chars) { #do something with $char } [/code] | |
Re: splice can be used to add elements to an array. [CODE]@array = qw(1 2 4 5); splice(@array,2,0,3); print "$_\n" for @array;[/CODE] In the above code: 2 - is the place in the array you are splicing (its the index value, not the element value) 0 - is the number of … | |
Re: Learing perl will take a big investment in your time and possibly energy. Its not a simple tool like html code, its a full blown programming language. You can start learning some basics but programming a site that is interactive using CGI scripts is not something will accomplish in the … | |
Re: [code] $decVal = <STDIN>; chomp($decVal);#<--- you need this [/code] | |
Re: get the name of the directory after you login, see the documentation for the FTP module you are using for details. | |
Re: Use the open() function to open a file in the CGI script to print data to the file. Something like: open(my $IN, ">>", "path/to/vfx.txt") or die "$!"; print $IN "some data\n"; close ($IN); >> = creates or appends to file > = creates or overwrites file See the open functions … | |
Re: CGI::Pretty comes with perl. I leave it up to you to read the documentation. | |
Re: Use capturing parentheses, this is covered in any basic regexp tutorial. One example: [code] $content = 'this is a test'; $content =~ m/(test)/; $match = $1; print $match; [/code] Of course that is silly because you already know you are looking for "test" so there is no need to capture … | |
Re: [QUOTE=sid78669;840930]Ok, I got it to work: [CODE=PERL] print $cgi->start_html(-title => 'Siddharth's Search Engine', -head => "<META HTTP-EQUIV=\"Pragma\" CONTENT=\"no cache\" />"), "\n"; [/CODE] Although, I would still like it more if there was a better way to do it.[/QUOTE] Its covered in the CGI modules documentation, you were pretty close actually: … | |
Re: I don't know, you can try [url]www.perlmonks.com[/url] or ask on the dbi modules mailing list (see the DBI module for details) | |
Re: You need to print the header first, not second: print $cgi->start_html(), $cgi->header(); should be: print $cgi->header(), $cgi->start_html(); |
The End.