1. I have a folder containing several files;
2. Now these files should be added a header with the file name in the first line;
How can I complish this using perl script?
5 5000 numberwhun 3,509
Recognized Expert Moderator Specialist
1. I have a folder containing several files;
2. Now these files should be added a header with the file name in the first line;
How can I complish this using perl script?
First, welcome to TSDN.
Second, we would love to help assist you with any code you have written. What have you tried so? Can you post your code please?
Regards,
Jeff
You can use UNIX command in perl, if u r working in unix platform.
and unix command is
sed -n "1i/
>ur line input
filename > $$
then
mv $$ filename
numberwhun 3,509
Recognized Expert Moderator Specialist
You can use UNIX command in perl, if u r working in unix platform.
and unix command is
sed -n "1i/
>ur line input
filename > $$
then
mv $$ filename
Yes, you certainly can, but the thing to remember is that the system command(s) need to be inside of either back tics or the system() function.
Regards,
Jeff
KevinADC 4,059
Recognized Expert Specialist
use perls inplace editor: -
use warnings;
-
chdir('path/to/folder') or die "$!";
-
@ARGV = <*.*>;
-
$^I = '.bak';
-
while(<>){
-
if ($. == 1) {
-
print "$ARGV\n";
-
}
-
print;
-
}
change <*.*> to whatever is appropriate or leave as-is to edit all files in the folder.
Sign in to post your reply or Sign up for a free account.
Similar topics |
by: Sherman Willden |
last post by:
I am trying to use Perl's XML::Twig to modify a version number in an
XML document. At the very end of this posting is an excerpt from the
xml document. Just before the xml excerpt is the Perl code I am trying
to use. The Xpath part of the script functions well.
I think I need help determining the @field entry. I have tried
//property/string, version/string, and string. I get
a "Can't modify non-lvalue subroutine call at C:\business...
|
by: Veeven |
last post by:
Hi,
Suppose I have an XML file like this on the web, say,
http://www.example.com/list.xml
<?xml version='1.0'?>
<list>
<item id='itm01'>
<name>Item 1</name>
<desc>This is item 1</desc>
|
by: von |
last post by:
I am trying to write a single piece of data (that is generated from a
Javascript) to a text file on my server via a Perl script.
The Javascript is setup so that I can display the required data on my
website using the following HTML:
<span name='Data1' class='data1'></span>
But I need it sent to a text file. :(
|
by: JMB |
last post by:
Hello,
I was wondering if anyone knew of any projects extending the inline upload
progress bar to utilize an inpage image uploader with bar, without having to
refresh or go to a seperate page, nor opening a second box for display of
the progress bar.
I had been using the MegaUpload that was adapted from Raditha's script at
http://www.raditha.com/upload.php . The MegaUpload script I have been using
takes the progress bar inpage,...
|
by: TimEl |
last post by:
Hi.
Using Perl, I want to modify data in an XML file and print out the entire modified file, not just the elements I modify. In CPAN I have found that XPath allows me to pinpoint the elements that I want to modify. But all of the code examples that I have seen assume that I want to assign the targeted elements to variables, modify each element, and then print only the modified elements out to a file. For example, this code is found at...
| |
by: raghav82 |
last post by:
New to perl. c++ file which needs to invoke perl file and provide input for it.how to invoke it.i also want to know setting of environment variable in windows environment using the perl script. i set a environment variable externally through control panel, but in the perl script its not getting set. one of the environment variable is set to a path and created logfile takes name from the environment variable.But its not getting so not creating...
|
by: smarsh |
last post by:
Hi,
Someone put together a small perl script for me that uses day and time to determine which of two images to display (open.gif or closed.gif). I need to modify the script to also include a hyperlink to open.html or closed.html so that if the open image is displayed it puts the open.html link on the image and the closed.html link on the closed image. The corresponding web page that loads the image is ultra basic, with a link to the .pl...
|
by: georgewa |
last post by:
Greetings all, great forum, this is my first post.
Recently trying to write a script that is designed to move files based on timestamps. I am fairly new to Perl, so please bare with me. I have written a short script that should iterate through all files in the current directory and output unix epoch time. The script in it's entirety is posted below:
#!/usr/bin/perl
use warnings;
use strict;
use Cwd;
use File::Find;
|
by: rajiv07 |
last post by:
Hi to all,
I have a script to list the file names in a directory .When i run this script locally (command prompt) it displays the exact file name (even though the file name has two spaces).But i upload the script into server (Browser) it shows trimmed file names(single space for double spaces).
I have checked both IE and Firefox it shows only single space file name instead on double space file name. Is it browser problem.
...
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look !
Part I. Meaning of...
|
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
| |
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own....
Now, this would greatly impact the work of software developers. The idea...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules.
He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms.
Adolph will...
|
by: conductexam |
last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one.
At the time of converting from word file to html my equations which are in the word document file was convert into image.
Globals.ThisAddIn.Application.ActiveDocument.Select();...
|
by: TSSRALBI |
last post by:
Hello
I'm a network technician in training and I need your help.
I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs.
The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols.
I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
|
by: 6302768590 |
last post by:
Hai team
i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
| |
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |