[25650] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 7892 Volume: 10

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Thu Mar 17 18:05:31 2005

Date: Thu, 17 Mar 2005 15:05:17 -0800 (PST)
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)

Perl-Users Digest           Thu, 17 Mar 2005     Volume: 10 Number: 7892

Today's topics:
    Re: FAQ 9.1 What is the correct form of response from a <flavell@ph.gla.ac.uk>
        getting and posting <mc79@cse.buffalo.edu>
    Re: getting and posting <spamtrap@dot-app.org>
    Re: getting and posting <kkeller-usenet@wombat.san-francisco.ca.us>
    Re: getting and posting <Im.so.HuckinFappy@spamgourmet.com>
    Re: getting and posting <postmaster@castleamber.com>
    Re: getting and posting <postmaster@castleamber.com>
    Re: getting and posting <segraves_f13@mindspring.com>
    Re: Is this considered ugly? <someone@example.com>
    Re: Is this considered ugly? <jgibson@mail.arc.nasa.gov>
        List hard drives on remote servers <"romain19 chez free point fr">
    Re: Log files in a Date / Time Stamped Directory <manzoorul.hassan@gmail.com>
    Re: Log files in a Date / Time Stamped Directory <mritty@gmail.com>
    Re: Log files in a Date / Time Stamped Directory <manzoorul.hassan@gmail.com>
    Re: Log files in a Date / Time Stamped Directory <mritty@gmail.com>
    Re: Log files in a Date / Time Stamped Directory <manzoorul.hassan@gmail.com>
    Re: Log files in a Date / Time Stamped Directory <matternc@comcast.net>
    Re: Log files in a Date / Time Stamped Directory <1usa@llenroc.ude.invalid>
    Re: Log files in a Date / Time Stamped Directory <manzoorul.hassan@gmail.com>
    Re: Log files in a Date / Time Stamped Directory <1usa@llenroc.ude.invalid>
    Re: Pattern Matching <mritty@gmail.com>
    Re: Perl equiv to PHP print_r <jboes@qtm.net>
        Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)

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

Date: Thu, 17 Mar 2005 20:38:16 +0000
From: "Alan J. Flavell" <flavell@ph.gla.ac.uk>
To: PerlFAQ Server <comdog@panix.com>
Subject: Re: FAQ 9.1 What is the correct form of response from a CGI script?
Message-Id: <Pine.LNX.4.61.0503172028100.2652@ppepc56.ph.gla.ac.uk>


[posted and emailed...]

On Wed, 16 Mar 2005, PerlFAQ Server wrote:

> 9.1: What is the correct form of response from a CGI script?
> 
>     (Alan Flavell <flavell+www@a5.ph.gla.ac.uk> answers...)
[1]

[...]
>     The original CGI specification is at: http://hoohoo.ncsa.uiuc.edu/cgi/
> 
>     Current best-practice RFC draft at: http://CGI-Spec.Golux.Com/
                            ^^^^^^^^^

Hi, brian...

That "draft" has meantime appeared as an informational RFC:  
http://www.ietf.org/rfc/rfc3875

It would be nice to update the FAQ to reflect that, I think.


While I'm here, folks, do you think that text:

    The Common Gateway Interface (CGI) specifies a software interface
    between a program ("CGI script") and a web server (HTTPD). It is
    not specific to Perl, and has its own FAQs and tutorials, and 
    usenet group, comp.infosystems.www.authoring.cgi

is forceful enough, or do you think the FAQ needs something more 
militant to discourage non-Perl-specific CGI questions here?  I'm
sure suggestions would be welcomed.

all the best


[1] that address is obsolescent, but no matter - it'll put the 
spammers off...


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

Date: Thu, 17 Mar 2005 15:59:18 -0500
From: Madhusudhanan Chandrasekaran <mc79@cse.buffalo.edu>
Subject: getting and posting
Message-Id: <d1cr36$sva$1@prometheus.acsu.buffalo.edu>

Hi,

    I am a perl newbie. All I want is to get any web page, 
see if it has any form and fields (i.e. like username, 
passwd) etc and post my information to it and get back the 
response. I would maintain the username and passwd my database.

Thanks,
Madhu


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

Date: Thu, 17 Mar 2005 16:12:55 -0500
From: Sherm Pendley <spamtrap@dot-app.org>
Subject: Re: getting and posting
Message-Id: <SOWdncWhTZ5Fb6TfRVn-gQ@adelphia.com>

Madhusudhanan Chandrasekaran wrote:

>     I am a perl newbie. All I want is to get any web page,
> see if it has any form and fields (i.e. like username,
> passwd) etc and post my information to it and get back the
> response. I would maintain the username and passwd my database.

Have a look at the WWW::Mechanize module on CPAN.

sherm--

-- 
Cocoa programming in Perl: http://camelbones.sourceforge.net
Hire me! My resume: http://www.dot-app.org


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

Date: Thu, 17 Mar 2005 13:11:00 -0800
From: Keith Keller <kkeller-usenet@wombat.san-francisco.ca.us>
Subject: Re: getting and posting
Message-Id: <jc8pg2xg1b.ln2@goaway.wombat.san-francisco.ca.us>

On 2005-03-17, Madhusudhanan Chandrasekaran <mc79@cse.buffalo.edu> wrote:
>
>     I am a perl newbie. All I want is to get any web page, 
> see if it has any form and fields (i.e. like username, 
> passwd) etc and post my information to it and get back the 
> response. I would maintain the username and passwd my database.

That's fabulous.  Do you have code that's not working that you
need help debugging?  You should probably post it if you do (and
you should also read the Posting Guidelines that are posted here
periodically).

--keith

-- 
kkeller-usenet@wombat.san-francisco.ca.us
(try just my userid to email me)
AOLSFAQ=http://wombat.san-francisco.ca.us/cgi-bin/fom
see X- headers for PGP signature information



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

Date: Thu, 17 Mar 2005 14:17:01 -0700
From: Jeff <Im.so.HuckinFappy@spamgourmet.com>
Subject: Re: getting and posting
Message-Id: <d1cs4e$3o12@xco-news.xilinx.com>

Madhusudhanan Chandrasekaran wrote:
>    I am a perl newbie. All I want is to get any web page, see if it has 
> any form and fields (i.e. like username, passwd) etc and post my 
> information to it and get back the response. I would maintain the 
> username and passwd my database.

Is there a perl question here?

Are you looking for someone to write you a script?  If so, there are 
websites and newsgroups dedicated to finding perl developers to hire.

What have you tried?  What didn't work?

As has been said many times, this is a discussion group, not a help 
desk.  Show us what you tried, and we'll discuss why it isn't working.

~Jeff


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

Date: 17 Mar 2005 21:35:44 GMT
From: John Bokma <postmaster@castleamber.com>
Subject: Re: getting and posting
Message-Id: <Xns961C9EA566E17castleamber@130.133.1.4>

Keith Keller wrote:

> On 2005-03-17, Madhusudhanan Chandrasekaran <mc79@cse.buffalo.edu> wrote:
>>
>>     I am a perl newbie. All I want is to get any web page, 
>> see if it has any form and fields (i.e. like username, 
>> passwd) etc and post my information to it and get back the 
>> response. I would maintain the username and passwd my database.
> 
> That's fabulous.  Do you have code that's not working that you
> need help debugging?  You should probably post it if you do (and
> you should also read the Posting Guidelines that are posted here
> periodically).

Maybe you should stop replying like this and read the Posting Guidelines 
yourself.

The OP just asks for pointers, and one can ask that without showing code, 
see reply by Sherm.

If you have nothing to post, get a different hobby. Learn some Perl.

-- 
John                   Small Perl scripts: http://johnbokma.com/perl/
               Perl programmer available:     http://castleamber.com/
            Happy Customers: http://castleamber.com/testimonials.html
                        


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

Date: 17 Mar 2005 21:36:39 GMT
From: John Bokma <postmaster@castleamber.com>
Subject: Re: getting and posting
Message-Id: <Xns961C9ECD2CA82castleamber@130.133.1.4>

Jeff wrote:

> Madhusudhanan Chandrasekaran wrote:
>>    I am a perl newbie. All I want is to get any web page, see if it has 
>> any form and fields (i.e. like username, passwd) etc and post my 
>> information to it and get back the response. I would maintain the 
>> username and passwd my database.
> 
> Is there a perl question here?

Yes.

> What have you tried?  What didn't work?

Maybe the OP wants a reply like Sherm gave?

> As has been said many times, this is a discussion group, not a help 
> desk.  Show us what you tried, and we'll discuss why it isn't working.

Or split a few more hairs.

-- 
John                   Small Perl scripts: http://johnbokma.com/perl/
               Perl programmer available:     http://castleamber.com/
            Happy Customers: http://castleamber.com/testimonials.html
                        


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

Date: Thu, 17 Mar 2005 22:43:14 GMT
From: "Bill Segraves" <segraves_f13@mindspring.com>
Subject: Re: getting and posting
Message-Id: <6Kn_d.12297$qf2.3285@newsread2.news.atl.earthlink.net>

"Madhusudhanan Chandrasekaran" <mc79@cse.buffalo.edu> wrote in message
news:d1cr36$sva$1@prometheus.acsu.buffalo.edu...
> Hi,
>
>     I am a perl newbie. All I want is to get any web page,
> see if it has any form and fields (i.e. like username,
> passwd) etc and post my information to it and get back the
> response. I would maintain the username and passwd my database.

Randal L. Schwartz wrote an excellent article on "Automatically Testing a
Form" in the (now defunct) magazine, _Web Techniques_, that should be
helpful to you. Here's a direct link to the article:

http://www.stonehenge.com/merlyn/WebTechniques/col43.html

IMO, Randal's Stonehenge site should be one of your "Go To" places when
you're looking to see if your problem has already been solved by an expert.

Enjoy!
--
Bill Segraves






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

Date: Thu, 17 Mar 2005 21:51:07 GMT
From: "John W. Krahn" <someone@example.com>
Subject: Re: Is this considered ugly?
Message-Id: <fZm_d.63361$gJ3.25009@clgrps13>

Paul Lalli wrote:
> "Kristo" <kristo605@gmail.com> wrote in message
> news:1111070399.123733.168230@f14g2000cwb.googlegroups.com...
> 
>>I'm in the process of learning Perl and I'm wondering if there's a
>>preferred way to do the following.  I have a list of strings that
>>potentially will contain ampersands.  I'd like to replace all
>>occurrances of & with &amp; for use on a webpage.  Here's what I have
>>so far:
>>
>>use warnings;
>>use strict;
>>
>>my ($foo, $bar, $baz) = ("A&B", "C&D", "E&F");
>>foreach (($foo, $bar, $baz))
>>{
>>     s/&/&amp;/g;
>>}
>>print "Foo = $foo, Bar = $bar, Baz = $baz\n";
>>__END__
>>
>>This outputs "Foo = A&amp;B, Bar = C&amp;D, Baz = E&amp;F" as
> 
> expected.
> 
>>The reason I chose to name each element of the list was so I could use
>>the strings later and retain an idea of what each element represented.
>>Now, in an attempt to be more concise, I came up with this:
>>
>>use warnings;
>>use strict;
>>
>>my @foo = ("A&B", "C&D", "E&F");
>>foreach (@foo)
>>{
>>     s/&/&amp;/g;
>>}
>>print "Foo = $foo[0], Bar = $foo[1], Baz = $foo[2]\n";
>>__END__
>>
>>I've succeeded in making the code shorter but at the cost of having to
>>remember which list element goes with each subscript.  My question to
>>everyone is this: which approach is more "Perlish"?
> 
> 
> Neither. :)
> 
> Hashes are used exactly for this reason - to associate a string with the
> value in that position of the structure.
> 
> my %strs = (Foo=>'A&B', Bar=>'C&D', Baz=>'E&F');
> foreach (keys %strs){
>   $strs{$_} =~ s/&/&amp;/g;
> }

And remember that hash keys can't be modified so this will work:

foreach (%strs)
{
      s/&/&amp;/g;
}


$ perl -le'
my %strs = qw( Foo A&B Bar C&D Baz E&F );
print for %strs;
s/&/&amp;/g for %strs;
print for %strs;
'
Bar
C&D
Baz
E&F
Foo
A&B
Bar
C&amp;D
Baz
E&amp;F
Foo
A&amp;B




John
-- 
use Perl;
program
fulfillment


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

Date: Thu, 17 Mar 2005 14:34:31 -0800
From: Jim Gibson <jgibson@mail.arc.nasa.gov>
Subject: Re: Is this considered ugly?
Message-Id: <170320051434314458%jgibson@mail.arc.nasa.gov>

In article <fZm_d.63361$gJ3.25009@clgrps13>, John W. Krahn
<someone@example.com> wrote:

> Paul Lalli wrote:
> > "Kristo" <kristo605@gmail.com> wrote in message
> > news:1111070399.123733.168230@f14g2000cwb.googlegroups.com...
> > 

[problem modifying values in a hash snipped]

> And remember that hash keys can't be modified so this will work:
> 
> foreach (%strs)
> {
>       s/&/&amp;/g;
> }

So you are going to attempt something impossible that you don't really
want to do because you know the compiler won't let you?

Why not just:

   foreach ( values %strs ) {
      s/&/&amp;/g;
   }

which might not confuse a potential reader.


----== Posted via Newsfeeds.Com - Unlimited-Uncensored-Secure Usenet News==----
http://www.newsfeeds.com The #1 Newsgroup Service in the World! >100,000 Newsgroups
---= East/West-Coast Server Farms - Total Privacy via Encryption =---


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

Date: Thu, 17 Mar 2005 21:00:44 +0100
From: Romain <"romain19 chez free point fr">
Subject: List hard drives on remote servers
Message-Id: <4239e1a2$0$27995$626a14ce@news.free.fr>

Hi,

First of all, I'm sorry for many mistakes that I could write because I'm 
French ...

So ! I have to list hard drives on remote servers (in a full Windows 
environnment). A Perl script is running on only one server. With the 
server hostname, I will give back these hard drives. In fact, I just 
have to have drives letters. I try the Win32::NetAdmin::GetServerDisks() 
function, but it returns *all* fixed drives, including floppy and cd-rom 
drives. Floppy isn't really a problem, because I remove the "A:" letter, 
but for the cd-rom, I don't know which letter it's represent.

Is a function that returns only hard drives exists ? And can it be used 
remotely ?


Thanks for your help,


Best regards,


;-) Romain
(Once, sorry for my bad english...)


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

Date: 17 Mar 2005 11:25:02 -0800
From: "Manzoorul Hassan" <manzoorul.hassan@gmail.com>
Subject: Re: Log files in a Date / Time Stamped Directory
Message-Id: <1111087502.046821.89690@l41g2000cwc.googlegroups.com>

OK, I tried the following for the Date and it works:

#!/usr/bin/perl -l
use Time::localtime;
$time = localtime;

printf ("%04d%02d%02d\n", $time->year+1900, $time->mon+1, $time->mday);
printf ("%02d%02d\n", $time->hour, $time->min);

But I can't store this as a value for my Date and Time Dir to be opened
/ created.

- manzoor



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

Date: Thu, 17 Mar 2005 19:39:06 GMT
From: "Paul Lalli" <mritty@gmail.com>
Subject: Re: Log files in a Date / Time Stamped Directory
Message-Id: <u1l_d.5340$db6.1754@trndny02>

"Manzoorul Hassan" <manzoorul.hassan@gmail.com> wrote in message
news:1111087502.046821.89690@l41g2000cwc.googlegroups.com...
> OK, I tried the following for the Date and it works:
>

To whom are you speaking?  Have you read the posting guidelines for this
group?  Please quote an appropirate amount of context.

> #!/usr/bin/perl -l

you forgot use strict; and use warnings;

> use Time::localtime;
> $time = localtime;
>
> printf ("%04d%02d%02d\n", $time->year+1900, $time->mon+1,
$time->mday);
> printf ("%02d%02d\n", $time->hour, $time->min);
>
> But I can't store this as a value for my Date and Time Dir to be
opened
> / created.

Why can't you?  What have you tried that failed?

Or do you just mean that you "can't" because printf() prints to the
screen instead of storing to a variable?   That's what printf() does.
It's cousin sprintf(), on the other hand, returns the formatted string.
Perhaps that's what you're looking for?

Paul Lalli



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

Date: 17 Mar 2005 12:21:12 -0800
From: "Manzoorul Hassan" <manzoorul.hassan@gmail.com>
Subject: Re: Log files in a Date / Time Stamped Directory
Message-Id: <1111090872.198833.155360@g14g2000cwa.googlegroups.com>

well, I was trying to do the following:

$date_val = printf ("%04d%02d%02d\n", $time->year+1900, $time->mon+1,
$time->mday);
opendir(DIR, "$date_val) || die "Cannot open Dir\n";

That didn't work. Now I am trying with the sprintf, but still not
opening.

- manzoor



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

Date: Thu, 17 Mar 2005 20:23:57 GMT
From: "Paul Lalli" <mritty@gmail.com>
Subject: Re: Log files in a Date / Time Stamped Directory
Message-Id: <xHl_d.5591$u76.5292@trndny08>


"Manzoorul Hassan" <manzoorul.hassan@gmail.com> wrote in message
news:1111090872.198833.155360@g14g2000cwa.googlegroups.com...
> well, I was trying to do the following:
>
> $date_val = printf ("%04d%02d%02d\n", $time->year+1900, $time->mon+1,
> $time->mday);

This is non-sensical.  printf() prints a string to the screen.
sprintf() returns the string.

> opendir(DIR, "$date_val) || die "Cannot open Dir\n";
>
> That didn't work.

Of course not.  It's a syntax error.  Post real code.

> Now I am trying with the sprintf, but still not opening.

Post your real code that is failing, along with the error messages you
are receiving.  It's not possible to help you otherwise.

Paul Lalli



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

Date: 17 Mar 2005 12:38:01 -0800
From: "Manzoorul Hassan" <manzoorul.hassan@gmail.com>
Subject: Re: Log files in a Date / Time Stamped Directory
Message-Id: <1111091881.072282.83000@o13g2000cwo.googlegroups.com>

#!/usr/bin/perl

use Time::localtime;
$time = localtime;

$date = sprintf ("%04d%02d%02d\n", $time->year+1900, $time->mon+1,
$time->mday);
opendir(DATE_DIR, "$date") || die "Cannot open directory";

closedir(DATE_DIR);



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

Date: Thu, 17 Mar 2005 15:51:28 -0500
From: Chris Mattern <matternc@comcast.net>
Subject: Re: Log files in a Date / Time Stamped Directory
Message-Id: <jLednUbBvaVNcKTfRVn-iA@comcast.com>

Manzoorul Hassan wrote:

> #!/usr/bin/perl
> 
> use Time::localtime;
> $time = localtime;
> 
> $date = sprintf ("%04d%02d%02d\n", $time->year+1900, $time->mon+1,
> $time->mday);
> opendir(DATE_DIR, "$date") || die "Cannot open directory";
> 
> closedir(DATE_DIR);

And what, exactly, is this code supposed to do?  Because, as near as
I can tell, it doesn't do anything, other than die with "Cannot open
directory" if the directory in $date doesn't exist.
-- 
             Christopher Mattern

"Which one you figure tracked us?"
"The ugly one, sir."
"...Could you be more specific?"


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

Date: Thu, 17 Mar 2005 20:52:18 GMT
From: "A. Sinan Unur" <1usa@llenroc.ude.invalid>
Subject: Re: Log files in a Date / Time Stamped Directory
Message-Id: <Xns961CA17572FBFasu1cornelledu@127.0.0.1>

"Manzoorul Hassan" <manzoorul.hassan@gmail.com> wrote in 
news:1111091881.072282.83000@o13g2000cwo.googlegroups.com:

Please make an effort to compose proper follow-ups by quoting an 
appropriate amount of context. Please *read* and *follow* the posting 
guidelines for this group.

> #!/usr/bin/perl

use strict;
use warnings;

missing.

> use Time::localtime;
> $time = localtime;

my $time = localtime;

> $date = sprintf ("%04d%02d%02d\n", $time->year+1900, $time->mon+1,
> $time->mday);

my $date = sprintf(
    q{%04d%02d%02d}, 
    $time->year + 1900,
    $time->mon + 1,
    $time->mday
);

Did you really, really want that \n in the directory name?

> opendir(DATE_DIR, "$date") || die "Cannot open directory";

opendir my $dir, $date or die "Cannot open $date: $!";

Get all the help you can from perl. See also:

perldoc -q always

Putting it all together:

#! /usr/bin/perl

use strict;
use warnings;

use Time::localtime;
my $time = localtime;

my $date = sprintf(
    q{%04d%02d%02d}, 
    $time->year + 1900,
    $time->mon + 1,
    $time->mday
);

opendir my $dir, $date or die "Cannot open $date: $!";

# do something

closedir $dir;

__END__

D:\Home> v
Cannot open 20050317: No such file or directory at D:\Home\v.pl line 16.

Sinan.


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

Date: 17 Mar 2005 14:00:59 -0800
From: "Manzoorul Hassan" <manzoorul.hassan@gmail.com>
Subject: Re: Log files in a Date / Time Stamped Directory
Message-Id: <1111096859.101869.148590@f14g2000cwb.googlegroups.com>

Thanx to everyone for your paitience and help. After all of this, I
have finally realized that this does not create a new directory. I was
hoping to have a directory, and a subdirectory, created to store all
the log files. But I guess, I'll just use the Date as part of the
filename of the log.

- manzoor



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

Date: Thu, 17 Mar 2005 22:17:02 GMT
From: "A. Sinan Unur" <1usa@llenroc.ude.invalid>
Subject: Re: Log files in a Date / Time Stamped Directory
Message-Id: <Xns961CAFD2B88D2asu1cornelledu@127.0.0.1>

"Manzoorul Hassan" <manzoorul.hassan@gmail.com> wrote in 
news:1111096859.101869.148590@f14g2000cwb.googlegroups.com:

> Thanx to everyone for your paitience and help.

You are welcome.

> After all of this, I have finally realized that this does not create a 
> new directory. 

"this" does indeed not create a directory. For that, you'll need to use 
the appropriate function, as was suggested in an earlier post:

perldoc -f mkdir

If you had taken a little bit of care in composing your follow-ups 
carefully, I would have known about your original purpose.

> I was hoping to have a directory, and a subdirectory, 
> created to store all the log files. 

What, apart from not bothering to read documentation, is stopping you 
from doing that?

> But I guess, I'll just use the Date as part of the filename of 
> the log.

Whatever floats your boat.

Sinan.


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

Date: Thu, 17 Mar 2005 19:15:58 GMT
From: "Paul Lalli" <mritty@gmail.com>
Subject: Re: Pattern Matching
Message-Id: <OHk_d.16239$FB6.3655@trndny09>

"Barry_Alder" <alder.bw@forces.gc.ca> wrote in message
news:6d79eff22f7c1464fd922cf92db6c370@localhost.talkaboutprogramming.com...
> First of all, thank you all for the quick response.

To whom are you speaking?

>
> Secondly, mea culpa, mea culpa, mea culpa. In my rush to simplify the
> explanation, I didn't give a clean example.
>
> The following is the test program I am using.
> =================================
> open (MOD, "bec2.xml");

1) Always, *always* check the return value of open().  You have no way
of knowing whether or not this file succeeded.
2) Lexical file handles are preferred over global barewords:
open my $mod, 'bec2.xml' or die "Could not open file: $!";

> @ModLines = <MOD>;
> $t2 = 'BFAX';

You're obviously not using strict.  This is a bad thing.  Always develop
your code with 'use strict;' enabled.  Especially when asking for help.
Have you read the posting guidelines?

>   $TRUE = 1;
>   $icnt = 0;
>   while ( $TRUE )

Why are you creating a separate variable for this?  Why not simply
while (1) {
?

Regardless, creating an infinite loop, and breaking out of it within the
loop itself, is poor style.

>     {
>      $t4 = @Modlines[$icnt];

If you'd enabled warnings, you'd know why this line is bad.

perldoc -q difference
(fourth entry)

Far more importantly, if you'd used strict, you'd know why this line is
the source of your entire problem.  Take a closer look at that variable
name.

>      $t3 = index ($t4 , $t2);

What on earth are all these variables?  Please choose meaningful
variable names.

>      print "index is $t3: @ModLines[$icnt]\n";
>      $icnt++;
>      if ($icnt > $#ModLines )
>        { exit 0 ; }
>     }

This entire loop should be re-written:

foreach my $line (@Modlines) {
  my $idx = index ($line, $t2);
  print "Index is $idx: $line\n";
}

<XML File and output snipped>

> Note that the input line that does contain the 'BFAX' string didn' get
> matched.

No it didn't.  Because you didn't provide an appropriate string to match
to.

>
> Can anyone suggest how I can process the file to get a match. Note
that
> this is only a test file and the real-life file will be more
complicated
> and bigger.

By cleaning your code, and ALWAYS enabling strict and warnings

Paul Lalli



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

Date: Thu, 17 Mar 2005 16:43:05 -0500
From: Jeff Boes <jboes@qtm.net>
Subject: Re: Perl equiv to PHP print_r
Message-Id: <1111095787.5145c5c1fa376c02cc145041eab58eba@teranews>

Aidan wrote:
> Hi Perl Peoples,
> 
> I'm quit new to perl, but have a pretty good knowledge of PHP.  I'm playing 
> around with a few packages, and I'm having a bit of trouble figuring out how 
> to deal with hashes.  In PHP, if I wanted to view the contents of $hash, all 
> I needed to do would be dump it out by using:
> 
> <? print_r($hash); ?>
> 
> And I would get a nice heirachial display of the data contained within 
> $hash.  Is there an equivalent function in Perl?  I'm sure there is, but 
> after much googling, I still can't find what it is... can anyone here tell 
> me what it is?
> 
> TIA
> 
> Aidan
> 

There may be others, but the best I've found is:

use strict;
use Data::Dumper;
my %hash = ('key1' => 'aaa',
             'key2' => { 'sub1' => '2bbb', 'sub2' => '2ccc' },
            );
print Dumper( \%hash );

which produces:

$VAR1 = {
           'key2' => {
                       'sub1' => '2bbb',
                       'sub2' => '2ccc'
                     },
           'key1' => 'aaa'
         };




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

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.  

NOTE: due to the current flood of worm email banging on ruby, the smtp
server on ruby has been shut off until further notice. 

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


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