09-01-2006
File processing on perl
Hey everyone ...
I wanted to process the contents of a file, as in modify its contents. whats the best way to do it on perl? In more detail I hav to go through the contents of the file, match patterns n then modify the contents of the same file depending on the matching results. Any help is welcome.
Thanks n regards,
Garric
10 More Discussions You Might Find Interesting
1. Shell Programming and Scripting
Aim:
To scan a file and ignore all characters that has an ASCII value from 0 to 31 and 127 to 255 and accept only those characters having an ASCII between 32 and 126.
Script:
#!/usr/local/bin/perl
$filename = "$ARGV";
if (-e $filename)
{
open(OUT, "${filename}") || die "can't... (10 Replies)
Discussion started by: SEEHTAS
10 Replies
2. Shell Programming and Scripting
I need a script to process a huge single line text file:
The sample of the text is:
"forward_inline_item": "Inline", "options_region_Australia": "Australia", "server_event_err_msg": "There was an error attempting to save", "Token": "Yes", "family": "Family","pwd_login_tab": "Enter Your... (1 Reply)
Discussion started by: hmsadiq
1 Replies
3. Shell Programming and Scripting
I am new to perl, and need a script to pull a CSV file, strip out 2 leading columns, and 2 ending columns, and resave the file in a new location. The file is basic and has less than 10,000 records. Secondly, can I schedule perl scripts to run daily? Can someone provide the basic script to... (1 Reply)
Discussion started by: cobbjob
1 Replies
4. Shell Programming and Scripting
Qspace ABC
Queue doCol: true
Queue order: fifo
Queue setCol: red
Queue order: fifo
Qspace XYZ
Queue getCol: true
Queue order: fifo
I need to append every line in this file with Qspace & Queue, so that final o/p shall look like this,
Qspace: ABC Queue: doCol
Qspace: ABC Queue: doCol... (2 Replies)
Discussion started by: deo_kaustubh
2 Replies
5. Shell Programming and Scripting
I have an input array like :
"SVR1" GRP="EVT_BOX06B" SRID=100 MIN=2
"SVR1" GRP="EVT_BOX06B" SRID=200 MIN=1
"SVR2" GRP="ADM_BOX06B" SRID=100 MIN=1
"SVR1" GRP="EVT_BOX88B" SRID=100 MIN=2
"SVR1" GRP="EVT_BOX88B" SRID=200 MIN=1... (4 Replies)
Discussion started by: deo_kaustubh
4 Replies
6. UNIX for Advanced & Expert Users
Hi Experts,
I have this requirement to process large files (200MB+).Format of files is like:
recordstart
val1 1
val2 2
val3 4
recordstart
val1 5
val2 6
val3 1
val4 1
recordstart
val1 ... (4 Replies)
Discussion started by: mtomar
4 Replies
7. Programming
Hi everyone,
I have Xml files in a folder, I need to extract some attribute values form xml files and store in a hash. My xml file look like this.
<?xml version="1.0" encoding="UTF-8"?>
<Servicelist xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"... (0 Replies)
Discussion started by: pavani reddy
0 Replies
8. Shell Programming and Scripting
Dear all,
I got a perl script to write some data into an excel file using Spreadsheet::ParseExcel::SaveParser. After that I find all formulas in the excel file are gone.
Does any body encounter this problem or have any work around? (2 Replies)
Discussion started by: eldonlck
2 Replies
9. Shell Programming and Scripting
HI All,
I have scenerio where I need to call sub modules through for loop
for (i=0; i<30 ;i++)
{
..
..
..
subroutine 1;
subroutine 2;
}
I want this to be run in parallel
process1
{
...
...
subroutine 1;
subroutine 2; (0 Replies)
Discussion started by: gvk25
0 Replies
10. Programming
Hello,
I extracted a list of files in a directory with the command ls . However this is not my computer, so the ls functionality has been revamped so that it gives the filesizes in front like this :
This is the output of ls command : I stored the output in a file filelist
1.1M... (5 Replies)
Discussion started by: ajayram
5 Replies
LEARN ABOUT DEBIAN
file::fnmatch
FnMatch(3pm) User Contributed Perl Documentation FnMatch(3pm)
NAME
File::FnMatch - simple filename and pathname matching
SYNOPSIS
use File::FnMatch qw(:fnmatch); # import everything
# shell-style: match "/a/bc", but not "/a/.bc" nor "/a/b/c"
fnmatch("/a/*", $fn, FNM_PATHNAME|FNM_PERIOD);
# find our A- executables only
grep { fnmatch("A-*.exe", $_) } readdir SOMEDIR;
DESCRIPTION
File::FnMatch::fnmatch() provides simple, shell-like pattern matching.
Though considerably less powerful than regular expressions, shell patterns are nonetheless useful and familiar to a large audience of end-
users.
Functions
fnmatch ( PATTERN, STRING [, FLAGS] )
Returns true if PATTERN matches STRING, undef otherwise. FLAGS may be the bitwise OR'ing of any supported FNM_* constants (see below).
Constants
FNM_NOESCAPE
Do not treat a backslash ('') in PATTERN specially. Otherwise, a backslash escapes the following character.
FNM_PATHNAME
Prohibit wildcards from matching a slash ('/').
FNM_PERIOD
Prohibit wildcards from matching a period ('.') at the start of a string and, if FNM_PATHNAME is also given, immediately after a slash.
Other possibilities include at least FNM_CASEFOLD (compare "qr//i"), FNM_LEADING_DIR to restrict matching to everything before the first
'/', FNM_FILE_NAME as a synonym for FNM_PATHNAME, and the rather more exotic FNM_EXTMATCH. Consult your system documentation for details.
EXPORT
None by default. The export tag ":fnmatch" exports the fnmatch function and all available FNM_* constants.
PATTERN SYNTAX
Wildcards are the question mark ('?') to match any single character and the asterisk ('*') to match zero or more characters. FNM_PATHNAME
and FNM_PERIOD restrict the scope of the wildcards, notably supporting the UNIX convention of concealing "dotfiles":
Bracket expressions, enclosed by '[' and ']', match any of a set of characters specified explicitly ("[abcdef]"), as a range ("[a-f0-9]"),
or as the combination these ("[a-f0-9XYZ]"). Additionally, many implementations support named character classes such as "[[:xdigit:]]".
Character sets may be negated with an initial '!' ("[![:space:]]").
Locale influences the meaning of fnmatch() patterns.
CAVEATS
Most UNIX-like systems provide an fnmatch implementation. This module will not work on platforms lacking an implementation, most notably
Win32.
SEE ALSO
File::Glob, POSIX::setlocale, fnmatch(3)
AUTHOR
Michael J. Pomraning
Please report bugs to <mjp-perl AT pilcrow.madison.wi.us>
COPYRIGHT AND LICENSE
Copyright 2005 by Michael J. Pomraning
This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself.
perl v5.14.2 2005-03-30 FnMatch(3pm)