Re: formatting text

2005-11-29 Thread Jeff 'japhy' Pinyan

On Nov 29, Ing. Branislav Gerzo said:


I'd like to know if there is module for following:


Yes, Perl6::Form.  It's a Perl 5 implementation of Perl 6's formats.


112
12345678901234567890
=== OUT ===
| This is just |
| small sentence   |
| about nothing.   |
=== OUT ===

So, I'd like to define | as start and as end, word-wrapped text,
and length of line is lets say 20 chars.


You could use Perl 5's formats, but they're ugly to work with. 
Perl6::Form presents them in a simpler and better fashion.


  use Perl6::Form;

  print form
| {} |,
   $string
  ;

does what you want.  See the module's documentation for details.

You'll have to download the module from CPAN, since I highly doubt you 
already have it.


--
Jeff japhy Pinyan%  How can we ever be the sold short or
RPI Acacia Brother #734%  the cheated, we who for every service
http://www.perlmonks.org/  %  have long ago been overpaid?
http://princeton.pm.org/   %-- Meister Eckhart

--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/ http://learn.perl.org/first-response




Re: formatting text

2005-11-29 Thread Ing. Branislav Gerzo
Jeff 'japhy' Pinyan [JP], on Tuesday, November 29, 2005 at 09:12
(-0500 (EST)) thoughtfully wrote the following:

 I'd like to know if there is module for following:
JP Yes, Perl6::Form.  It's a Perl 5 implementation of Perl 6's formats.

sometime is better ask, than DIY. Thanks a lot Japhy, this is exactly
what I'm looking for!

Thanks, thanks and again: thanks.

-- 

How do you protect mail on web? I use http://www.2pu.net

[Windows: At least the disks make nice drink coasters]



-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/ http://learn.perl.org/first-response




Re: formatting text

2005-11-29 Thread Ing. Branislav Gerzo
Jeff 'japhy' Pinyan [JP], on Tuesday, November 29, 2005 at 09:12
(-0500 (EST)) wrote the following:

Jeff, Perl6::Form is so powerful. But I can't find how to properly do
this:

I have values:
('Name','Branislav');
('Surname','Gerzo');

And I'd like to print:
|Name: Branislav  |
|Surname.: Gerzo  |
  26.^ 80.^
   
Could you please help me with this one ? Other I need I already got,
but this one seems tricky for me.

Thanks.

-- 

How do you protect mail on web? I use http://www.2pu.net

[I wanna get my kicks now before I go.]


-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/ http://learn.perl.org/first-response




Re: formatting text

2005-11-29 Thread Brano Gerzo
Ing. Branislav Gerzo [IBG], on Tuesday, November 29, 2005 at 17:14
(+0100) wrote:


IBG And I'd like to print:
IBG |Name: Branislav  |
IBG |Surname.: Gerzo  |
IBG   26.^ 80.^

Nothing is tricky, if man want. So:

sub formie {
  print form 
  '|{}: {[[[} 
  |',
  {rfill='.'}, shift,   {rfill=' '},  shift;  
}


-- 

 ...m8s, cu l8r, Brano.

[Don't bother with the shrimp baby, daddy's comin' home with the crabs!]



-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/ http://learn.perl.org/first-response




RE: formatting text

2001-09-19 Thread Najamuddin, Junaid

Hi,

# Define your fields
my($fld1, $fld2, $fld3, $fld4, $fld5, $fld6, $fld7, $fld8);

# load fields in array which are separated by pipe delimit
foreach $val1(@arr1) # referring to values in array
{($fld1, $fld2, $fld3, $fld4, $fld5, $fld6, $fld7, $fld8) =
split(/\|/,$val1);

# Print the selected fields
print  $fld4,  '$fld3'($fld2)\n;

I hope I have answered your question
Take care
junaid

-Original Message-
From: Edward [mailto:[EMAIL PROTECTED]]
Sent: Wednesday, September 19, 2001 11:34 AM
To: [EMAIL PROTECTED]
Subject: formatting text


Hi ,
I'm trying to extract clients with Lost-Carrier as Terminate-Cause from a
raw radius file.
I'm interested in 2 fields. User-name and Terminate Cause.
On running my script. I get a full list of all client User-names. and those
with Termiante-Cause.
Can some one assist me


 One cannot guess the real difficulties of a problem before having solved
it.


-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]




RE: Formatting text

2001-08-28 Thread Gibbs Tanton - tgibbs

 
If you are on a unix system...you can just say diff file1 file2.  On Windows
there is probably something comparable.
-Original Message-
From: Najamuddin, Junaid
To: [EMAIL PROTECTED]
Sent: 8/28/2001 9:18 AM
Subject: Formatting text

Hi,
Here is my script, I am comparing two txt files which are pipe delimited
line by line if they match then their is no output but if they do not
match then it gives an output about the difference 
My both files are loaded in the array and I am comparing line by line
How can I compare a value in a certain field within an array line by
line between two files so that I can have result I want 
instead of comparing whole line
The txt files are attached for your visual ease they are not pipe
delimited and the field names are displayed, In the script they will be
pipe delimited without any field name or header
If you can help me out
thanks
 
 
my($snapshot, $baseline);  # Defining txt files 
 
# First file
$snapshot = ./302-snap.txt; # List of Svcs currently running loc at
c:\perl
 
# Second file
$baseline = ./302-base.txt;  # List of All Svcs which should be
running
 
my(@arr1, @arr2, @result);  # Defining arrays
my($fld1, $fld2, $fld3, $fld4); # Defining variables for fields
my($match, $cnt, $val1, $val2, $finalresult); # Defining scalar
variables
$match = N; 
 
#Open snapshot file and insert every line into @arr1
open(SNAPSHOT, $snapshot) or die Unable to open $snapshot.; # Open the
txt file and place it in filehandle
 
$cnt = 0;
while ( SNAPSHOT ) # Looping thru the filehandle snapshot
 {
 $arr1[$cnt] = $_;
 $cnt = $cnt + 1;
  } 
  close (SNAPSHOT); # close the filehandle snapshot
 
#Open baseline file and insert every line into @arr2
open(BASELINE, $baseline) or die Unable to open $baseline.; # Open the
txt file and place it in filehandle 
 
$cnt = 0;
while ( BASELINE ) # Looping thru the filehandle baseline
{
 $arr2[$cnt] = $_;
 $cnt = $cnt + 1;
  } 
  close (BASELINE); # close filehandle baseline
 
# Outer loop is for baseline file
# Inner loop is for snapshot file
# Taking one element from @arr2 (baseline) and comparing it with all the
elements in @arr1(snapshot) and 
# If their is no match then insert that name into @result.
 
$cnt = 0;
foreach $val2 (@arr2) # referring to baseline
{
 foreach $val1 (@arr1) # referring to snapshot
 {
  if ($val1 eq $val2) 
  {
   $match = Y;
  }
 }
 if  ($match eq N) 
 {
  $result[$cnt] = $val2;
  $cnt = $cnt + 1;
 }
 
 $match = N;
 }
 
$finalresult = 0; # initializing to zero
foreach $val1 (@result)
{
 $finalresult = $finalresult + 1;
}
 
if ($finalresult   0 ) 
{
 print \nList of SICK Siebel-Components \n\n; # If some svc is not
functioning
 foreach $val1 (@result)
 {
  ($fld1,$fld2,$fld3,$fld4) =  split(/\|/,$val1);# separating req
fields for output
  print Svc-Component $fld4, of Siebel-Svc '$fld3'($fld2)\n;
  
 }
}
else
{
 print \nAll Siebel-Components are Functioning Fine\n; # When all svcs
are running fine
}

 
 302-base.txt  302-snap.txt  ATT3705189.txt 

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]




RE: Formatting text

2001-08-28 Thread Najamuddin, Junaid

Sorry I forgot about the platform
It is on Windows NT platform
thanks

-Original Message-
From: Gibbs Tanton - tgibbs [mailto:[EMAIL PROTECTED]]
Sent: Tuesday, August 28, 2001 9:34 AM
To: 'Najamuddin, Junaid '; '[EMAIL PROTECTED] '
Subject: RE: Formatting text


 
If you are on a unix system...you can just say diff file1 file2.  On Windows
there is probably something comparable.
-Original Message-
From: Najamuddin, Junaid
To: [EMAIL PROTECTED]
Sent: 8/28/2001 9:18 AM
Subject: Formatting text

Hi,
Here is my script, I am comparing two txt files which are pipe delimited
line by line if they match then their is no output but if they do not
match then it gives an output about the difference 
My both files are loaded in the array and I am comparing line by line
How can I compare a value in a certain field within an array line by
line between two files so that I can have result I want 
instead of comparing whole line
The txt files are attached for your visual ease they are not pipe
delimited and the field names are displayed, In the script they will be
pipe delimited without any field name or header
If you can help me out
thanks
 
 
my($snapshot, $baseline);  # Defining txt files 
 
# First file
$snapshot = ./302-snap.txt; # List of Svcs currently running loc at
c:\perl
 
# Second file
$baseline = ./302-base.txt;  # List of All Svcs which should be
running
 
my(@arr1, @arr2, @result);  # Defining arrays
my($fld1, $fld2, $fld3, $fld4); # Defining variables for fields
my($match, $cnt, $val1, $val2, $finalresult); # Defining scalar
variables
$match = N; 
 
#Open snapshot file and insert every line into @arr1
open(SNAPSHOT, $snapshot) or die Unable to open $snapshot.; # Open the
txt file and place it in filehandle
 
$cnt = 0;
while ( SNAPSHOT ) # Looping thru the filehandle snapshot
 {
 $arr1[$cnt] = $_;
 $cnt = $cnt + 1;
  } 
  close (SNAPSHOT); # close the filehandle snapshot
 
#Open baseline file and insert every line into @arr2
open(BASELINE, $baseline) or die Unable to open $baseline.; # Open the
txt file and place it in filehandle 
 
$cnt = 0;
while ( BASELINE ) # Looping thru the filehandle baseline
{
 $arr2[$cnt] = $_;
 $cnt = $cnt + 1;
  } 
  close (BASELINE); # close filehandle baseline
 
# Outer loop is for baseline file
# Inner loop is for snapshot file
# Taking one element from @arr2 (baseline) and comparing it with all the
elements in @arr1(snapshot) and 
# If their is no match then insert that name into @result.
 
$cnt = 0;
foreach $val2 (@arr2) # referring to baseline
{
 foreach $val1 (@arr1) # referring to snapshot
 {
  if ($val1 eq $val2) 
  {
   $match = Y;
  }
 }
 if  ($match eq N) 
 {
  $result[$cnt] = $val2;
  $cnt = $cnt + 1;
 }
 
 $match = N;
 }
 
$finalresult = 0; # initializing to zero
foreach $val1 (@result)
{
 $finalresult = $finalresult + 1;
}
 
if ($finalresult   0 ) 
{
 print \nList of SICK Siebel-Components \n\n; # If some svc is not
functioning
 foreach $val1 (@result)
 {
  ($fld1,$fld2,$fld3,$fld4) =  split(/\|/,$val1);# separating req
fields for output
  print Svc-Component $fld4, of Siebel-Svc '$fld3'($fld2)\n;
  
 }
}
else
{
 print \nAll Siebel-Components are Functioning Fine\n; # When all svcs
are running fine
}

 
 302-base.txt  302-snap.txt  ATT3705189.txt 

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]




RE: Formatting text

2001-08-28 Thread Mike Rapuano

HI all -- 

I was searching for a diff-like perl tool for NT and came accross this
persons code. Worked well for me.

Mike


-Original Message-
From: Gibbs Tanton - tgibbs [mailto:[EMAIL PROTECTED]]
Sent: Tuesday, August 28, 2001 10:34 AM
To: 'Najamuddin, Junaid '; '[EMAIL PROTECTED] '
Subject: RE: Formatting text


 
If you are on a unix system...you can just say diff file1 file2.  On
Windows
there is probably something comparable.
-Original Message-
From: Najamuddin, Junaid
To: [EMAIL PROTECTED]
Sent: 8/28/2001 9:18 AM
Subject: Formatting text

Hi,
Here is my script, I am comparing two txt files which are pipe delimited
line by line if they match then their is no output but if they do not
match then it gives an output about the difference 
My both files are loaded in the array and I am comparing line by line
How can I compare a value in a certain field within an array line by
line between two files so that I can have result I want 
instead of comparing whole line
The txt files are attached for your visual ease they are not pipe
delimited and the field names are displayed, In the script they will be
pipe delimited without any field name or header
If you can help me out
thanks
 
 
my($snapshot, $baseline);  # Defining txt files 
 
# First file
$snapshot = ./302-snap.txt; # List of Svcs currently running loc at
c:\perl
 
# Second file
$baseline = ./302-base.txt;  # List of All Svcs which should be
running
 
my(@arr1, @arr2, @result);  # Defining arrays
my($fld1, $fld2, $fld3, $fld4); # Defining variables for fields
my($match, $cnt, $val1, $val2, $finalresult); # Defining scalar
variables
$match = N; 
 
#Open snapshot file and insert every line into @arr1
open(SNAPSHOT, $snapshot) or die Unable to open $snapshot.; # Open the
txt file and place it in filehandle
 
$cnt = 0;
while ( SNAPSHOT ) # Looping thru the filehandle snapshot
 {
 $arr1[$cnt] = $_;
 $cnt = $cnt + 1;
  } 
  close (SNAPSHOT); # close the filehandle snapshot
 
#Open baseline file and insert every line into @arr2
open(BASELINE, $baseline) or die Unable to open $baseline.; # Open the
txt file and place it in filehandle 
 
$cnt = 0;
while ( BASELINE ) # Looping thru the filehandle baseline
{
 $arr2[$cnt] = $_;
 $cnt = $cnt + 1;
  } 
  close (BASELINE); # close filehandle baseline
 
# Outer loop is for baseline file
# Inner loop is for snapshot file
# Taking one element from @arr2 (baseline) and comparing it with all the
elements in @arr1(snapshot) and 
# If their is no match then insert that name into @result.
 
$cnt = 0;
foreach $val2 (@arr2) # referring to baseline
{
 foreach $val1 (@arr1) # referring to snapshot
 {
  if ($val1 eq $val2) 
  {
   $match = Y;
  }
 }
 if  ($match eq N) 
 {
  $result[$cnt] = $val2;
  $cnt = $cnt + 1;
 }
 
 $match = N;
 }
 
$finalresult = 0; # initializing to zero
foreach $val1 (@result)
{
 $finalresult = $finalresult + 1;
}
 
if ($finalresult   0 ) 
{
 print \nList of SICK Siebel-Components \n\n; # If some svc is not
functioning
 foreach $val1 (@result)
 {
  ($fld1,$fld2,$fld3,$fld4) =  split(/\|/,$val1);# separating req
fields for output
  print Svc-Component $fld4, of Siebel-Svc '$fld3'($fld2)\n;
  
 }
}
else
{
 print \nAll Siebel-Components are Functioning Fine\n; # When all svcs
are running fine
}

 
 302-base.txt  302-snap.txt  ATT3705189.txt 

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]


 cdiff.pl

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]


Re: Formatting text

2001-08-28 Thread Aravindan . Sundaram


Hope you have a file which contains these lines,

Just check below code :

$File = sample.txt;

open(IN,$File);

while(IN)
{
 $_ =~ s/\x0d//g;

 if( $_ =~ m/play/i )
 {
  $Result = ;
  while( $_ =~ /.{0,5}play.{0,5}/i  )
  {
   $Result .= $`;
   $Temp = $;
   $_ = $';

   print $Temp.\n;

   $Result .= $Temp;
  }
  $Result .= $_;
  $_ = $Result;
 }
}
close(IN);

bye
aravind
System Executive
eFunds International India Pvt. Ltd.
8272628, Ext. 4593


  1. What should I do , if I want to read each line
 of
  text with the search word. Should I put the
  occurence of search word in an array ? (I'm not so
  sure).

  2. If I want to read the string, provided only a
  certain length (for e.g., 5 words to the LEFT of
  search word  5 words to the RIGHT of search
  word). Is there a range to declare but how to
 detect
  the starting point and end point for each
 occurence?




This  electronic  mail  message is intended solely for the named recipients
and may contain confidential and proprietary business information of eFunds
Corporation  and  all its subsidiaries.   If you are not a named recipient,
please notify the sender immediately.  You may not disclose the contents to
any  other person; use this electronic mail message or its contents for any
other purpose; or further store or copy its contents in any medium.



-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]




Re: Formatting text

2001-08-28 Thread Randal L. Schwartz

 Mike == Mike Rapuano [EMAIL PROTECTED] writes:

Mike I was searching for a diff-like perl tool for NT and came
Mike accross this persons code. Worked well for me.

You might look at Algorithm::Diff, and especially the magazine column
I wrote on that.  The advantage over the [snipped] code is that it
finds the best fit, not just a sequential match that can get lost.

See http://www.stonehenge.com/merlyn/UnixReview/col35.html.

-- 
Randal L. Schwartz - Stonehenge Consulting Services, Inc. - +1 503 777 0095
[EMAIL PROTECTED] URL:http://www.stonehenge.com/merlyn/
Perl/Unix/security consulting, Technical writing, Comedy, etc. etc.
See PerlTraining.Stonehenge.com for onsite and open-enrollment Perl training!

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]




RE: Formatting text

2001-08-24 Thread Najamuddin, Junaid
Title: RE: Formatting text



Thanks
Attached is a text file which needs 
formatting
It has records withfields defined, but has some 
records repeated
I want to format this file and out put to another one 
with fields of my choice and only one instance of each 
record
Thanks 

  -Original Message-From: Wagner-David 
  [mailto:[EMAIL PROTECTED]]Sent: Friday, August 24, 
  2001 11:42 AMTo: 'Najamuddin, Junaid'Subject: RE: 
  Formatting text
   I am unsure what 
  you are really after. If you provided some input, code snippet, etc so 
  the list can see. Along with how do you determine which columns are to 
  be bypassed, then you might get a response.
   At this point, it 
  is very vague for most to do something with. 
  Wags ;) 
  -Original Message- From: 
  Najamuddin, Junaid [mailto:[EMAIL PROTECTED]] 
  Sent: Friday, August 24, 2001 09:06 To: '[EMAIL PROTECTED]' Subject: Formatting 
  text 
  Thanks in advance How can we read a 
  log text file which has columns and rows. The file has 
  ten columns defined by a header/field name What i want 
  is to out put into another text file but only the desired columns not all of them Some lines/records have 
  duplicates so after this I want to sort them so that a 
  record/line only apprears once can someone help me 
  please. Oh, I am in NT environment Thanks again 
   
  -- To unsubscribe, e-mail: 
  [EMAIL PROTECTED] For additional 
  commands, e-mail: [EMAIL PROTECTED] 

SBLSRVR_NAME  SVC_NAME   COMP_NAME  SVC_COMP   TASK_NUM  TASK_PID  SVC_MODE  
TASK_STATE  START_TIME   END_TIME TASK_STATUS  

  -  -  -        
--  ---  ---  
--
   
S2_NXLKPRDServerMgr  ServerMgr  ServerMgr  47148 881   Session   
NotRunning  08/23/2001 11:14:25   Processing List Tasks command  

S2_NXLKPRDSynchMgr   SynchMgr   SynchMgr   47147   Session   Completed 
  08/23/2001 11:14:09  08/23/2001 11:14:09  COMPLETED : Wrote 0 Kbytes, read 0 Kbytes, 
sent 0 msgs, rcvd 0 msgs  
S2_NXLKPRDSynchMgr   SynchMgr   SynchMgr   47146   Session   Completed 
  08/23/2001 11:13:09  08/23/2001 11:13:09  COMPLETED : Wrote 0 Kbytes, read 0 Kbytes, 
sent 0 msgs, rcvd 0 msgs  
S2_NXLKPRDSynchMgr   SynchMgr   SynchMgr   47145   Session   Completed 
  08/23/2001 11:12:09  08/23/2001 11:12:09  COMPLETED : Wrote 0 Kbytes, read 0 Kbytes, 
sent 0 msgs, rcvd 0 msgs  
S2_NXLKPRDSynchMgr   SynchMgr   SynchMgr   47144   Session   Completed 
  08/23/2001 11:11:09  08/23/2001 11:11:09  COMPLETED : Wrote 0 Kbytes, read 0 Kbytes, 
sent 0 msgs, rcvd 0 msgs  
S2_NXLKPRDSynchMgr   SynchMgr   SynchMgr   47143   Session   Completed 
  08/23/2001 11:10:09  08/23/2001 11:10:09  COMPLETED : Wrote 0 Kbytes, read 0 Kbytes, 
sent 0 msgs, rcvd 0 msgs  
S2_NXLKPRDSynchMgr   SynchMgr   SynchMgr   47142   Session   Completed 
  08/23/2001 11:09:08  08/23/2001 11:09:09  COMPLETED : Wrote 0 Kbytes, read 0 Kbytes, 
sent 0 msgs, rcvd 0 msgs  
S2_NXLKPRDSynchMgr   SynchMgr   SynchMgr   47141   Session   Completed 
  08/23/2001 11:08:08  08/23/2001 11:08:08  COMPLETED : Wrote 0 Kbytes, read 0 Kbytes, 
sent 0 msgs, rcvd 0 msgs  
S2_NXLKPRDSynchMgr   SynchMgr   SynchMgr   47140   Session   Completed 
  08/23/2001 11:07:08  08/23/2001 11:07:08  COMPLETED : Wrote 0 Kbytes, read 0 Kbytes, 
sent 0 msgs, rcvd 0 msgs  
S2_NXLKPRDServerMgr  ServerMgr  ServerMgr  47139 753   Session   Running   
  08/23/2001 11:06:27   Waiting for command
  
S2_NXLKPRDSynchMgr   SynchMgr   SynchMgr   47138   Session   Completed 
  08/23/2001 11:06:08  08/23/2001 11:06:08  COMPLETED : Wrote 0 Kbytes, read 0 Kbytes, 
sent 0 msgs, rcvd 0 msgs  
S2_NXLKPRDSynchMgr   SynchMgr   SynchMgr   47137   Session   Completed 
  08/23/2001 11:05:08  08/23/2001 11:05:08  COMPLETED : Wrote 0 Kbytes, read 0 Kbytes, 
sent 0 msgs, rcvd 0 msgs  
S2_NXLKPRDSynchMgr   SynchMgr   SynchMgr   47136   Session   Completed 
  08/23/2001 11:04:08  08/23/2001 11:04:08  COMPLETED : Wrote 0 Kbytes, read 0 Kbytes, 
sent 0 msgs, rcvd 0 msgs  
S2_NXLKPRDSynchMgr   SynchMgr   SynchMgr   47135   Session   Completed 
  08/23/2001 11:03:08  08/23/2001 11:03:08

RE: Formatting text

2001-08-24 Thread Wagner-David

What is the key that you desire to use? Task_Num? or ??? Also how are you going to 
select the fields? I see no code snippet, so does this mean you have nothing at this 
point and are trying to get started?
 
Wags ;)

-Original Message-
From: Najamuddin, Junaid [mailto:[EMAIL PROTECTED]]
Sent: Friday, August 24, 2001 09:47
To: Wagner-David
Cc: '[EMAIL PROTECTED]'
Subject: RE: Formatting text


Thanks
Attached is a text file which needs formatting
It has records with fields defined, but has some records repeated
I want to format this file and out put to another one with fields of my choice and 
only one instance of each record
Thanks 

-Original Message-
From: Wagner-David [mailto:[EMAIL PROTECTED]]
Sent: Friday, August 24, 2001 11:42 AM
To: 'Najamuddin, Junaid'
Subject: RE: Formatting text



I am unsure what you are really after.  If you provided some input, code 
snippet, etc so the list can see.  Along with how do you determine which columns are 
to be bypassed, then you might get a response.

At this point, it is very vague for most to do something with. 

Wags ;) 

-Original Message- 
From: Najamuddin, Junaid [ mailto:[EMAIL PROTECTED] 
mailto:[EMAIL PROTECTED] ] 
Sent: Friday, August 24, 2001 09:06 
To: '[EMAIL PROTECTED]' 
Subject: Formatting text 


Thanks in advance 
How can we read a log text file which has columns and rows. 
The file has ten columns defined by a header/field name 
What i want is to out put into another text file but only the desired 
columns not all of them 
Some lines/records have duplicates so after this 
I want to sort them so that a record/line only apprears once 
can someone help me please. 
Oh, I am in NT environment 
Thanks again 

  


-- 
To unsubscribe, e-mail: [EMAIL PROTECTED] 
For additional commands, e-mail: [EMAIL PROTECTED] 




RE: Formatting text

2001-08-24 Thread pconnolly

This is going off of two assumptions, 1) that you want the task number to be
unique and 2) the fields are supposed to be tab delimited. If you want to
remove the dups from a different column then make that column as the key to
the hash. As for which fields, you can add and remove any column from the
value of the hash. Hope this helps.
 
 
open FILE, file;
open OUT, outfile;
while (FILE) {
  chomp;
  next if /^SBLSRVR_NAME/; # ignore the first line.
  next if /^/; # ignore the second line.
  split /\t/,; # split each line and put it into @_.
  $hash{$_[4]} = qq[@_[4]\t@_[5]\t@_[8]\t@_[9]\t@_[10]]; # Assign parts of
@_ to %hash.
}
 
print OUT qq[$hash{$_}\n], for sort keys %hash; # Print your hash to the
outfile.
 

Patrick J Connolly 
 

 -Original Message-
From: Najamuddin, Junaid [mailto:[EMAIL PROTECTED]]
Sent: Friday, August 24, 2001 11:47 AM
To: 'Wagner-David'
Cc: '[EMAIL PROTECTED]'
Subject: RE: Formatting text



Thanks
Attached is a text file which needs formatting
It has records with fields defined, but has some records repeated
I want to format this file and out put to another one with fields of my
choice and only one instance of each record
Thanks 

-Original Message-
From: Wagner-David [mailto:[EMAIL PROTECTED]]
Sent: Friday, August 24, 2001 11:42 AM
To: 'Najamuddin, Junaid'
Subject: RE: Formatting text



I am unsure what you are really after.  If you provided some input,
code snippet, etc so the list can see.  Along with how do you determine
which columns are to be bypassed, then you might get a response.

At this point, it is very vague for most to do something with. 

Wags ;) 

-Original Message- 
From: Najamuddin, Junaid [ mailto:[EMAIL PROTECTED]
mailto:[EMAIL PROTECTED] ] 
Sent: Friday, August 24, 2001 09:06 
To: '[EMAIL PROTECTED]' 
Subject: Formatting text 


Thanks in advance 
How can we read a log text file which has columns and rows. 
The file has ten columns defined by a header/field name 
What i want is to out put into another text file but only the desired 
columns not all of them 
Some lines/records have duplicates so after this 
I want to sort them so that a record/line only apprears once 
can someone help me please. 
Oh, I am in NT environment 
Thanks again 

  


-- 
To unsubscribe, e-mail: [EMAIL PROTECTED] 
For additional commands, e-mail: [EMAIL PROTECTED] 




RE: Formatting text

2001-08-24 Thread Curtis Poe

--- [EMAIL PROTECTED] wrote:
 This is going off of two assumptions, 1) that you want the task number to be
 unique and 2) the fields are supposed to be tab delimited. If you want to
 remove the dups from a different column then make that column as the key to
 the hash. As for which fields, you can add and remove any column from the
 value of the hash. Hope this helps.
  
  
 open FILE, file;
 open OUT, outfile;

Without really checking out the rest of the code, I see a problem here.

What happens if 'file' or 'outfile' don't exist?  This code will silently fail and 
tracking down
the bug could be a pain if this is embedded in a large system.  This is such a common 
problem that
use strict 'system' is being considered for Perl 6.  With this, the script would 
automatically
die if someone forgets to check the return value of a system call.  The above code is 
better
written as:

open FILE, $file or die Can't open $file for reading: $!;
open OUT,  $outfile or die Can't open $outfile for writing: $!;

I know, I know, I can hear the protests already:  but Ovid, you're just being 
anal-retentive. 
This programmer *knows* the files are there.

That's a frequent rebuttal, but if you work with Perl for any length of time, you're 
likely to
have many programs just lying around.  I've repeatedly seen people get bitten by this 
when they
reorganize directories, migrate their scripts to new boxes, or simply get rid of 
'unnecessary'
files to save some disk space.  It takes so little work up from to save so much pain 
later.

Cheers,
Curtis Poe

=
Senior Programmer
Onsite! Technology (http://www.onsitetech.com/)
Ovid on http://www.perlmonks.org/

__
Do You Yahoo!?
Make international calls for as low as $.04/minute with Yahoo! Messenger
http://phonecard.yahoo.com/

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]




Re: Formatting text

2001-08-24 Thread Michael Fowler

On Fri, Aug 24, 2001 at 12:23:17PM -0700, Curtis Poe wrote:
 --- [EMAIL PROTECTED] wrote:
 This is such a common problem that use strict 'system' is being
 considered for Perl 6.

Hm, I don't remember any discussion on that one, but perhaps I missed
something.

Regardless, you don't need to wait until Perl 6 for similar functionality. 
Perl has as standard, since at least Perl 5.005, the Fatal module.

use Fatal qw(:void open);
open(FILE, /etc/passwd);

*KABOOM*

Or, you can use it to do your checking for you (the above only does a check
if open is called in void context):

use Fatal qw(open);
open(FILE, /etc/passwd);

*KABOOM* 


Granted, it's not as simple as use strict 'system', but you can pretty
easily write a pragma or module to effectively do that for you.  You could
even patch strict.pm to do it, just don't expect it to get adopted into core
(strict's stricture are frozen, AFAIK).


Michael
--
Administrator  www.shoebox.net
Programmer, System Administrator   www.gallanttech.com
--

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]




Re: Formatting text

2001-08-24 Thread Curtis Poe

--- Michael Fowler [EMAIL PROTECTED] wrote:
 On Fri, Aug 24, 2001 at 12:23:17PM -0700, Curtis Poe wrote:
  --- [EMAIL PROTECTED] wrote:
  This is such a common problem that use strict 'system' is being
  considered for Perl 6.
 
 Hm, I don't remember any discussion on that one, but perhaps I missed
 something.

I don't know how widely that was discussed.  Damian Conway was here in Portland a 
couple of weeks
ago giving a prospectus on Perl 6 and that was one of the issues he mentioned.

Cheers,
Curtis Poe

=
Senior Programmer
Onsite! Technology (http://www.onsitetech.com/)
Ovid on http://www.perlmonks.org/

__
Do You Yahoo!?
Make international calls for as low as $.04/minute with Yahoo! Messenger
http://phonecard.yahoo.com/

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]