"John W. Krahn" schreef:
> tr/\t/ /s;
To also squash adjacent space characters:
tr/\t / /s;
--
Affijn, Ruud
"Gewoon is een tijger."
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/
Andrej Kastrin wrote:
John W. Krahn wrote:
This should do what you want:
#!/usr/bin/perl
use warnings;
use strict;
my $FNI = shift;
my $FNO = "$FNI.dat";
open my $OUT, '>', $FNO or die "Cannot open '$FNO' $!";
open my $IN, '<', $FNI or die "Cannot open '$FNI' $!";
my ( $id, $line );
while
Dear Jonh,
many, many thanks for your quick answer.
I modified your script a bit:
$line .= $_ if /Id|To|From/;
print $OUT "$id\t$line\n" if m!/Note!;
to:
$line .= $_ if m!! .. m!!;
print $OUT "$id\t$line\n" if m!!;
but some problem still persists with the output:
001
001Tho
Andrej Kastrin wrote:
Dear all,
Hello,
to pre-process my XML dataset in run simple Perl script on it, which
extract Id identifier from XML data and paste the whole XML record to
it. For example, the input data looks like:
001
Thomas
Joana
002
> -Original Message-
> From: NYIMI Jose (BMB) [mailto:[EMAIL PROTECTED]]
> Sent: Wednesday, December 11, 2002 1:00 PM
> To: popeye _; [EMAIL PROTECTED]
> Subject: RE: Last Line in Packages
>
>
> See this archive :
>
> http://archive.develooper.com/begi
See this archive :
http://archive.develooper.com/beginners%40perl.org/msg38109.html
José.
> -Original Message-
> From: popeye _ [mailto:[EMAIL PROTECTED]]
> Sent: Monday, December 09, 2002 11:47 PM
> To: [EMAIL PROTECTED]
> Subject: Last Line in Packages
>
>
> Often, but not always, I
"James Kelty" <[EMAIL PROTECTED]> writes:
> Well, I thought of that earlier, but I also thought that I
> was not guaranteed that the order of an array was
> unreliable, so I may not actually be getting the 'last' of
> the file. True or untrue ?
By definition:
Arrays are ordered.
Diamond
James Kelty wrote:
>
> Is there a document in perldoc that tells the best way to get the last line
> of a file? Below is my usual code for reading a file.
>
> #!/usr/bin/perl -w
>
> $file = qq(/some/file/);
>
> open FILE, "$file" or die "Cannot open file: $!\n";
>
> while() {
>do somethin
If you know the size of the last line you can use 'seek' to get there, but
this operates on bytes, not chars. If the records are of a fixed size this
would be the most efficient way to do it.
use POSIX; #This gives us the SEEK_END constant
seek (FH, -$recsize, SEEK_END) or die "Could not seek: $
You are probably thinking of associative arrays. They are declared with the
'%' character in the lead and do not have any intelligible order. With a
normal array the order is guaranteed.
If your files aren't to big I've found this idiom useful when I just want
the last line.
open (FH, "smallfi
On Tue, Dec 18, 2001 at 10:43:54AM -0800, James Kelty wrote:
> Well, I thought of that earlier, but I also thought that I was not
> guaranteed that the order of an array was unreliable, so I may not actually
> be getting the 'last' of the file. True or untrue ?
Arrays are ordered, they must be, t
;
Cc: "James Kelty" <[EMAIL PROTECTED]>; <[EMAIL PROTECTED]>
Sent: Tuesday, December 18, 2001 11:02 AM
Subject: Re: Last line of file...
> If the file is huge I wouldn't recommend doing so.. because it puts all
> the file into your array
>
> I think you can go
uot; <[EMAIL PROTECTED]>
> To: "Agustin Rivera" <[EMAIL PROTECTED]>
> Sent: Tuesday, December 18, 2001 10:27 AM
> Subject: RE: Last line of file...
>
> > Thank you, but I would like to programmatically do it from perl rather
> than
> > using shell co
Ok, thanks!
-James
-Original Message-
From: Agustin Rivera [mailto:[EMAIL PROTECTED]]
Sent: Tuesday, December 18, 2001 10:49 AM
To: James Kelty; [EMAIL PROTECTED]
Subject: Re: Last line of file...
I've never had an instance where that didn't work. I use for $a(0..$#array
> "McCollum, Frank" <[EMAIL PROTECTED]> said:
> I'm a beginner too, given, but alternatively, you could unshift the lines
> into an array and just check the last variable. This would allow you to
> reference the other lines later if there was more work to be done here.
Something like this while
a" <[EMAIL PROTECTED]>; <[EMAIL PROTECTED]>
Sent: Tuesday, December 18, 2001 10:43 AM
Subject: RE: Last line of file...
> Well, I thought of that earlier, but I also thought that I was not
> guaranteed that the order of an array was unreliable, so I may not
actual
t: Tuesday, December 18, 2001 10:44 AM
To: James Kelty; [EMAIL PROTECTED]
Subject: Re: Last line of file...
In that case, do this..
open(IN, "filename");
@file=;
print "$file[$#file]\n";
Agustin Rivera
Webmaster, Pollstar.com
http://www.pollstar.com
- Original Message ---
ROTECTED]>
Sent: Tuesday, December 18, 2001 10:27 AM
Subject: RE: Last line of file...
> Thank you, but I would like to programmatically do it from perl rather
than
> using shell commands. Make the whole script more portable.
>
> -James
>
>
> -Original Message-
>
I'm a beginner too, given, but alternatively, you could unshift the lines
into an array and just check the last variable. This would allow you to
reference the other lines later if there was more work to be done here.
-Original Message-
From: James Kelty [mailto:[EMAIL PROTECTED]]
Sent:
If this is all you want your script to do, I suggest using this command
tail -n1 filename
Agustin Rivera
Webmaster, Pollstar.com
http://www.pollstar.com
- Original Message -
From: "James Kelty" <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Sent: Tuesday, December 18, 2001 10:21 AM
Subje
> -Original Message-
> From: Jorge Goncalvez [mailto:[EMAIL PROTECTED]]
> Sent: Friday, September 07, 2001 6:10 AM
> To: [EMAIL PROTECTED]
> Subject: Re:Last line
>
>
> Hi, how to parse the last line of a file.
>
> I have this code:
> $pb->destroy unless($last_line=~/^dhcpd|LOG_INFO|ftp
COLLINEAU writes:
> How can i do to delete the last line of a file ?
>From perlfaq5...
How do I change one line in a file/delete a line in a
file/insert a line in the middle of a file/append to the
beginning of a file?
In the unique case of deleting lines at the end o
--- COLLINEAU Franck FTRD/DMI/TAM <[EMAIL PROTECTED]> wrote:
> Hi!
>
> How can i do to delete the last line of a file ?
>
> Thanks
>
> --
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
>
Try:
#Get the data
open(FILE, $file) or die "Couldn't o
23 matches
Mail list logo