Skip to search.

Breaking News Visit Yahoo! News for the latest.

×Close this window

perl-beginner · Perl Beginners Mailing List

The Yahoo! Groups Product Blog

Check it out!

Group Information

  • Members: 3764
  • Category: Perl
  • Founded: Aug 2, 1998
  • Language: English
? Already a member? Sign in to Yahoo!

Yahoo! Groups Tips

Did you know...
Message search is now enhanced, find messages faster. Take it for a spin.

Messages

Advanced
Messages Help
Messages 3666 - 3695 of 27465   Oldest  |  < Older  |  Newer >  |  Newest
Messages: Show Message Summaries Sort by Date ^  
#3666 From: "Greg" <webmaster@...>
Date: Thu May 31, 2001 9:34 am
Subject: Re: [PBML] Calling a cgi program
webmaster@...
Send Email Send Email
 
--- In perl-beginner@y..., "Bob" <bob@a...> wrote:
> Thanks all, for your help.
>
> SSI worked a treat, when I remembered to use the shtml extension.
>
> Still couldn't find an 'exec' in your prog, Gordon.
>
> I've read that there's a security risk with SSI, but I don't know
why.
> Is there any special precautions I should take?
> Bob.
========================================
If you don't want to or cannot use SSI, try the META Refresh tag in
the HTML header of your document.

Why does no-one ever think of the simple solution?

LOL
Greg Smith

#3667 From: "Bob" <bob@...>
Date: Thu May 31, 2001 10:50 am
Subject: Re: [PBML] Calling a cgi program
bob@...
Send Email Send Email
 
--- In perl-beginner@y..., "Greg" <webmaster@b...> wrote:
> --- In perl-beginner@y..., "Bob" <bob@a...> wrote:
> > Thanks all, for your help.
> >
> > SSI worked a treat, when I remembered to use the shtml extension.
> >
> > Still couldn't find an 'exec' in your prog, Gordon.
> >
> > I've read that there's a security risk with SSI, but I don't know
> why.
> > Is there any special precautions I should take?
> > Bob.
> ========================================
> If you don't want to or cannot use SSI, try the META Refresh tag in
> the HTML header of your document.
>
> Why does no-one ever think of the simple solution?
>
> LOL
> Greg Smith

Hi Greg

Sounds good.
Can you tell me more about this tag, as I've never used it.

Bob.

#3668 From: "Greg" <webmaster@...>
Date: Thu May 31, 2001 11:25 am
Subject: Re: [PBML] Calling a cgi program
webmaster@...
Send Email Send Email
 
--- In perl-beginner@y..., "Bob" <bob@a...> wrote:
> > If you don't want to or cannot use SSI, try the META Refresh tag
in
> > the HTML header of your document.
> >
> > Why does no-one ever think of the simple solution?
> >
> > LOL
> > Greg Smith
>
> Hi Greg
>
> Sounds good.
> Can you tell me more about this tag, as I've never used it.
>
> Bob.
========================================================
OK, here's an example:
The content value is number of seconds after page has been displayed
before transfer takes place.

<html><head><title>Lets go Surfin</title>
<meta http-equiv="Refresh" content="5; URL=script.cgi">
</head>
<body>

Advice: If you are using perl for cgi, you really should know all
there is to know about html as well.

Greg Smith
webmaster
www.bmw-club.org.uk

#3669 From: Alex Dyas <ADyas@...>
Date: Thu May 31, 2001 11:34 am
Subject: Multi-dimensional arrays
ADyas@...
Send Email Send Email
 
Can someone please tell me why the following script does not return "aa".
In other words, how do I assign an array variable with part of an other
multi-dimensional array?

<script>
#!/usr/bin/perl -w
use strict;
my @a;
my @b;
my @alex;
my @z;
@a=[ "aa","bb","cc" ];
@b=[ "dd","ee","ff" ];
$alex[0] = @a;
$alex[1] = @b;
@z = $alex[0];
print($z[0]);
</script>

thanks,

alex..

-= Alex Dyas - Webmaster - Broadcast Ops - TwoWayTV =-

#3670 From: "Greg" <webmaster@...>
Date: Thu May 31, 2001 11:46 am
Subject: Re: Multi-dimensional arrays
webmaster@...
Send Email Send Email
 
--- In perl-beginner@y..., Alex Dyas <ADyas@t...> wrote:
> Can someone please tell me why the following script does not
return "aa".
> In other words, how do I assign an array variable with part of an
other
> multi-dimensional array?
>
> <script>
> #!/usr/bin/perl -w
> use strict;
> my @a;
> my @b;
> my @alex;
> my @z;
> @a=[ "aa","bb","cc" ];
> @b=[ "dd","ee","ff" ];
> $alex[0] = @a;
> $alex[1] = @b;
> @z = $alex[0];
> print($z[0]);
> </script>
>
> thanks,
>
> alex..
====================================================
BRACES!
Change:
@a=[ "aa","bb","cc" ];
@b=[ "dd","ee","ff" ];

To:
@a=("aa","bb","cc");
@b=("dd","ee","ff");

Greg Smith
Webmaster
www.bmw-club.org.uk

#3671 From: Alex Dyas <ADyas@...>
Date: Thu May 31, 2001 11:56 am
Subject: RE: [PBML] Re: Multi-dimensional arrays
ADyas@...
Send Email Send Email
 
> BRACES!
> Change:
> @a=[ "aa","bb","cc" ];
> @b=[ "dd","ee","ff" ];
>
> To:
> @a=("aa","bb","cc");
> @b=("dd","ee","ff");

Doesn't seem to work.  Now I get "3" printed, which I'm guessing to be the
size of the array?

alex..

#3672 From: "Rivera Alonso, David" <drivera@...>
Date: Thu May 31, 2001 12:03 pm
Subject: unsubscribe
drivera@...
Send Email Send Email
 
_____________________________________________
Este mensaje, incluyendo los ficheros que pudiera llevar como anexos,
puede contener información confidencial.
Si ha recibido este mensaje por error, le rogamos que borre de su
sistema inmediatamente el mensaje asi como todas sus copias, incluyendo
las posibles copias del mismo en su disco duro, notifique al remitente
y se abstenga de usar, revelar, distribuir a terceros, imprimir o
copiar ninguna de las partes de este mensaje. Gracias por su
cooperación
_____________________________________________

#3673 From: Gareth Hughes <g.hughes@...>
Date: Thu May 31, 2001 12:02 pm
Subject: Re: [PBML] Multi-dimensional arrays
g.hughes@...
Send Email Send Email
 
see comments below....

> Can someone please tell me why the following script does not return "aa".
> In other words, how do I assign an array variable with part of an other
> multi-dimensional array?
>
> <DEFANGED_script>
> #!/usr/bin/perl -w
> use strict;
> my @a;
> my @b;
> my @alex;
> my @z;
> @a=[ "aa","bb","cc" ];
> @b=[ "dd","ee","ff" ];

  @a is now an array with a single element containing a reference:
  $a[0] = ARRAY REF

  to access "aa" use $a[0][0] (or $a[0]->[0])

> $alex[0] = @a;

   $alex[0] now contains the length of the array @a (i.e. 1).


> $alex[1] = @b;

   likewise

> @z = $alex[0];

    array element $z[0] gets the value 1 (length of array @a)

> print($z[0]);

    prints 1

> </script>


try.... instead of $alex[0] = @a

$alex[0] = \@a;
@z       = $alex[0];

now $z[0] contains a references to @a.

to access "aa" you need to several de-references

print "\$z[0] = ", $z[0][0][0] , "\n";

output = aa

similarly for the third element

print "\$z[0] = ", $z[0][0][2] , "\n";

output = cc


			 cheers, Gareth.

>
> thanks,
>
> alex..
>
> -= Alex Dyas - Webmaster - Broadcast Ops - TwoWayTV =-
>
>
>
> Your use of Yahoo! Groups is subject to http://docs.yahoo.com/info/terms/
>
>

#3674 From: "Gordon Stewart" <gordonistewart_nz@...>
Date: Thu May 31, 2001 12:06 pm
Subject: Re: Cookies ?
gordonistewart_nz@...
Send Email Send Email
 
--- In perl-beginner@y..., "Gordon Stewart" <gordonistewart_nz@y...>

Hi - I think ive fixed my problems.

Im still stuck on setting TWO cookies at once - but for what i want
to do, I only need one cookie (but would like to know how to set two -
  later on.)

ive got a query...

Ive found out, that the (existing) cookies on my system have 'spaces'
before the actual name.

so if i query '(space)name', then i get the result, but if i just ask
for 'name' I dont.

I'll assume ive got to be careful when setting them in the first
place.

- is this normal behaviour ?

I'll adjust the script to suit.

Thanks for all your help - various people, different groups.

G.

#3675 From: Danar Prabandaru <equusman@...>
Date: Thu May 31, 2001 1:12 pm
Subject: remove whitespace
equusman@...
Send Email Send Email
 
hello there,

   how to replace a whitespace with a single space character?
   so a string : "hello    world"
   become      : "hello world"

   PS : I assume that whitespace can contain one or more tab or space
        character
--
EquusMan (equusman@...)
--
look the master, follow the master, walk with the master,
see through the master, BECOME A MASTER !

#3676 From: webmaster@...
Date: Thu May 31, 2001 1:27 pm
Subject: Re: remove whitespace
webmaster@...
Send Email Send Email
 
--- In perl-beginner@y..., Danar Prabandaru <equusman@a...> wrote:
> hello there,
>
>   how to replace a whitespace with a single space character?
>   so a string : "hello    world"
>   become      : "hello world"
>
>   PS : I assume that whitespace can contain one or more tab or space
>        character
> --
> EquusMan (equusman@g...)
> --

# Well, I suppose you could replace every tab with a space:#

$string =~(s/\t/ /g);

# Then replace multiple spaces with single spaces in a loop:#

while ($string =~/  /)
  {
   $string =~(s/  / /g);
  }

# Untried - and there may be neater solutions out there.

Greg Smith
www.bmw-club.org.uk

#3677 From: Dan Boger <dan@...>
Date: Thu May 31, 2001 1:37 pm
Subject: Re: [PBML] remove whitespace
dan@...
Send Email Send Email
 
On Thu, 31 May 2001, Danar Prabandaru wrote:
>   how to replace a whitespace with a single space character?
>   so a string : "hello    world"
>   become      : "hello world"
>
>   PS : I assume that whitespace can contain one or more tab or space
>        character

this should do the trick:

$string =~ s/\s+/ /g;

HTH,

Dan

--
dan@...
Linux MVP
Brainbench.com

#3678 From: "Greg" <webmaster@...>
Date: Thu May 31, 2001 2:39 pm
Subject: Re: Cookies ?
webmaster@...
Send Email Send Email
 
--- In perl-beginner@y..., "Gordon Stewart" <gordonistewart_nz@y...>
wrote:
> --- In perl-beginner@y..., "Gordon Stewart" <gordonistewart_nz@y...>
>
> Hi - I think ive fixed my problems.
>
> Im still stuck on setting TWO cookies at once - but for what i want
> to do, I only need one cookie (but would like to know how to set
two -
>  later on.)
############################################
There is a way of combining cookies and compressing them into one,
but I've never tried it. An alternative is to combine the data for
each cookie into the data for the one, using a separator of some
sort, eg
$cookiedata = "$data1|$data2";
print "Set-Cookie: TYPE=$cookiedata; ...

When you read in the cookie data, you can then split on the "|".
###############################
> ive got a query...
>
> Ive found out, that the (existing) cookies on my system
have 'spaces'
> before the actual name.
>
> so if i query '(space)name', then i get the result, but if i just
ask
> for 'name' I dont.
>
> I'll assume ive got to be careful when setting them in the first
> place.
>
> - is this normal behaviour ?
#######################################
No it isn't. There should not be spaces before the name.
Are these cookies that your script created?
Try chomping everything you read in and split out, and remove all
spaces before doing the tests.

Greg Smith
www.bmw-club.org.uk

#3679 From: J M <john_20_28_2000@...>
Date: Thu May 31, 2001 3:13 pm
Subject: Why can't I print out this array?
john_20_28_2000@...
Send Email Send Email
 

Why can't I print out this array?  I goet the internal server error, so I used the command line.

I am using the CGI module for perl apache within mod_perl.  If I run the following line:

@values = (1,2,3,4,5);
foreach(@values)
{
print "$_\n";
}

everything is fine.  However, whenever I change it to read from the querystring in the address bar I get a syntax error.  Here is the code.  It is just a modification of the example from the CGI homepage.  Thanks.

#!/usr/local/bin/perl
use CGI;
$q = new CGI;
@names = $q->param;
@values = $q->param('choice');

print $q->header(),
      $q->start_html(-title=>'Wow!'),


      $q->h1('Wow!'),
      'Look Ma, no hands!',

foreach(@values)  #this is the line that dies
{ # it says syntax error at this bracket; it goes away if I use the array at top of this message.
print "$_\n";
}

print $q-> submit



Do You Yahoo!?
Yahoo! Mail Personal Address - Get email at your own domain with Yahoo! Mail.

#3680 From: Alex Dyas <ADyas@...>
Date: Thu May 31, 2001 4:00 pm
Subject: RE: [PBML] Multi-dimensional arrays
ADyas@...
Send Email Send Email
 
Right, makes sense, thanks Gareth.

So the upshot is that I can't use multi-dimensional arrays without resorting
to references?

alex..

> -----Original Message-----
> From: Gareth Hughes [mailto:g.hughes@...]
> Sent: 31 May 2001 13:03
> To: perl-beginner@yahoogroups.com
> Subject: Re: [PBML] Multi-dimensional arrays
>
>
> see comments below....
>
> > Can someone please tell me why the following script does
> not return "aa".
> > In other words, how do I assign an array variable with part
> of an other
> > multi-dimensional array?
> >
> > <DEFANGED_script>
> > #!/usr/bin/perl -w
> > use strict;
> > my @a;
> > my @b;
> > my @alex;
> > my @z;
> > @a=[ "aa","bb","cc" ];
> > @b=[ "dd","ee","ff" ];
>
>  @a is now an array with a single element containing a reference:
>  $a[0] = ARRAY REF
>
>  to access "aa" use $a[0][0] (or $a[0]->[0])
>
> > $alex[0] = @a;
>
>   $alex[0] now contains the length of the array @a (i.e. 1).
>
>
> > $alex[1] = @b;
>
>   likewise
>
> > @z = $alex[0];
>
>    array element $z[0] gets the value 1 (length of array @a)
>
> > print($z[0]);
>
>    prints 1
>
> > </script>
>
>
> try.... instead of $alex[0] = @a
>
> $alex[0] = \@a;
> @z       = $alex[0];
>
> now $z[0] contains a references to @a.
>
> to access "aa" you need to several de-references
>
> print "\$z[0] = ", $z[0][0][0] , "\n";
>
> output = aa
>
> similarly for the third element
>
> print "\$z[0] = ", $z[0][0][2] , "\n";
>
> output = cc
>
>
> 		 cheers, Gareth.
>
> >
> > thanks,
> >
> > alex..
> >
> > -= Alex Dyas - Webmaster - Broadcast Ops - TwoWayTV =-
> >
> >
> >
> > Your use of Yahoo! Groups is subject to
http://docs.yahoo.com/info/terms/
>
>




Your use of Yahoo! Groups is subject to http://docs.yahoo.com/info/terms/

#3681 From: "Bob" <bob@...>
Date: Thu May 31, 2001 4:04 pm
Subject: Re: [PBML] Calling a cgi program
bob@...
Send Email Send Email
 
--- In perl-beginner@y..., "Greg" <webmaster@b...> wrote:
> --- In perl-beginner@y..., "Bob" <bob@a...> wrote:
> > > If you don't want to or cannot use SSI, try the META Refresh
tag
> in
> > > the HTML header of your document.
> > >
> > > Why does no-one ever think of the simple solution?
> > >
> > > LOL
> > > Greg Smith
> >
> > Hi Greg
> >
> > Sounds good.
> > Can you tell me more about this tag, as I've never used it.
> >
> > Bob.
> ========================================================
> OK, here's an example:
> The content value is number of seconds after page has been
displayed
> before transfer takes place.
>
> <html><head><title>Lets go Surfin</title>
> <meta http-equiv="Refresh" content="5; URL=script.cgi">
> </head>
> <body>
>
> Advice: If you are using perl for cgi, you really should know all
> there is to know about html as well.
>
> Greg Smith
> webmaster
> www.bmw-club.org.uk

Hi Greg
That's definitely a better solution.

I have 4 books on html, and none explain the refresh meta tag.
Do you know where I can get a list of all the tags, with explanations?
Can't buy any more books yet, as the wife would kill me!

Thanks, Bob.
My site: www.sleepdesk.co.uk

p.s. I suppose someone has to like BMW bikes (ha ha)
I was a BSA fan myself, but no longer sadly (1953 BSA B31).

#3682 From: Doug Wells <dougawells@...>
Date: Thu May 31, 2001 6:05 pm
Subject: Re: [PBML] Why can't I print out this array?
dougawells@...
Send Email Send Email
 
Without testing your code, it looks to me like you
need a ';' after your the last of your cgi html
statements (after the 'Look Ma, no hands!').

Good luck

Doug

--- J M <john_20_28_2000@...> wrote:
>
> Why can't I print out this array?  I goet the
> internal server error, so I used the command line.
>
> I am using the CGI module for perl apache within
> mod_perl.  If I run the following line:
>
> @values = (1,2,3,4,5);
> foreach(@values)
> {
> print "$_\n";
> }
>
> everything is fine.  However, whenever I change it
> to read from the querystring in the address bar I
> get a syntax error.  Here is the code.  It is just a
> modification of the example from the CGI homepage.
> Thanks.
>
> #!/usr/local/bin/perl
> use CGI;
> $q = new CGI;
> @names = $q->param;
> @values = $q->param('choice');
>
> print $q->header(),
>       $q->start_html(-title=>'Wow!'),
>
>
>       $q->h1('Wow!'),
>       'Look Ma, no hands!',
>
> foreach(@values)  #this is the line that dies
> { # it says syntax error at this bracket; it goes
> away if I use the array at top of this message.
> print "$_\n";
> }
>
> print $q-> submit
>
>
>
>
> ---------------------------------
> Do You Yahoo!?
> Yahoo! Mail Personal Address - Get email at your own
> domain with Yahoo! Mail.


__________________________________________________
Do You Yahoo!?
Get personalized email addresses from Yahoo! Mail - only $35
a year!  http://personal.mail.yahoo.com/

#3683 From: Doug Wells <dougawells@...>
Date: Thu May 31, 2001 6:08 pm
Subject: Re: [PBML] Calling a cgi program
dougawells@...
Send Email Send Email
 
Try this site:

http://vancouver-webpages.com/META/metatags.detail.html

It explains the use of HTML Meta tags.

Good luck

Doug


--- Bob <bob@...> wrote:
> --- In perl-beginner@y..., "Greg" <webmaster@b...>
> wrote:
> > --- In perl-beginner@y..., "Bob" <bob@a...> wrote:
> > > > If you don't want to or cannot use SSI, try
> the META Refresh
> tag
> > in
> > > > the HTML header of your document.
> > > >
> > > > Why does no-one ever think of the simple
> solution?
> > > >
> > > > LOL
> > > > Greg Smith
> > >
> > > Hi Greg
> > >
> > > Sounds good.
> > > Can you tell me more about this tag, as I've
> never used it.
> > >
> > > Bob.
> >
>
========================================================
> > OK, here's an example:
> > The content value is number of seconds after page
> has been
> displayed
> > before transfer takes place.
> >
> > <html><head><title>Lets go Surfin</title>
> > <meta http-equiv="Refresh" content="5;
> URL=script.cgi">
> > </head>
> > <body>
> >
> > Advice: If you are using perl for cgi, you really
> should know all
> > there is to know about html as well.
> >
> > Greg Smith
> > webmaster
> > www.bmw-club.org.uk
>
> Hi Greg
> That's definitely a better solution.
>
> I have 4 books on html, and none explain the refresh
> meta tag.
> Do you know where I can get a list of all the tags,
> with explanations?
> Can't buy any more books yet, as the wife would kill
> me!
>
> Thanks, Bob.
> My site: www.sleepdesk.co.uk
>
> p.s. I suppose someone has to like BMW bikes (ha ha)
> I was a BSA fan myself, but no longer sadly (1953
> BSA B31).
>
>
>
>


__________________________________________________
Do You Yahoo!?
Get personalized email addresses from Yahoo! Mail - only $35
a year!  http://personal.mail.yahoo.com/

#3684 From: Angi <angib@...>
Date: Thu May 31, 2001 7:41 pm
Subject: LWP::Simple...how to retrieve "content-type"?
angib@...
Send Email Send Email
 
Hi,

I am using the script below to retrieve a page off the
net and save it to my server. This works fine. I would
like to also get the content-type, IP address, file
size, etc... of the document and pass it in my redirect
Url. I want the variables of the file "before" it is
saved. Does anyone know where and how I can do this??
I know how to pass them in the Url, I just don't know
how to get them! Thanks.

#!/perl/bin/perl

use LWP::Simple;
&get_form;
$URL = $INPUT{'url'};

$CONTENT = get($URL);

if (not head($URL)) {

print "Location: $ERRREDIRECTURL\n\n";

} else {

open (HANDLE, ">$TEMPFILE") or die "$!\n";
print HANDLE $CONTENT;
close (HANDLE);
print "Location: $REDIRECTURL\n\n";

How can I grab those variables before I redirect?

Angi

#3685 From: "Kai Hintze" <kai_hintze@...>
Date: Thu May 31, 2001 8:17 pm
Subject: Re: [PBML] -M File Test
kai_hintze@...
Send Email Send Email
 
That should work, but it makes debugging more difficult,
because you can't print the value of (-M $rfile) in a trace.

- Kai.

You cannot spend your time on things that take you away from
the Spirit, then expect to feel close to God.

-----Original Message-----
From: "Damien Carbery" <daymobrew@...>
To: perl-beginner@yahoogroups.com
Date: Wed, 30 May 2001 04:37:42 -0000
Subject: Re: [PBML] -M File Test

> What about using extra brackets?
>
>     if( ( -M $$rfile ) > $old_file)
>
> --- In perl-beginner@y..., "Kai Hintze" <kai_hintze@e...>
> wrote:
> >
> > I suspect operator precedence. In my copy of the Camel
> Book,
> > comparison happens before -X operators, so
> >
> > > if(-M $$rfile >$old_file){
> >
> > Is being interpreted as (-M ($$rfile > $old_file)), ie,
> since
> > this is a numeric test, (-M (0 > .5)), which leads to (-M
> 0)
> > which I would expect to be false.
> >
> > I find that it is much easier to debug programs if you
> split
> > complex operations up into multiple lines:
> >
> > $r_age = (-M $$rfile);
> > if ($r_age > $old_file) {
> > ....
> >
> >
> > Have fun!
> > - Kai.
> >

#3686 From: "Wagner Teixeira" <wagner@...>
Date: Thu May 31, 2001 8:43 pm
Subject: RE: [PBML] Simple question !!
wagner@...
Send Email Send Email
 
> Hi,
> > hi
> > first try this command from ur unix shell
> > which perl
> > it will tell u where perl is installed .
> > if it is /usr/bin/perl
> > then
> > #!/usr/bin/perl
> > print "Hope this helps\n";
>
> --> I already verified this, perl is installed in the given
>      location only (/usr/bin/perl)
>
> - Balaji.

This topic is getting out of focus. There are some different ways to spawn
external processes. The one I like mostly is open2(). Try the code below:

== Start ==
#!/usr/bin/perl -w

use IPC::Open2;

pipe READPIPE, WRITEPIPE;
$externalcommand = "/path/to/command";

$pid = open2( READPIPE, WRITEPIPE, "$externalcommand" );
if( $pid == 0 ) {
    print "Cannot spawn $externalcommand\n";
}
else {
    print "External process result:\n";

    $line = 1;
    while( <READPIPE> ) {
       print "Line $line: $_";
       ++$line;
    }
}
== End ==

#3687 From: "Wagner Teixeira" <wagner@...>
Date: Thu May 31, 2001 9:04 pm
Subject: RE: [PBML] Serial/Parallel Ports
wagner@...
Send Email Send Email
 
If you need the 'raw' control over the data sent/received, just open the
device file assigned to your phisical devices. Once openned, just read
and/or write and you'll get the results. Probably you'll need ioctl() the
device, but it's much more complex. Try the easiest first.

open( PRINTER, ">/dev/lp0" );

BUT, printing in *ix is much more than simply open and use device files
because printers usually are shared among some processes. I suggest you read
about printing in Linux (there's a queue manager, and many tools).

Once card readers are not common devices, I think you can assume that no
other processes will use it, and you don't need to share them.

open( CARDREADER, "</dev/tty1S" );

PS: the device file names are different between *in versions and flavors.
Again, check it out locally.

> -----Original Message-----
> From: David Irvine [mailto:co2cool@...]
> Sent: Quarta-feira, 23 de Maio de 2001 08:41
> To: perl-beginner@yahoogroups.com
> Subject: [PBML] Serial/Parallel Ports
>
>
> Hi,
>
> I'm new to perl, I'm currently using it to write an
> EPOS system, i have a number of devices, reciept
> printer, and credit card charger, which are serial
> devices.
>
> I would like to be able to attach a file handle to
> these devices so i can print to them directly since
> they are only every being written to.
>
> Is it possible to attach a file handle to the serial
> device and then print to it. if so how?
>
> All the terminals are running Linux.
>
>
> Thanks in Advance
>
>
> David Irvine
>
>
> =====
> "Artificial Intelligence is no match for human stupitity!"
>
>
> __________________________________________________
> Do You Yahoo!?
> Yahoo! Auctions - buy the things you want at great prices
> http://auctions.yahoo.com/
>
>
>
> Your use of Yahoo! Groups is subject to http://docs.yahoo.com/info/terms/
>
>
>

#3688 From: dougawells@...
Date: Thu May 31, 2001 9:11 pm
Subject: Re: LWP::Simple...how to retrieve "content-type"?
dougawells@...
Send Email Send Email
 
I know that you can get the content type, file size, and file age
from the head() method. So, in your case:

my @vars = head ($URL);
my $content_type = $vars[0];
my $filesize = $vars[1];
my $fileage = $vars[2];

I believe there are ways to get others, but I haven't read up on it.
You should be able to get this from the LWP manpage.

Good luck

Doug

--- In perl-beginner@y..., Angi <angib@s...> wrote:
> Hi,
>
> I am using the script below to retrieve a page off the
> net and save it to my server. This works fine. I would
> like to also get the content-type, IP address, file
> size, etc... of the document and pass it in my redirect
> Url. I want the variables of the file "before" it is
> saved. Does anyone know where and how I can do this??
> I know how to pass them in the Url, I just don't know
> how to get them! Thanks.
>
> #!/perl/bin/perl
>
> use LWP::Simple;
> &get_form;
> $URL = $INPUT{'url'};
>
> $CONTENT = get($URL);
>
> if (not head($URL)) {
>
> print "Location: $ERRREDIRECTURL\n\n";
>
> } else {
>
> open (HANDLE, ">$TEMPFILE") or die "$!\n";
> print HANDLE $CONTENT;
> close (HANDLE);
> print "Location: $REDIRECTURL\n\n";
>
> How can I grab those variables before I redirect?
>
> Angi

#3689 From: "J.E. Cripps" <cycmn@...>
Date: Thu May 31, 2001 9:22 pm
Subject: Re: [PBML] remove whitespace
cycmn@...
Send Email Send Email
 
> >   PS : I assume that whitespace can contain one or more tab or space
> >        character

> this should do the trick:
>
> $string =~ s/\s+/ /g;

s/[\t\s]+/ /g;

if there might be tabs

#3690 From: "byron wise" <bywise@...>
Date: Thu May 31, 2001 10:10 pm
Subject: Re: [PBML] Calling a cgi program
bywise@...
Send Email Send Email
 
Here is the ultimate source for Meta Tags etc.

http://www.w3.org/TR/1998/REC-html40-19980424/struct/global.html#adef-name-META

byron


>From: Doug Wells <dougawells@...>
>Reply-To: perl-beginner@yahoogroups.com
>To: perl-beginner@yahoogroups.com
>Subject: Re: [PBML] Calling a cgi program
>Date: Thu, 31 May 2001 11:08:21 -0700 (PDT)
>
>Try this site:
>
>http://vancouver-webpages.com/META/metatags.detail.html
>
>It explains the use of HTML Meta tags.
>
>Good luck
>
>Doug
>
>
>--- Bob <bob@...> wrote:
> > --- In perl-beginner@y..., "Greg" <webmaster@b...>
> > wrote:
> > > --- In perl-beginner@y..., "Bob" <bob@a...> wrote:
> > > > > If you don't want to or cannot use SSI, try
> > the META Refresh
> > tag
> > > in
> > > > > the HTML header of your document.
> > > > >
> > > > > Why does no-one ever think of the simple
> > solution?
> > > > >
> > > > > LOL
> > > > > Greg Smith
> > > >
> > > > Hi Greg
> > > >
> > > > Sounds good.
> > > > Can you tell me more about this tag, as I've
> > never used it.
> > > >
> > > > Bob.
> > >
> >
>========================================================
> > > OK, here's an example:
> > > The content value is number of seconds after page
> > has been
> > displayed
> > > before transfer takes place.
> > >
> > > <html><head><title>Lets go Surfin</title>
> > > <meta http-equiv="Refresh" content="5;
> > URL=script.cgi">
> > > </head>
> > > <body>
> > >
> > > Advice: If you are using perl for cgi, you really
> > should know all
> > > there is to know about html as well.
> > >
> > > Greg Smith
> > > webmaster
> > > www.bmw-club.org.uk
> >
> > Hi Greg
> > That's definitely a better solution.
> >
> > I have 4 books on html, and none explain the refresh
> > meta tag.
> > Do you know where I can get a list of all the tags,
> > with explanations?
> > Can't buy any more books yet, as the wife would kill
> > me!
> >
> > Thanks, Bob.
> > My site: www.sleepdesk.co.uk
> >
> > p.s. I suppose someone has to like BMW bikes (ha ha)
> > I was a BSA fan myself, but no longer sadly (1953
> > BSA B31).
> >
> >
> >
> >
>
>
>__________________________________________________
>Do You Yahoo!?
>Get personalized email addresses from Yahoo! Mail - only $35
>a year!  http://personal.mail.yahoo.com/
>
>
>
>Your use of Yahoo! Groups is subject to http://docs.yahoo.com/info/terms/
>
>

_________________________________________________________________
Get your FREE download of MSN Explorer at http://explorer.msn.com

#3691 From: "David Aldridge" <holein5@...>
Date: Thu May 31, 2001 10:55 pm
Subject: Quick Perl Question
holein5@...
Send Email Send Email
 
How hard would it be to whip up a PERL script to do a "dir" in a
directory then copy the file with the latest date and timestamp to
another directory? I was thinking PERL would be best for this but if
anyone has any other ideas I would really appreciate it.

Thanks for your time,
David Aldridge
Sr Systems Analyst
Convergys Corp

#3692 From: "Bob" <bob@...>
Date: Fri Jun 1, 2001 12:08 am
Subject: Re: [PBML] Calling a cgi program
bob@...
Send Email Send Email
 
I'm sorted now, thanks all.

Bob.


--- In perl-beginner@y..., "byron wise" <bywise@h...> wrote:
> Here is the ultimate source for Meta Tags etc.
>
> http://www.w3.org/TR/1998/REC-html40-
19980424/struct/global.html#adef-name-META
>
> byron
>
>
> >From: Doug Wells <dougawells@y...>
> >Reply-To: perl-beginner@y...
> >To: perl-beginner@y...
> >Subject: Re: [PBML] Calling a cgi program
> >Date: Thu, 31 May 2001 11:08:21 -0700 (PDT)
> >
> >Try this site:
> >
> >http://vancouver-webpages.com/META/metatags.detail.html
> >
> >It explains the use of HTML Meta tags.
> >
> >Good luck
> >
> >Doug
> >
> >
> >--- Bob <bob@a...> wrote:
> > > --- In perl-beginner@y..., "Greg" <webmaster@b...>
> > > wrote:
> > > > --- In perl-beginner@y..., "Bob" <bob@a...> wrote:
> > > > > > If you don't want to or cannot use SSI, try
> > > the META Refresh
> > > tag
> > > > in
> > > > > > the HTML header of your document.
> > > > > >
> > > > > > Why does no-one ever think of the simple
> > > solution?
> > > > > >
> > > > > > LOL
> > > > > > Greg Smith
> > > > >
> > > > > Hi Greg
> > > > >
> > > > > Sounds good.
> > > > > Can you tell me more about this tag, as I've
> > > never used it.
> > > > >
> > > > > Bob.
> > > >
> > >
> >========================================================
> > > > OK, here's an example:
> > > > The content value is number of seconds after page
> > > has been
> > > displayed
> > > > before transfer takes place.
> > > >
> > > > <html><head><title>Lets go Surfin</title>
> > > > <meta http-equiv="Refresh" content="5;
> > > URL=script.cgi">
> > > > </head>
> > > > <body>
> > > >
> > > > Advice: If you are using perl for cgi, you really
> > > should know all
> > > > there is to know about html as well.
> > > >
> > > > Greg Smith
> > > > webmaster
> > > > www.bmw-club.org.uk
> > >
> > > Hi Greg
> > > That's definitely a better solution.
> > >
> > > I have 4 books on html, and none explain the refresh
> > > meta tag.
> > > Do you know where I can get a list of all the tags,
> > > with explanations?
> > > Can't buy any more books yet, as the wife would kill
> > > me!
> > >
> > > Thanks, Bob.
> > > My site: www.sleepdesk.co.uk
> > >
> > > p.s. I suppose someone has to like BMW bikes (ha ha)
> > > I was a BSA fan myself, but no longer sadly (1953
> > > BSA B31).
> > >
> > >
> > >
> > >
> >
> >
> >__________________________________________________
> >Do You Yahoo!?
> >Get personalized email addresses from Yahoo! Mail - only $35
> >a year!  http://personal.mail.yahoo.com/
> >
> >
> >
> >Your use of Yahoo! Groups is subject to
http://docs.yahoo.com/info/terms/
> >
> >
>
> _________________________________________________________________
> Get your FREE download of MSN Explorer at http://explorer.msn.com

#3693 From: "Charles K. Clarkson" <c_clarkson@...>
Date: Fri Jun 1, 2001 1:54 am
Subject: Re: [PBML] remove whitespace
c_clarkson@...
Send Email Send Email
 
J.E. Cripps <cycmn@...> writes:

: > >   PS : I assume that whitespace can contain
: > > one or more tab or space character
: > this should do the trick:
: >
: > $string =~ s/\s+/ /g;
:
: s/[\t\s]+/ /g;
:
: if there might be tabs

     Although the perl documentation seems loathe
to define it, white space includes tabs, spaces
and any character that moves the cursor in an
editor, but doesn't display anything - like the
line feed and the form feed characters, so:

     s/[\t\s]+/ /g;

     is equivalent to:

     s/\s+/ /g;

HTH,
Charles K. Clarkson


If you value anything,
     value other humans,
for they are the only help you
     will have in times of trouble.
- John B. Hodges

#3694 From: "J.E. Cripps" <cycmn@...>
Date: Fri Jun 1, 2001 3:45 am
Subject: Re: [PBML] Quick Perl Question
cycmn@...
Send Email Send Email
 
> How hard would it be to whip up a PERL script to do a "dir" in a
> directory then copy the file with the latest date and timestamp to
> another directory?

not very hard with readdir() and stat()

#3695 From: "J.E. Cripps" <cycmn@...>
Date: Fri Jun 1, 2001 4:33 am
Subject: Re: [PBML] Quick Perl Question
cycmn@...
Send Email Send Email
 
> How hard would it be to whip up a PERL script to do a "dir" in a
> directory then copy the file with the latest date and timestamp to
> another directory? I was thinking PERL would be best for this but if
> anyone has any other ideas I would really appreciate it.

#here's one approach
#find the file in source directory with the latest update time (mtime)

#!/usr/bin/perl -w
use strict;


my $src  = '/path/to/source_directory';
my $tgt =  '/path/to/target_directory';

			      #open source directory
unless (opendir(IN,"$src")) {
	 print "couldn't open directory($!)\n";
	 exit;
}
                              #list of files in source_directory
my @files =  readdir(IN);
closedir(IN);

my %files; 	     #associate file with time of last update
foreach my $f(@files) {
       $files{$f} = (stat($f))[9];
}

			      #sort to find newest file
my @timesort = sort { $files{$b} <=> $files{$a} } keys(%files);

my $newest;
                              #print newest file that's not the directory
foreach my $f(@timesort) {
	 if ($f !~ /\./) {
	  $newest = $f;
	  print "$f\n"; last;
          }
}


# that's all folks; to _copy_  $newest look at:

#  system()     perldoc perlfunc            or
# or File::Copy    perldoc File::Copy


=head
			      #print files and uptdate times
                              #this  reminded us  that . is in @files also
foreach my $t(@timesort) {
         printf "file %s updated at %s\n", $t,
             scalar localtime($files{$t});
}

=cut

Messages 3666 - 3695 of 27465   Oldest  |  < Older  |  Newer >  |  Newest
Add to My Yahoo!      XML What's This?

Copyright © 2010 Yahoo! Inc. All rights reserved.
Privacy Policy - Terms of Service - Guidelines NEW - Help