460 Posted Topics

Member Avatar for LSU_223

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/} …

Member Avatar for LSU_223
0
134
Member Avatar for Amps

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.

Member Avatar for Amps
0
234
Member Avatar for Vandithar

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]

Member Avatar for KevinADC
0
201
Member Avatar for perlfan

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 …

Member Avatar for KevinADC
0
698
Member Avatar for Amps
Member Avatar for adkona

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]

Member Avatar for KevinADC
0
66
Member Avatar for jlondon

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 …

Member Avatar for onaclov2000
0
112
Member Avatar for himanshukec

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]

Member Avatar for Prakash_8111
0
73
Member Avatar for derekn

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]

Member Avatar for onaclov2000
0
375
Member Avatar for TeamUSA

considering that a .bin file is a compressed and encoded file its no wonder you can't just open it like a text file.

Member Avatar for Fest3er
0
110
Member Avatar for derekn

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: …

Member Avatar for onaclov2000
0
138
Member Avatar for Niteshay

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 …

Member Avatar for mapsonyllaer
0
156
Member Avatar for derekn

[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]

Member Avatar for KevinADC
0
294
Member Avatar for binfPerl

OK, now the easy way...... [CODE]open(LISTFILE, $filename); @filearray = <LISTFILE>; close LISTFILE; print "$_\n" for reverse @filearray;[/CODE]

Member Avatar for binfPerl
0
227
Member Avatar for kummetha

[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?

Member Avatar for KevinADC
0
171
Member Avatar for rayken1

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 …

Member Avatar for onaclov2000
0
144
Member Avatar for Arsench
Member Avatar for KevinADC
0
114
Member Avatar for abhi_elementx
Member Avatar for larryperl

click on the "flag bad post" link in the threads you want deleted and ask that they be deleted. Provide a good reason though.

Member Avatar for KevinADC
0
61
Member Avatar for rayken1
Re: help

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 …

Member Avatar for KevinADC
0
133
Member Avatar for designblocks

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. …

Member Avatar for Akase
0
121
Member Avatar for sap_maniam

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.

Member Avatar for KevinADC
0
136
Member Avatar for rolinski

$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 …

Member Avatar for KevinADC
0
312
Member Avatar for Prakash_8111

Maybe: [url]http://search.cpan.org/~leakin/File-Rsync-0.42/Rsync.pm[/url] search CPAN for rsync

Member Avatar for mitchems
0
108
Member Avatar for oryesyes

[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

Member Avatar for KevinADC
0
104
Member Avatar for VernonDozier

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 …

Member Avatar for VernonDozier
0
218
Member Avatar for ajay_p5

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.

Member Avatar for ajay_p5
0
149
Member Avatar for redmaverick

[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.

Member Avatar for KevinADC
0
129
Member Avatar for vigneshrao
Member Avatar for sowmyav
Member Avatar for k2k

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]

Member Avatar for katharnakh
0
161
Member Avatar for rana03

[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]

Member Avatar for crb3
0
95
Member Avatar for derekn

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.

Member Avatar for derekn
0
253
Member Avatar for perlguy

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.

Member Avatar for KevinADC
0
125
Member Avatar for kenji
Member Avatar for gsarin

The question is probably best asked on a forum dedicated to http servers and not a CGI forum dedicated to CGI scripts.

Member Avatar for gsarin
0
451
Member Avatar for LSU_223

"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. …

Member Avatar for LSU_223
0
294
Member Avatar for musturd

try this: [CODE]my $dir = <STDIN>; chomp $dir;#<-- remove the end of line character(s)[/CODE] and change "else if" to "elsif".

Member Avatar for musturd
0
191
Member Avatar for mysouthcity
Member Avatar for orwell84

use split instead: [code] my $var = 'abcdefghijklmnop'; my @chars = split(//,$var); foreach my $char (@chars) { #do something with $char } [/code]

Member Avatar for orwell84
0
310
Member Avatar for babno

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 …

Member Avatar for babno
0
2K
Member Avatar for qaokpl

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 …

Member Avatar for ghostdog74
0
172
Member Avatar for sprok
Member Avatar for sprok
0
616
Member Avatar for Debangana
Member Avatar for ghostdog74
0
119
Member Avatar for solocky

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 …

Member Avatar for KevinADC
0
84
Member Avatar for sid78669
Member Avatar for sid78669
0
81
Member Avatar for arya6000

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 …

Member Avatar for KevinADC
0
77
Member Avatar for sid78669

[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: …

Member Avatar for sid78669
0
164
Member Avatar for punitdam

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)

Member Avatar for punitdam
0
531
Member Avatar for sid78669

You need to print the header first, not second: print $cgi->start_html(), $cgi->header(); should be: print $cgi->header(), $cgi->start_html();

Member Avatar for sid78669
0
225

The End.