[23376] in Perl-Users-Digest

home help back first fref pref prev next nref lref last post

Perl-Users Digest, Issue: 5595 Volume: 10

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Wed Oct 1 03:05:42 2003

Date: Wed, 1 Oct 2003 00:05:08 -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           Wed, 1 Oct 2003     Volume: 10 Number: 5595

Today's topics:
        Can another Perl script without using exec or system (Great Deals)
    Re: Can another Perl script without using exec or syste (Sam Holden)
    Re: Downloading older versions of Perl (Jay Tilton)
        hashes (John Carroll)
    Re: hashes <jurgenex@hotmail.com>
    Re: hashes <tore@aursand.no>
        Numbers not acting like numbers <dasquith@austin.rr.com>
    Re: Passing Variables from One Perlscript to Another <NoName@yahoo.com>
    Re: Passing Variables from One Perlscript to Another <tcurrey@no.no.i.said.no>
    Re: Passing Variables from One Perlscript to Another <mbudash@sonic.net>
        Perl script crashing at lockfile ? <jehoshua@my-deja.com>
        Postal Lottery: Turn $6 into $60,000 in 90 days, GUARAN (Louis)
    Re: Prog. testing. <jurgenex@hotmail.com>
    Re: Prog. testing. <elp@pnsihq.com>
    Re: regexp help (mani)
    Re: regexp help (Sam Holden)
        Right way to wrap FileHandle? <newspost@coppit.org>
    Re:  <bwalton@rochester.rr.com>
        Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)

----------------------------------------------------------------------

Date: 30 Sep 2003 20:50:54 -0700
From: deals@slip-12-64-108-121.mis.prserv.net (Great Deals)
Subject: Can another Perl script without using exec or system
Message-Id: <cafe07c7.0309301950.511f3f74@posting.google.com>

I don't have shell access from the hosting company, so I cannot use
exec or system, but I need to run several perl scripts at once. So in
a pure perl enviroment, totally indepentent from shell/os, how can I
call other perl scripts from another perl script? use, include, ...?


------------------------------

Date: 1 Oct 2003 04:04:25 GMT
From: sholden@flexal.cs.usyd.edu.au (Sam Holden)
Subject: Re: Can another Perl script without using exec or system
Message-Id: <slrnbnkki9.t6d.sholden@flexal.cs.usyd.edu.au>

On 30 Sep 2003 20:50:54 -0700,
	Great Deals <deals@slip-12-64-108-121.mis.prserv.net> wrote:
> I don't have shell access from the hosting company, so I cannot use
> exec or system, but I need to run several perl scripts at once. So in
> a pure perl enviroment, totally indepentent from shell/os, how can I
> call other perl scripts from another perl script? use, include, ...?

Not having shell access isn't going to stop you using exec or system
in a perl script. It just stops you logging into the machine and
getting a command prompt.

perldoc -f do

Of course the scripts probably wont work unchanged anyway, since
their environments will be different then when run seperately at
the command line.

-- 
Sam Holden



------------------------------

Date: Wed, 01 Oct 2003 06:00:47 GMT
From: tiltonj@erols.com (Jay Tilton)
Subject: Re: Downloading older versions of Perl
Message-Id: <3f7a6d21.106101070@news.erols.com>

lphiecfu2002@yahoo.com (cfu20) wrote:

: Does anyone know where I can download older versions of Perl binary
: distributions (specifically 4.0) ?

http://cpan.org/src/unsupported/



------------------------------

Date: 30 Sep 2003 18:05:41 -0700
From: john.carroll@usap.gov (John Carroll)
Subject: hashes
Message-Id: <6b4da9ff.0309301705.10aa2972@posting.google.com>

I believe this is a seriously newbie question, but I can't find
anything that gives me the correct result. :^)

How do you get the actual string value of a hash value, when the key
is known?  I am using the following:

%in is set using the &ReadParse from cgi-lib.pl, with "Password" being
one of the keys, with a value of "test".

$file_password = "test";
$password = $in{"Password"};
print $password;   # output is "test"
print $file_password;   # output is "test"
if ($password ne $file_password) {   # result is true
    $incorrect_pw = "true";
}

I know about "each", "keys", and "values", but I can't find anything
in O'Reilly's "Programming Perl 2nd Edition" that shows me how to get
the value of a hash when you know the key using these commands.

If anyone has any ideas, I would appreciate them greatly.
Please send email to john.carroll@usap.gov with any help.  I will also
check back on this list until Friday.

thanks,
john


------------------------------

Date: Wed, 01 Oct 2003 01:13:20 GMT
From: "Jürgen Exner" <jurgenex@hotmail.com>
Subject: Re: hashes
Message-Id: <QSpeb.23654$Wd7.21629@nwrddc03.gnilink.net>

John Carroll wrote:
> How do you get the actual string value of a hash value, when the key
> is known?

Do you want to the value or do you want the value as a string? Those may be
two different requests.

> %in is set using the &ReadParse from cgi-lib.pl, with "Password" being
> one of the keys, with a value of "test".
>
> $file_password = "test";
> $password = $in{"Password"};

You are doing it right there.
$password now contains the value of the hash %in for the key 'Password'.

If you want to make sure that the value is a string (why do you care?) then
just concatenate the value with an empty string.

> Please send email to john.carroll@usap.gov with any help.

Don't think so, this is not how Usenet works.

> I will also check back on this list until Friday.

The answer will still be waiting for you.

jue




------------------------------

Date: Wed, 01 Oct 2003 03:38:54 +0200
From: Tore Aursand <tore@aursand.no>
Subject: Re: hashes
Message-Id: <pan.2003.10.01.01.37.51.495613@aursand.no>

On Tue, 30 Sep 2003 18:05:41 -0700, John Carroll wrote:
> %in is set using the &ReadParse from cgi-lib.pl

Why don't you use CGI.pm instead?  I don't know the current status of the
'cgi-lib.pl' thing, but as far as I know we're talking about code which
isn't updated anymore.

> $file_password = "test";
> $password = $in{"Password"};

That would be ...

  my $cgi = CGI->new();
  my $file_password = 'test';
  my $password = $cgi->param( 'Password' ) || '';

 ... if you're using CGI.pm and strict.

> print $password;   # output is "test"
> print $file_password;   # output is "test"
> if ($password ne $file_password) {   # result is true
>     $incorrect_pw = "true";
> }

Remember that there's not 'true' value in Perl.  Personally, I stick with
setting variables to 1 or 0, and just testing them;

  my @bool = qw( 1 0 );
  foreach ( @bool ) {
      if ( $_ ) {
          print "True\n";
      }
      else {
          print "False\n";
      }
  }

> I know about "each", "keys", and "values", but I can't find anything
> in O'Reilly's "Programming Perl 2nd Edition" that shows me how to get
> the value of a hash when you know the key using these commands.

You must have missed a part, if I'm not misunderstanding you completely.
Have a look at this:

  my %hash = (key_1 => 'value 1',
              key_2 => 'value 2');
  print $hash{ 'key_1' } . "\n";

What do you think?  Will this print 'value 1' or 'value 2'? :-)

> Please send email to john.carroll@usap.gov with any help.

Can't do that.  This is Usenet.


-- 
Tore Aursand <tore@aursand.no>


------------------------------

Date: Wed, 01 Oct 2003 01:57:07 GMT
From: D'Anne Asquith <dasquith@austin.rr.com>
Subject: Numbers not acting like numbers
Message-Id: <BB9F9EA1.17A8%dasquith@austin.rr.com>

I have subroutine for computing base-10 log.  With a recent upgrade from
Perl5.6 to Perl5.8 on both Linux and Solaris systems, a very large program
with a proven track record is not behaving right.  The subroutine snippet is
as follows.

use constant logof10 => scalar log(10);
use constant ZERO    => scalar 0;
sub log10 {
   my $n = shift;
   #my $n = &repackit(shift);  # HACK HERE
   ($n <= ZERO) ? undef : log($n)/logof10;
}

On apparently random occurrences the argument (say 0.1) is testing as <= 0
and the subroutine returns undef.  Surprize.  However, the subroutine might
work for a thousand calls before return undef.  I have carefully tracked the
argument upto the subroutine call and inside the subroutine (code not shown)
here and $n is 0.1.  The ZERO instead of 0 does not seem to affect the
behavior--still occurs.

If I uncomment the HACK HERE line and comment out the first line, the
subroutine works everytime!

sub repackit {
   my $n = shift;
   return unpack("d",pack("d",$n));
}

I should not have to do the pack/unpack.  It is possible that the argument
is really "0.1" (note double quotes) and not 0.1 deep in the program logic.
Would this be the source of the problem?  Unfortunately, when I create a
tiny test program I can not reproduce the problem.  The only thing changed
in years of multiple users of the program is use of Perl5.8.

Could someone comment on how a value that looks like 0.1 would test as <=
0--could Perl somehow consider 0.1 as int(0.1) internally?

Thanks,
dasq




------------------------------

Date: Wed, 01 Oct 2003 03:04:48 GMT
From: "Joe" <NoName@yahoo.com>
Subject: Re: Passing Variables from One Perlscript to Another
Message-Id: <kvreb.173431$Lnr1.2969@news01.bloor.is.net.cable.rogers.com>


> >
>
> i normally use one script to do it all.
>
> in the script, if the form has been submitted, the script validates the
> input data. if the data is valid, final processing occurs (db
> activities, emails sent, etc.), whatever thank you page is shown, then
> the script exits. if the data is not valid, the script "falls thru" to a
> section where the input form is displayed, populated with input data, if
> any. note that both the input form and the thank you pages are usually
> external template files.
>

I can live with just one script.  But what I want to do is to display the
validated input and ask for confirmation before proceeding with the long
data extraction process.  I don't know how to get user input in the middle
of a script.

Joe




------------------------------

Date: Tue, 30 Sep 2003 20:36:22 -0700
From: "Trent Curry" <tcurrey@no.no.i.said.no>
Subject: Re: Passing Variables from One Perlscript to Another
Message-Id: <bldi4a$pg8$1@news.astound.net>

Joe wrote:
>> i normally use one script to do it all.
>>
>> in the script, if the form has been submitted, the script validates
>> the input data. if the data is valid, final processing occurs (db
>> activities, emails sent, etc.), whatever thank you page is shown,
>> then the script exits. if the data is not valid, the script "falls
>> thru" to a section where the input form is displayed, populated with
>> input data, if any. note that both the input form and the thank you
>> pages are usually external template files.
>>
>
> I can live with just one script.  But what I want to do is to display
> the validated input and ask for confirmation before proceeding with
> the long data extraction process.  I don't know how to get user input
> in the middle of a script.
>
> Joe

What you could do is,

1) First write the input to a confirmation page in the form on hidden
   fields, then when that is submitted, then process the data, or

2) First write the input to a temp file (MD5.pm is a good way to
   generate random files names; I would suggest File::Temp for temp
   files, but afaik the file would be deleted by the time the script
   exits.) After you have a temp file written, send a confirmation
   page, and include the name of the temp file, which is being used
   sort of as a session id, so when the user sends the confirmation,
   it gets the file name from the hidden input field containing it
   and then process as necessary.

Hope this is of some use.

-- 
Trent Curry

perl -e
'($s=qq/e29716770256864702379602c6275605/)=~s!([0-9a-f]{2})!pack("h2",$1)!eg
;print(reverse("$s")."\n");'




------------------------------

Date: Wed, 01 Oct 2003 03:36:12 GMT
From: Michael Budash <mbudash@sonic.net>
Subject: Re: Passing Variables from One Perlscript to Another
Message-Id: <mbudash-1A99B7.20361130092003@typhoon.sonic.net>

In article 
<kvreb.173431$Lnr1.2969@news01.bloor.is.net.cable.rogers.com>,
 "Joe" <NoName@yahoo.com> wrote:

> > >
> >
> > i normally use one script to do it all.
> >
> > in the script, if the form has been submitted, the script validates the
> > input data. if the data is valid, final processing occurs (db
> > activities, emails sent, etc.), whatever thank you page is shown, then
> > the script exits. if the data is not valid, the script "falls thru" to a
> > section where the input form is displayed, populated with input data, if
> > any. note that both the input form and the thank you pages are usually
> > external template files.
> >
> 
> I can live with just one script.  But what I want to do is to display the
> validated input and ask for confirmation before proceeding with the long
> data extraction process.  I don't know how to get user input in the middle
> of a script.

if {formsubmitbutton) {
   validatedata(); # may set error
   unless (error) {
      showconfirmpage(); # hidden fields hold input data
      exit;
   }
}

if (confirmbutton) {
   dodataextraction(); # use data from hidden fields
   exit;
}

# if we get this far:
showinputform(); # populate with input data, if any; show error, if any

-- 
Michael Budash


------------------------------

Date: Wed, 01 Oct 2003 12:47:31 +1000
From: Peter Richards <jehoshua@my-deja.com>
Subject: Perl script crashing at lockfile ?
Message-Id: <7lfknv8uv6frra6n3igldclu3gjoimr71k@4ax.com>

Hi,

I've recently moved a website and one Perl script will not work. The
previous site had a Unix box with Perl 5.006 , and the new site has a
Linux box with Perl 5.006001

After inserting "print" statements all over the place, finally this
piece of code is where the script is stopping:

----------------------------------------------------------------------
system ("lockfile -2 -r 5 $base_dir/.lock" ) == 0 or diehtml("Lock
error: ", $? >> 8, "\n" ); # TODO stop stderr of system
--------------------------------------------------------------------

There is no msg appearing (what happened to the "diehtml" ?), the
script just stops. I have checked all the path and file permissions,
and they are exactly the same s the previous website. The variable
$base_dir has a value of '/home/username/public_html/.orders' 

The 'shebang' line, etc is:

-----------------------------------------------
#!/usr/bin/perl -wT

use CGI qw/:standard/;
use DBI;

# resource limits
$CGI:DISABLE_UPLOADS = 1;
$CGI::POST_MAX = 1024;
-----------------------------------------------

Any clues as to why this is stopping ?

Thanks,

Peter


Peter Richards
peter_j_richards@nospamplease.com
 (but use hotmail to email)


------------------------------

Date: Wed, 01 Oct 2003 02:12:07 GMT
From: anon@anon.com (Louis)
Subject: Postal Lottery: Turn $6 into $60,000 in 90 days, GUARANTEED
Message-Id: <40d0b085.10295594@news.rcn.com>

Postal Lottery: Turn $6 into $60,000 in 90 days, GUARANTEED

I found this in a news group and decided to try it. A little while
back, I was browsing through newsgroups, just like you are now and
came across a message just like this that said you could make
thousands of dollars within weeks with only an initial investment of
$6.00!!! 

So I thought yeah right, this must be a scam!!! But like most of us, I
was curious, so I kept reading. Anyway, it said that you send $1.00 to
each of the 6 names and addresses stated in the message. You then
place your own name and address at the bottom of the list at #6 and
post the message in at least 200 news groups. (There are thousands to
choose from). No catch, that was it.

So after thinking it over, and talking to a few people first. I
thought about trying it. I figured, what have I got to lose except 6
stamps and $6.00, right? So I invested the measly $6.00!!! Guess what?
Within 7 days I started getting money in the mail!!! I was shocked!!!
I figured it would end soon, but the money just kept coming in!!! In
my first week, I had made about $25.00. By the end of the second week,
I had made a total of over $1,000.00!!! In the third week, I had over
$10,000.00 and it is still growing!!! This is now my fourth week and I
have made a total of just over $42,000.00 and it is still coming in
rapidly!!! It's certainly worth $6.00 and 6 stamps!!! I have spent
more than that on the lottery!!! 

Let me tell you how this works and most importantly, why it works!!! 

Also, make sure you print a copy of this message now. So you can get
the information off of it as you need it. I promise you that if you
follow the directions exactly, that you will start making more money
than you thought possible by doing something so easy!!! 

Suggestion: Read this entire message carefully!!! (Print it out or
download it.) Follow the simple directions and watch the money come
in!!! It's easy!!! It's legal!!! Your investment is only $6.00 (plus
postage). 

IMPORTANT: This is not a rip-off!!! It is not illegal!!! ? It is
almost entirely risk free and it really works!!! If all of the
following instructions are adhered to, you will receive extraordinary
dividends!!! 

Please note: Follow these directions EXACTLY, and $60,000.00 or more
can be yours in 20 to 90 days!!! This program remains successful
because of the honesty and the integrity of the participants!!! Please
continue its success by carefully adhering to the instructions. 

You will now become part of the mail order business. In this business
your product is not solid or tangible, it is a service. You are in the
business of developing mailing lists. Many large corporations are
happy to pay big bucks for quality lists. However, the money made from
a mailing list is secondary to the income which is made from people
like you and me asking to be included on your mailing list!!! 

Here are the 4 easy steps to success:-

Step 1:- Get 6 separate pieces of paper and write the following on
each piece of paper. 

PLEASE PUT ME ON YOUR MAILING LIST
 
Now get 6 U.S. dollar bills and place ONE inside each of the 6 pieces
of paper so the bills will not be seen through the envelopes (to
prevent mail theft). Next, place one paper in each of the 6 envelopes
and seal them, you should now have 6 sealed envelopes. Each with a
piece of paper stating the above phrase, your name and address, and a
$1.00 bill. 

THIS IS ABSOLUTELY LEGAL!!! YOU ARE REQUESTING A LEGITIMATE SERVICE
AND YOU ARE PAYING FOR IT!!! 

Like most of us, I was a little skeptical and a little worried about
the legal aspect of it all. So I checked it out with the U.S. Postal
Service and they confirmed that it is indeed legal!!!

Mail the 6 envelopes to the following addresses:-


S. A. Blair
14601 Portland Ave #219
Burnsville, MN 55306 

D. Kumar
Room 2.36 Burkhardt House
Oxford Place, Victoria Park
M14 5RR Manchester
ENGLAND

T. Perce
11505 Headley Avenue
Cleveland, Oh 44111



T. Beckers
Rijksweg 46
6267AH Cadier en Keer
The Netherlands

J. Eddolls
144 Pursey Drive
Bradley Stoke
Bristol
BS32 8DP
United Kingdom

Louis Joseph
1933 Highway 35, #104
Wall, NJ  07719

Step 2:- Now take the #1 name off the list that you see above, move
the other names up (6 becomes 5, 5 becomes 4, etc.) and add your name
as number 6 on the list. 

Step 3:- Change anything you need to, but try to keep this message as
close to what you see as possible. Now, post your amended message to
at least 200 news groups. I think there are close to 24,000 groups!!!
All you need is 200, but remember, the more you post, the more money
you make!!! This is perfectly legal!! If you have any doubts, refer to
Title18 Sec. 1302 & 1341 of the postal lottery laws. Keep a copy of
these steps for yourself and whenever you need money, you can use it
again.

Please remember that this program remains successful because of the
honesty and the integrity of the participants and by their carefully
adhering to the directions!!! 

Look at it this way. If you are of integrity, the program will
continue and the money that so many others have received will come
your way!!! 

Note: - You may want to retain every name and address sent to you,
either on your computer or hard copy and keep the notes people send
you. This verifies that you are truly providing a service. Also, it
might be a good Idea to wrap the $1 bills in dark paper to reduce the
risk of mail theft. 

So, as each post is downloaded and the directions carefully followed,
six members will be reimbursed for their participation as a list
developer with one dollar each. Your name will move up the list
geometrically so that when your name reaches the #1 position, you will
be receiving thousands of dollars in cash!!! What an opportunity for
only $6.00!!! ($1.00 for each of the first six people listed above).

Send it now, add your own name to the list and your in business!!!


DIRECTIONS FOR HOW TO POST TO A NEWS GROUP!!!

Step 1:- You do not need to re-type this entire message to do your own
posting. Simply put your cursor at the beginning of this message and
drag your cursor to the bottom of this message and select copy from
the edit menu. This will copy the entire message into the computer
memory.

Step 2:- Open a blank note pad file and place your cursor at the top
of the blank page. From the edit menu select paste. This will paste a
copy of the message into notepad so that you can add your name to the
list.

Step 3:- Save your new notepad file as a txt file. If you want to do
your posting in a different setting, you'll always have this file to
go back to.

Step 4:- Use Netscape or Internet Explorer and try searching for
various news groups (on-line forums, message boards, chat sites,
discussions, etc.) 

Step 5:- Visit these message boards and post this message as a new
message by highlighting the text of this message from your notepad and
selecting paste from the edit menu. Fill in the subject, this will be
the header that everybody sees as they scroll through the list of
postings in a particular group. Click the post message button. You've
done your first one! Congratulations!!! All you have to do is jump to
different news groups and post away, after you get the hang of it, it
will take about 30 seconds for each news group!

REMEMBER, THE MORE NEWS GROUPS YOU POST IN, THE MORE MONEY YOU WILL
MAKE!!! (But you have to post a minimum of 200).

That's it!!! You will begin receiving money from around the world
within days!!! You may eventually want to rent a P.O. Box due to the
large amount of mail you will receive. If you wish to stay anonymous,
you can invent a name to use, as long as the postman will deliver it.

JUST MAKE SURE ALL THE ADDRESSES ARE CORRECT!!! 

Now the why part. Out of 200 postings, say you receive only 5 replies
(a very low example). So then you made $5.00 with your name at #6 on
the letter. Now, each of the 5 persons who sent you $1.00 make the
minimum 200 postings, each with your name at #5 and only 5 persons
respond to each of the original 5, that is another $25.00 for you. Now
those 25 each make 200 MINIMUM posts with your name at #4 and only 5
replies each, you will bring in an additional $125.00!!! Now, those
125 persons turn around and post the minimum 200 with your name at #3
and only receive 5 replies each, you will make an additional
$625.00!!! OK, now here is the fun part, each of those 625 persons
post a minimum 200 messages with your name at #2 and they each only
receive 5 replies, that
just made you $3,125.00!!! Those 3,125 persons will all deliver this
message to 200 news groups. If just 5 more reply you will receive
$15,625.00!!! All with an original investment of only $6.00!!! Amazing
isn't it!!!! When your name is no longer on the list, you just take
the latest posting in the news groups and send out another $6.00 to
the names on the list, putting your name at number 6 again.

You must realize that thousands of people all over the world are
joining the internet and reading these messages every day!!! Just like
you are now!!! So, can you afford $6.00 and see if it really works?
I'm glad I did!!! People have said, "what if the plan is played out
and no one sends you the money?" So what!!! What are the chances of
that happening, when there are tons of new honest users and new honest
people who are joining the internet and news groups everyday and are
willing to give it a try? Estimates are at 20,000 to 50,000 new users,
every day!!!

REMEMBER PLAY HONESTLY AND FAIRLY AND THIS WILL REALLY WORK!!!

-- Comments/Feedback (please post your feedback/experiences here) --

Not bad for 1 hr's work....made me around $5320 in roughly 35 days
Anthony M - TX

Hello, I rcvd 269 bucks in the post in 2 weeks.
Dan Miami - FL

I had to wait around 10 days before I had any results - $13,450 as of
3rd Jan 2003 to date (14th Feb 2003).Am gonna re-post it again for
more money!!
Del from Alberta - Canada

Only received around £588 in the post the last 2 months since I
started the program but I'd posted to approx. 100 newsgroups.
James P - Manchester, UK

Cool....didn't expect much out of this "scam" initially but I have pay
my credit card bill
Mustafa - Jordan

For $6,I made $246 in 2 weeks
ROMEO2326 - Little Rock, AR -US of A 

Hey, just droppin a line to say that after posting to well over 820
newsgroups on google and my ISP newsgroup server over a period of 4
1/2 months ,Ive raked in $54280 . Mucho dinero baby!!!!  Peace…
Drew Dallas - TX



------------------------------

Date: Wed, 01 Oct 2003 01:14:54 GMT
From: "Jürgen Exner" <jurgenex@hotmail.com>
Subject: Re: Prog. testing.
Message-Id: <iUpeb.23655$Wd7.17198@nwrddc03.gnilink.net>

Dr. Pastor wrote:
> I want to test a program running on Windows 2K pro. Would be Perl
> suitable to manipulate the user interface and examine the results
> produced by this program?

Sure.
You may want to check out the Expect module. It will make your work much
easier.

jue




------------------------------

Date: Wed, 01 Oct 2003 01:22:08 GMT
From: "Dr. Pastor" <elp@pnsihq.com>
Subject: Re: Prog. testing.
Message-Id: <4%peb.10618$NX3.10482@newsread3.news.pas.earthlink.net>

Thanks Jürgen!





------------------------------

Date: 30 Sep 2003 22:04:53 -0700
From: indian_spindoctor@yahoo.com (mani)
Subject: Re: regexp help
Message-Id: <1c84265c.0309302104.4ba153d8@posting.google.com>

Thanks a lot for helping me. As i see the solution is /^\s*#/ 

I have questions. Martien, I am ok at reading documents but sometimes
i find it better discussing with some good people like you guys :).
How does that \s help?. I mean what does it mean?..... Can u tell me?.
I thought it is

/^s*#/.. My interpretation is anything that starts with a space or any
number of space followed by a hash and if it is the beginning and so
this regexp suffices but you guys have said /^\s*#/ why this \?????


Martien Verbruggen <mgjv@tradingpost.com.au> wrote in message news:<slrnbniumh.d8h.mgjv@martien.heliotrope.home>...
> On 30 Sep 2003 05:29:08 -0700,
> 	mani <indian_spindoctor@yahoo.com> wrote:
> 
> >    if($x!~/^#/)
>  
> >                                                           I want to
> > ignore anything that starts with a <space># or # at the start.
>  
> >   I tried /s*^#/ which does not give what i want....
> 
> /^ ?#/
> 
> Or, if you meant "any whitespace" instead of "a <space>"
> 
> /^\s?#/
> 
> Or, if you meant any number of whitespace
> 
> /^\s*#/
> 
> And, please, don't just copy this, but read the perlre documentation,
> and read about what I just told you. It'll help you solve these sorts of
> problems yourself in the future.
> 
> Martien


------------------------------

Date: 1 Oct 2003 05:14:50 GMT
From: sholden@flexal.cs.usyd.edu.au (Sam Holden)
Subject: Re: regexp help
Message-Id: <slrnbnkoma.ugu.sholden@flexal.cs.usyd.edu.au>

On 30 Sep 2003 22:04:53 -0700, mani <indian_spindoctor@yahoo.com> wrote:
> Thanks a lot for helping me. As i see the solution is /^\s*#/ 
> 
> I have questions. Martien, I am ok at reading documents but sometimes
> i find it better discussing with some good people like you guys :).
> How does that \s help?. I mean what does it mean?..... Can u tell me?.
> I thought it is
> 
> /^s*#/.. My interpretation is anything that starts with a space or any
> number of space followed by a hash and if it is the beginning and so
> this regexp suffices but you guys have said /^\s*#/ why this \?????

s matches 's'.
\s matches whitespace.

perldoc perlre

-- 
Sam Holden



------------------------------

Date: Wed, 01 Oct 2003 02:28:04 GMT
From: David Coppit <newspost@coppit.org>
Subject: Right way to wrap FileHandle?
Message-Id: <Pine.BSF.4.56.0309302213080.4749@www.provisio.net>

Hi folks,

I'd like to write FileHandle::Unget, a version of FileHandle whose ungetc
supports more than one byte. As a first step, I thought I'd write a fully
compatible replacement for FileHandle.

My implementation is below, and is based on ideas from FileHandle::Rollback.
According to the docs, you can't just inherit from FileHandle, so the
filehandle is encapsulated in a tied reference.

A few questions:

- Does anyone have an example I can look at besides FileHandle::Rollback?
- Is there any existing test suite for FileHandle, separate from the main perl
  source?
- ungetc doesn't seem to work in my implementation. The code is below. Can
  anyone spot the problem?

TIA,
David

----------------------------%<----------------------------
# First line
# Second line
package FileHandle::Unget;

use strict;
use IO::Handle;
use IO::Seekable;
use Symbol;

use 5.000;

use vars qw( @ISA $VERSION $AUTOLOAD );

@ISA = qw( IO::Handle IO::Seekable );

$VERSION = '0.10';

#--------------------------------------------------------------------------

sub new
{
  my $class = shift;

  my $fh = gensym;

  ${*$fh} = tie *$fh, "${class}::Tie", @_;

  ref(${*$fh}) or return undef;

  bless $fh, $class;
  return $fh;
}

##########################################################################

package FileHandle::Unget::Tie;

use strict;
use IO::Seekable;
use FileHandle;

use 5.000;

use vars qw( $VERSION $AUTOLOAD );

$VERSION = '0.10';

#--------------------------------------------------------------------------

my %tie_mapping = (
  PRINT => 'print', PRINTF => 'printf', WRITE => 'syswrite',
  READLINE => 'getline', GETC => 'getc', READ => 'read', CLOSE => 'close',
  BINMODE => 'binmode', OPEN => 'open', EOF => 'eof', FILENO => 'fileno',
  SEEK => 'seek', TELL => 'tell',
);

#--------------------------------------------------------------------------

sub AUTOLOAD
{
  my $name = $AUTOLOAD;
  $name =~ s/.*://;

  die "Unhandled function $name!" unless exists $tie_mapping{$name};

  my $sub = $tie_mapping{$name};

  # Alias the anonymous subroutine to the name of the sub we want ...
  no strict 'refs';
  *{$name} = sub
    {
      my $self = shift;

      $sub = 'getlines' if $sub eq 'getline' && wantarray;

      $self->{'fh'}->$sub(@_);
    };

  # ... and go to it.
  goto &$name;
}

#--------------------------------------------------------------------------

sub TIEHANDLE
{
  my $class = shift;

  my $self = bless({}, $class);

  $self->{'fh'} = FileHandle->new(@_) or return undef;

  return $self;
}

1;

###########################################################################
# Test program below
# It should print the first line, then a *, then the second file

my $fh = new FileHandle::Unget($0);
# FileHandle works right
#my $fh = new FileHandle($0);

print scalar <$fh>;

$fh->ungetc(ord('*'));

print $fh->getline;

$fh->close;
----------------------------%<----------------------------


------------------------------

Date: Sat, 19 Jul 2003 01:59:56 GMT
From: Bob Walton <bwalton@rochester.rr.com>
Subject: Re: 
Message-Id: <3F18A600.3040306@rochester.rr.com>

Ron wrote:

> Tried this code get a server 500 error.
> 
> Anyone know what's wrong with it?
> 
> if $DayName eq "Select a Day" or $RouteName eq "Select A Route") {

(---^


>     dienice("Please use the back button on your browser to fill out the Day
> & Route fields.");
> }
 ...
> Ron

 ...
-- 
Bob Walton



------------------------------

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 5595
***************************************


home help back first fref pref prev next nref lref last post