copying multiple files


hello all, How can i copy files with a particular extension. For eg: I am using copy ("$HOME_DIR/file1.txt" ,"$LOCAL_DIR/") or warn "Cannot copy file: $!"; to copy a file, but if i have to copy all the files with the ...
Posted On: Monday 26th of November 2012 08:48:15 PM Total Views:  270
View Complete with Replies

RELATED TOPICS OF Perl PROGRAMMING LANGUAGE




DBI:mysql how to do multiple inserts/modification?

How can I do multiple database modifications without writing too much code For a single modification, I would write: $SQL = "INSERT INTO aaaaa.."; $db->do($SQL); How can I do it without repeating "$db->do($SQL);" each time Something like this throws an error, so obviously I must be missing something. $SQL = "INSERT INTO aaaaa... ; INSERT INTO bbbbb... ; INSERT INTO bbbbb... ;"; $db->do($SQL); -- Tomasz Chmielewski http://wpkg.org , Paul Lalli schrieb: > On Feb 13, 9:03 am, Tomasz Chmielewski > wrote: >> How can I do multiple database modifications without writing too much code >> >> For a single modification, I would write: >> >> $SQL = "INSERT INTO aaaaa.."; >> $db->do($SQL); >> >> How can I do it without repeating "$db->do($SQL);" each time >> >> Something like this throws an error, so obviously I must be missing >> something. >> >> $SQL = "INSERT INTO aaaaa... ; >> INSERT INTO bbbbb... ; >> INSERT INTO bbbbb... ;"; >> $db->do($SQL); > > uh. How about... > > for my $stmt (split /;\n/, $SQL) { > $db->do($stmt); > } Ah, that simple.
VIEWS ON THIS POST

125

Posted on:

Monday 5th November 2012
View Replies!

How to extract Min and Max value from multiple rows

i am very new to PERL. I need to find Min and Max values for different ID (4,5,6) in multiple rows. eg:\t\t\t\t\t\t\t\t\t\t\t13976\t\t14249\t\t414306\t\t14416\t\t415094\t\t15651\t\t416111\t\t16236\t\t516367\t\t16643\t\t519092\t\t19624\t\t519683\t\t20561\t\t521204\t\t22151\t\t622217\t\t22765\t\t6This data is in data.dat file. The result should be:Min 13976 and Max 15651 for ID 4Min 16111 and Max 20561 for ID 5Min 21204 and Max 22765 for ID 6How to do this in PERL
VIEWS ON THIS POST

77

Posted on:

Wednesday 7th November 2012
View Replies!

writing to multiple file handles at once

In my script I open two file handles, one is a pipe to sendmail to send email, and the other is a file handle to a local file on the system.\tHow can I print to both of these at the same timeCODE$sendmail = "/usr/sbin/sendmail -t";open(SENDMAIL, "|$sendmail") or die "Cannot open $sendmail: $!";open(FILE, "
VIEWS ON THIS POST

74

Posted on:

Wednesday 7th November 2012
View Replies!

Displaying multiple images from array

i have 4 pics ( jpeg) in an array, but i'm having trouble displaying them all. It never displays all pics, tends to display them in random order, and some pics are repeated 2 or 3 times.Here's the html and the perl code:CODEhtml:i gave all file uploads the same name bcos its easier for me to put and arrange in an arrayPerl:CODE#!/usr/bin/perl \t\t\tuse warnings;\tuse CGI;\tuse CGI::Carp qw/fatalsToBrowser/;\tmy $query = new CGI;\t\t\t$upload_dir = 'C:/mystuff_htm/uploads';\t\t\t\tmy @fh = $query->upload('photo');\tmy $filename = $query->param("photo");\tprint "Content-type: text/html\n\n";foreach my $fhan(@fh){\topen (UPLOADFILE, ">$upload_dir/$filename") or error($!);\tbinmode UPLOADFILE;\twhile ( ) {\t\t\tprint UPLOADFILE;\t}}\tclose UPLOADFILE;foreach $fhan(@fh){print "\n";\t\t\t\t }
VIEWS ON THIS POST

70

Posted on:

Wednesday 7th November 2012
View Replies!

Matching multiple subexpressions in a regular expression

On Mar 11, 6:13 pm, "John W. Krahn" wrote: .... > > since the one > > big regular expression can be compiled into a single large finite- > > state-machine that is more efficient than running 100 little FSM. > > That question is answered in perlfaq6: > > perldoc -q "How do I efficiently match many regular expressions at once" Hi John, If I structure my program as in the example, using many small regex instead of one big regex, Perl 5.8.6 runs out of memory and dies: vm_allocate failed, Out of memory! I have 400'000 regex of exactly 27 characters each, and the input string is one line 100 kB long. The machine has 2 GB of memory and free disk space, which should be enough, so I presume the code is somehow leeking memory. It's only a dozen or so lines long, so I've posted my code below. Can you see an obvious leak
VIEWS ON THIS POST

59

Posted on:

Wednesday 7th November 2012
View Replies!

syntax for or {multiple; statements;}?

sorry for this lame question but I can't search it becuase I don't know how to explain it in searchable terms, what I did search turned up nothing useful. How can you execute multiple statements in Perl when perl ...
VIEWS ON THIS POST

74

Posted on:

Sunday 11th November 2012
View Replies!

Copy multiples files to a single file in seperate pages..

I'm a beginner with Perl and requires help.. Trying to understand if we have a mechanism to copy multiple files ( txt files ) to a single file (say abc.txt) with each file residing in single page. Each input ...
VIEWS ON THIS POST

117

Posted on:

Sunday 11th November 2012
View Replies!

copying arrays

In the following code the array @drop is modified as well as @drop2. How can I achieve modifying @drop2 without affecting @drop > @drop = ( > { 'hello' => 'world', 'hi' => 'there' }, > { 'hello' => 'dude', ...
VIEWS ON THIS POST

72

Posted on:

Sunday 11th November 2012
View Replies!

Re: How to transparently download multiple files?

On Apr 7, 9:35 pm, Ed Jay wrote: Normally I don't see stuff posted by trolls. This time someone failed to ignore a troll and so the trolls writings became visible in Ed's posting. People unfamiliar with Kiralynne Schilitubi ...
VIEWS ON THIS POST

67

Posted on:

Thursday 15th November 2012
View Replies!

Telnet to multiple systems, continue on failure

I'm trying to telnet to multiple system IP address that I'm loading from a file. However, if one of the telnet connections fails, the scripts stops. I want it to continue trying to telnet to the rest of the devices ...
VIEWS ON THIS POST

69

Posted on:

Thursday 15th November 2012
View Replies!

Printing main window with multiple canvases...

Does anybody know a simple way (an available Perl/Tk module perhaps ) of printing the contents of a mainwindow with multiple canvases I have saved the contents as a bitmap file, but if one wants to print them ...
VIEWS ON THIS POST

83

Posted on:

Thursday 15th November 2012
View Replies!

match pattern of multiple lines

I need to match the following pattern with a file, begin ...... end I check the web, it says I should use pattern modifier s & m, so I ...
VIEWS ON THIS POST

51

Posted on:

Thursday 15th November 2012
View Replies!

Tk & Multi-port monitor cards (or multiple cards)

How does one control the multiple displays of a multi-port monitor card with Tk...
VIEWS ON THIS POST

61

Posted on:

Monday 19th November 2012
View Replies!

Calling multiple perl subroutines from XS procedure

XS manual pages, "Advanced perl programming" etc all mention the more-or-less such sequence to be used while calling perl subroutine from C code: { dSP; ENTER; SAVETMPS; PUSHMARK(sp); /* ... populating params with XPUSHs */ PUTBACK; int n = perl_call_method(...); ...
VIEWS ON THIS POST

69

Posted on:

Monday 19th November 2012
View Replies!

Complex multiple condition sort routine

I'm trying to sort data in a particular way:-\t\tPrimarily by the users choice.-\t\tSecondarily by "coordinates" (keys 'X' or 'Y' or 'Z').However, when the user first visits the webpage, because they haven't yet made a choice on how to sort the data, it should be sorted by default by the secondary method only.I am struggling to achieve the above task because the first condition of the sort routine would be "dynamic" (0 arguements (no user input), 1 arguement (user input), or possibly 3 arguements (default x, y, z)), if you understand what I mean.Here is some example data:CODEmy $data = [\t\t{\t\t\t\t'X' => "1",\t\t\t\t'Y' => "1",\t\t\t\t'Z' => "12",\t\t\t\t'Username' => "Chris",\t\t\t\t'ID' => "1672"\t\t},\t\t{\t\t\t\t'X' => "1",\t\t\t\t'Y' => "1",\t\t\t\t'Z' => "14",\t\t\t\t'Username' => "Peter",\t\t\t\t'ID' => "849"\t\t},\t\t{\t\t\t\t'X' => "1",\t\t\t\t'Y' => "2",\t\t\t\t'Z' => "2",\t\t\t\t'Username' => "Laura",\t\t\t\t'ID' => "801"\t\t},\t\t{\t\t\t\t'X' => "4",\t\t\t\t'Y' => "6",\t\t\t\t'Z' => "8",\t\t\t\t'Username' => "Emily",\t\t\t\t'ID' => "4690"\t\t},\t\t{\t\t\t\t'X' => "2",\t\t\t\t'Y' => "9",\t\t\t\t'Z' => "12",\t\t\t\t'Username' => "Daniel",\t\t\t\t'ID' => "7012"\t\t},\t\t{\t\t\t\t'X' => "1",\t\t\t\t'Y' => "1",\t\t\t\t'Z' => "4",\t\t\t\t'Username' => "Chris",\t\t\t\t'ID' => "1674"\t\t}];And here is my initial attempt at sorting it, pretending there is user input:CODEmy %sortroutines = (\t\t'X' => sub { $_[0] $_[1] },\t\t'Y' => sub { $_[0] $_[1] },\t\t'Z' => sub { $_[0] $_[1] },\t\t'Username' => sub { $_[0] cmp $_[1] },\t\t'ID' => sub { $_[0] $_[1] });my $sortby = 'Username';foreach my $row (sort { (\t\t$sortroutines{$sortby}->($a->{$sortby}, $b->{$sortby})\t\t) || (\t\t$sortroutines{'X'}->($a->{'X'}, $b->{'X'}) || $sortroutines{'Y'}->($a->{'Y'}, $b->{'Y'}) || $sortroutines{'Z'}->($a->{'Z'}, $b->{'Z'})\t\t) } @$data) {\t\tforeach my $cell (sort keys %$row) {\t\t\t\tprint "$$row{$cell}";\t\t}\t\tprint "";}And my most recent attempt at achieving my overall task (messy):CODEmy %sortroutines = ();%sortroutines = (\t\t'Initial' => sub { $sortroutines{'X'}->($_[0], $_[1], 'X') || $sortroutines{'Y'}->($_[0], $_[1], 'Y') || $sortroutines{'Z'}->($_[0], $_[1], 'Z') },\t\t'X' => sub { $_[0]->{$_[2]} $_[1]->{$_[2]} },\t\t'Y' => sub { $_[0]->{$_[2]} $_[1]->{$_[2]} },\t\t'Z' => sub { $_[0]->{$_[2]} $_[1]->{$_[2]} },\t\t'Username' => sub { $_[0]->{$_[2]} cmp $_[1]->{$_[2]} },\t\t'ID' => sub { $_[0]->{$_[2]} $_[1]->{$_[2]} });my $sortby = param('sortby') || 'Initial';foreach my $row (sort { (\t\t$sortroutines{$sortby}->($a, $b, $sortby)\t\t) || (\t\t$sortroutines{'X'}->($a, $b, $sortby) || $sortroutines{'Y'}->($a, $b, $sortby) || $sortroutines{'Z'}->($a, $b, $sortby)\t\t) } @$data) {\t\tforeach my $cell (sort keys %$row) {\t\t\t\tprint "$$row{$cell}";\t\t}\t\tprint "";}My 2nd attempt doesn't work correctly. My question is, how can I ignore the first condition of the sort routine if it isn't needed If I haven't made myself clear enough, please ask for further details.Thank you very much in advance for helping.Chris
VIEWS ON THIS POST

48

Posted on:

Saturday 24th November 2012
View Replies!

Data Parsing of multiple lines into fields

I have been able to parse the data from many blocks and lines into single fields, but am running into a brain freeze for further correlation.\tData looks as follows and I need to make it look like FINAL data.\tAny pointers and my brain will thank you.DATASETsig1 a b c d esig1 f g h i jsig2 a b c d esig2 f g h i jFINAL DATAsig1 a f b g c h d i e jsig2 a f b g c h d i e j
VIEWS ON THIS POST

104

Posted on:

Saturday 24th November 2012
View Replies!

Format fields in multiple files to Comma separated format.

In need script for taking field's from multiple files in one directory files have the same "fields".example file:---------------------#####\tTEST NAME\t\t\t\t\t\t\t\t\t\t: xxxxxxxx#####\tTEST OWNER\t\t\t\t\t\t\t\t\t: XXXxxxxxx#####\tXXX DIGIT IDENTIFIER\t\t\t\t: AAA, AAA, AAA---------------------Need format , separated starting with the FILENAME in the first field:Need format to look like this------------------------FILENAME, TEST NAME, xxxxxxxx, xxxxxxxx, AAA, AAA, AAAFILENAME, TEST NAME, xxxxxxxx, xxxxxxxx, AAA, AAA, AAAFILENAME, TEST NAME, xxxxxxxx, xxxxxxxx, AAA, AAA, AAAFILENAME, TEST NAME, xxxxxxxx, xxxxxxxx, AAA, AAA, AAA------------------------Hoping someone can help here Given two equally predictive theories, choose the simpler.\t
VIEWS ON THIS POST

98

Posted on:

Saturday 24th November 2012
View Replies!

How copying a file in a remote server to your own site

Using perl how do you write a script to copy a remote file into your own site. In my situation want to copy a rss feed from http://remoteserver/news.xml for example. Marcos...
VIEWS ON THIS POST

96

Posted on:

Sunday 25th November 2012
View Replies!

perl parse across multiple line in txt file

i have a file with the following sample text 1 create table xyz 2 no before journal, 3 no after journal 4 ( 5 col1 integer, 6 col2 integer, 7 ... 8 coln varchar(10) 9 ) 10; i want to ...
VIEWS ON THIS POST

101

Posted on:

Monday 26th November 2012
View Replies!

Re: output from multiple files

On comp.unix.shell, in , "John W. Krahn" wrote: > > > suraj_c@hotmail.com wrote: >> There are three files called first , second and third . Each is having >> three columns >> >> $cat first >> a b c >> ...
VIEWS ON THIS POST

90

Posted on:

Monday 26th November 2012
View Replies!