[22348] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 4569 Volume: 10

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Sat Feb 15 06:06:10 2003

Date: Sat, 15 Feb 2003 03:05:07 -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           Sat, 15 Feb 2003     Volume: 10 Number: 4569

Today's topics:
    Re: Bad Output from Perldoc (James Willmore)
        case insensitive hash key comparison (squillion)
    Re: case insensitive hash key comparison <goldbb2@earthlink.net>
    Re: case insensitive hash key comparison <krahnj@acm.org>
        code to change a word in a file? <dbruno@ucla.edu>
    Re: code to change a word in a file? <andrew.rich@bigpond.com>
    Re: code to change a word in a file? <jurgenex@hotmail.com>
    Re: code to change a word in a file? <usenet@dwall.fastmail.fm>
    Re: Copying the contents of a directory <goldbb2@earthlink.net>
    Re: Easy filter running for Win32 GUI users <goldbb2@earthlink.net>
    Re: Easy filter running for Win32 GUI users <nmihai_2000@yahoo.com>
        help spotting the obvious - regex <nwzmattXX@XXnetscape.net>
    Re: help spotting the obvious - regex <krahnj@acm.org>
    Re: help spotting the obvious - regex (Jay Tilton)
    Re: help spotting the obvious - regex <nwzmattXX@XXnetscape.net>
    Re: help spotting the obvious - regex <nwzmattXX@XXnetscape.net>
    Re: how to do string concatenation <jurgenex@hotmail.com>
        New JAPH <goldbb2@earthlink.net>
        one liner in command line <dbruno@ucla.edu>
        Perl my variable question (AB)
    Re: Perl my variable question (Jay Tilton)
    Re: read content_len with use:cgi <me@privacy.net>
        Retrieving Network Shares <sapbasis2003@netscape.net>
    Re: String Compare Help <jurgenex@hotmail.com>
    Re: sysread and length <goldbb2@earthlink.net>
        Unable to load modules <brian.smart@blueyonder.co.uk>
        Yet Another Regex Question... <bfons.rmv@usermail.com>
        Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)

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

Date: 14 Feb 2003 19:49:33 -0800
From: jwillmore@cyberia.com (James Willmore)
Subject: Re: Bad Output from Perldoc
Message-Id: <e0160815.0302141949.5a848423@posting.google.com>

Have you tried 'perldoc -t <what_ever_else_you_need>'?  I had a
simmilar issue with a Linux box.  There was something funny about
groff and it would print strange characters.  If you use the '-t'
option, it prints the output in text format - then you can pipe the
output through 'more' (or 'less' or what ever else there is as a pager
on your box).

Just a suggestion
HTH

Jim
> the text is not properly left-aligning.  Instead, it is skewing across the
> page as if it were a stack of playing cards being tilted to the right.  Each
> line of POD starts 1 line below the previous but approx 4-14 characters to
> the right of the *last* character in the previous line.  Each line then
> wraps around the edge of the command prompt window, creating the skewing
> effect.  For example, the first few lines of the response to 'perldoc -f
> push' look like this (beware wrapping in your mail reader):
> 
>     push ARRAY, LIST
>                                  Treats ARRAY as a stack, and pushes the
> values of
>  LIST onto the
>                             end of ARRAY. The length of ARRAY increases by
> the len
> gth of
> 
> ... and so forth.


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

Date: 14 Feb 2003 23:40:05 -0800
From: squillion@hotmail.com (squillion)
Subject: case insensitive hash key comparison
Message-Id: <81016f2d.0302142340.502e2735@posting.google.com>

i want to know if a given string is used as a key in a given hash, but
i want the comparison to be case insensitive.  i can assume that the
string will match at most one key - i.e. the hash keys are unique even
when compared case-insensitively.

the code below seems to do the trick -

sub my_defined {
    my ($s,$h)=@_;
    uc($s) eq uc ($_) && return $_ for keys %$h;
    return undef;
}
my %h=qw(key1 val1 key2 val2);
my @test_keys=qw(KEY1 kEy1 xxx);
for (@test_keys) {
    my $key=my_defined($_,\%h);
    if ($key) {
        print "string $_ matches hash key $key\n";
    } else {
        print "string $_ is not a hash key\n";
    }
}

output -
string KEY1 matches hash key key1
string kEy1 matches hash key key1
string xxx is not a hash key

can this be accomplished in a more hip and groovy way?

TIA


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

Date: Sat, 15 Feb 2003 03:30:14 -0500
From: Benjamin Goldberg <goldbb2@earthlink.net>
Subject: Re: case insensitive hash key comparison
Message-Id: <3E4DFA96.322BC90E@earthlink.net>

squillion wrote:
> 
> i want to know if a given string is used as a key in a given hash, but
> i want the comparison to be case insensitive.  i can assume that the
> string will match at most one key - i.e. the hash keys are unique even
> when compared case-insensitively.
[snip]
> can this be accomplished in a more hip and groovy way?

Consider simply performing uc() on all keys, when putting the data in,
and when accessing.

my %h = qw(key1 val1 key2 val2);
my @need_to_change = grep /[[:lower:]]/, keys %h;
@h{map uc, @need_to_change} = delete @h{@need_to_change};

sub my_exists {
   my ($str, $h) = @_;
   return exists $h->{uc $str};
}

my @test_keys=qw(KEY1 kEy1 xxx);

for (@test_keys) {
    if (my_exists($_,\%h)) {
        print "string $_ is a hash key\n";
    } else {
        print "string $_ is not a hash key\n";
    }
}


-- 
"So, who beat the clueless idiot today?"
"Well, we flipped for it, but when Kuno
 landed, he wasn't in any shape to fight."
"Next time, try flipping a *coin.*"


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

Date: Sat, 15 Feb 2003 09:53:10 GMT
From: "John W. Krahn" <krahnj@acm.org>
Subject: Re: case insensitive hash key comparison
Message-Id: <3E4E0DC9.B9C67D1@acm.org>

squillion wrote:
> 
> i want to know if a given string is used as a key in a given hash, but
> i want the comparison to be case insensitive.  i can assume that the
> string will match at most one key - i.e. the hash keys are unique even
> when compared case-insensitively.

Get the Tie::CPHash module from CPAN.

http://search.cpan.org/author/CJM/Tie-CPHash-1.001/


John
-- 
use Perl;
program
fulfillment


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

Date: Fri, 14 Feb 2003 21:34:11 -0800
From: "David Bruno" <dbruno@ucla.edu>
Subject: code to change a word in a file?
Message-Id: <b2kjh0$aft$1@zinnia.noc.ucla.edu>

Hi,
I'm trying to make a script change one word in a file.
I saw this in an archive of this newsgroup:
"% perl -pi.bak -e 's/word1/word2/'  file_name;"

I tried this, but only got errors.  Is there a module I need
to use to get this to work?  Does the file have to be opened first?

If it's any help, the word I want to change is at a fixed place in the file.
that is, I know the line number....it's not like I need to search for the
word.

thanks,
David




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

Date: Sat, 15 Feb 2003 15:47:31 +1000
From: "Andrew Rich" <andrew.rich@bigpond.com>
Subject: Re: code to change a word in a file?
Message-Id: <kfk3a.47865$jM5.119350@newsfeeds.bigpond.com>

`touch xxxxxxx`

On Fri, 14 Feb 2003 21:34:11 +0000, David Bruno wrote:

> Hi,
> I'm trying to make a script change one word in a file.
> I saw this in an archive of this newsgroup:
> "% perl -pi.bak -e 's/word1/word2/'  file_name;"
> 
> I tried this, but only got errors.  Is there a module I need
> to use to get this to work?  Does the file have to be opened first?
> 
> If it's any help, the word I want to change is at a fixed place in the file.
> that is, I know the line number....it's not like I need to search for the
> word.
> 
> thanks,
> David



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

Date: Sat, 15 Feb 2003 05:55:57 GMT
From: "Jürgen Exner" <jurgenex@hotmail.com>
Subject: Re: code to change a word in a file?
Message-Id: <NDk3a.18069$rE3.7688@nwrddc01.gnilink.net>

David Bruno wrote:
> I'm trying to make a script change one word in a file.

perldoc -q change:
  How do I change one line in a file/delete a line in a file/insert a line
in th
e middle of a file/append to the beginning of a file?

jue




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

Date: Sat, 15 Feb 2003 07:26:26 GMT
From: "David K. Wall" <usenet@dwall.fastmail.fm>
Subject: Re: code to change a word in a file?
Message-Id: <Xns932318D41C56Bdkwwashere@63.240.76.16>

"Andrew Rich" <andrew.rich@bigpond.com> wrote:

> On Fri, 14 Feb 2003 21:34:11 +0000, David Bruno wrote:
> 
>> Hi,
>> I'm trying to make a script change one word in a file.
>> I saw this in an archive of this newsgroup:
>> "% perl -pi.bak -e 's/word1/word2/'  file_name;"
>> 
>> I tried this, but only got errors.  Is there a module I need
>> to use to get this to work?  Does the file have to be opened first?
>
> `touch xxxxxxx`

That's not even wrong; it has nothing to do with the question.  And you 
top-posted, too.

David: listen to Jürgen and read the FAQ entry.

-- 
David Wall - usenet@dwall.fastmail.fm
"Oook."


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

Date: Sat, 15 Feb 2003 01:59:42 -0500
From: Benjamin Goldberg <goldbb2@earthlink.net>
Subject: Re: Copying the contents of a directory
Message-Id: <3E4DE55E.38B75B7C@earthlink.net>

Steve wrote:
> 
> I've been able to successfully copy individual files from one
> directory to another using
> 
> use File::Copy;
> copy("$sourcedir/$filename", "$destinationdir/" . "$filename");
> 
> but have had no luck copying the entire contents of the directory.
> 
> I would appreciate any suggestions.

   use File::NCopy;
   copy \1, $sourcedir, $destinationdir;


-- 
"So, who beat the clueless idiot today?"
"Well, we flipped for it, but when Kuno
 landed, he wasn't in any shape to fight."
"Next time, try flipping a *coin.*"


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

Date: Sat, 15 Feb 2003 01:30:44 -0500
From: Benjamin Goldberg <goldbb2@earthlink.net>
Subject: Re: Easy filter running for Win32 GUI users
Message-Id: <3E4DDE94.48F9B383@earthlink.net>

Phil Hibbs wrote:
> 
> I have written a few perl scripts to reformat text, and I want to make
> them easy to use for end users that don't like the Command Line on
> their Windows machines.
> 
> Currently, the script takes stdin and prints to stdout, but that means
> the user has to put '< input.dat > output.dat' at the end of the
> command line, which is less than friendly. Ideally, I'd like them to
> be able to do it all with the mouse.
> 
> Any ideas how I can set this up?
> 
> I'm thinking about implementing them as clipboard processors instead
> of stream processors. Then, bind the .cmd file to a keypress via a
> Start menu shortcut, so the user does Ctrl-A (select all), Ctrl-C
> (copy), Ctrl-Shift-T (runs transform script), then Ctrl-V to paste the
> transformed text back in. This would not be good for large volumes of
> data, though, and some of our files are many megabytes.

   use Win32::Clipboard;
   my $clip = Win32::Clipboard->new();
   if( $clip->IsFiles ) {
      @ARGV = $clip->GetFiles;
      $^I = ".bak";
      while( <> ) {
         # transform $_ here.
      }
   } elsif( $clip->IsText ) {
      my $data = $clip->GetText;
      # transform $data.
      $clip->Set($data);
   } else {
      die "Don't know how to transform clipboard
   }
   __END__
[untested]      

If the file is big, have your user select it in Explorer, then copy the
file icon, and then run the program through the shortcut.  This will go
into the IsFiles branch of code, and modify your files in-place.

-- 
"So, who beat the clueless idiot today?"
"Well, we flipped for it, but when Kuno
 landed, he wasn't in any shape to fight."
"Next time, try flipping a *coin.*"


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

Date: Sat, 15 Feb 2003 08:33:06 GMT
From: "Mihai N." <nmihai_2000@yahoo.com>
Subject: Re: Easy filter running for Win32 GUI users
Message-Id: <Xns932359FD692CMihaiN@63.240.76.16>

> Currently, the script takes stdin and prints to stdout, but that means
> the user has to put '< input.dat > output.dat' at the end of the
> command line, which is less than friendly. Ideally, I'd like them to
> be able to do it all with the mouse.
> 
> Any ideas how I can set this up?

You can create a bat file starting your script:

@echo off
perl d:\tst.pl %1 %2 %3 %4 %5 %6 %7 %8 %9

You can create a link to the bat, with a nice icon, maybe on the desktop.
When you drag a file to the icon, the bat is called with the file name as 
parameters. If you drag more than one file, the names are in @ARGV
You can name the result files based on the original file names
(i.e. something.txt => something_sorted.txt, is the perl script is sorting)

Problem: only 9 parameters

A more elaborate solution: a C/C++ application, with nice UI, calling your 
perl script with exec. Or creating a perl interpreter inside your 
application (see perlembed).
For something this simple I would not go all the way to install Tk.

Mihai


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

Date: Fri, 14 Feb 2003 23:56:52 GMT
From: Matt <nwzmattXX@XXnetscape.net>
Subject: help spotting the obvious - regex
Message-Id: <uof5eju97.fsf@XXnetscape.net>


Can someone help me spot what's going on here. It's probably obvious,
but I can't seem to catch it.

I have a simple regex:

        $text =~ s/([^\\]|^)&/$1&amp;/g;

to me this says - substitute anything other than a `\' or a beginning
of a line, followed by an ampersand, and replace it with the first
match plus `&amp;'.

It works fine, until the string has two &'s together. It then seems to
skip the second match.

Example:

        ##
        my $text="& & some stuff";
        $text =~ s/([^\\]|^)&/$1&amp;/g;
        ##

        Output: 
                &amp; &amp; some stuff


        ##
        my $text="&& some stuff";
        $text =~ s/([^\\]|^)&/$1&amp;/g;
        ##

        Output:
                &amp;& some stuff


In the second case, shouldn't it sub the first match, making the
string "&amp;& some stuff", then match the `;&' and substitute it with
`;&amp' ?


TIA -- Matt
         
-- 
Remove the X's to reply directly.


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

Date: Sat, 15 Feb 2003 00:12:48 GMT
From: "John W. Krahn" <krahnj@acm.org>
Subject: Re: help spotting the obvious - regex
Message-Id: <3E4D85C4.D025B769@acm.org>

Matt wrote:
> 
> Can someone help me spot what's going on here. It's probably obvious,
> but I can't seem to catch it.
> 
> I have a simple regex:
> 
>         $text =~ s/([^\\]|^)&/$1&amp;/g;
> 
> to me this says - substitute anything other than a `\' or a beginning
> of a line, followed by an ampersand, and replace it with the first
> match plus `&amp;'.
> 
> It works fine, until the string has two &'s together. It then seems to
> skip the second match.

The problem is that your regular expression has to match TWO characters.

abc&&def
  ^^          match succeeds

abc&amp;&def
        ^^    second match fails

You should use the zero-width negative look-behind assertion.

         $text =~ s/(?<!\\)&/&amp;/g;



John
-- 
use Perl;
program
fulfillment


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

Date: Sat, 15 Feb 2003 00:49:48 GMT
From: tiltonj@erols.com (Jay Tilton)
Subject: Re: help spotting the obvious - regex
Message-Id: <3e4d8ab5.109952882@news.erols.com>

Matt <nwzmattXX@XXnetscape.net> wrote:

:         my $text="&& some stuff";
:         $text =~ s/([^\\]|^)&/$1&amp;/g;
:         ##
: 
:         Output:
:                 &amp;& some stuff
: 
: In the second case, shouldn't it sub the first match, making the
: string "&amp;& some stuff", then match the `;&' and substitute it with
: `;&amp' ?

How many times should this match?

   'xxx' =~ m/xx/g;

Twice?  Nope.  Only once.  Nonzero-width patterns can't match at
overlapping positions in the string.

A zero-width subpattern (negative lookbehind in this case) will get
the job done.

    $text =~ s/(?<!\\)&/&amp;/g;

Or, looking at the most probable reason behind the question, use a
module that does the work for you.

    use HTML::Entities;
    my $text="&& some stuff";
    print encode_entities($text, '&');



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

Date: Sat, 15 Feb 2003 01:03:22 GMT
From: Matt <nwzmattXX@XXnetscape.net>
Subject: Re: help spotting the obvious - regex
Message-Id: <ud6lujr6f.fsf@XXnetscape.net>


"John W. Krahn" <krahnj@acm.org> writes:
> Matt wrote:
> > 
> > Can someone help me spot what's going on here. It's probably obvious,
> > but I can't seem to catch it.
> > 
> > I have a simple regex:
> > 
> >         $text =~ s/([^\\]|^)&/$1&amp;/g;
> > 
> > to me this says - substitute anything other than a `\' or a beginning
> > of a line, followed by an ampersand, and replace it with the first
> > match plus `&amp;'.
> > 
> > It works fine, until the string has two &'s together. It then seems to
> > skip the second match.
> 
> The problem is that your regular expression has to match TWO characters.
> 
> abc&&def
>   ^^          match succeeds
> 
> abc&amp;&def
>         ^^    second match fails
> 
> You should use the zero-width negative look-behind assertion.
> 
>          $text =~ s/(?<!\\)&/&amp;/g;

Thanks John. Not quite sure what that means(not yet at least),
but it works as expected. 


-- Matt

-- 
Remove the X's to reply directly.


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

Date: Sat, 15 Feb 2003 01:19:24 GMT
From: Matt <nwzmattXX@XXnetscape.net>
Subject: Re: help spotting the obvious - regex
Message-Id: <u65rmjqfo.fsf@XXnetscape.net>

tiltonj@erols.com (Jay Tilton) writes:
 
> A zero-width subpattern (negative lookbehind in this case) will get
> the job done.
> 
>     $text =~ s/(?<!\\)&/&amp;/g;
> 
> Or, looking at the most probable reason behind the question, use a
> module that does the work for you.
> 
>     use HTML::Entities;
>     my $text="&& some stuff";
>     print encode_entities($text, '&');
> 

Thanks Jay. I am working on something similar. Basically, I am parsing
user input, and turning it into HTML. The problem with this module and
some others that I looked at is that there is no way for to escape a
*single* instance of a a character, i.e., put a literal `<' in if
match `\<', and encode all the others. This is so that users can add
their own HTML tags if they want to.

-- Matt

-- 
Remove the X's to reply directly.


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

Date: Fri, 14 Feb 2003 23:29:48 GMT
From: "Jürgen Exner" <jurgenex@hotmail.com>
Subject: Re: how to do string concatenation
Message-Id: <MZe3a.17478$rE3.13965@nwrddc01.gnilink.net>

eWisdom wrote:
> I am trying to add two strings like,
> $str1 = "FirstName";
> $str2 = "LastName";
> $str3 = $str1 + " " + $str2;
>
> How can I do this in perl?

What happened when you tried it?
The numerical values of "FirstName", "LastName", and the space " " are all
zero.
So if you add them then you will get 0, just like your code does already.

jue





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

Date: Sat, 15 Feb 2003 03:25:37 -0500
From: Benjamin Goldberg <goldbb2@earthlink.net>
Subject: New JAPH
Message-Id: <3E4DF981.CF176094@earthlink.net>


$,=q=,JtutsarfornreehaPefhkfcl=;$;=25;sub _{
my$__ if 0;++$__;print substr$,,$;&&$__%$;,1
,q;;;--$;;$__>2&&&_;}$,=~tr;f; ;;_ for 1..9;

This is of course dependent on the funky behavior of my $foo if 0;, and
thus is subject to breakage on any future perls which alter that
behavior.

[Tested with AS Perl 5.6.1 build 631]

-- 
"So, who beat the clueless idiot today?"
"Well, we flipped for it, but when Kuno
 landed, he wasn't in any shape to fight."
"Next time, try flipping a *coin.*"


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

Date: Sat, 15 Feb 2003 00:22:15 -0800
From: "David Bruno" <dbruno@ucla.edu>
Subject: one liner in command line
Message-Id: <b2ktca$g4p$1@zinnia.noc.ucla.edu>

how can use a variable in a one line program
if it's in the command line?

can one liners be in the body of the code?




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

Date: 14 Feb 2003 19:39:22 -0800
From: absolsp@yahoo.com (AB)
Subject: Perl my variable question
Message-Id: <333ccbff.0302141939.521227c6@posting.google.com>

I have question regarding my and if statements.  Here is a sample
program

use strict;
sub te {
    my $t = shift;
    my $a = $t if ($t);
    print "- First  Value of a = $a and Address = " , \$a ,"\n";
    $a = 4 if (!$a);
    print "- Second Value of a = $a and Address = ", \$a ,"\n";
}
print "First  Invocation\n";
te();
print "Second Invocation\n";
te(1);
print "Third  Invocation\n";
te();
print "Fourth Invocation\n";
te();
print "Done\n";


Here is the result
First  Invocation
- First  Value of a =  and Address = SCALAR(0x1a45874)
- Second Value of a = 4 and Address = SCALAR(0x1a45874)
Second Invocation
- First  Value of a = 1 and Address = SCALAR(0x1a45874)
- Second Value of a = 1 and Address = SCALAR(0x1a45874)
Third  Invocation
- First  Value of a =  and Address = SCALAR(0x15d4fa4)
- Second Value of a = 4 and Address = SCALAR(0x15d4fa4)
Fourth Invocation
- First  Value of a = 4 and Address = SCALAR(0x15d4fa4) #expecting
null value
- Second Value of a = 4 and Address = SCALAR(0x15d4fa4)
Done


The question I have is on the fourth invocation, the first value of
'a' I was expecting was null but it prints '4', is this a bug in perl
or is this the correct behaviour.  Note in the program if I change the
line
my $a = $t if ($t) 

to 
my $a;
$a = $t if ($t)

then the program behaves as expected (The First value of 'a' in the
fourth invocation is null as expected).  Any insights into this
behaviour would be much appreciated.

thx, 
AB


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

Date: Sat, 15 Feb 2003 06:58:30 GMT
From: tiltonj@erols.com (Jay Tilton)
Subject: Re: Perl my variable question
Message-Id: <3e4dde21.16452586@news.erols.com>

On 14 Feb 2003 19:39:22 -0800, absolsp@yahoo.com (AB) wrote:

: I have question regarding my and if statements.  Here is a sample
: program

[code snipped]

A much simpler demonstration:

    #!perl -l
    use warnings;
    use strict;
    sub foo {
        my $x if 0;
        my $y;
        print ++$x, ' ', ++$y;
    }
    foo() for 1..10;

: The question I have is on the fourth invocation, the first value of
: 'a' I was expecting was null but it prints '4', is this a bug in perl
: or is this the correct behaviour.  Note in the program if I change the
: line
: my $a = $t if ($t) 
: 
: to 
: my $a;
: $a = $t if ($t)
: 
: then the program behaves as expected (The First value of 'a' in the
: fourth invocation is null as expected).  Any insights into this
: behaviour would be much appreciated.

From the "Private Variables via my()" subsection of perlsub:

    NOTE: The behaviour of a my statement modified with a 
    statement modifier conditional or loop construct (e.g. my $x 
    if ...) is undefined. The value of the my variable may be 
    undef, any previously assigned value, or possibly anything 
    else. Don't rely on it. Future versions of perl might do 
    something different from the version of perl you try it out 
    on. Here be dragons.

What you've discovered is a separation of compile time effects (the
variable declaration) and runtime effects (assigning a value to the
variable).  When the if modifier evaluates false, no value is
assigned, not even the undef value one might expect.  The variable
keeps whatever value it had before.

This behavior is fairly startling the first time you see it, but it's
well known.  In the past some have treated it as a feature, using it
to create subroutine lexicals with persistent values.  The docs now do
the Right Thing by disclosing it and discouraging its use.



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

Date: Sat, 15 Feb 2003 16:34:41 +1100
From: "Tintin" <me@privacy.net>
Subject: Re: read content_len with use:cgi
Message-Id: <b2kjhl$1dkkf0$1@ID-172104.news.dfncis.de>


"someuser" <user@someserver123abc.com> wrote in message
news:3E4D6B8E.919035B7@someserver123abc.com...
> why can't I :
>     read(STDIN, $buffer, $ENV{'CONTENT_LENGTH'});
> when I:
> use CGI qw/param/;
> $option=param('option');

A better question is why would you want to do that in the first place.




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

Date: Fri, 14 Feb 2003 23:20:43 -0800
From: Giovanni Davila <sapbasis2003@netscape.net>
Subject: Retrieving Network Shares
Message-Id: <3E4DEA4B.6010506@netscape.net>

I cannot retrieve the shares from a server.
The following is the code I have:

$c_comp=0;
use Win32::NetResource;
if (Win32::NetResource::GetSharedResources(\@Resources, 
RESOURCETYPE_ANY, "MYSERVER"))
{
map
         {
         $c_comp++;
         print "$_\n";
         }
@Resources;
}

Does anybody know what the problem is with the code?

Thank you.



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

Date: Fri, 14 Feb 2003 23:33:42 GMT
From: "Jürgen Exner" <jurgenex@hotmail.com>
Subject: Re: String Compare Help
Message-Id: <q1f3a.17490$rE3.4798@nwrddc01.gnilink.net>

Ryan wrote:
> What is wrong with this?  The evaluation of the strings is wrong
> somehow?

How can we say? You mentioned neither what you expect you code to do nor
what the code actually does. So how can we guess why you think this code is
wrong.

> $name = "abc";
> $testdir = "zxy";
> if($name == $testdir)
> {
>     $result = "True";
> }
> else
> {
>     $result = "False";
> }

For all I can tell this piece of code should set $result to "True". Does it
not do that?

jue




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

Date: Sat, 15 Feb 2003 01:46:04 -0500
From: Benjamin Goldberg <goldbb2@earthlink.net>
Subject: Re: sysread and length
Message-Id: <3E4DE22C.BB07853D@earthlink.net>

"George C. Demetros" wrote:
> 
> Hi.
> 
> How does one determine the right LENGTH to specify on sysread:
> 
> sysread(FILEHANDLE, SCALAR, LENGTH, OFFSET)
> 
> I have file handles that are a socket, a fifo file, and file
> descriptor 3 handle on a pipe.  The data I will be reading can
> vary in length from a few bytes to a whole lot of bytes.  Is there
> an optimum length to select for each type of handle if the data is
> not fixed in length?

Well, sometimes, sorta.

You may be able to do (stat($stream))[11], and find out the optimal
blocksize for reading data -- this might not work for some operating
systems, or if it does, might only work on disk files, not streams.

If you know the proper constant for the ioctl, you could try
   my $n_ready = pack 'L';
   ioctl( $stream, FIONREAD, $n_ready ) or die horribly;
   $n_ready = unpack 'L', $n_ready;
to learn how much data is available, and use that number for how much to
read.  The problem with the ioctl approach is finding out what FIONREAD
needs to be for your OS.  This only works on streams (sockets, pipes,
etc.; essentially anything other than a disk file).

Another alternative is either (stat($stream))[9] or -s $stream.  As with
the ioctl thingy, this (if it works) tells how much data is available to
read on that stream... on some OSs, anyway.

-- 
"So, who beat the clueless idiot today?"
"Well, we flipped for it, but when Kuno
 landed, he wasn't in any shape to fight."
"Next time, try flipping a *coin.*"


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

Date: Sat, 15 Feb 2003 10:02:24 -0000
From: "Brian Smart" <brian.smart@blueyonder.co.uk>
Subject: Unable to load modules
Message-Id: <L5o3a.45533$sZ5.31118@news-binary.blueyonder.co.uk>

Hi all,
I have had to start this subject again as the original thread has
disappeared. When I try to load a module, I get the following series of
statements.

" There's a new CPAN.pm version (v1.65) available!
  You might want to try
    install Bundle::CPAN
    reload cpan
  without quitting the current session. It should be a seamless upgrade
  while we are running...

Fetching with LWP:
  ftp://cpan.teleglobe.net/pub/CPAN/modules/03modlist.data.gz
Going to read y/sources/modules/03modlist.data.gz
Running make for J/JH/JHI/perl-5.8.0.tar.gz
Fetching with LWP:
  ftp://cpan.teleglobe.net/pub/CPAN/authors/id/J/JH/JHI/perl-5.8.0.tar.gz
CPAN: MD5 loaded ok
Fetching with LWP:
  ftp://cpan.teleglobe.net/pub/CPAN/authors/id/J/JH/JHI/CHECKSUMS
Could not gzopen y/sources/authors/id/J/JH/JHI/perl-5.8.0.tar.gz at
/usr/lib/perl5/5.00503/CPAN.pm line 4159."

Various suggestions have been made but probably my ignorance has stopped me
from fixing the problem.

Can anybody work with me to resolve the problem. I will provide any
information requested about my web site and the server upon which it
resides. Unfortunately as a beginner, the previous suggestions via this site
have been a little too criptic for me to understand.

Thanks for any help you can provide.

Brian Smart






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

Date: Sat, 15 Feb 2003 03:32:10 GMT
From: "Bfons" <bfons.rmv@usermail.com>
Subject: Yet Another Regex Question...
Message-Id: <_wi3a.113932$be.80454@rwcrnsc53>

Hello all,

Here is my problem.  I have Sendmail compiled with Regex support.  I have a
very annoying spammer using my server to relay their junk.  I have been
keeping up with him as we use pop-before-smtp but have also been using Regex
to block their activities.  I found an example on the net and here is what I
am using in the sendmail.mc.

The user is emailing with the FROM field as: MustBookof2003@yahoo.com, so I
have the following.

Scheck_from
R$*MustBookof2003$*     $#error $: ${Msg_mailer}- ${Msg_master}
R$*MustBook2003$*       $#error $: ${Msg_mailer}- ${Msg_master}

In these examples, the spammer always uses "MustBook".

My Question is, how do I block based on just the "MustBook"?

I have tried:
R$*MustBook.       $#error $: ${Msg_mailer}- ${Msg_master}
R$*[MustBook]       $#error $: ${Msg_mailer}- ${Msg_master}
R$*MustBook........      $#error $: ${Msg_mailer}- ${Msg_master}
R$*^MustBook       $#error $: ${Msg_mailer}- ${Msg_master}

I then test with my email client with the from field as
MustBook12345@yahoo.com and I am unsuccessfully getting a match.


Your help would be greatly appreciated,

Brian







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

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


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