[22615] in Perl-Users-Digest
Perl-Users Digest, Issue: 4836 Volume: 10
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Sat Apr 12 09:05:47 2003
Date: Sat, 12 Apr 2003 06:05:06 -0700 (PDT)
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)
Perl-Users Digest Sat, 12 Apr 2003 Volume: 10 Number: 4836
Today's topics:
Re: Allowing User to delete image files via HTML page i <georgeconklin@NO.SpaM.re.move.this.ALL.comcast.net>
Re: Convert curses screen output to space-delimited tex <dickey@saltmine.radix.net>
Re: DBI and binding <bigus NO @ SPAM creationfactor .net>
executing perl script (bhat)
Re: executing perl script <bigus NO @ SPAM creationfactor .net>
Re: From Perl 5.6 migration to 5.8 problem <kasp@epatra.com>
Re: From Perl 5.6 migration to 5.8 problem <kasp@epatra.com>
Re: hashes as lists <uri@stemsystems.com>
Re: My 1st japh!! <bik.mido@tiscalinet.it>
Re: perl problem and not so much <bwalton@rochester.rr.com>
Re: PHP Code to PERL conversion... <georgeconklin@NO.SpaM.re.move.this.ALL.comcast.net>
Re: PHP Code to PERL conversion... <noreply@gunnar.cc>
protocol() method of HTTP::Message affects client reque <bob@nowhere.com>
Re: protocol() method of HTTP::Message affects client r <grazz@pobox.com>
Re: protocol() method of HTTP::Message affects client r <bob@nowhere.com>
Search for text than search again based on results. (supportgeek)
Re: Search for text than search again based on results. <mbudash@sonic.net>
Re: Search for text than search again based on results. <grazz@pobox.com>
Re: Ugly code; what does it do? (Tad McClellan)
Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: Sat, 12 Apr 2003 07:00:40 -0400
From: "George" <georgeconklin@NO.SpaM.re.move.this.ALL.comcast.net>
Subject: Re: Allowing User to delete image files via HTML page in flat text database
Message-Id: <UpKcnYBkwrCbbAqjXTWcpw@comcast.com>
Thank you all very much. I do plan on absolutely restricting access to what
files can be deleted, though I had not given thought to the web server's
overall security. I will be sure to consult some security docs (as mentioned
by some) to insure this is done safely. The current edit form is already
password-protected and I plan making use of that functionality to "validate"
the user who requests file deletions. I think the password coupled with the
fact that there are no links to the edit page offers an acceptable level of
security.
-George
"Chris Olive" <nospam@raytheon.com> wrote in message
news:sCDla.281$35.1126@dfw-service2.ext.raytheon.com...
> Helgi Briem wrote:
> > On Fri, 11 Apr 2003 02:33:18 -0400, "George"
> > <georgeconklin@NO.SpaM.re.move.this.ALL.comcast.net> wrote:
> >
> >
> >>Thanks very much, I will try it out. I just realized the server is a
Windows
> >>NT or Windows2000 server and came back to post that -fast response, Jay!
> >>
> >>Will unlink() work on the Windows web servers?
> >>
> >>Something like this?
> >>
> >>the_file = (filename passed from form)
> >>unlink(the_file)
> >
> >
> > Yes, given the appropriate permissions.
> >
> > Note two things:
> >
> > The web server runs as a special user with restricted
> > privileges. Often called nobody or httpd on apache
> > web servers, IUSR_machinename on IIS servers
> > and so on.
> >
> > Allowing anonymous users to delete files on
> > your web servers is a *very* hazardous thing.
> > Take extra, extra care that you can't enter
> > C: or *.* or ..\..\..\* into the file field and
> > have your program delete files there.
>
> Far better to simply place a checkbox on the form beside the picture
> that says "Delete picture?", and if checked, the SCRIPT handles the
> delete for just that picture behind the scenes. The holes provided by
> allowing a typed filename (or even a so-called "locked in" filename via
> a combo or list box since the POST can be reconstructed on the
> client-side) are too numerous to mention.
>
> Chris
> -----
> Chris Olive
> Systems Consultant
> Raytheon Technical Services Corporation
> Indianapolis, IN
>
> email: olivec(AT)indy(DOT)raytheon(DOT)com
>
------------------------------
Date: 12 Apr 2003 11:13:46 GMT
From: Thomas Dickey <dickey@saltmine.radix.net>
Subject: Re: Convert curses screen output to space-delimited text output ?
Message-Id: <b78sda$ft6$1@news1.radix.net>
Sean O'Neill <sean@deletethistorespond.seanoneill.deletethistorespond.info> wrote:
> On 11 Apr 2003 10:47:57 GMT, Thomas Dickey <dickey@saltmine.radix.net>
> wrote:
>>Sean O'Neill <sean@deletethistorespond.seanoneill.deletethistorespond.info> wrote:
>>> Does anyone know of a modules or combo of modules that will take
>>> curses screen output and convert it to space-delimited text output ?
...
> That's what I was kinda thinkin' but what about different terminal
> types ? Not that I'm worried about a large number of them - probably
> just VT100, VT220, sun, xterm, and maybe a few others. I haven't dug
> into this yet but I would assume that the curses control sequences are
> slightly different between terminal types and the "20-or-so" sequences
> would actually be more.
perhaps. I interpreted the question as asking about relatively simple
programs such as "top", which don't generally use curses per se, but
termcap (no optimization). For the ANSI terminals you would have the
same cursor-position sequence. "sun" differs from vt100/vt220/xterm
by its treatment of line-wrapping, which would mean that you'd have to
worry about special cases in the optimized output from curses/ncurses.
But since you'd be constructing a picture of the screen as you went,
it wouldn't be that hard, relatively speaking (line-wrapping is only
a few comparisons/assignments).
To handle the non-ANSI cases, you'd have to be more elaborate - would
have to build up regular expressions dynamically from the terminal
description rather than being able to build them up by hand. The
ANSI sequences are easy to pick out of the data stream (an escape,
following by one of the initial character sequence, one or more intermediate
characters and a final), and then match (you're only looking for cursor
movement or cursor addressing).
--
Thomas E. Dickey <dickey@radix.net> <dickey@herndon4.his.com>
http://dickey.his.com
ftp://dickey.his.com
------------------------------
Date: Sat, 12 Apr 2003 10:49:39 +0100
From: "Bigus" <bigus NO @ SPAM creationfactor .net>
Subject: Re: DBI and binding
Message-Id: <HiRla.1512$Aq1.8@newsfep4-winn.server.ntli.net>
"Michael Budash" <mbudash@sonic.net> wrote in message
news:mbudash-018449.16094711042003@typhoon.sonic.net...
> In article <k9Hla.210$FA6.4057@newsfep4-glfd.server.ntli.net>,
> "Bigus" <bigus NO @ SPAM creationfactor .net> wrote:
>>
> > if($by eq "thread"){
> > $sth = $db->prepare("SELECT * FROM thetable WHERE refs LIKE
'%$display%'
> > OR messageid = '$display' ORDER BY article DESC");}
[..]
> $quoted_display = $db->quote($display);
>
> now use $quoted_display in place of $display in your above sql
> statements.
Hi.. the problem there is that I'm using wildcards in the criteria and
$db->quote() places quotes at either end of the string. Eg: when getting
records by thread, as in the if() condition above, I get the following error
message:
Microsoft][ODBC Microsoft Access Driver] Syntax error in query expression
'refs LIKE %'b5nbe7.mo.1@hamster.local.invalid'% OR messageid =
'b5nbe7.mo.1@hamster.local.invalid''. (SQL-42000)(DBD: st_prepare/SQLPrepare
err=-1)
Where I am searching the refs column in the DB I need wildcards either side
of the messageid, but of course they are outside the quotes that
$db->quote() applies, hence the syntax error.
Would placing the wildcards into $display before processing it with
$db->quote() be the best way or might it try and escape the wildcards?
Perhaps I should place the wildcards into the $quoted_display with something
like:
$quoted_display =~ s/^\'(.*)\'$/\'%$1%\'/;
.. but I would need a separate $quoted_display for the second condition
where it looks for a match on messageid and doesn't need wildcards, so it's
starting to rapidly get messy - is this really the right way to go about it?
Thanks
Bigus
------------------------------
Date: 12 Apr 2003 02:09:46 -0700
From: rnbhat89@yahoo.com (bhat)
Subject: executing perl script
Message-Id: <4f49dc09.0304120109.2bcb01da@posting.google.com>
Hello,
I am able to execute the below script from the command prompt.
However when i try to run through internet explorer the script doesn't
work as intended. The variable $folder in the script below now has
null value. Seems like it doesn't execute any command after the
statement my $msg = $folder->message(0);. I don't see any error
messages. Any clues to solve this problem would be appriciated.
Regards,
Roopa
#!/usr/bin/perl --
use Mail::Box;
use Mail::Box::POP3;
use Mail::Box::Manager;
use Mail::Message::Body;
use Mail::Message;
print "Content-type: text/html\n\n";
my $mgr = new Mail::Box::Manager;
my $folder = $mgr->open(type => "pop3", username => "roopa", password
=> "bhat", server_name => "mail.xxxx.net");
#---i am getting null value in the folder dirctory.
my $msg = $folder->message(0);
my $head = $msg->head;
my $body = $msg->body;
#--all the values remain null and even the print statemnt doesn't
print anything the below statement.
print "the header is $head\n";
#--for the above diagonistic print statement i am expecting to see on
the screen "the header is " but i don't even see "the header is "
$folder->close;
------------------------------
Date: Sat, 12 Apr 2003 10:59:57 +0100
From: "Bigus" <bigus NO @ SPAM creationfactor .net>
Subject: Re: executing perl script
Message-Id: <msRla.1516$Aq1.1198@newsfep4-winn.server.ntli.net>
"bhat" <rnbhat89@yahoo.com> wrote in message
news:4f49dc09.0304120109.2bcb01da@posting.google.com...
> Hello,
> I am able to execute the below script from the command prompt.
> However when i try to run through internet explorer the script doesn't
> work as intended. The variable $folder in the script below now has
> null value. Seems like it doesn't execute any command after the
> statement my $msg = $folder->message(0);. I don't see any error
> messages. Any clues to solve this problem would be appriciated.
> Regards,
> Roopa
If something works at the command line but not via CGI then in my experience
it's usually a permissions issue. I don't know anything about Unix, but
perhaps your web server is "logged on" with an account that doesn't have
whatever the Unix equivalent of administrator priveleges are?
Sorry about being vague, but you never know - it might help before all the
US guys wake up later and read the newsgroup and correct me :-)
Regards
Bigus
------------------------------
Date: Sat, 12 Apr 2003 12:23:43 +0530
From: "Kasp" <kasp@epatra.com>
Subject: Re: From Perl 5.6 migration to 5.8 problem
Message-Id: <b78d8t$qb3$1@newsreader.mailgate.org>
> It might need to find 'perl58.lib' (located in perl\lib\core\) to
"resolve"
> that "external symbol".
>
> Are you sure that all references to 'perl56*' have been amended to
'perl58*'?
I did replace perl56.lib with perl58.lib and also the PerlEz.lib (which
apparent is the same in both the versions).
But as Benjamin pointed out, Perl 5.8 is not entirely compatible with Perl
5.6. So I replaced all the header files to Perl 5.8
(PERL_HOME/lib/CORE/*.*) and it worked!
--
Perl is designed to give you several ways to do anything, so
consider picking the most readable one.
-- Larry Wall
------------------------------
Date: Sat, 12 Apr 2003 12:25:17 +0530
From: "Kasp" <kasp@epatra.com>
Subject: Re: From Perl 5.6 migration to 5.8 problem
Message-Id: <b78d8v$qb3$2@newsreader.mailgate.org>
> You can't do that. Perl 5.8 is not binary compatible with perl 5.6.
> Didn't you read the perldelta file?
I am sorry I did not read the perldelta file. Honestly, before you pointed
out, I didn't know it there was any such thing!
My problem is solved, thanks to you.
--
Perl is designed to give you several ways to do anything, so
consider picking the most readable one.
-- Larry Wall
------------------------------
Date: Sat, 12 Apr 2003 01:20:14 GMT
From: Uri Guttman <uri@stemsystems.com>
Subject: Re: hashes as lists
Message-Id: <x7fzoojyup.fsf@mail.sysarch.com>
>>>>> "KS" == Kevin Shay <kevin_shay@yahoo.com> writes:
KS> genericax@hotmail.com (Sara) wrote in message
KS> news:<776e0325.0304110624.9c187bf@posting.google.com>
>> Now I have a request. Eric and I talked about (2) useful ways to deal
>> with hashes with a succinct and effective syntax. I suspect the Guru's
>> know about 1000 more that we hadn't thought of- so even though it may
>> see obvious to you, please post more here?
KS> Here's one: when you have an array and/or a list of values, and you
KS> want to succinctly create a hash whose keys are those values (so you
KS> can do "does this value exist?" checks):
KS> my %h = map { $_ => 1 } (@a, $foo, $bar);
see my aforementioned hash slice tutorial for more of those.
and your phrase does this value exists is poorly worded. you are
checking keys there and not values. and by making all the values = 1 you
don't need to use the exists function.
and if your hash is already declared this is a simpler way:
@is_a_foo{ @a, $foo, $bar } = () ;
if( exists $is_a_foo{ $blah } ) { ... }
if you only have an array of keys you can do this:
@is_a_foo{ @a } = (1) x @a ;
if( $is_a_foo{ $blah } ) { ... }
note: neither of those wipes out the hash so keys outside of @a will
still be in there.
uri
--
Uri Guttman ------ uri@stemsystems.com -------- http://www.stemsystems.com
--Perl Consulting, Stem Development, Systems Architecture, Design and Coding-
Search or Offer Perl Jobs ---------------------------- http://jobs.perl.org
------------------------------
Date: Sat, 12 Apr 2003 11:41:23 +0200
From: Michele Dondi <bik.mido@tiscalinet.it>
Subject: Re: My 1st japh!!
Message-Id: <tshf9vg3n39otd7g7osc83uos35l7brus5@4ax.com>
On Fri, 11 Apr 2003 09:28:29 +0200, Michele Dondi
<bik.mido@tiscalinet.it> wrote:
>Sorry, I've been away lately: too busy to read news... but yesterday,
OK, I've not read any answers yet (using my newsreader offline), but
I've already modified it: e.g. I removed the useless s op...
Michele
--
$\=q.,.,$\.=$/,print qq,\112,,(qw,a c e h, ,map{$_-=1<<5if/112/;chr}
107..117,32)[map+hex,split//,join q,2B,,qw$ECDF078D3 F9 5F3014$,$,];
------------------------------
Date: Sat, 12 Apr 2003 03:11:13 GMT
From: Bob Walton <bwalton@rochester.rr.com>
Subject: Re: perl problem and not so much
Message-Id: <3E9783A7.6040802@rochester.rr.com>
Gary wrote:
...
> Is there any way from inside a cgi/perl program to evaluate if the program
> is being executed because someone typed the address directly in a browser? I
> have a script that I want to call from one of my pages but want to make sure
> it can't be called directly by typing the address in a browser. I understand
> that checking the HTTP_REFERER variable is not recommended but I would be
> looking at something like that. For clarity....
>
> The script somescript.cgi will always be called from
> http://www.somedomain.com/somefile.html
> I just want to make sure that you can't type in
> http://www.somedomain.com/cgi-bin/somescript.cgi directly into a browser.
...
> Gary
>
>
>
Well, one thing you could do would be to set your CGI script up to
accept only POST requests and have a required ?key=value field in your
URL. Typing in a URL containing the key=value field (which one could
always obtain just by looking at your HTML) will generate a GET request.
Of course, this doesn't stop the determined user from writing a Perl
or other program which will make the appropriate POST request -- it is
just harder and more hassle. You can't 100% prevent it, but you can
stop the casual user.
--
Bob Walton
------------------------------
Date: Sat, 12 Apr 2003 07:47:14 -0400
From: "George" <georgeconklin@NO.SpaM.re.move.this.ALL.comcast.net>
Subject: Re: PHP Code to PERL conversion...
Message-Id: <FZOcnUdWspRtZgqjXTWcqw@comcast.com>
I got some very free nice help in this group, and I was surprised by these
"complaints" about Vijoy's request. If I had the knowledge I certainly would
have translated that small code segment, a simple enough task for the
knowledgeable.
Its not like Vijoy asked for a complete CGI application to be written.
I have been using Newsgroups and mailing lists (both asking and giving
information) for years and when asking I've usually found polite, free help.
========================================
TAD the Informative:
Yes.
TONY CURTIS the Cynic:
So you want someone else to do your work for you for free.
I think you need to revise your expectations of the world
somewhat.
IAN the Obvious:
So learn to code in Perl then, problem solved.. no?
========================================
Tad and Ian your statements are so obvious as to render them a waste of your
time to post them. Tony, someone must have been very mean to you. But you
should revise your own expectations because there are actually friendly,
professional souls in these forums that are secure enough in their finances
to do favors for others.
Now you have GOT to be wondering why I even cared to write this, but you
would not understand (part of it is because I was bored and part is because
I do not enjoy mean peeps). I wish you all well in your futures, and hope
you can dig into your hearts before responding to people in the future; even
if your heart tells you to respond by resisting the urge to ridicule nice
people.
-George
"If you don't like yourself, you won't like anyone else, either"
"Ian.H [dS]" <ian@WINDOZEdigiserv.net> wrote in message
news:vitv8v8k0gs7m26m8hgc6f1b6ikhbgmp1k@4ax.com...
> -----BEGIN xxx SIGNED MESSAGE-----
> Hash: SHA1
>
> [ rearranged into correct chronological order ]
>
>
> >
> > tadmc@augustmail.com (Tad McClellan) wrote in message
> > news:<slrnb8un43.6ca.tadmc@magna.augustmail.com>...
> > > Vijoy Varghese <viijv@thedifferenZ.com> wrote:
> > >
> > > > The new php function is like this
> > > > // MD5 Encryption
> > > > function md5_hmac($data, $key)
>
>
> [ snip ]
>
>
> > > > Can some one translate this to perl?
> > >
> > >
> > > Yes.
>
>
> In a fit of excitement on 5 Apr 2003 20:05:12 -0800,
> viijv@thedifferenZ.com (Vijoy Varghese) managed to scribble:
>
> > I want this stuff for free, this is for a non-profit
> > website(educational purpose) and i am a student of that institute.
> > And i am doing the web-interface development as my acadamic
> > project.
> >
> > Vijoy~
>
>
> So learn to code in Perl then, problem solved.. no?
>
>
>
> Regards,
>
> Ian
>
> -----BEGIN xxx SIGNATURE-----
> Version: PGP 8.0
>
> iQA/AwUBPo/2nGfqtj251CDhEQLJAACg9Z6r8P1aD/Lh8P+bKPbpYe7BlKAAn3e4
> UyM2nJwEGn6n1AtCdqu5U08P
> =8y7q
> -----END PGP SIGNATURE-----
>
> --
> Ian.H [Design & Development]
> digiServ Network - Web solutions
> www.digiserv.net | irc.digiserv.net | forum.digiserv.net
> Scripting, Web design, development & hosting.
------------------------------
Date: Sat, 12 Apr 2003 14:35:56 +0200
From: Gunnar Hjalmarsson <noreply@gunnar.cc>
Subject: Re: PHP Code to PERL conversion...
Message-Id: <b7921e$cd748$1@ID-184292.news.dfncis.de>
Vijoy Varghese wrote:
> Can some one translate this to perl?
> ...
> I want this stuff for free
George wrote:
> I got some very free nice help in this group, and I was surprised
> by these "complaints" about Vijoy's request. If I had the knowledge
> I certainly would have translated that small code segment, a simple
> enough task for the knowledgeable. Its not like Vijoy asked for a
> complete CGI application to be written.
I have also got some valuable help in this group. Nevertheless, I find
the responses you quoted very reasonable.
When somebody is struggling with, but fails in solving, some Perl
problem, this group is a good place to seek help. But asking for free
programming help, when it's obvious that the poster hasn't made any
own effort - this poster had apparently not even considered to learn
*any* Perl - it's unreasonable. Totally unreasonable.
/ Gunnar
--
Gunnar Hjalmarsson
Email: http://www.gunnar.cc/cgi-bin/contact.pl
------------------------------
Date: Fri, 11 Apr 2003 23:25:42 -0500
From: bob <bob@nowhere.com>
Subject: protocol() method of HTTP::Message affects client requests?
Message-Id: <3e978f51_1@127.0.0.1>
email to: bob AT bob DASH n DOT com
I'm trying to get LWP::UserAgent to send GETs with "..HTTP/1.1" instead
of HTTP/1.0.
I'm doing:
use LWP::UserAgent;
$ua = new LWP::UserAgent;
$prot = 'HTTP/1.1';
$request = new HTTP::Request('GET', $init_url);
$request->protocol($prot);
$ret_code = $request->protocol();
print "Ret code: '$ret_code'\n";
$response = $ua->request($request);
The print statement shows HTTP/1.1, but tethereal still shows the request
going out as HTTP/1.0.
Is the protcol() method *only* for daemons?
----== Posted via Newsfeed.Com - Unlimited-Uncensored-Secure Usenet News==----
http://www.newsfeed.com The #1 Newsgroup Service in the World! >100,000 Newsgroups
---= 19 East/West-Coast Specialized Servers - Total Privacy via Encryption =---
------------------------------
Date: Sat, 12 Apr 2003 04:35:08 GMT
From: Steve Grazzini <grazz@pobox.com>
Subject: Re: protocol() method of HTTP::Message affects client requests?
Message-Id: <0IMla.4031$mC1.1239582@twister.nyc.rr.com>
bob <bob@nowhere.com> wrote:
> email to: bob AT bob DASH n DOT com
>
> I'm trying to get LWP::UserAgent to send GETs with "..HTTP/1.1"
> instead of HTTP/1.0.
>
Which version of LWP?
The current release defaults to HTTP 1.1.
--
Steve
------------------------------
Date: Sat, 12 Apr 2003 01:54:05 -0500
From: bob <bob@nowhere.com>
Subject: Re: protocol() method of HTTP::Message affects client requests?
Message-Id: <3e97b20f$1_1@127.0.0.1>
perl -MLWP -e 'print $LWP::VERSION'
5.53
perl -MLWP::UserAgent -e 'print $LWP::UserAgent::VERSION'
1.80
On Fri, 11 Apr 2003 23:35:08 -0500, Steve Grazzini wrote:
> bob <bob@nowhere.com> wrote:
>> email to: bob AT bob DASH n DOT com
>>
>> I'm trying to get LWP::UserAgent to send GETs with "..HTTP/1.1" instead
>> of HTTP/1.0.
>>
>>
> Which version of LWP?
>
> The current release defaults to HTTP 1.1.
>
----== Posted via Newsfeed.Com - Unlimited-Uncensored-Secure Usenet News==----
http://www.newsfeed.com The #1 Newsgroup Service in the World! >100,000 Newsgroups
---= 19 East/West-Coast Specialized Servers - Total Privacy via Encryption =---
------------------------------
Date: 11 Apr 2003 18:34:16 -0700
From: molivier@caregroup.harvard.edu (supportgeek)
Subject: Search for text than search again based on results.
Message-Id: <da063e5d.0304111734.1f6d3b35@posting.google.com>
Greetings.
I would greatly appreciate it if someone could point me in the right
direction on this one:
What I need to accomplish: I search for an account and once I find it
I need to search down in the file until I find the first occurence of
a line beginning in 0764
Here's what I'm working with.
#!usr/bin/perl
open (IN, "test.txt") or die $!;
@lines = <IN>;
foreach $_(@lines) {
if ($_ =~ /$acct/) {
print $_;
#this is where i need something in the way of search down file until
#$_ = /^0764/
}
}
any help on this would be great.
------------------------------
Date: Sat, 12 Apr 2003 02:37:32 GMT
From: Michael Budash <mbudash@sonic.net>
Subject: Re: Search for text than search again based on results.
Message-Id: <mbudash-223707.19373111042003@typhoon.sonic.net>
In article <da063e5d.0304111734.1f6d3b35@posting.google.com>,
molivier@caregroup.harvard.edu (supportgeek) wrote:
> Greetings.
>
> I would greatly appreciate it if someone could point me in the right
> direction on this one:
>
> What I need to accomplish: I search for an account and once I find it
> I need to search down in the file until I find the first occurence of
> a line beginning in 0764
>
> Here's what I'm working with.
>
> #!usr/bin/perl
>
> open (IN, "test.txt") or die $!;
>
> @lines = <IN>;
>
> foreach $_(@lines) {
> if ($_ =~ /$acct/) {
> print $_;
>
> #this is where i need something in the way of search down file until
> #$_ = /^0764/
>
> }
> }
>
> any help on this would be great.
since it looks like you _want_ to read the whole file into memory, i'll
continue with that method:
#!usr/bin/perl
use strict;
open (IN, "test.txt") or die $!;
my @lines = <IN>;
my $found_acct;
foreach (@lines) {
unless ($found_acct) {
if (/$acct/) {
print $_;
$found_acct++;
}
}
else {
if (/^0764/) {
print $_;
}
}
}
hth-
--
Michael Budash
------------------------------
Date: Sat, 12 Apr 2003 03:55:58 GMT
From: Steve Grazzini <grazz@pobox.com>
Subject: Re: Search for text than search again based on results.
Message-Id: <i7Mla.3795$mC1.1223357@twister.nyc.rr.com>
supportgeek <molivier@caregroup.harvard.edu> wrote:
>
> I search for an account and once I find it I need to search
> down in the file until I find the first occurence of a line
> beginning in 0764
>
You could use two loops:
#!/usr/bin/perl
my $acct = shift
or die "usage: $0 account [filename]\n";
while (<>) { print, last if /\Q$acct/ }
while (<>) {
if (/^0764/) {
...
}
}
--
Steve
------------------------------
Date: Fri, 11 Apr 2003 19:19:07 -0500
From: tadmc@augustmail.com (Tad McClellan)
Subject: Re: Ugly code; what does it do?
Message-Id: <slrnb9emrr.2fg.tadmc@magna.augustmail.com>
Michael P. Broida <michael.p.broida@boeing.com> wrote:
> "Michael P. Broida" wrote:
>> print join("\n",@$[0..$#$]) if( $$[-1] );
> At the very end, I don't understand the use of:
> if( $$[-1] );
>
> OK, $$[x] is the xth element of array @$ created in the
> preceding line. But I don't understand the index of -1.
From the very first paragraph in perldata.pod:
Normal arrays are ordered lists of scalars indexed by number,
starting with 0 and with negative subscripts counting from the end.
--
Tad McClellan SGML consulting
tadmc@augustmail.com Perl programming
Fort Worth, Texas
------------------------------
Date: 6 Apr 2001 21:33:47 GMT (Last modified)
From: Perl-Users-Request@ruby.oce.orst.edu (Perl-Users-Digest Admin)
Subject: Digest Administrivia (Last modified: 6 Apr 01)
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.
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 V10 Issue 4836
***************************************