Kevin,
This time I won't post any code and ask the OP to try do some homework before posting anything.
Thanks,
Kalyan
User Profile
Collapse
-
Assuming that script name is replace
usage is replace 'substitute expression' list of files
Code:replace 's/this/that/g' 1.txt 2.txt 3.txt 4.txt
Leave a comment:
-
I think this script will help you out...I've tested this on Unix and a homework for you to test on Windows.
...Code:#!/usr/local/bin/perl # # Replaces a string within multiple files # specified on the command line $mv = '/bin/mv'; $op = shift || die("Usage: $0 perlexpr [filenames]\n"); if (!@ARGV) { @ARGV = <STDIN>; chop(@ARGV);Leave a comment:
-
Both Perl's exec() function and system() function execute a system shell command. The big difference is that system() creates a fork process and waits to see if the command succeeds or fails - returning a value. exec() does not return anything, it simply executes the command. Neither of these commands should be used to capture the output of a...Code:exec(PATH_TO_THE_PROGRAM); $result = system(PATH_TO_THE_PROGRAM);
Leave a comment:
-
It depends on which box you're working on now...windows or *nix.
The following code works perfectly on windows and unix.
This will work on Unix...Code:#!/usr/bin/perl # get logged-in user name print "Current user is " . getlogin();
HTH,Code:perl -le 'print scalar getpwuid $<'
Kalyan RajLeave a comment:
-
kalyanrajsista replied to To test the pattern whether it is.jpg or .xml by comparing with the extensionin PerlI've tested the following code on unix box with the sample data provided in common.txt and found to be working fine.
...Code:#!/usr/bin/perl -w use strict; open (COMMON,"common.txt") or die $!; open (IMAGE,">image.txt") or die $!; open (HTML,">html.txt") or die $!; my @commonFile = <COMMON>; print IMAGE grep(/\.(jpg|bmp)$/, @commonFile);
Leave a comment:
No activity results to display
Show More
Leave a comment: