String Formatting by Column
String Formatting by Column
am 24.06.2011 09:45:38 von Wernher Eksteen
--00151750d9ca3b4c3f04a67063ab
Content-Type: multipart/alternative; boundary=00151750d9ca3b4c3604a67063a9
--00151750d9ca3b4c3604a67063a9
Content-Type: text/plain; charset=ISO-8859-1
Hi,
I've attached a text file containing the original and required format and
avoid the format
being lost by just pasting it in the email body.
The original format is separated by a space, but need to replace the space
with a comma,
so it will become a comma delimited csv file which I will then import to MS
Excel.
I'm not sure how to parse the "Connection" and "Sync'ed-as-of-time" columns
since the dates
there in is in this format "Fri Jun 24 06:37" which also separated by space,
but the spaces in
those columns shouldn't be replaced by a comma. The date format in those
columns should
remain the same.
Also, is it possible to convert this directly into a MS Excel document using
Perl?
Many thanks!
Regards,
Wernher
--00151750d9ca3b4c3604a67063a9
Content-Type: text/html; charset=ISO-8859-1
Content-Transfer-Encoding: quoted-printable
Hi,
I've attached a text file containing the original and requir=
ed format and avoid the format
being lost by just pasting it in the emai=
l body.
The original format is separated by a space, but need to rep=
lace the space with a comma,
so it will become a comma delimited csv file which I will then import to MS=
Excel.
I'm not sure how to parse the "Connection" and=
"Sync'ed-as-of-time" columns since the dates
there in is=
in this format "Fri Jun 24 06:37" which also separated by space,=
but the spaces in
those columns shouldn't be replaced by a comma. The date format in thos=
e columns should
remain the same.
Also, is it possible to conver=
t this directly into a MS Excel document using Perl?
Many thanks!
>
Regards,
Wernher
--00151750d9ca3b4c3604a67063a9--
--00151750d9ca3b4c3f04a67063ab
Content-Type: text/plain; charset=US-ASCII; name="string-column-formatting.txt"
Content-Disposition: attachment; filename="string-column-formatting.txt"
Content-Transfer-Encoding: base64
X-Attachment-Id: f_gpau4izr0
T3JpZ2luYWwgRm9ybWF0DQo9PT09PT09PT09PT09PT0NCg0KQ1RYICAgRGVz dGluYXRpb24gICAg
ICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAg ICAgICAgICAgICAg
RW5hYmxlZCAgIENvbm5lY3Rpb24gICAgICAgIC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LS0tLC0tLS0tLS0tLS0t LS0tLS0tLQ==
--00151750d9ca3b4c3f04a67063ab
Content-Type: text/plain; charset=us-ascii
--
To unsubscribe, e-mail: beginners-unsubscribe@perl.org
For additional commands, e-mail: beginners-help@perl.org
http://learn.perl.org/
--00151750d9ca3b4c3f04a67063ab--
Re: String Formatting by Column
am 24.06.2011 10:19:24 von dermot
On 24 June 2011 08:45, Wernher Eksteen wrote:
> Hi,
>
> I've attached a text file containing the original and required format and
> avoid the format
> being lost by just pasting it in the email body.
>
> The original format is separated by a space, but need to replace the space
> with a comma,
> so it will become a comma delimited csv file which I will then import to MS
> Excel.
>
> I'm not sure how to parse the "Connection" and "Sync'ed-as-of-time" columns
> since the dates
> there in is in this format "Fri Jun 24 06:37" which also separated by space,
> but the spaces in
> those columns shouldn't be replaced by a comma. The date format in those
> columns should
> remain the same.
>
> Also, is it possible to convert this directly into a MS Excel document using
> Perl?
Yes, you can achieve all your goals with perl. Have a look and
Text::CSV_XS[1] or Text::CSV[2]. They will read the file correctly and
write the file out for you with any separator you want. BTW, you want
quotes around each field so as not to confuse you spreadsheet program.
Writing the file into XLS format would require another module but I'll
leave others to make that recommendation.
Perhaps you could have a look at those, try and write something and
when, or if, you get stuck, come back to the list showing the code
you've got and get some pointers.
Thanks,
Dermot.
1) http://search.cpan.org/~hmbrand/Text-CSV_XS-0.82/CSV_XS.pm
2) http://search.cpan.org/~makamaka/Text-CSV-1.21/lib/Text/CSV. pm
--
To unsubscribe, e-mail: beginners-unsubscribe@perl.org
For additional commands, e-mail: beginners-help@perl.org
http://learn.perl.org/
Re: String Formatting by Column
am 24.06.2011 10:53:38 von Wernher Eksteen
--000e0cd2c2466ca00604a6715608
Content-Type: text/plain; charset=ISO-8859-1
Hi,
Thanks for the tip, will try to figure it out on the weekend and come back
if I'm
stuck.
Just a few questions before I try this...
Does these modules have the ability to add the commas in the way I need them
to be?
The CVS_XS.pm module seems more flexible/powerful than the CVS.pm one
or am I wrong?
Regards,
Wernher
On 24 June 2011 10:19, Dermot wrote:
> On 24 June 2011 08:45, Wernher Eksteen wrote:
> > Hi,
> >
> > I've attached a text file containing the original and required format and
> > avoid the format
> > being lost by just pasting it in the email body.
> >
> > The original format is separated by a space, but need to replace the
> space
> > with a comma,
> > so it will become a comma delimited csv file which I will then import to
> MS
> > Excel.
> >
> > I'm not sure how to parse the "Connection" and "Sync'ed-as-of-time"
> columns
> > since the dates
> > there in is in this format "Fri Jun 24 06:37" which also separated by
> space,
> > but the spaces in
> > those columns shouldn't be replaced by a comma. The date format in those
> > columns should
> > remain the same.
> >
> > Also, is it possible to convert this directly into a MS Excel document
> using
> > Perl?
>
> Yes, you can achieve all your goals with perl. Have a look and
> Text::CSV_XS[1] or Text::CSV[2]. They will read the file correctly and
> write the file out for you with any separator you want. BTW, you want
> quotes around each field so as not to confuse you spreadsheet program.
> Writing the file into XLS format would require another module but I'll
> leave others to make that recommendation.
>
> Perhaps you could have a look at those, try and write something and
> when, or if, you get stuck, come back to the list showing the code
> you've got and get some pointers.
>
> Thanks,
> Dermot.
>
>
> 1) http://search.cpan.org/~hmbrand/Text-CSV_XS-0.82/CSV_XS.pm
> 2) http://search.cpan.org/~makamaka/Text-CSV-1.21/lib/Text/CSV. pm
>
> --
> To unsubscribe, e-mail: beginners-unsubscribe@perl.org
> For additional commands, e-mail: beginners-help@perl.org
> http://learn.perl.org/
>
>
>
--000e0cd2c2466ca00604a6715608--
Re: String Formatting by Column
am 24.06.2011 11:19:31 von dermot
On 24 June 2011 09:53, Wernher Eksteen wrote:
> Hi,
>
> Thanks for the tip, will try to figure it out on the weekend and come back
> if I'm
> stuck.
>
> Just a few questions before I try this...
>
> Does these modules have the ability to add the commas in the way I need them
> to be?
Yes. When you construct a new Text::CSV_XS object, set the sep_char to
the tab character so that when you read the file in, each value from
each column is stored correctly. They reset sep_char to ',' when you
want to send the output to a file.
> The CVS_XS.pm module seems more flexible/powerful than the CVS.pm one
> or am I wrong?
>
The _XS means that this module uses C code under the bonnet so it runs
really fast. If you are on a *nix based PC and have all the necessary
libraries and a compiler this is probably a better option. It's the
one I generally use. This module also has a _PP (pure perl) version[1]
in case you do not have a compiler on your PC.
1) http://search.cpan.org/perldoc?Text%3A%3ACSV_PP
HTH,
Dermot.
--
To unsubscribe, e-mail: beginners-unsubscribe@perl.org
For additional commands, e-mail: beginners-help@perl.org
http://learn.perl.org/
Re: String Formatting by Column
am 24.06.2011 16:47:10 von Jim Gibson
At 9:45 AM +0200 6/24/11, Wernher Eksteen wrote:
>Hi,
>
>I've attached a text file containing the original and required
>format and avoid the format
>being lost by just pasting it in the email body.
>
>The original format is separated by a space, but need to replace the
>space with a comma,
>so it will become a comma delimited csv file which I will then
>import to MS Excel.
>
>I'm not sure how to parse the "Connection" and "Sync'ed-as-of-time"
>columns since the dates
>there in is in this format "Fri Jun 24 06:37" which also separated
>by space, but the spaces in
>those columns shouldn't be replaced by a comma. The date format in
>those columns should
>remain the same.
Since your columns are fixed-width, you can use the unpack function
to unpack the lines into individual fields. You could also use a
series of substr calls, but unpack would be less code.
See 'perldoc -f unpack' for details, and 'perldoc -f pack' for
template elements describing your data columns.
>
>Also, is it possible to convert this directly into a MS Excel
>document using Perl?
Not directly, but once you have the lines unpacked, you can use the
Spreadsheet::WriteExcel module to create a spreadsheet and populate
it with your data.
--
To unsubscribe, e-mail: beginners-unsubscribe@perl.org
For additional commands, e-mail: beginners-help@perl.org
http://learn.perl.org/
Re: String Formatting by Column
am 25.06.2011 15:52:55 von Rob Dixon
On 24/06/2011 08:45, Wernher Eksteen wrote:
> Hi,
>
> I've attached a text file containing the original and required
> format and avoid the format being lost by just pasting it in the
> email body.
>
> The original format is separated by a space, but need to replace the
> space with a comma, so it will become a comma delimited csv file
> which I will then import to MS Excel.
>
> I'm not sure how to parse the "Connection" and "Sync'ed-as-of-time"
> columns since the dates there in is in this format "Fri Jun 24 06:37"
> which also separated by space, but the spaces in those columns
> shouldn't be replaced by a comma. The date format in those columns
> should remain the same.
>
> Also, is it possible to convert this directly into a MS Excel document
> using Perl?
Hey Wernher
Your data appears to have three or more spaces separating the data
fields, whereas there is never more than a single space within the data.
If that is always the case, and there are never any blank fields, we can
use it to split the line into fields.
Take a look at the program below.
HTH,
Rob
use strict;
use warnings;
while (my $record = ) {
chomp $record;
my @fields = split /[ ]{3,}/, $record;
print join ',', @fields;
print "\n";
}
__DATA__
CTX Destination Enabled Connection Sync'ed-as-of-time
--- ------------------------------------------------------------ --------- ------- ---------------- ------------------
1 pool://ZABRYDD01.localdomain/RDP_NEW_REP yes Sat Jun 18 08:56 Fri Jun 24 06:37
2 dir://ZARDPDD01.localdomain/backup/ZABRYDD01REP/linux/backup /test101 yes Sat Jun 18 08:57 Fri Jun 24 08:01
4 dir://ZARDPDD01.localdomain/backup/ZABRYDD01REP/linux/backup /test22 yes Sat Jun 18 08:57 Fri Jun 24 09:00
5 pool://ZARDPDD01.localdomain/BRYREP yes Sat Jun 18 08:57 Fri Jun 24 07:01
8 dir://ZARDPDD01.localdomain/backup/ZABRYDD01REP/linux/backup /test31 yes Sat Jun 18 08:57 Fri Jun 24 09:00
10 dir://ZARDPDD01.localdomain/backup/ZABRYDD01REP/linux/backup /test421 yes Sat Jun 18 08:57 Fri Jun 24 09:00
12 dir://ZARDPDD01.localdomain/backup/ZABRYDD01REP/linux/backup /test5 yes Sat Jun 18 08:57 Fri Jun 24 09:00
13 dir://ZARDPDD01.localdomain/backup/ZABRYDD01REP/linux/backup /test60 yes Sat Jun 18 08:57 Fri Jun 24 09:00
--- ------------------------------------------------------------ --------- ------- ---------------- ------------------
**OUTPUT**
CTX,Destination,Enabled,Connection,Sync'ed-as-of-time
---,-------------------------------------------------------- -------------,-------,----------------,------------------
1,pool://ZABRYDD01.localdomain/RDP_NEW_REP,yes,Sat Jun 18 08:56,Fri Jun 24 06:37
2,dir://ZARDPDD01.localdomain/backup/ZABRYDD01REP/linux/back up/test101,yes,Sat Jun 18 08:57,Fri Jun 24 08:01
4,dir://ZARDPDD01.localdomain/backup/ZABRYDD01REP/linux/back up/test22,yes,Sat Jun 18 08:57,Fri Jun 24 09:00
5,pool://ZARDPDD01.localdomain/BRYREP,yes,Sat Jun 18 08:57,Fri Jun 24 07:01
8,dir://ZARDPDD01.localdomain/backup/ZABRYDD01REP/linux/back up/test31,yes,Sat Jun 18 08:57,Fri Jun 24 09:00
10,dir://ZARDPDD01.localdomain/backup/ZABRYDD01REP/linux/bac kup/test421,yes,Sat Jun 18 08:57,Fri Jun 24 09:00
12,dir://ZARDPDD01.localdomain/backup/ZABRYDD01REP/linux/bac kup/test5,yes,Sat Jun 18 08:57,Fri Jun 24 09:00
13,dir://ZARDPDD01.localdomain/backup/ZABRYDD01REP/linux/bac kup/test60,yes,Sat Jun 18 08:57,Fri Jun 24 09:00
---,-------------------------------------------------------- -------------,-------,----------------,------------------
--
To unsubscribe, e-mail: beginners-unsubscribe@perl.org
For additional commands, e-mail: beginners-help@perl.org
http://learn.perl.org/
Re: String Formatting by Column
am 25.06.2011 19:02:29 von Rob Dixon
On 24/06/2011 08:45, Wernher Eksteen wrote:
>
> I've attached a text file containing the original and required
> format and avoid the format being lost by just pasting it in the
> email body.
>
> The original format is separated by a space, but need to replace the
> space with a comma, so it will become a comma delimited csv file
> which I will then import to MS Excel.
>
> I'm not sure how to parse the "Connection" and "Sync'ed-as-of-time"
> columns since the dates there in is in this format "Fri Jun 24
> 06:37" which also separated by space, but the spaces in those
> columns shouldn't be replaced by a comma. The date format in those
> columns should remain the same.
>
> Also, is it possible to convert this directly into a MS Excel
> document using Perl?
Hello again Wernher.
My first guess for this problem was to build an 'unpack' format based on
the row of hyphens beneath the header captions. As it may still be
useful, and well worth studying for similar applications, here is my
alternative solution doing just that.
The program grabs everything in the file that is aligned with the row
of hyphens beneath the captions. It works by finding the first line in
the file that contains only hyphens or spaces, and scanning that to
build an unpack string using the @- and @+ arrays that hold the offsets
of the start and end of the previous successful regex match.
Unlike my previous solution, empty (all-space) fields are handled
correctly: the 'A' unpack format discards trailing spaces, and my only
proviso is that if you ever expect leading spaces in fields they must be
trimmed explicitly.
HTH,
Rob
use strict;
use warnings;
use Fcntl 'SEEK_SET';
my $format;
my $fh = *DATA; # Replace with the appropriate 'open my $fh, '<', ... or die $!;
# Remember the where the file begins, and then build the unpack pattern from
# the first line continaining only hyphens and underscores
#
my $bof = tell $fh;
while () {
chomp;
if (tr/- //c == 0 and tr/-// > 0) {
while (/-+/g) {
my ($beg, $len) = ($-[0], $+[0] - $-[0]);
$format .= "\@$beg A$len ";
}
last;
}
}
warn qq(Data will be upacked with a format of "$format"\n\n);
# Now rewind to the beginning of the file, ignore anything that contains only
# whitespace, and unpack every record according to the pattern that we just built
#
seek $fh, $bof, SEEK_SET;
while (<$fh>) {
next unless /\S/;
my @data = unpack $format;
print join ',', @data;
print "\n";
}
__DATA__
CTX Destination Enabled Connection Sync'ed-as-of-time
--- ------------------------------------------------------------ --------- ------- ---------------- ------------------
1 pool://ZABRYDD01.localdomain/RDP_NEW_REP yes Sat Jun 18 08:56 Fri Jun 24 06:37
2 dir://ZARDPDD01.localdomain/backup/ZABRYDD01REP/linux/backup /test101 yes Sat Jun 18 08:57 Fri Jun 24 08:01
4 dir://ZARDPDD01.localdomain/backup/ZABRYDD01REP/linux/backup /test22 yes Sat Jun 18 08:57 Fri Jun 24 09:00
5 pool://ZARDPDD01.localdomain/BRYREP yes Sat Jun 18 08:57 Fri Jun 24 07:01
8 dir://ZARDPDD01.localdomain/backup/ZABRYDD01REP/linux/backup /test31 yes Sat Jun 18 08:57 Fri Jun 24 09:00
10 dir://ZARDPDD01.localdomain/backup/ZABRYDD01REP/linux/backup /test421 yes Sat Jun 18 08:57 Fri Jun 24 09:00
12 dir://ZARDPDD01.localdomain/backup/ZABRYDD01REP/linux/backup /test5 yes Sat Jun 18 08:57 Fri Jun 24 09:00
13 dir://ZARDPDD01.localdomain/backup/ZABRYDD01REP/linux/backup /test60 yes Sat Jun 18 08:57 Fri Jun 24 09:00
--- ------------------------------------------------------------ --------- ------- ---------------- ------------------
**OUTPUT**
Data will be upacked with a format of "@0 A3 @6 A69 @78 A7 @88 A16 @107 A18 "
"CTX","Destination","Enabled","Connection","Sync'ed-as-of-ti me"
"---","----------------------------------------------------- ----------------","-------","----------------","------------ ------"
"1","pool://ZABRYDD01.localdomain/RDP_NEW_REP","","Sat Jun 18 08:56","Fri Jun 24 06:37"
"2","dir://ZARDPDD01.localdomain/backup/ZABRYDD01REP/linux/b ackup/test101","yes","Sat Jun 18 08:57","Fri Jun 24 08:01"
"4","dir://ZARDPDD01.localdomain/backup/ZABRYDD01REP/linux/b ackup/test22","yes","Sat Jun 18 08:57","Fri Jun 24 09:00"
"5","pool://ZARDPDD01.localdomain/BRYREP","yes","Sat Jun 18 08:57","Fri Jun 24 07:01"
"8","dir://ZARDPDD01.localdomain/backup/ZABRYDD01REP/linux/b ackup/test31","yes","Sat Jun 18 08:57","Fri Jun 24 09:00"
"10","dir://ZARDPDD01.localdomain/backup/ZABRYDD01REP/linux/ backup/test421","yes","Sat Jun 18 08:57","Fri Jun 24 09:00"
"12","dir://ZARDPDD01.localdomain/backup/ZABRYDD01REP/linux/ backup/test5","yes","Sat Jun 18 08:57","Fri Jun 24 09:00"
"13","dir://ZARDPDD01.localdomain/backup/ZABRYDD01REP/linux/ backup/test60","yes","Sat Jun 18 08:57","Fri Jun 24 09:00"
"---","----------------------------------------------------- ----------------","-------","----------------","------------ ------"
--
To unsubscribe, e-mail: beginners-unsubscribe@perl.org
For additional commands, e-mail: beginners-help@perl.org
http://learn.perl.org/
Re: String Formatting by Column
am 26.06.2011 14:32:15 von Wernher Eksteen
--000e0cd3517af0e26504a69c9fd6
Content-Type: text/plain; charset=ISO-8859-1
Hi Rob,
Once again your expertise and willingness to help is astounding.
I appreciate the idea that everyone else is trying to force me into learning
a new concept I have never
encountered before by giving me pointers in the direction such as telling me
to look at pack and unpack
or the CSV related modules, which are all good, but I found that often
learning through example and then
take what I've learned and expand on that going forth usually works for me.
The fact that you went the extra mile and actually gave me a real example
based on what I need, not
only do I learn from this, but I also grasp it much quicker than having to
first learn the entire new concept
such as pack, unpack or the CSV related modules, but I also now have a very
good understanding from
which I can build on and have a good base from where I can dig deeper from
here.
Thank you very much for your assistance and literally showing me the ropes
and even explaining it so
that Perl newbies such as myself can understand it.
Perl is a great language and a great tool that is very useful in a wide
range of things, but grasping it's
power is often not easy for newcomers who want to know it, but don't always
have the time to reinvent
the wheel, which is why standing on the shoulders of giants who does
understand these things and who
are willing to share their expertise and guide newcomers such as myself so
that many more in future can
eventually do what you do and so have a "return of investment" by helping
the Perl community grow even
faster as to keep it obscured and out of reach for the norm.
Personally, I am a Java developer and Linux Admin of profession and don't
always have the time as much
as I would love to have digging into the finer details and aspects of
things, and understand that I will not and
cannot possibly know everything there is to know about any particular
subject, but know there are people such
as yourself out there willing to lend a hand and point those such as myself
not only in the right direction, but also
providing the map to get there. All I need to do is follow the road, and
then build my own maps based on what
I have learned from people such as yourself.
Regards,
Wernher
On 25 June 2011 19:02, Rob Dixon wrote:
> On 24/06/2011 08:45, Wernher Eksteen wrote:
> >
> > I've attached a text file containing the original and required
> > format and avoid the format being lost by just pasting it in the
> > email body.
> >
> > The original format is separated by a space, but need to replace the
> > space with a comma, so it will become a comma delimited csv file
> > which I will then import to MS Excel.
> >
> > I'm not sure how to parse the "Connection" and "Sync'ed-as-of-time"
> > columns since the dates there in is in this format "Fri Jun 24
> > 06:37" which also separated by space, but the spaces in those
> > columns shouldn't be replaced by a comma. The date format in those
> > columns should remain the same.
> >
> > Also, is it possible to convert this directly into a MS Excel
> > document using Perl?
>
> Hello again Wernher.
>
> My first guess for this problem was to build an 'unpack' format based on
> the row of hyphens beneath the header captions. As it may still be
> useful, and well worth studying for similar applications, here is my
> alternative solution doing just that.
>
> The program grabs everything in the file that is aligned with the row
> of hyphens beneath the captions. It works by finding the first line in
> the file that contains only hyphens or spaces, and scanning that to
> build an unpack string using the @- and @+ arrays that hold the offsets
> of the start and end of the previous successful regex match.
>
> Unlike my previous solution, empty (all-space) fields are handled
> correctly: the 'A' unpack format discards trailing spaces, and my only
> proviso is that if you ever expect leading spaces in fields they must be
> trimmed explicitly.
>
> HTH,
>
> Rob
>
>
> use strict;
> use warnings;
>
> use Fcntl 'SEEK_SET';
>
> my $format;
>
> my $fh = *DATA; # Replace with the appropriate 'open my $fh, '<', ... or
> die $!;
>
> # Remember the where the file begins, and then build the unpack pattern
> from
> # the first line continaining only hyphens and underscores
> #
> my $bof = tell $fh;
> while () {
> chomp;
> if (tr/- //c == 0 and tr/-// > 0) {
> while (/-+/g) {
> my ($beg, $len) = ($-[0], $+[0] - $-[0]);
> $format .= "\@$beg A$len ";
> }
> last;
> }
> }
>
> warn qq(Data will be upacked with a format of "$format"\n\n);
>
> # Now rewind to the beginning of the file, ignore anything that contains
> only
> # whitespace, and unpack every record according to the pattern that we just
> built
> #
> seek $fh, $bof, SEEK_SET;
> while (<$fh>) {
> next unless /\S/;
> my @data = unpack $format;
> print join ',', @data;
> print "\n";
> }
>
>
> __DATA__
>
>
> CTX Destination
> Enabled Connection Sync'ed-as-of-time
> --- ------------------------------------------------------------ ---------
> ------- ---------------- ------------------
> 1 pool://ZABRYDD01.localdomain/RDP_NEW_REP
> yes Sat Jun 18 08:56 Fri Jun 24 06:37
> 2 dir://ZARDPDD01.localdomain/backup/ZABRYDD01REP/linux/backup /test101
> yes Sat Jun 18 08:57 Fri Jun 24 08:01
> 4 dir://ZARDPDD01.localdomain/backup/ZABRYDD01REP/linux/backup /test22
> yes Sat Jun 18 08:57 Fri Jun 24 09:00
> 5 pool://ZARDPDD01.localdomain/BRYREP
> yes Sat Jun 18 08:57 Fri Jun 24 07:01
> 8 dir://ZARDPDD01.localdomain/backup/ZABRYDD01REP/linux/backup /test31
> yes Sat Jun 18 08:57 Fri Jun 24 09:00
> 10 dir://ZARDPDD01.localdomain/backup/ZABRYDD01REP/linux/backup /test421
> yes Sat Jun 18 08:57 Fri Jun 24 09:00
> 12 dir://ZARDPDD01.localdomain/backup/ZABRYDD01REP/linux/backup /test5
> yes Sat Jun 18 08:57 Fri Jun 24 09:00
> 13 dir://ZARDPDD01.localdomain/backup/ZABRYDD01REP/linux/backup /test60
> yes Sat Jun 18 08:57 Fri Jun 24 09:00
> --- ------------------------------------------------------------ ---------
> ------- ---------------- ------------------
>
> **OUTPUT**
>
> Data will be upacked with a format of "@0 A3 @6 A69 @78 A7 @88 A16 @107 A18
> "
>
> "CTX","Destination","Enabled","Connection","Sync'ed-as-of-ti me"
>
> "---","----------------------------------------------------- ----------------","-------","----------------","------------ ------"
> "1","pool://ZABRYDD01.localdomain/RDP_NEW_REP","","Sat Jun 18 08:56","Fri
> Jun 24 06:37"
> "2","dir://ZARDPDD01.localdomain/backup/ZABRYDD01REP/linux/b ackup/test101","yes","Sat
> Jun 18 08:57","Fri Jun 24 08:01"
> "4","dir://ZARDPDD01.localdomain/backup/ZABRYDD01REP/linux/b ackup/test22","yes","Sat
> Jun 18 08:57","Fri Jun 24 09:00"
> "5","pool://ZARDPDD01.localdomain/BRYREP","yes","Sat Jun 18 08:57","Fri Jun
> 24 07:01"
> "8","dir://ZARDPDD01.localdomain/backup/ZABRYDD01REP/linux/b ackup/test31","yes","Sat
> Jun 18 08:57","Fri Jun 24 09:00"
> "10","dir://ZARDPDD01.localdomain/backup/ZABRYDD01REP/linux/ backup/test421","yes","Sat
> Jun 18 08:57","Fri Jun 24 09:00"
> "12","dir://ZARDPDD01.localdomain/backup/ZABRYDD01REP/linux/ backup/test5","yes","Sat
> Jun 18 08:57","Fri Jun 24 09:00"
> "13","dir://ZARDPDD01.localdomain/backup/ZABRYDD01REP/linux/ backup/test60","yes","Sat
> Jun 18 08:57","Fri Jun 24 09:00"
>
> "---","----------------------------------------------------- ----------------","-------","----------------","------------ ------"
>
--000e0cd3517af0e26504a69c9fd6--
Re: String Formatting by Column
am 28.06.2011 19:28:37 von Wernher Eksteen
Hi Rob,
I wasn't quite sure at first what you meant by passing the file handle
in the while loop when $fh already existed,
so I changed the code slightly like this:
my $file =3D "file.txt";
open(my $fh, "<", $file) or die $!;
while (<$fh>) {
Works like a charm, thanks again!
Regards,
Wernher
>
> Rob
>
>
> use strict;
> use warnings;
>
> use Fcntl 'SEEK_SET';
>
> my $format;
>
> my $fh =3D *DATA; =A0# Replace with the appropriate 'open my $fh, '<', ..=
.. or die $!;
>
> # Remember the where the file begins, and then build the unpack pattern f=
rom
> # the first line continaining only hyphens and underscores
> #
> my $bof =3D tell $fh;
> while () {
> =A0chomp;
> =A0if (tr/- //c == 0 and tr/-// > 0) {
> =A0 =A0while (/-+/g) {
> =A0 =A0 =A0my ($beg, $len) =3D ($-[0], $+[0] - $-[0]);
> =A0 =A0 =A0$format .=3D "\@$beg A$len ";
> =A0 =A0}
> =A0 =A0last;
> =A0}
> }
>
> warn qq(Data will be upacked with a format of "$format"\n\n);
>
> # Now rewind to the beginning of the file, ignore anything that contains =
only
> # whitespace, and unpack every record according to the pattern that we ju=
st built
> #
> seek $fh, $bof, SEEK_SET;
> while (<$fh>) {
> =A0next unless /\S/;
> =A0my @data =3D unpack $format;
> =A0print join ',', @data;
> =A0print "\n";
> }
>
>
> __DATA__
>
>
> CTX =A0 Destination =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =
=A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 Enabled=
=A0 Connection =A0 =A0 =A0 =A0 Sync'ed-as-of-time
> --- =A0 ------------------------------------------------------------ -----=
---- =A0 ------- =A0 ---------------- =A0 ------------------
> 1 =A0 =A0 pool://ZABRYDD01.localdomain/RDP_NEW_REP =A0 =A0 =A0 =A0 =A0 =
=A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0yes =A0 =A0 =A0 Sat Jun 18 08:56=
=A0 Fri Jun 24 06:37
> 2 =A0 =A0 dir://ZARDPDD01.localdomain/backup/ZABRYDD01REP/linux/backup /te=
st101 =A0 =A0yes =A0 =A0 =A0 Sat Jun 18 08:57 =A0 Fri Jun 24 08:01
> 4 =A0 =A0 dir://ZARDPDD01.localdomain/backup/ZABRYDD01REP/linux/backup /te=
st22 =A0 =A0 yes =A0 =A0 =A0 Sat Jun 18 08:57 =A0 Fri Jun 24 09:00
> 5 =A0 =A0 pool://ZARDPDD01.localdomain/BRYREP =A0 =A0 =A0 =A0 =A0 =A0 =A0=
=A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 yes =A0 =A0 =A0 Sat Jun 18 08:=
57 =A0 Fri Jun 24 07:01
> 8 =A0 =A0 dir://ZARDPDD01.localdomain/backup/ZABRYDD01REP/linux/backup /te=
st31 =A0 =A0 yes =A0 =A0 =A0 Sat Jun 18 08:57 =A0 Fri Jun 24 09:00
> 10 =A0 =A0dir://ZARDPDD01.localdomain/backup/ZABRYDD01REP/linux/bac kup/te=
st421 =A0 =A0yes =A0 =A0 =A0 Sat Jun 18 08:57 =A0 Fri Jun 24 09:00
> 12 =A0 =A0dir://ZARDPDD01.localdomain/backup/ZABRYDD01REP/linux/bac kup/te=
st5 =A0 =A0 =A0yes =A0 =A0 =A0 Sat Jun 18 08:57 =A0 Fri Jun 24 09:00
> 13 =A0 =A0dir://ZARDPDD01.localdomain/backup/ZABRYDD01REP/linux/bac kup/te=
st60 =A0 =A0 yes =A0 =A0 =A0 Sat Jun 18 08:57 =A0 Fri Jun 24 09:00
> --- =A0 ------------------------------------------------------------ -----=
---- =A0 ------- =A0 ---------------- =A0 ------------------
>
> **OUTPUT**
>
> Data will be upacked with a format of "@0 A3 @6 A69 @78 A7 @88 A16 @107 A=
18 "
>
> "CTX","Destination","Enabled","Connection","Sync'ed-as-of-ti me"
> "---","----------------------------------------------------- -------------=
---","-------","----------------","------------------"
> "1","pool://ZABRYDD01.localdomain/RDP_NEW_REP","","Sat Jun 18 08:56","Fri=
Jun 24 06:37"
> "2","dir://ZARDPDD01.localdomain/backup/ZABRYDD01REP/linux/b ackup/test101=
","yes","Sat Jun 18 08:57","Fri Jun 24 08:01"
> "4","dir://ZARDPDD01.localdomain/backup/ZABRYDD01REP/linux/b ackup/test22"=
,"yes","Sat Jun 18 08:57","Fri Jun 24 09:00"
> "5","pool://ZARDPDD01.localdomain/BRYREP","yes","Sat Jun 18 08:57","Fri J=
un 24 07:01"
> "8","dir://ZARDPDD01.localdomain/backup/ZABRYDD01REP/linux/b ackup/test31"=
,"yes","Sat Jun 18 08:57","Fri Jun 24 09:00"
> "10","dir://ZARDPDD01.localdomain/backup/ZABRYDD01REP/linux/ backup/test42=
1","yes","Sat Jun 18 08:57","Fri Jun 24 09:00"
> "12","dir://ZARDPDD01.localdomain/backup/ZABRYDD01REP/linux/ backup/test5"=
,"yes","Sat Jun 18 08:57","Fri Jun 24 09:00"
> "13","dir://ZARDPDD01.localdomain/backup/ZABRYDD01REP/linux/ backup/test60=
","yes","Sat Jun 18 08:57","Fri Jun 24 09:00"
> "---","----------------------------------------------------- -------------=
---","-------","----------------","------------------"
>
> --
> To unsubscribe, e-mail: beginners-unsubscribe@perl.org
> For additional commands, e-mail: beginners-help@perl.org
> http://learn.perl.org/
>
>
>
--
To unsubscribe, e-mail: beginners-unsubscribe@perl.org
For additional commands, e-mail: beginners-help@perl.org
http://learn.perl.org/
Re: String Formatting by Column
am 28.06.2011 22:08:41 von Rob Dixon
On 28/06/2011 18:28, Wernher Eksteen wrote:
>>
>> Rob
>>
>>
>> use strict;
>> use warnings;
>>
>> use Fcntl 'SEEK_SET';
>>
>> my $format;
>>
>> my $fh = *DATA; # Replace with the appropriate 'open my $fh, '<', ... or die $!;
>
> I wasn't quite sure at first what you meant by passing the file handle
> in the while loop when $fh already existed,
> so I changed the code slightly like this:
>
>
> my $file = "file.txt";
> open(my $fh, "<", $file) or die $!;
>
> while (<$fh>) {
>
> Works like a charm, thanks again!
That's exactly right. I meant that, if you were using an external file,
you only needed to replace the line
my $fh = *DATA;
with
open my $fh, '<', 'myfile.txt' or die $!;
which is pretty much what you have done. Unfortunately I made a mistake
and wrote
while () {
in the first loop, when it should be the same as the second loop which reads
while (<$fh>) {
My apologies.
Rob
--
To unsubscribe, e-mail: beginners-unsubscribe@perl.org
For additional commands, e-mail: beginners-help@perl.org
http://learn.perl.org/
Re: String Formatting by Column
am 28.06.2011 23:04:03 von Wernher Eksteen
--0016e64c1a6a0163cd04a6cc02c7
Content-Type: text/plain; charset=ISO-8859-1
>
> That's exactly right. I meant that, if you were using an external file,
> you only needed to replace the line
>
> my $fh = *DATA;
>
> with
>
> open my $fh, '<', 'myfile.txt' or die $!;
>
> which is pretty much what you have done. Unfortunately I made a mistake
> and wrote
>
> while () {
>
> in the first loop, when it should be the same as the second loop which
> reads
>
> while (<$fh>) {
>
> My apologies.
>
> Rob
>
No apologies necessary, I'm just very happy that I could figure it out and
resolve it without any help :)
And so I'm a little bit wiser thanks to your help! Like someone said before,
Rob you rock!
Wernher
--0016e64c1a6a0163cd04a6cc02c7--