Re: Newbie Perl Question



Hello Rod,

I am not the author of the initial message, but thanks a lot for your
reply.
I am trying to adopt your script to my need, and, basically, it works
for me.

But I am totally frustrated in regexp part in the script:
/^DR\d+.*?(\d+).*?(\d+)(.+)/

Could you please explain it? Or maybe you have a link to intelligible
guide for perl regexp?

I am sure a lot of the readers of this list would happy to understand
this really great part of perl :)


On Mon, Jul 17, 2006 at 08:13:59PM +0200, Dr.Ruud wrote:
"Rod Burgess" schreef:

Your Subject has no quality. Please come up with something like "convert
data lines".

I am new to the Perl world and am trying to learn it. A coworker
tells me that Perl will not work for what I am trying to do however,
I think Perl would be a great tool to use and I feel this coworker
is wrong.
I have a file that contains several lines all as below:
DR03555{tab} 45600062888{tab} 00008FLAT WASHER
DR03555{tab} 228765329{tab} 00001GASKET

The meaning of the file is
DR03555 = order number
45600062888 = part number
00008 = quantity
FLAT WASHER = Description

The lines all begin with the prefex DR I would like to read this
file and produce the following output:

45600062888;8;FLAT WASHER
228765329;1;GASKET

basiclly I need a file that lists the following:
Part#;Quantity;Description

Is this possible with Perl?

Certainly.

#!/usr/bin/perl
# ID: pqd.pl
use warnings ;
use strict ;

while ( <> )
{
/^DR\d+.*?(\d+).*?(\d+)(.+)/
and print "$1;", 0+$2, ";$3\n" ;
}

If your data is in pqd.in, and pqd.pl is execuable, then just run it as

pqd.pl pqd.in

--
Affijn, Ruud

"Gewoon is een tijger."



--
To unsubscribe, e-mail: beginners-unsubscribe@xxxxxxxx
For additional commands, e-mail: beginners-help@xxxxxxxx
<http://learn.perl.org/> <http://learn.perl.org/first-response>


--
Maxim
.



Relevant Pages

  • 2005-11-20 [de.comp.lang.perl.cgi] FAQ
    ... Programmiersprache Perl in CGI-Scripten. ... Wo gibt es Dokumentation über Perl und CGI? ... Hilfe zum Programm perldoc kann man mit 'perldoc perldoc' ... Mein Script läuft nicht bei meinem Provider. ...
    (de.comp.lang.perl.cgi)
  • 2005-11-20 [de.comp.lang.perl.cgi] FAQ
    ... Programmiersprache Perl in CGI-Scripten. ... Wo gibt es Dokumentation über Perl und CGI? ... Hilfe zum Programm perldoc kann man mit 'perldoc perldoc' ... Mein Script läuft nicht bei meinem Provider. ...
    (de.comp.lang.perl.cgi)
  • 2005-11-20 [de.comp.lang.perl.cgi] FAQ
    ... Programmiersprache Perl in CGI-Scripten. ... Wo gibt es Dokumentation über Perl und CGI? ... Hilfe zum Programm perldoc kann man mit 'perldoc perldoc' ... Mein Script läuft nicht bei meinem Provider. ...
    (de.comp.lang.perl.cgi)
  • 2005-11-20 [de.comp.lang.perl.cgi] FAQ
    ... Programmiersprache Perl in CGI-Scripten. ... Wo gibt es Dokumentation über Perl und CGI? ... Hilfe zum Programm perldoc kann man mit 'perldoc perldoc' ... Mein Script läuft nicht bei meinem Provider. ...
    (de.comp.lang.perl.cgi)
  • 2005-11-20 [de.comp.lang.perl.cgi] FAQ
    ... Programmiersprache Perl in CGI-Scripten. ... Wo gibt es Dokumentation über Perl und CGI? ... Hilfe zum Programm perldoc kann man mit 'perldoc perldoc' ... Mein Script läuft nicht bei meinem Provider. ...
    (de.comp.lang.perl.cgi)