[17465] in Perl-Users-Digest
Perl-Users Digest, Issue: 4885 Volume: 9
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Tue Nov 14 09:10:29 2000
Date: Tue, 14 Nov 2000 06:10:14 -0800 (PST)
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)
Message-Id: <974211014-v9-i4885@ruby.oce.orst.edu>
Content-Type: text
Perl-Users Digest Tue, 14 Nov 2000 Volume: 9 Number: 4885
Today's topics:
Re: Newbee question, help wanted ! (Anno Siegel)
Re: Newbee question, help wanted ! <rvbeek@usa.net>
Re: Newbee question, help wanted ! (Martien Verbruggen)
Re: Perl32 <mmthoma@attglobal.net>
Re: Problem with chomp and print (Martien Verbruggen)
Re: Problem with TokeParser <kstep@pepsdesign.com>
Re: Recursively delete directory on Windows <mmthoma@attglobal.net>
Re: regular expression for jpg images (Rafael Garcia-Suarez)
Re: regular expression for jpg images <wyzelli@yahoo.com>
retrieve URL from text file <jpmcgowan@ireland.com>
Re: retrieve URL from text file <graham.wood@iona.com>
Re: retrieve URL from text file (Martien Verbruggen)
Re: Simple regex problem <W.Hielscher@mssys.com>
Re: Simple regex problem <bart.lateur@skynet.be>
skipping Lines <arm@home.com>
Re: skipping Lines (Martien Verbruggen)
Re: Sort (Bernard El-Hagin)
Re: Sysread and 0x0A <rpanman@my-deja.com>
Re: Sysread and 0x0A <bart.lateur@skynet.be>
Re: Target of goto is too deeply nested (Ilya Zakharevich)
Digest Administrivia (Last modified: 16 Sep 99) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: 14 Nov 2000 11:02:03 -0000
From: anno4000@lublin.zrz.tu-berlin.de (Anno Siegel)
Subject: Re: Newbee question, help wanted !
Message-Id: <8ur63b$cab$1@lublin.zrz.tu-berlin.de>
Jeff Zucker <jeff@vpservices.com> wrote in comp.lang.perl.misc:
>Jeff Zucker wrote:
>>
>> Ray wrote:
>> >
>> > $string =~ s/^\s+//;
>> > ...
>> >
>> > then everything is removed from the string and the result is an empty
>> > string.
>
>It just occured to me that you might have mistakenly capitalized the
>second "s" in your regular expression which would remove all the text
>because \S means "anything other than a whitespace" whereas \s means
>"whitespace".
...though that wouldn't lead to an empty string - the blanks would
remain. Looks pretty empty, though.
Anno
------------------------------
Date: Tue, 14 Nov 2000 12:16:32 +0100
From: "Ray" <rvbeek@usa.net>
Subject: Re: Newbee question, help wanted !
Message-Id: <8ur6rd$qd8$1@porthos.nl.uu.net>
Hi Jeff!
I'm sorry, but there are no capitalized s-es in te code. Here's some more of
the code:
my $refs = $header_hash{'References'};
my $firstref;
my $remref;
( $firstref , $remref ) = split(/ /, $refs, 2);
$firstref =~ s/^\s+//;
print "|".$refs."|".$firstref."|"<br>";
The last line is to check on the results of the variables.
The strange thing is that when the this is executed WITH the '<' and '>' in
the initial string, the entire string is deleted and the result is empty.
When I repeat the experiment WITHOUT the '<' and '>', it works fine.
Sorry for the nothing-saying subject, your right!
Thanks again!
Ray.
"Jeff Zucker" <jeff@vpservices.com> wrote in message
news:3A104ED3.60FD59F9@vpservices.com...
> Jeff Zucker wrote:
> >
> > Ray wrote:
> > >
> > > $string =~ s/^\s+//;
> > > ...
> > >
> > > then everything is removed from the string and the result is an empty
> > > string.
>
> It just occured to me that you might have mistakenly capitalized the
> second "s" in your regular expression which would remove all the text
> because \S means "anything other than a whitespace" whereas \s means
> "whitespace".
>
> --
> Jeff
------------------------------
Date: Tue, 14 Nov 2000 23:28:52 +1100
From: mgjv@tradingpost.com.au (Martien Verbruggen)
Subject: Re: Newbee question, help wanted !
Message-Id: <slrn912c04.gs3.mgjv@martien.heliotrope.home>
[comp/lang.perl removed. Newsgroup doesn't exist. Notify your news
admin]
On Mon, 13 Nov 2000 12:28:03 -0800,
Jeff Zucker <jeff@vpservices.com> wrote:
> Jeff Zucker wrote:
>>
>> Ray wrote:
>> >
>> > $string =~ s/^\s+//;
>> > ...
>> >
>> > then everything is removed from the string and the result is an empty
>> > string.
I propose that it isn't an empty string. I propose that you're just not
seeing the string, because you look at it the wrong way.
> It just occured to me that you might have mistakenly capitalized the
> second "s" in your regular expression which would remove all the text
> because \S means "anything other than a whitespace" whereas \s means
> "whitespace".
I think it is much more likely that the OP is viewing the output of this
stuff in a Web browser. Since the original string contained something
like:
" <stuff here> "
what will remain is
"<stuff here>"
and I invite you all to view that piece of text in a non-validating web
browser. It will silently not display it.
To the OP:
Is that by any chance what happened? And if so, have you now learned the
lesson to NEVER debug stuff like this in a browser? And if you must
debug this stuff in a browser, at least run these strings through a
filter that changes invalid characters to their markup equivalents.
Martien
--
Martien Verbruggen |
Interactive Media Division | Useful Statistic: 75% of the people
Commercial Dynamics Pty. Ltd. | make up 3/4 of the population.
NSW, Australia |
------------------------------
Date: Tue, 14 Nov 2000 05:57:10 -0800
From: Marshall Thomas <mmthoma@attglobal.net>
To: R & Y <kuma@whidbey.net>
Subject: Re: Perl32
Message-Id: <3A1144B6.8B4D6BC@attglobal.net>
R & Y wrote:
>
> I know that with the Unix systems you would use #!/usr/bin/perl. But, I'm
> trying to expand myself with Perl for windows. What I have not found is how
> do I call up Perl in Windows? is it something like #!d:/perl/bin? I have
> ActiveState Perl installed on my D: drive under it's own file (d:/perl/bin).
> Thanks for your help in advance.
>
> Robert
In general, you are barking up the wrong tree here. Winbloze and Unix
variants are very different in how they figure out what to do with
an executeable.
Go ahead and put in the normal stuff like "#!/usr/bin/perl" in your
source file, you want to maintain platform independence,
however Winbloze does not care about it at all.
In the Unix world, you mark a file as executable and the system looks
INSIDE the file to figure out what to do. If it is a binary file, it
does one thing with that, if it is a text file, it does something else.
Winbloze doesn't do that.
It only cares about the file extension like .bat or .pl or .plx, etc.
It will not look inside the file. It will do something that is
essentially
based upon the file name extension (the .XXX at the end).
When you installed the active state stuff, it registered the .pl and
perhaps the .plx extensions as being perl programs as perceived
by the Winbloze gui. I don't remember, but you may have to add
D:\perl\bin to your path statement, maybe even requiring a mod to
the autoexec.bat file. However, I think the latest versions of
the active state distributions do all of that.
If somehow things have gone wrong with the GUI setup, go into
Windboze Explorer|View|Folder Options|File Types and this will take you
a place where you can associate a program to run based on the file
name extension.
Having done that, you can launch perl programs from the gui with
a double click.
So now, you want to run a perl program like xxx.pl by typing
just xxx instead of perl xxx.pl at the command line? This is more
complicated. I forget the exact syntax, but this is the "associate"
command. There is a faq on the activestate site about this one.
This command will definately need to go in your autoexec.bat file
for this to work right.
I haven't bothered with this on my Win98 machine because the command
line shell window support is almost worthless on win98. On my WinNT
box, it is better, but still lame. (On WinNT, you want to start a
command line box, then right click on the top of the window, go into
properties and set the buffer size to be something reasonable, like
300-500 lines - you can't do this under win98). Cutting and pasting
from these boxes on Winbloze is also terrible. There is a thing called
"quick edit" mode which is also super damn lame.
I use TextPad as my PERL launch environment on Winbloze. This is a
nice shareware text editor and you can configure it to launch PERL
from within this text editor. This is nice for Winbloze since it
captures the STDOUT and STDERR stuff into another text window that is
unlimited in size so this avoids the ugly aspects of command line
shells on Winbloze. On my Unix machines, I don't have this problem
and I do really well from the command line although there are zoomy
things that can be done there too.
Anyway, good luck.
/Marshall
------------------------------
Date: Tue, 14 Nov 2000 22:15:39 +1100
From: mgjv@tradingpost.com.au (Martien Verbruggen)
Subject: Re: Problem with chomp and print
Message-Id: <slrn9127mr.gs3.mgjv@martien.heliotrope.home>
[Please, in the future, if you send a private email as well as post,
state so in the body of your message. email generally arrives faster
than news, which means that I run the risk of answering an email wile I
should be answering news. Fortunately, I have gotten into the habit of
not answering email that is in response to Usenet articles, and that
just asks for help.]
On Tue, 14 Nov 2000 05:49:21 GMT,
Alan Melton <arm@home.com> wrote:
> Martien Verbruggen wrote:
[huge snip of unnecessarily quotes material]
let me try to define your file format for you. Your files contains 10
lines that are the 'header'. Then, for each item ordered, it contains
another 7 lines. Let me try to create a little program that actually
uses those numbers. The output you want, but slightly different.ly
formatted, is:
> 10 30 2000 0-06-093195-7 1 9.05 9.05
> 10 30 2000 0-226-30784-0 1 9.30 9.30
> 10 30 2000 0-226-30780-8 1 19.25 19.25
> 10 30 2000 0-226-30792-1 1 29.30 29.30
> 10 30 2000 0-87220-390-5 1 229.25 229.25
A program that produces output like that from data that you provided
earlier (slightly altered), looks like:
#!/usr/local/bin/perl
use warnings;
use strict;
open(OUTPUT, ">&STDOUT") or die $!;
select OUTPUT;
chomp(my @order = <DATA>); # read all lines of this file
# Get the first 10 lines.
my @head = splice @order, 0, 10;
# Each 7 following lines, are an ordered item
while (my @item = splice @order, 0, 7)
{
# call the output function with the apropriate data
write_order_line(@head[1,2,3], @item[0,3,4,5]);
}
sub write_order_line
{
write OUTPUT;
format OUTPUT =
@< @< @<<< @<<<<<<<<<<<< @> @##.## @##.##
@_
.
}
__DATA__
t-adam03@cougar.com
10
30
2000
46.15
2.65
2.50
51.30
Call
@
0-06-093195-7
STAFF
12499
1
9.05
9.05
ODYSSEY OF HOMER (TRANS LATTIMORE)(PERENNIAL (New)0-06-093195-7
0-226-30784-0
STAFF
12499
1
9.30
9.30
EURIPIDES V: THREE TRAGEDIES (P) (New)0-226-30784-0
0-226-30780-8
STAFF
12499
1
9.25
9.25
EURIPIDES I: FOUR TRAGEDIES (P) (New)0-226-30780-8
0-226-30792-1
STAFF
12499
1
99.30
99.30
SOPHOCLES I: THREE TRAGEDIES (P) (New)0-226-30792-1
0-87220-390-5
STAFF
ALL
1
129.25
129.25
ORESTEIA (TRANS MEINECK) (P) (New)0-87220-390-5
The output coming out of this is:
10 30 2000 0-06-093195-7 1 9.05 9.05
10 30 2000 0-226-30784-0 1 9.30 9.30
10 30 2000 0-226-30780-8 1 9.25 9.25
10 30 2000 0-226-30792-1 1 99.30 99.30
10 30 2000 0-87220-390-5 1 129.25 129.25
The open and select at the top are there mainly so that it resembles
your original a bit more. You used OUTPUT, so I did too. If you read the
perlform documentation, you'll note that the output format should have
the same name as the output file handle (or you fiddle with $~).
When the input file format changes, all you need to do is change the 10,
and/or the 7, and the indexes into @head and @item. The rest should stay
the same.
Anyway, I think that this probably should get you a good start towards a
more maintainable program. You'll of course still need to wrap the 11
lines that read the order info, and call the write stuff into a loop
that runs over all orders, but that should be easy enough.
Documentation of interest: perlform, perlfunc (write, splice, select).
Martien
--
Martien Verbruggen |
Interactive Media Division |
Commercial Dynamics Pty. Ltd. | Curiouser and curiouser, said Alice.
NSW, Australia |
------------------------------
Date: Tue, 14 Nov 2000 06:00:34 -0500
From: "Kurt Stephens" <kstep@pepsdesign.com>
Subject: Re: Problem with TokeParser
Message-Id: <8ur5tk$gkd$1@slb6.atl.mindspring.net>
"Richard Kewish" <r.kewish@iname.com> wrote in message
news:8updpu$fka$1@neptunium.btinternet.com...
> Hi,
>
> I am creating some perl CGI scripts but keep getting an error. I suspect
> that there is a problem with the TokeParser module installed on my host.
> I receive this error message:
Your problem stems from the fact that the HTML::TokeParser constructor is
expecting either a scalar containing a filename, a file handle, a reference
to an object with a read method, or what we want, a reference to a scalar
containing the HTML to parse. The code bombs when you pass it a
HTTP::Response object.
Here is a cllip from your code, modified to pass the content to parse_title,
plus a little error handling thrown in.
<< Begin code >>
$webPage = $ua->request($req);
die "Error: " . $webPage->as_string
unless $webPage->is_success;
# Assign the content to a scalar, and pass
# a reference to parse_title
my $content = $webPage->content;
&parse_title(\$content);
exit 0;
sub parse_title{
#parse and output page title
$p = HTML::TokeParser->new(shift);
if ($p && $p->get_tag("title")) {
my $title = $p->get_trimmed_text;
print "Title: $title\n";
}
else {
print "Title not found\n";
}
}
<< End code >>
------------------------------
Date: Tue, 14 Nov 2000 04:18:49 -0800
From: Marshall Thomas <mmthoma@attglobal.net>
To: dave@andromeda.rutgers.edu
Subject: Re: Recursively delete directory on Windows
Message-Id: <3A112DA8.575DC83E@attglobal.net>
dave@andromeda.rutgers.edu wrote:
>
> Is there a module or other simple solution
> that allows me to recursively delete
> a directory under Windows 2000?
>
Might also want to look at File::Recurse
which is part of the File::Tools package from
Active State (www.activestate.com). There is more
than one way to do what you want.
/Marshall
> Thanks!
>
> Dave
>
> Sent via Deja.com http://www.deja.com/
> Before you buy.
------------------------------
Date: Tue, 14 Nov 2000 08:14:45 GMT
From: rgarciasuarez@free.fr (Rafael Garcia-Suarez)
Subject: Re: regular expression for jpg images
Message-Id: <slrn911t57.at4.rgarciasuarez@rafael.kazibao.net>
Wyzelli wrote in comp.lang.perl.misc:
>"chris @ home" <dextre@pacbell.net> wrote in message
>news:3A10632A.A41D82D@pacbell.net...
>> How do I convert this regular expression, which gets a handle on all
>> images:
>>
>> <img[^>]+>
>>
>> To only get image tags which are jpegs, aka, no gifs or pngs. I just
>> want to get the
>>
>> <img src="http://www.wherever.org/images/thisorthat.jpg">
>>
>
>This should be a suitable modification, with the caveats that Gwyn
>already raised.
>
><img[^>]+jpg[^>]*>
>
><img[^>]+jpe?g[^>]*> # this will grab all jpeg as well
What about :
<img src="jpg.gif">
or, beyond parsing :
<img src="jpg.cgi">
(with jpg.cgi outputting a jpeg)
--
# Rafael Garcia-Suarez / http://rgarciasuarez.free.fr/
------------------------------
Date: Tue, 14 Nov 2000 18:16:42 +0930
From: "Wyzelli" <wyzelli@yahoo.com>
Subject: Re: regular expression for jpg images
Message-Id: <kV6Q5.2$YO.798@vic.nntp.telstra.net>
"Rafael Garcia-Suarez" <rgarciasuarez@free.fr> wrote in message
news:slrn911t57.at4.rgarciasuarez@rafael.kazibao.net...
> >
> >This should be a suitable modification, with the caveats that Gwyn
> >already raised.
> >
> ><img[^>]+jpg[^>]*>
> >
> ><img[^>]+jpe?g[^>]*> # this will grab all jpeg as well
>
> What about :
>
> <img src="jpg.gif">
What about it? Is that a highly likely file to encounter?
> or, beyond parsing :
>
> <img src="jpg.cgi">
As far as I can tell from the highly limited information provided and
the unstated assumption that things were already working OK, but just
needed refining a little, plus the caveats mentioned by Gwyn ("You
really need to do proper parsing of the html to get the tags out.") that
should be acceptable.
I could think of a few more that won't work as well, but in my
experience this type of thing is required for a few limited cases of a
couple of pages (or a couple of hundred as in re-working an entire
web-site) rather than generally parsing all pages encountered on the
net.
Still, let the buyer beware!
Wyzelli
--
@x='07411711511603209711011111610410111403208010111410803210409709910710
1114'=~/(...)/g;
print chr for @x;
------------------------------
Date: Tue, 14 Nov 2000 11:57:10 -0000
From: "john" <jpmcgowan@ireland.com>
Subject: retrieve URL from text file
Message-Id: <newscache$9vj04g$mea$1@weblab.ucd.ie>
Hi,
I need to parse a file, which is of the form
<text> LINK_(digit1):(digit2):(url) <text>
<text> <text>,
(this is repeated many times, and the surrounding text is arbitrary),
where (url) represents a URL which may include periods, slashes, ampersands,
etc.
I need to parse the file so that I can access each digit1, digit2, and url.
My problem is with the url - it can be any length, have any number of
periods, slashes, ampersands. I can easily match the line, but retrieving
the url part is giving me problems.
Any suggestions?
Thanks,
J.
------------------------------
Date: Tue, 14 Nov 2000 12:24:38 -0000
From: "Graham Wood" <graham.wood@iona.com>
Subject: Re: retrieve URL from text file
Message-Id: <8urbev$gkg$1@bvweb.iona.com>
john <jpmcgowan@ireland.com> wrote in message
news:newscache$9vj04g$mea$1@weblab.ucd.ie...
> Hi,
> I need to parse a file, which is of the form
>
> <text> LINK_(digit1):(digit2):(url) <text>
> <text> <text>,
>
> (this is repeated many times, and the surrounding text is arbitrary),
> where (url) represents a URL which may include periods, slashes,
ampersands,
> etc.
>
> I need to parse the file so that I can access each digit1, digit2, and
url.
> My problem is with the url - it can be any length, have any number of
> periods, slashes, ampersands. I can easily match the line, but retrieving
> the url part is giving me problems.
>
> Any suggestions?
Have you tried matching the URL by matching the characters between things
that are not URL? Do your URLs contain colons or < characters? If not, you
can match a colon followed by "anything not a colon or a <", followed by a
"<text>" at the end of a line.
Here's an example
$string=q{<text> LINK_100:2345:www.where.com/directory@otherstuff<text>};
$string =~ m/:([^:<]+)\<text\>$/;
$URL=$1;
print "STRING $string contains URL $URL\n";
see perldoc perlop section on Regexp Quote-Like Operators for details of how
q{} stops @otherstuff being an array name.
Proper Perl programmers could probably do this in one line.
Graham Wood
>
> Thanks,
> J.
>
>
------------------------------
Date: Tue, 14 Nov 2000 23:36:56 +1100
From: mgjv@tradingpost.com.au (Martien Verbruggen)
Subject: Re: retrieve URL from text file
Message-Id: <slrn912cf8.gs3.mgjv@martien.heliotrope.home>
On Tue, 14 Nov 2000 11:57:10 -0000,
john <jpmcgowan@ireland.com> wrote:
> Hi,
> I need to parse a file, which is of the form
>
><text> LINK_(digit1):(digit2):(url) <text>
><text> <text>,
>
> (this is repeated many times, and the surrounding text is arbitrary),
> where (url) represents a URL which may include periods, slashes, ampersands,
> etc.
Without having a real example to work on, I'll guess that this might do
what you want. I'll interpret the above as 'url may contain anything,
except whitespace'. I am also assuming that those brackets in your
'example' (a real one would have been much better), are not actually
there.
my ($link, $digit, $url) = /(LINK_\d):(\d):(\S+)/;
> Any suggestions?
No more than that, until you give us some more data to work with.
Martien
--
Martien Verbruggen |
Interactive Media Division | +++ Out of Cheese Error +++ Reinstall
Commercial Dynamics Pty. Ltd. | Universe and Reboot +++
NSW, Australia |
------------------------------
Date: Tue, 14 Nov 2000 11:07:52 +0100
From: Wolfgang Hielscher <W.Hielscher@mssys.com>
Subject: Re: Simple regex problem
Message-Id: <3A110EF8.77C793E2@mssys.com>
Oliver Söder wrote:
> $arrayl=$#array;
$#array will return the subscript of the last element of the array, or
one less than the length.
You may find the number of elements in the array by evaluating @array in
a scalar context, for example by
$array1 = @array;
Nearly every form or perl documentation I came across (the above
explanation is taking form The Camel) makes this perfectly clear.
Cheers
Wolfgang
------------------------------
Date: Tue, 14 Nov 2000 10:50:48 GMT
From: Bart Lateur <bart.lateur@skynet.be>
Subject: Re: Simple regex problem
Message-Id: <a5621tohv59qm8b6k6q1o9qf27bgau0ken@4ax.com>
G.A.D.Miles wrote:
>I want to check whether a variable contains more than 1,000
>characters. I hoped this would work:
>
>$text =~ /.{1000,}/
>
>but it doesn't.
What this tests, is to see if the string contains a LINE of at least
1000 characters. By default, . doesn't match a newline (line end). With
the /s modifier, it will.
$text =~ /.{1000,}/s
But there is a more efficient way:
length($text)>= 1000
--
Bart.
------------------------------
Date: Tue, 14 Nov 2000 12:11:10 GMT
From: Alan <arm@home.com>
Subject: skipping Lines
Message-Id: <3A112B26.B8CFDC3E@home.com>
starting with a file as below
t-adam03@cougar.com
10
30
2000
46.15
2.65
2.50
51.30
Call
@
0-06-093195-7
STAFF
12499
1
9.05
9.05
ODYSSEY OF HOMER (TRANS LATTIMORE)(PERENNIAL (New)0-06-093195-7
0-226-30784-0
STAFF
12499
1
9.30
9.30
EURIPIDES V: THREE TRAGEDIES (P) (New)0-226-30784-0
0-226-30780-8
STAFF
12499
1
9.25
9.25
EURIPIDES I: FOUR TRAGEDIES (P) (New)0-226-30780-8
0-226-30792-1
STAFF
12499
1
9.30
9.30
SOPHOCLES I: THREE TRAGEDIES (P) (New)0-226-30792-1
0-87220-390-5
STAFF
ALL
1
9.25
9.25
ORESTEIA (TRANS MEINECK) (P) (New)0-87220-390-5
By using this program:
@a = <IN>; # read all lines of this file
chomp (@vals=@a[1,2,3,10,13,14,15]);
print OUTPUT join (" ",@vals), "\n";
chomp (@vals=@a[1,2,3,17,20,21,22]);
print OUTPUT join (" ",@vals), "\n";
print unless $a eq /^$/;
chomp (@vals=@a[1,2,3,24,27,28,29]);
print OUTPUT join (" ",@vals), "\n";
print unless ($a[22]) eq /^$/;
chomp (@vals=@a[1,2,3,31,34,35,36]);
print OUTPUT join (" ",@vals), "\n";
print unless ($a[28]) eq /^$/;
chomp (@vals=@a[1,2,3,38,41,42,43]);
print OUTPUT join (" ",@vals), "\n";
print unless ($a[34]) eq /^$/;
chomp (@vals=@a[1,2,3,45,48,49,50]);
print OUTPUT join (" ",@vals), "\n";
print unless ($a[40]) eq /^$/;
chomp (@vals=@a[1,2,3,52,55,56,57]);
print OUTPUT join (" ",@vals), "\n";
print unless ($a[46]) eq /^$/;
chomp (@vals=@a[1,2,3,59,62,63,64]);
print OUTPUT join (" ",@vals), "\n";
print unless ($a[52]) eq /^$/;
close IN;
# unlink $filename or die "Cannot delete $filename: $!";
I am getting:
10 30 2000 0-06-093195-7 1 9.05 9.05
10 30 2000 0-226-30784-0 1 9.30 9.30
10 30 2000 0-226-30780-8 1 19.25 19.25
10 30 2000 0-226-30792-1 1 29.30 29.30
10 30 2000 0-87220-390-5 1 229.25 229.25
10 30 2000 <====these are all blanks
10 30 2000 <====these are all blanks
10 30 2000 <====these are all blanks
10 30 2000 <====these are all blanks
10 30 2000 <====these are all blanks
10 30 2000
10 30 2000
10 30 2000 until it reaches the next record
10 30 2000 0-324-03301-X 1 8.25 8.25
10 30 2000
10 30 2000
10 30 2000
Have many files to read, each file may have 20,30,40,50 lines.
Each file is vertical as in the top.
The output has to include lines 1,2,3 plus other selected lines on each
line of the output
so I keep reading the file.
When it finishes, the next file is read and so on.
I want to get lines 1,2 and 3 on each line of output i.e. 10 30 2000 but
want to stop it when say
line 45 as in the code is blank, end the read of that file and go onto
the next file.
Please help.
Alan
------------------------------
Date: Tue, 14 Nov 2000 23:38:20 +1100
From: mgjv@tradingpost.com.au (Martien Verbruggen)
Subject: Re: skipping Lines
Message-Id: <slrn912chs.gs3.mgjv@martien.heliotrope.home>
On Tue, 14 Nov 2000 12:11:10 GMT,
Alan <arm@home.com> wrote:
> starting with a file as below
Ok, that's enough already. This is the third time you post this, even
though there have already been followups, and an answer, to the other
posts.
Usenet is not instantaneous. Please be patient.
Martien
--
Martien Verbruggen |
Interactive Media Division | Useful Statistic: 75% of the people
Commercial Dynamics Pty. Ltd. | make up 3/4 of the population.
NSW, Australia |
------------------------------
Date: Tue, 14 Nov 2000 09:40:36 +0000 (UTC)
From: bernard.el-hagin@lido-tech.net (Bernard El-Hagin)
Subject: Re: Sort
Message-Id: <slrn91221g.7hk.bernard.el-hagin@gdndev25.lido-tech>
>jtjohnston wrote:
>
> I'm using this to sort the lines in a db file. The problem is each line
> begins with a number.
>
> When the number is below 10, it sorts like this:
>
> 1 asdasd
> 10 asdasd
> 2 asdasda
> 3 wsfdsdfs
>
> etc
>
> I would like to sort so that it would come out like:
>
> 1 asdasd
> 2 asdasda
> 3 wsfdsdfs
> 10 asdasd
>
> What do I have to do differently?
----------------------------------------
#!/usr/bin/perl -w
use strict;
my @sorted = map {$_->[0]}
sort {$a->[1] <=> $b->[1]}
map {[$_, (split/\s+/)[0]]}
<DATA>;
print @sorted;
__DATA__
1 asdasd
10 asdasd
2 asdasda
3 wsfdsdfs
----------------------------------------
For an explanation of how that works check the FAQ.
Cheers,
Bernard
--
perl -le '$#="Just Another Perl Hacker"; print \Bernard'
------------------------------
Date: Tue, 14 Nov 2000 10:03:31 -0000
From: "Richard Panman" <rpanman@my-deja.com>
Subject: Re: Sysread and 0x0A
Message-Id: <8ur272$ktn$1@newstoo.ericsson.se>
The fault was in the sysopen... as Tim said it should have been:
sysopen(INPUT, $inputFile,0) or die $1;
^^^
NOT
sysopen(INPUT, $inputFile,">") or die $1;
^^^
Cheers
Richard
------------------------------
Date: Tue, 14 Nov 2000 10:54:57 GMT
From: Bart Lateur <bart.lateur@skynet.be>
Subject: Re: Sysread and 0x0A
Message-Id: <qf621t4lf59jpklss4f8hg6dfdgseq0crp@4ax.com>
rpanman@my-deja.com wrote:
>I'm having problems using sysread to read data from a file. The problem
>is that when sysread() encounters 0x0A it doesn't put it in the scalar.
>The data on either side of 0x0A are present so I don't know where it's
>going.
It doesn't? Gee. On Windows, it dares take out "0x0D" (= CR), but using
binmode on the filehandle fixes that.
--
Bart.
------------------------------
Date: 14 Nov 2000 08:06:34 GMT
From: ilya@math.ohio-state.edu (Ilya Zakharevich)
Subject: Re: Target of goto is too deeply nested
Message-Id: <8uqrqa$d5s$1@charm.magnus.acs.ohio-state.edu>
[A complimentary Cc of this posting was sent to Dave Hodson
<dave@iprint.com>],
who wrote in article <3A10584D.5B42DD1D@iprint.com>:
> I'm attempting to fix a bug in my code which is causing the following
> DIE msg
>
> "Target of goto is too deeply nested"
Anyone who knows what goto actually does, will tell you: do not use
goto LABEL in Perl.
AFAIK, The only reason it exists is to make some porting script (a2p?)
easier.
Ilya
------------------------------
Date: 16 Sep 99 21:33:47 GMT (Last modified)
From: Perl-Users-Request@ruby.oce.orst.edu (Perl-Users-Digest Admin)
Subject: Digest Administrivia (Last modified: 16 Sep 99)
Message-Id: <null>
Administrivia:
The Perl-Users Digest is a retransmission of the USENET newsgroup
comp.lang.perl.misc. For subscription or unsubscription requests, send
the single line:
subscribe perl-users
or:
unsubscribe perl-users
to almanac@ruby.oce.orst.edu.
| NOTE: The mail to news gateway, and thus the ability to submit articles
| through this service to the newsgroup, has been removed. I do not have
| time to individually vet each article to make sure that someone isn't
| abusing the service, and I no longer have any desire to waste my time
| dealing with the campus admins when some fool complains to them about an
| article that has come through the gateway instead of complaining
| to the source.
To submit articles to comp.lang.perl.announce, send your article to
clpa@perl.com.
To request back copies (available for a week or so), send your request
to almanac@ruby.oce.orst.edu with the command "send perl-users x.y",
where x is the volume number and y is the issue number.
For other requests pertaining to the digest, send mail to
perl-users-request@ruby.oce.orst.edu. Do not waste your time or mine
sending perl questions to the -request address, I don't have time to
answer them even if I did know the answer.
------------------------------
End of Perl-Users Digest V9 Issue 4885
**************************************