I have a file that i want to split out into a hash, but the delimiter is either a space or a comma but the last column needs to be able to include spaces ..
so for example my file
Code:
/opt/accounts 80,90,60,70 Accounts Team
/opt/finance 70,45,90,89 Finance Team
which I split out using into a hash by doing the following
Code:
open (IN, "/var/opt/file.cfg");
while (<IN>) {
chomp();
my ( $filesystem,$warning,$minor,$major,$critical,$team ) = split(/[ ,]/);
$hash->{$counter} = {
counter => $counter,
filesystem => $filesystem,
warning => $warning,
major => $major,
minor => $minor,
critical => $critical,
team => $team
};
$counter++;
}
but the problem is, because I have split() using commas and spaces, when it comes to the last value I want to capture, its pulling "Accounts" into the hash instead of "Accounts Team".
unfortunately I am unable to change the source file, but does anyone know how I can split using spaces and commas except for the last column ? (which incedentally will always be the 6th and last value in the file)
$mystring = "name:blk:house::";
print "$mystring\n";
@s_format = split(/:/, $mystring);
for ($i=0; $i <= $#s_format; $i++) {
print "index is $i,field is $s_format";
print "\n";
}
$size = $#s_format + 1;
print "total size of array is $size\n";
i am expecting my size to be 5, why is it... (5 Replies)
I am interested in 2 and 36th fields in this input file. I was wondering if there was a more efficeint way to do this.
($pt1,$bkup_name,$pt3,$pt4,$pt5,$pt6,$pt7,$pt8,$pt9,
$pt10,$pt11,$pt12,$pt13,$pt14,$pt15,$pt16,$pt17,
... (7 Replies)
Hi,
I have to split a line of the form
1232423#asdf#124324#54534#dcfg#wert#rrftt#4567
into an array in perl. I am using
@fields;
@fields=split('#',$line);
if($fields eq "1")
But this is not working. By using the syntax, the statements in "if" are never executed. Please help.... (9 Replies)
hi, I have a seemingly really stupid question, but here goes!
What do you enter into split delimiter to seperate something like this
"December 12, 1995"
and get
December
12
1995
?
thanks (5 Replies)
Hi... I have a question regarding the split function in PERL.
I have a very huge csv file (more than 80 million records). I need to extract a particular position(eg : 50th position) of each line from the csv file. I tried using split function. But I realized split takes a very long time.
Also... (1 Reply)
Hi... I have a question regarding the split function in PERL.
I have a very huge csv file (more than 80 million records). I need to extract a particular position(eg : 50th position) of each line from the csv file. I tried using split function. But I realized split takes a very long time.
Also... (1 Reply)
Hi,
I have tried the split and join functions but stuck with unexpected results. Any help appreciated. I pass multiple values at command line like perl test.pl -type java,xml. This works good for me but i am not sure how to print it in the required format.
Here is the code i tried:... (4 Replies)
my @d =split('\|', $_);
west|ACH|3|Y|LuV|N||N||
Qt|UWST|57|Y|LSV|Y|Bng|N|KT|
It Returns d as 8 for First Line, and 9 as for Second Line . I want to Process Both the Files, How to Handle It. (3 Replies)
Hi,
I need your help for below with shell scripting or perl
I/P
key, Sentence
customer1, I am David
customer2, I am Taylor
O/P
Key, Words
Customer1,I
Customer1,am
Customer1,David
Customer2,I
Customer2,am
Customer2,Taylor (4 Replies)
Discussion started by: monishathampi
4 Replies
LEARN ABOUT DEBIAN
autopush
autopush(1M) System Administration Commands autopush(1M)NAME
autopush - configures lists of automatically pushed STREAMS modules
SYNOPSIS
autopush -f filename
autopush -g -M major -m minor
autopush -r -M major -m minor
DESCRIPTION
The autopush command configures the list of modules to be automatically pushed onto the stream when a device is opened. It can also be used
to remove a previous setting or get information on a setting.
OPTIONS
The following options are supported:
-f filename Sets up the autopush configuration for each driver according to the information stored in filename. An autopush file con-
sists of lines of four or more fields, separated by spaces as shown below:
major minor last-minor module1 module2 ... module8
The first field is a string that specifies the major device name, as listed in the /kernel/drv directory. The next two
fields are integers that specify the minor device number and last-minor device number. The fields following represent the
names of modules. If minor is -1, then all minor devices of a major driver specified by major are configured, and the value
for last-minor is ignored. If last-minor is 0, then only a single minor device is configured. To configure a range of minor
devices for a particular major, minor must be less than last-minor.
The remaining fields list the names of modules to be automatically pushed onto the stream when opened, along with the posi-
tion of an optional anchor. The maximum number of modules that can be pushed is eight. The modules are pushed in the order
they are specified. The optional special character sequence [anchor] indicates that a STREAMS anchor should be placed on
the stream at the module previously specified in the list; it is an error to specify more than one anchor or to have an
anchor first in the list.
A nonzero exit status indicates that one or more of the lines in the specified file failed to complete successfully.
-g Gets the current configuration setting of a particular major and minor device number specified with the -M and -m options
respectively and displays the autopush modules associated with it. It will also return the starting minor device number if
the request corresponds to a setting of a range (as described with the -f option).
-m minor Specifies the minor device number.
-M major Specifies the major device number.
-r Removes the previous configuration setting of the particular major and minor device number specified with the -M and -m
options respectively. If the values of major and minor correspond to a previously established setting of a range of minor
devices, where minor matches the first minor device number in the range, the configuration would be removed for the entire
range.
EXIT STATUS
The following exit values are returned:
0 Successful completion.
non-zero An error occurred.
EXAMPLES
Example 1: Using the autopush command.
The following example gets the current configuration settings for the major and minor device numbers as indicated and displays the autopush
modules associated with them for the character-special device /dev/term/a:
example# autopush -g -M 29 -m 0
Major Minor Lastminor Modules
29 0 1 ldterm ttcompat
FILES
/etc/iu.ap
ATTRIBUTES
See attributes(5) for descriptions of the following attributes:
+-----------------------------+-----------------------------+
| ATTRIBUTE TYPE | ATTRIBUTE VALUE |
+-----------------------------+-----------------------------+
|Availability |SUNWcsu |
+-----------------------------+-----------------------------+
SEE ALSO bdconfig(1M), ttymon(1M), attributes(5), ldterm(7M), sad(7D), streamio(7I), ttcompat(7M)
STREAMS Programming Guide
SunOS 5.10 26 Mar 1999 autopush(1M)