[22714] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 4935 Volume: 10

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Mon May 5 06:06:31 2003

Date: Mon, 5 May 2003 03: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           Mon, 5 May 2003     Volume: 10 Number: 4935

Today's topics:
    Re: clearing stdin (Anno Siegel)
    Re: Compare Lists - built in Function? <koos_pol@NO.nl.JUNK.compuware.MAIL.com>
    Re: Compare Lists - built in Function? <bik.mido@tiscalinet.it>
    Re: Controlling external device with Perl <upro@gmx.net>
        dereference of hash-slices <pilsl_usenet@goldfisch.at>
        Multithreading on Windows using ActiveState's Perl <kasp@epatra.com>
        packages/objects and data <bike@bowser.stanford.edu>
    Re: packages/objects and data <bernard.el-hagin@DODGE_THISlido-tech.net>
    Re: packages/objects and data <bike@bowser.stanford.edu>
    Re: packages/objects and data <tassilo.parseval@rwth-aachen.de>
    Re: Passing hash and string to subroutine <richp1234@hotmail.com>
    Re: Passing hash and string to subroutine <richp1234@hotmail.com>
    Re: Passing hash and string to subroutine <richp1234@hotmail.com>
    Re: Passing hash and string to subroutine (Anno Siegel)
        Perl 5.6.1 under Cygwin: rules-dbm test fails <nospam@spam.no>
        PID's, killing processes when new one starts - revisite <anthony@no_spam.movielink.net.au>
    Re: string checking, before using in SENDMAIL -> =?iso- (Villy Kruse)
    Re: waste of time <no@spam.for.me.invalid>
        writing in a new file <samj@austarmetro.com.au>
    Re: writing in a new file <fxn@hashref.com>
    Re: writing in a new file <krahnj@acm.org>
    Re: writing in a new file <bart.lateur@pandora.be>
        Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)

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

Date: 5 May 2003 09:54:04 GMT
From: anno4000@lublin.zrz.tu-berlin.de (Anno Siegel)
Subject: Re: clearing stdin
Message-Id: <b95cbs$2av$1@mamenchi.zrz.TU-Berlin.DE>

Lee&James  <schnoz@adelphia.net> wrote in comp.lang.perl.misc:
> On a windows platform I want to clear stdin before putting out a message
> and then reading stdin. Can someone tell me how to do this?

"stdin" is a file handle (well, STDIN is).  What do you mean by "clearing
stdin"?

Anno


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

Date: Mon, 05 May 2003 08:25:42 +0200
From: Koos Pol <koos_pol@NO.nl.JUNK.compuware.MAIL.com>
Subject: Re: Compare Lists - built in Function?
Message-Id: <newscache$uuheeh$0ra$1@news.emea.compuware.com>

news.chello.at wrote (Saturday 03 May 2003 20:14):

> Is there any builtin function which does a compare of two sorted lists? I
> only need true for 2 lists with the same values.


You might consider List::Compare.

-- 
KP



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

Date: Mon, 05 May 2003 09:23:22 +0200
From: Michele Dondi <bik.mido@tiscalinet.it>
Subject: Re: Compare Lists - built in Function?
Message-Id: <u34cbvsq9n8gnqumslanjqpdfgi7eddl1s@4ax.com>

On Sat, 03 May 2003 21:07:21 +0200, Gunnar Hjalmarsson
<noreply@gunnar.cc> wrote:

>news.chello.at wrote:
>> Is there any builtin function which does a compare of two sorted
>> lists? I only need true for 2 lists with the same values.
>
>Maybe you could compare two interpolated arrays:
>
>     if ("@list1" eq "@list2") {
>         print 'Identical lists';
>     } else {
>         print 'Not identical lists';
>     }

Others have suggested that this approach is flawed and pointed to the
relevant faq entry. However when I'm sure about the content of the
lists I use something like

  print "equal\n" if do { local $"="\0"; "@list1" eq "@list2" };


Michele
-- 
$\=q.,.,$_=q.print'  ,\g,,( w,a'c'e'h,,map{$_-=qif/g/;chr
}107..q[..117,q)[map+hex,split//,join' ,2B,, w$ECDF078D3'
F9'5F3014$,$,];];$\.=$/,s,q,32,g,s,g,112,g,y,' , q,,eval;


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

Date: Mon, 05 May 2003 10:10:04 +0200
From: upro <upro@gmx.net>
Subject: Re: Controlling external device with Perl
Message-Id: <877k95zueb.fsf@gmx.net>

mbS <removeX_stevensx4000x@earthlinxk.next> writes:

> On or around Sun, 04 May 2003 19:36:38 +0200, there was a message,
> possibly from upro <upro@gmx.net>, as follows:
>
>>I meant sonething like witching on and off a lamp with a self-made
>>circuit, which I give signals from the parallel port (as you can read
>>in the coffee-howto). I use Linux, and I'd have to switch on and off
>>one electricity in one of the pins from the parallel port...
>
> I've controlled labs with a 488 bus/board and with parallel ports,
> by calling assembler routines through C.  You should be able to call
> C functions from Perl through the Extension Interface,
> so there is your hook.  
>
> (Places like National Instruments used to
> sell C libraries for controlling devices in real time, too.)
>
> You need to set up a little testing setup for the lines coming from
> the back of your computer so you can test when you've turned something
> on or off.   A cheap voltmeter and a 'break out box' will do.
>
> Probably best to get everything working with C and assembler
> before trying to hook the result into Perl.  (I  havn't actually tried
> this with Perl, but have done it with high level things like X Windows
> and MS windows).    You'll need documents
> for the internal addresses of device controllers  used by your Op
> system so you can access them with the assembler calls.
>
> Then, at the lamp end, you need some kind of amplifier and
> switch to respond to the lines coming from the computer.  More
> complex devices may have their own specialized controllers.   It's all
> conceptually very simple, but it sucks down many hours while you try
> to get things to actually work, assembling just the right parts that
> will work together, talking to various device techs by email, etc... 
>
> Sound like fun?
> HTH
> m
> http://www.mbstevens.com/
>
>
>
>
Thanks a lot for your extensive answer!

My problem is that I have no knowledge of assembler, I'm bad in C and
have no one to help me... (well, let's say, apart from NGs).

I will probably try with the few lines I found in the Coffee
Howto. But I'll have to assemble something to see if actually
something is getting out of the parport.

What is a "break out box"?

thanks again!

-- 
Michael

r-znvy: zvpunry.wryqra  jro.qr (chg gur "@" jurer vg svgf...)
ab fcnz cyrnfr


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

Date: Mon, 5 May 2003 11:45:11 +0200
From: peter pilsl <pilsl_usenet@goldfisch.at>
Subject: dereference of hash-slices
Message-Id: <3eb63307$1@e-post.inode.at>



Assuming I've a anonymous hash and an anonymous array and I'd like to 
evaluate the correspsonding hash-slice. By now I need to do a lot of nasty 
explicit dereferences and like to know if there is a more elegant way, 
espcially as I'm used to the arrow-operator for accessing anyomous 
structures.

example what I do now: 

$a={1=>1,2=>4,3=>9,4=>16};
$b={a=>1,b=>2,c=>3,d=>4};
$c=['a','b','d'];
print join("-",@{$a}{@{$b}{@{$c}}}),"\n"

=>
1-4-16

thnx,
peter


-- 
peter pilsl
pilsl_usenet@goldfisch.at
http://www.goldfisch.at



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

Date: Mon, 5 May 2003 13:34:28 +0530
From: "Kasp" <kasp@epatra.com>
Subject: Multithreading on Windows using ActiveState's Perl
Message-Id: <b95655$cb4$1@newsreader.mailgate.org>

Hi,

I am trying to do multithreading on Windows using Perl 5.6 from ActiveState.

What I need to do is to run multiple instances of a perl script that accepts
one command line argument - a FILENAME. The program scans this file,
performs some data extraction and creates a file called "FILENAME.out". So
we can consider this equivalent to opening many shells and running the
script but with different arguments.

As per ActiveState's documentation,
1. perlfork - Perl's fork() emulation (EXPERIMENTAL, subject to change)
2. Thread - manipulate threads in Perl (EXPERIMENTAL, subject to change)

Now its not very comforting to read "EXPERIMENTAL, subject to change". I am
not confident if I write a perl script today, that it will run with later
versions of perl.

Is there some way I can achieve safe-multi-threading?

Thanks,
Kasp.
--
"Accept that some days you are the pigeon and some days the statue."
"A pat on the back is only a few inches from a kick in the butt." - Dilbert.




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

Date: Mon, 05 May 2003 00:04:39 -0700
From: J Dugan <bike@bowser.stanford.edu>
Subject: packages/objects and data
Message-Id: <5u1cbv8oddbd7eravhq31v6e4tbl6dv1fj@4ax.com>

I've used perl for a few years, mostly just simple scripts.

I want to start writing using packages and/or objects and I'm finding
it really frustrating.


Why can't I put simple variables into packages (or objects)?

-or-

How do I get the equivalent of this functionality?


I must be missing something very basic here.


I am very familiar with objects in C++, wich can have methods and
(separate) data in each object instantiation.  It would appear after
reading many man pages that packages can only have methods.  The
example given in perlbot gives me one anonymous hash or an anonymous
array or a single scalar value.  I want more than this -- I want to
define variables in a package, then be able to access and manipluate
them in each instance.


I want to be able to something like this:

# in file Foo.pm
package Foo;

%data = ( 'user' => 'XYZZY' );
%data2 = ( 'user' => 'blah' );

sub new {
    my $this = shift;
    my $class = ref($this) || $this;
    my $self = {};
    $self->{'data'} = \%data;
    $self->{'data2'} = \%data2;
    bless $self, $class;
    return $self;
}


# and in a separate file...test4.pl

#!/usr/bin/perl
use strict;
use Foo;

my $thing = Foo->new;

print $thing->$data->user;
$thing->$data->user = 'newname';
print $thing->$data->user; 	


#--

 ./test4.pl gives this:

Global symbol "$data" requires explicit package name at ./test4.pl
line 7.
Global symbol "$data" requires explicit package name at ./test4.pl
line 8.
Global symbol "$data" requires explicit package name at ./test4.pl
line 9.


what am I doing wrong?  How do I define and use variables in objects?



Thanks in advance to anyone who can help with this.


Jon






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

Date: Mon, 5 May 2003 07:13:54 +0000 (UTC)
From: "Bernard El-Hagin" <bernard.el-hagin@DODGE_THISlido-tech.net>
Subject: Re: packages/objects and data
Message-Id: <Xns93725DBFC7BABelhber1lidotechnet@62.89.127.66>

J Dugan wrote:

> I've used perl for a few years, mostly just simple scripts.
> 
> I want to start writing using packages and/or objects and I'm finding
> it really frustrating.


[...]


perldoc perltoot


-- 
Cheers,
Bernard
--
echo 42|perl -pe '$#="Just another Perl hacker,"'



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

Date: Mon, 05 May 2003 00:38:07 -0700
From: J Dugan <bike@bowser.stanford.edu>
Subject: Re: packages/objects and data
Message-Id: <k45cbvkkehglrf4dpo4qhegbnk1mivlql2@4ax.com>

yup missed that one.  thanks.  I'm still reading it, but I already see
why my questions were not on track.


On Mon, 5 May 2003 07:13:54 +0000 (UTC), "Bernard El-Hagin"
<bernard.el-hagin@DODGE_THISlido-tech.net> wrote:

>J Dugan wrote:
>
>> I've used perl for a few years, mostly just simple scripts.
>> 
>> I want to start writing using packages and/or objects and I'm finding
>> it really frustrating.
>
>
>[...]
>
>
>perldoc perltoot
>
>
>-- 
>Cheers,
>Bernard



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

Date: 5 May 2003 08:29:23 GMT
From: "Tassilo v. Parseval" <tassilo.parseval@rwth-aachen.de>
Subject: Re: packages/objects and data
Message-Id: <b957d3$edv$1@nets3.rz.RWTH-Aachen.DE>

[ Please do not top-post. You did it in your reply to Bernard and I'd
  like to guard against that happening again in beforehand.
  Please see  <http://www.dickalba.demon.co.uk/usenet/guide/faq_topp.html>
  before proceeding ]
  
Also sprach J Dugan:

> I've used perl for a few years, mostly just simple scripts.
> 
> I want to start writing using packages and/or objects and I'm finding
> it really frustrating.
> 
> 
> Why can't I put simple variables into packages (or objects)?

You can.

> How do I get the equivalent of this functionality?

Equivalents to putting variables into packages? No equivalent required,
just do it properly.

> I must be missing something very basic here.
> 
> 
> I am very familiar with objects in C++, wich can have methods and
> (separate) data in each object instantiation.  It would appear after
> reading many man pages that packages can only have methods.  The
> example given in perlbot gives me one anonymous hash or an anonymous
> array or a single scalar value.  I want more than this -- I want to
> define variables in a package, then be able to access and manipluate
> them in each instance.

Perl's object model is different from that of C++. Both have instance
and class data but, indeed, Perl classes only know of methods when it
comes to inheritance. There is no data-inheritance. But this is not even
relevant for your problem.

> I want to be able to something like this:
> 
> # in file Foo.pm
> package Foo;
> 
> %data = ( 'user' => 'XYZZY' );
> %data2 = ( 'user' => 'blah' );
> 
> sub new {
>     my $this = shift;
>     my $class = ref($this) || $this;
>     my $self = {};
>     $self->{'data'} = \%data;
>     $self->{'data2'} = \%data2;
>     bless $self, $class;
>     return $self;
> }
> 
> 
> # and in a separate file...test4.pl
> 
> #!/usr/bin/perl
> use strict;
> use Foo;
> 
> my $thing = Foo->new;
> 
> print $thing->$data->user;
> $thing->$data->user = 'newname';
> print $thing->$data->user; 

You are dangerously mixing instance data (that is, data per object) with
class data (static content that all objects can access and that is the
same for each object derived from the class).

It looks like you want instance data in your example. 

    package Foo;

    sub new {
        my $proto = shift;
        my $class = ref($proto) || $proto;
        return bless {
            data    => undef,
            data2   => undef,
        } => $class;
    }

The above is already enough if you want per-object data. You can now
access the members of your object thusly:

    use Foo;

    my $o = new Foo;
    $o->{data} = "data";
    ...

However, one shouldn't access members explicitely but instead use
accessor methods for them, so we should add some:

    package Foo;
    ...
    sub set_data {
        my ($self, $data) = @_;
        $self->{ data } = $data;
    }

    sub get_data {
        my $self = shift;
        return $self->{ data };
    }

Your main-program would now become:

    use Foo;
    
    my $o = new Foo;
    $o->set_data("data");
    print $o->get_data;

More complex data can also be stored:

    $o->set_data( { user => 'name' } ); # stores a hash-ref
    print $o->get_data->{ user };

Since you are familiar I expect that you know what class-members are. In
Perl data that belongs to a class instead of single objects become
package-variables. Those are variables that are not declared using my()
(because then they would be lexicals which do not live in packages but
scopes). Like so:

    package Foo;

    %Foo::default = (
        user => 'noname',
        ...
    );

    # the above could be used in the constructor to set some defaults
    # for each object
    sub new {
        my $proto = shift;
        my $class = ref($proto) || $proto;
        return bless {
            data => { %Foo::default },
            ...
        } => $class;
    }

There is a difference between '\%hash' and '{ %hash }'. The second form
creates a reference to a copy of %hash while the first one stores a
reference to the original %hash. But this is probably not what you want
because now you are in danger of changing static class-data through an
object and suddenly all other objects will suffer from this change.
That's why a copy is needed.

There is actually more to say about it. '%Foo::hash' could have been made
a lexical, too ('my %hash = ...' instead). In such a case you could no
longer access %hash from outside the file in which package Foo resides.
Sometimes this is what you want, sometimes it is not.

Anyway, following Bernhard's suggestion to read perltoot.pod would be
good. Perhaps you should even start with the even more gentle
introduction in perlboot.pod. 

Another recommended reading is

    http://perl.plover.com/FAQs/Namespaces.html

It covers Perl's sometimes confusing scoping rules and explains the
difference between dynamic (or package) scoping and lexical scoping that
is often necessary ti know about when working with classes.

Tassilo
-- 
$_=q#",}])!JAPH!qq(tsuJ[{@"tnirp}3..0}_$;//::niam/s~=)]3[))_$-3(rellac(=_$({
pam{rekcahbus})(rekcah{lrePbus})(lreP{rehtonabus})!JAPH!qq(rehtona{tsuJbus#;
$_=reverse,s+(?<=sub).+q#q!'"qq.\t$&."'!#+sexisexiixesixeseg;y~\n~~dddd;eval


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

Date: Sun, 04 May 2003 21:57:20 -0700
From: Rich Pasco <richp1234@hotmail.com>
Subject: Re: Passing hash and string to subroutine
Message-Id: <3EB5EF30.7090206@hotmail.com>

James E Keenan wrote:

> "Rich Pasco" <richp1234@hotmail.com> wrote in message
> news:3EB5B187.3040501@hotmail.com...
>> Is it possible in Perl to pass two parameters to a subroutine,
>> one of which is a hash and one of which is a string?
> 
> Pass the hash by reference:
> process_events(\%criterion,$text);

This is the best idea yet.  Then what would the body of my subroutine
"sub process_events" look like to retrieve the values in the hash?
Here's what I came up with:

#pass both a hash and a string
my (%criterion, $text);
$criterion{'a'} = 'AAA';
$criterion{'b'} = 'BBB';
$text = 'The Quick Brown Fox';
process_events(\%criterion, $text);
exit;

sub process_events {
  my($criteria, $body) = @_;
  print "a=$$criteria{'a'}\n";
  print "b=$$criteria{'b'}\n";
  print "\nbody = $body\n";
}



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

Date: Sun, 04 May 2003 21:59:04 -0700
From: Rich Pasco <richp1234@hotmail.com>
Subject: Re: Passing hash and string to subroutine
Message-Id: <3EB5EF98.3090509@hotmail.com>

bob wrote:

>   print "a=$ref_criteria->{'a'}\n";
> #                       ^^ uses reference ("dereferences")

How does this differ from
    print "a=$$ref_criteria{'a'}\n";

They both seem to work.

     - Rich



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

Date: Sun, 04 May 2003 22:04:19 -0700
From: Rich Pasco <richp1234@hotmail.com>
Subject: Re: Passing hash and string to subroutine
Message-Id: <3EB5F0D3.4000408@hotmail.com>

Jürgen Exner wrote:

> You must have missed the thread
>     "Is it possible to pass @somethig and $something_else to sub"
> which was discussed here in this very NG over the last 2 weeks.

Yes, I did miss it.  Thank.s

     - Rich



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

Date: 5 May 2003 08:50:39 GMT
From: anno4000@lublin.zrz.tu-berlin.de (Anno Siegel)
Subject: Re: Passing hash and string to subroutine
Message-Id: <b958kv$rd$1@mamenchi.zrz.TU-Berlin.DE>

Rich Pasco  <richp1234@hotmail.com> wrote in comp.lang.perl.misc:
> bob wrote:
> 
> >   print "a=$ref_criteria->{'a'}\n";
> > #                       ^^ uses reference ("dereferences")
> 
> How does this differ from
>     print "a=$$ref_criteria{'a'}\n";
> 
> They both seem to work.

Functionally they don't differ at all, they do the same thing.
Systematically, the second one is the full form, or rather
"${ $ref_criteria}{ a}" is.  The arrow notation is syntactic sugar,
but preferred where applicable.

Oh, and the quotes in "{}" are not needed, Perl auto-quotes things
that look like a Perl identifier.

Anno


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

Date: Mon, 05 May 2003 04:00:50 -0500
From: rd <nospam@spam.no>
Subject: Perl 5.6.1 under Cygwin: rules-dbm test fails
Message-Id: <3EB62842.2FE379AE@spam.no>

I'm using Perl-5.6.1 under Cygwin, and trying to use the CPAN module to
get some modules.  I'm using the older version because with Perl 5.8.0,
there are numerous crashes, particularly when using perldoc, so I
downgraded.  I'm using Cygwin on Windows 95.

Anyway, I'm having trouble with the LWP module.  Under the CPAN shell
(perl -MCPAN -e shell), I do "install LWP", and the rules-dbm tests fail.
Is there a dependancy it doesn't know about that's causing this, or is it
a factor of Cygwin?

Also, it also fails on module "CPAN" when i do "install Bundle::CPAN", but
doesn't show anymore helpful information.

Google searches turned up occurances of the first problem, but no
solutions for them.

So, does anyone know why this is happening, or even better, how to fix it?


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

Date: Mon, 05 May 2003 16:41:03 +1000
From: "Tony" <anthony@no_spam.movielink.net.au>
Subject: PID's, killing processes when new one starts - revisited
Message-Id: <pan.2003.05.05.06.41.02.425069@no_spam.movielink.net.au>


Hi again guys,

I have writen a program which now works as desired but with a small
problem still remaining.

A simple setup scans a config file looking for a match with local
day and time.  A match triggers playing a list of files in the
config file.

The flow is like this:

#!/usr/bin/perl
use warnings
use strict

my $cfg_file = "/opt/cfg.text;
my $cfg_temp = "/opt/cfg.tmp";

read_convert(cfg_file,cfg_temp); # Convert cfg and write it to temp file


START: open(FILE,$cfg_temp) or die "$!\n";
  foreach my $file_llist(<FILE>
   {
    extract DAY, TIME and other details from each line
    my $something = "some_params";
	if (LOCAL_DAY LOCAL_LTIME eq DAY TIME)  # Day, time in cfg...
	  {
	  process_list($something,$file_list); # Send the data to sub
	  }
		
    }
goto START

# This is a simple and crude way of continuesly reading the
# "/opt/cfg.tmp" file line by line, looking for a day/time match.

sub process_list
  {
  my ($params, $file_list) = @_;
  my $number = $params;
  my @list = (convert $file_list to array)
  foreach my $file(@list)
    {
    play_file($number,$file);
    }
  }

# The sub above calls an other sub that actually handles
# playing the files with $params

sub play_file
  {
  my $program = "/opt/player_program";
  my $device = "/dev/device";
  my $device_no = $_[0];
  my $file = $_[1];
  system `$program $device$device_no $file`;
  }


The above is very simplified but should be enough to
understand my predicement with childs and PID's.

The looping section at the top will send some data and a list
of files to play to a sub called "process_list".

Without fork the program will wait for the "process_list"
sub to send each file in turn to the "play_file" sub which
will wait for each "play" to complete (The system call).

When all files are played, we return to the initial loop.

I need to be able to continue the loop at the beginning
after each match and sending files off to be processed.

The use of "fork" seems to be the way to handle this.

My understanding is that the perl main program will create
a PID for itself.  If I call the "process_list" with fork
I end up with a situation where the main loop will continue
with its PID and a new PID will be created for the "process_list"
sub, that is fine.

The "play_file" sub is called from the forked child "process_list".

The "play_file" starts the player which creates yet another
PID.

How do i go about killing the first "forked" process
for the "process_list" as well as any file play process
in progress (Its children) when a new event is triggered?


I know it is a big mouthful, that is why I have tried
to shorten it all a bit.  The program dos a lot of other
bits and pieces but this is not important.

Tony



-- 
--------------------------------------------------------------
To reply directly send to: anthony AT movielink DOT net DOT au
Replace AT and DOT with @ and . and mail will get through.
Any spammers will be persued until they get booted off the net



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

Date: 05 May 2003 07:53:20 GMT
From: vek@station02.ohout.pharmapartners.nl (Villy Kruse)
Subject: Re: string checking, before using in SENDMAIL -> =?iso-8859-1?Q?'=E9=E9n'?= has to become 'een'
Message-Id: <slrnbbc63g.4sv.vek@station02.ohout.pharmapartners.nl>

On Sat, 03 May 2003 08:58:45 GMT,
    joe <tunmaster@hotmail.com> wrote:


>Hi there,
>
>This is what it is. I'd like people to send emails through my site using
>SENDMAIL. But I'm afraid using the users input in the email, can hang the
>server if not checked properly. So I have to do some taintchecking. But I
>don't know what to expect for an email.
>
>I thought it to be a wise thing to replace all the not to often occurring
>characters with a questionmark, like this:
>$::x2  =~ s/[^\w\s\n.,:;+-=\[\]()!@#$%&?<>]/?/g;
>I can perfectly live with that, wasn't it that a string like "Één
>goedemiddag" will become "??n goedemiddag".
>
>Is there a better way to make sure a string doesn't contain any dangerous
>codes or if I like the above code, it's just fine. But how than can I make
>"Een goedemiddag" out of the first string?
>


The various transfer encodings as defined in the MIME standards was created
for this purpose.  The MIME::Lite module available from CPAN can handle
the required details.


Villy


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

Date: Mon, 05 May 2003 07:43:25 GMT
From: "Nils Petter Vaskinn" <no@spam.for.me.invalid>
Subject: Re: waste of time
Message-Id: <pan.2003.05.05.07.43.25.223071@spam.for.me.invalid>

On Sat, 03 May 2003 10:51:02 -0700, smugbuster wrote:


> 
> Thank you all for participating in my little "sociological
> experiment." I'm doing my masters thesis on internet communication. I
> have never even visited your newsgroup before I posted my original
> message.
> 

> 
> Again, I apologize and will not post any messages in the future.
> 

Please do when you've finished your thesis, atleast if this group is
mentioned specifically in it, and tell us where to find it (if it's
possible).

regards
NP



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

Date: Mon, 05 May 2003 05:06:41 GMT
From: "Sam Jesse" <samj@austarmetro.com.au>
Subject: writing in a new file
Message-Id: <3eb5f160@news.comindico.com.au>

Hello
another primitive question which I just feel too small asking but I need to
find out how to get the $content to be copied over to the file
C:/.../abc.html
thanks

Sam


#!/perl -w
use strict;
use LWP::Simple;
my $url= 'http://www.abc.com/nn.shtml');
my $content = get $url; #oh.. is there a way to find out if the connection
is alive before going further from here
my $path = 'C:/1/2/nn.shtml';
if ($content){
 open(FILE, "> $path") || die "file, $path, no good $!";
 <<write the $content into the file>> ??? help needed
 close FILE;
}else{
 die "Couldn't get $url $!"
}





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

Date: Mon, 5 May 2003 06:55:00 +0000 (UTC)
From: Xavier Noria <fxn@hashref.com>
Subject: Re: writing in a new file
Message-Id: <b951s4$a74$1@news.ya.com>

In article <3eb5f160@news.comindico.com.au>, Sam Jesse wrote:

: #!/perl -w
: use strict;
: use LWP::Simple;
: my $url= 'http://www.abc.com/nn.shtml');
: my $content = get $url; #oh.. is there a way to find out if the connection
: is alive before going further from here

Read what happens if that call fails in the documentation of the function
get() available with the incantation perldoc LWP::Simple.

: my $path = 'C:/1/2/nn.shtml';
: if ($content){
:  open(FILE, "> $path") || die "file, $path, no good $!";
: <<write the $content into the file>> ??? help needed

How to write to FILE is explained in perldoc -f print.

-- fxn



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

Date: Mon, 05 May 2003 06:57:40 GMT
From: "John W. Krahn" <krahnj@acm.org>
Subject: Re: writing in a new file
Message-Id: <3EB60B50.FEAF6BB7@acm.org>

Sam Jesse wrote:
> 
> another primitive question which I just feel too small asking but I need to
> find out how to get the $content to be copied over to the file
> C:/.../abc.html
> 
> #!/perl -w
> use strict;
> use LWP::Simple;
> my $url= 'http://www.abc.com/nn.shtml');
> my $content = get $url; #oh.. is there a way to find out if the connection
> is alive before going further from here
> my $path = 'C:/1/2/nn.shtml';
> if ($content){
>  open(FILE, "> $path") || die "file, $path, no good $!";
>  <<write the $content into the file>> ??? help needed

   print FILE $content;

>  close FILE;
> }else{
>  die "Couldn't get $url $!"
> }


John
-- 
use Perl;
program
fulfillment


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

Date: Mon, 05 May 2003 09:52:09 GMT
From: Bart Lateur <bart.lateur@pandora.be>
Subject: Re: writing in a new file
Message-Id: <41dcbvckmerauhfiu1r576kjra2krde3lu@4ax.com>

Sam Jesse wrote:

>another primitive question which I just feel too small asking but I need to
>find out how to get the $content to be copied over to the file
>C:/.../abc.html
 ...
>use LWP::Simple;
>my $url= 'http://www.abc.com/nn.shtml');
>my $content = get $url;

Look into LWP::Simple's method getstore(). It'll save directly to file.

-- 
	Bart.


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

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


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