Extracting links.

2005-01-16 Thread Sara
I am trying to extract links along with HTML tags a href=blah from a list, 
but it's not working on my XP machine with Active State Perl 5.0.6
Kindly help.

# CODE START 

my @array = qq|
bodya href=http://www.mydomain.com;img alt=Free Hosting, Freebies 
border=0 src=http://www.mydomain.com/images/logo2.gif;/a
|;
#extract LINKS (no image links) only a href=http://www.mydomain.com;

my @get = grep {/a .*?/} @array;
print @get\n

### CODE END ###

Thanks,

Sara.






Re: Extracting links.

2005-01-16 Thread Randy W. Sims
Sara wrote:
I am trying to extract links along with HTML tags a href=blah from a list, 
but it's not working on my XP machine with Active State Perl 5.0.6
Kindly help.
# CODE START 
my @array = qq|
bodya href=http://www.mydomain.com;img alt=Free Hosting, Freebies border=0 
src=http://www.mydomain.com/images/logo2.gif;/a
|;
#extract LINKS (no image links) only a href=http://www.mydomain.com;
my @get = grep {/a .*?/} @array;
print @get\n
### CODE END ###
I'm not sure why you're assigning a string to an array...
(completely untested)
my $html = HTML;
bodya href=http://www.mydomain.com;img alt=Free Hosting, 
Freebies border=0 src=http://www.mydomain.com/images/logo2.gif;/a
HTML

use HTML::LinkExtractor;
my $lx = new HTML::LinkExtractor();
$lx-parse(\$html);
for my $link( @{$lx-links} ) {
  if( $$link{tag} !~ /img/i ) {
my $href = $$link{href};
print $href-as_string();
  }
}
__END__
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/ http://learn.perl.org/first-response



RE: Extracting links.

2005-01-16 Thread Charles K. Clarkson
Sara [EMAIL PROTECTED] wrote:

: I am trying to extract links along with HTML tags a
: href=blah from a list, but it's not working on my XP machine
: with Active State Perl 5.0.6 Kindly help.
: 

While Randy already addressed using HTML::LinkExtractor to
retrieve links, you should also hop over to ActiveState. 5.0.6
is a pretty old version of perl.

 http://www.activestate.com/Products/ActivePerl/


HTH,

Charles K. Clarkson
-- 
Mobile Homes Specialist
254 968-8328



-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/ http://learn.perl.org/first-response




print $q-p(with CSS)

2005-01-16 Thread David Gilden
Happy New year out there,

Is it possible to get CGI.pm to print  p class=myclasstext.../p
I also need to print out the one these as well:

link rel=stylesheet href=/css/main.css type=text/css
but it has to be in the head of the starting HTML? -- and I would like it 
before the /head and after the /title

 Is any of this possible and would be the correct syntax for this?
 Below is my starting point. 

use CGI;
my $q = new CGI;
print $q-header( text/html ),
  $q-start_html( Error ),
 $q-p( Your upload was not procesed because the following error ,
 occured:  ),
   


Thanks for any help on this,
Dave Gilden
(kora musician / audiophile / webmaster @ www.coraconnection.com  / Ft. Worth, 
TX, USA)


Visit my schedule page for up to the minute performance info:
http://www.coraconnection.com/cgi-bin/schedule.pl


==
 Cora Connection: Your West African Music Source
  Resources, Recordings, Instruments  More!
   http://www.coraconnection.com/ 
==

--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/ http://learn.perl.org/first-response




Re: print $q-p(with CSS)

2005-01-16 Thread Ovid
Hi David,

 Is it possible to get CGI.pm to print  p
 class=myclasstext.../p

Yes.  If the first argument is a hashref, it will use the name/value
pairs as tag attributes.

  print $q-p({class=myclass}, text...);
  
 I also need to print out the one these as well:
 
 link rel=stylesheet href=/css/main.css type=text/css
 but it has to be in the head of the starting HTML? -- and I would
 like it 
 before the /head and after the /title

  print $q-start_html(
-head  = $q-Link({-rel=stylesheet, -href=main.css}),
-title = some title
  );

See perldoc CGI for more detailed information.

Cheers,
Ovid

=
Silence is Evil
http://users.easystreet.com/ovid/philosophy/decency.html
Ovid   http://www.perlmonks.org/index.pl?node_id=17000
Web Programming with Perl  http://users.easystreet.com/ovid/cgi_course/

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/ http://learn.perl.org/first-response




SWITCH / CASE statements

2005-01-16 Thread David Gilden
Quick question here for the PERL gurus!

What should be the order for these two statements?

exit;
last switch;

i.e is this correct?

Thanks!!
Dave -- Ft. Worth

__CODE__

SWITCH: {

if  ($action =~ /Update/) {

print redirect(./import_clean_csv.php);
exit;
last switch;
};


if  ($action =~ /Clean/) {

print header;

chdir UPLOAD_DIR or die Couldn't chdir to afm_data directory: $!;

my @filesToRemove = *;

foreach my $fr (@filesToRemove) {

print  Deleting $frbr\n;
unlink($fr)  or die Couldn't Delete $fr $!;
}

print HTML_OUT;
p style=font-weight:boldYour Done close this window! 
forminput type=button onclick=self.close() value=Close  
Window/form/p
HTML_OUT

exit;
last switch;
};

}


Visit my schedule page for up to the minute performance info:
http://www.coraconnection.com/cgi-bin/schedule.pl


==
 Cora Connection: Your West African Music Source
  Resources, Recordings, Instruments  More!
   http://www.coraconnection.com/ 
==

--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/ http://learn.perl.org/first-response




Insecure dependency in glob while running with -T switch

2005-01-16 Thread David Gilden
Last question here,

#!/usr/bin/perl -wT


 Snip ...

my @filesToRemove = *;

The line above is causing:

Insecure dependency in glob while running with -T switch

What can I do still have this functionally and satisfy 'tainting'


Thanks,


Dave

tel: 817-741-2327 fax: 972-916-3451
(kora musician / audiophile / webmaster @ www.coraconnection.com  / Ft. Worth, 
TX, USA)

--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/ http://learn.perl.org/first-response




RE: Insecure dependency in glob ... with -T switch

2005-01-16 Thread David Gilden
I thought this would do it, but I am at stopping point:

#!/usr/bin/perl -wT

my @filesToRemove  =  map  {$_ =~ /^(\w[\w.-]*)/} *;

Still  getting : Insecure dependency in glob while running with -T switch

What can I do still have this functionally and satisfy 'tainting'

Thanks,
Dave

tel: 817-741-2327 fax: 972-916-3451
(kora musician / audiophile / webmaster @ www.coraconnection.com  / Ft. Worth, 
TX, USA)

--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/ http://learn.perl.org/first-response




hash of array

2005-01-16 Thread Ken Gillett
I'm trying to store a named array in a hash(%dbm), which ought to be 
entirely possible. with the key,value pairs being the name and array 
respectively.

I'm using the following line to add items to the array:-
push @{ $dbm{ $name } }, $ID;
So the key in $name has ID added as an extra member of its array. This 
is done repeatedly with many new items added to the arrays for 
different names. But, the first one is somehow always missed. Whatever 
this script adds to the arrays, the first one somehow misses and is 
simply not in the array, although all other members are there as 
expected.

I know there can be referencing problems in complex data structures, 
but I am sure the code is correct, in particular because whatever tests 
I do with test scripts that add multiple array items for many names 
(keys), they always work perfectly. I'm using the exact same code and 
setting up variables in the same way, but it works in one and not the 
other.

This is the real puzzle. I am never surprised when code doesn't do what 
I expect, but in this case it works perfectly in the test scripts, 
exactly as expected and required, but in the real script in which it 
actually needs to work, the first attempt to add an item always fails 
and I am at a loss to understand what the reason could be.

Can anyone shed any light on why this 'push'ing onto the array might 
fail for the first item only? If I have some ideas about that I can 
investigate further as to how this might occur in one script but not 
the other.

Please???

Ken  G i l l e t t
_/_/_/_/_/_/_/_/_/
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/ http://learn.perl.org/first-response



hash of arrays

2005-01-16 Thread Ken Gillett
Why do I think of a possible solution within minutes of sending a 
question to this list:-(

One difference between the scripts is that the one which fails ties the 
hash to a Berkeley DB file and this is the cause. Without that the 
first item is always successfully added, but once tied to the file it 
misses the first one.

Great.
Now I need to figure out how to prevent this. Anyone any ideas on that?

Ken  G i l l e t t
_/_/_/_/_/_/_/_/_/
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/ http://learn.perl.org/first-response



RE: hash of array

2005-01-16 Thread Charles K. Clarkson
From: Ken Gillett mailto:[EMAIL PROTECTED] wrote:

: I'm trying to store a named array in a hash(%dbm), which ought
: to be entirely possible. with the key,value pairs being the
: name and array respectively. 
: 
: I'm using the following line to add items to the array:-
: 
:   push @{ $dbm{ $name } }, $ID;

Er, that is better written as this (no quotes):

push @{ $dbm{ $name } }, $ID;


: Can anyone shed any light on why this 'push'ing onto the array
: might fail for the first item only? If I have some ideas about
: that I can investigate further as to how this might occur in
: one script but not the other. 
:
: One difference between the scripts is that the one which fails
: ties the hash to a Berkeley DB file and this is the cause.
: Without that the first item is always successfully added, but
: once tied to the file it misses the first one.

I have never had this problem with perl. Can you show us the
relevant code? Why don't the test scripts tie to the db?


HTH,

Charles K. Clarkson
-- 
Mobile Homes Specialist
254 968-8328


-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/ http://learn.perl.org/first-response




CGI::Session

2005-01-16 Thread Octavian Rasnita
Hi,

I would like to use a session mechanism that allows to store some hashes in
a MySQL database, but also allow storing some other visitor preferences like
the font style, colors, font sizes, the language, etc.

Do you know if CGI::Session allows storing some more values in a MySQL
record than the session ID?

Or if you know that it doesn't allow such a thing, please tell me if there
are other modules that can do this.

Thank you.

Teddy


-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/ http://learn.perl.org/first-response




Re: CGI::Session

2005-01-16 Thread Joe Mecklin
i don't know if there are modules or functions that would do it all
bhind the scenes, but at the worst, just write everything you want
to store to variables and write them in a standard mysql insert
query.

you may want to use CGI qw(:all) rather than limit yourself to
CGI::Session (that's from memory, the syntax may not be exact).


On Sun, 16 Jan 2005 17:56:19 +0200, Octavian Rasnita [EMAIL PROTECTED] wrote:
 Hi,
 
 I would like to use a session mechanism that allows to store some hashes in
 a MySQL database, but also allow storing some other visitor preferences like
 the font style, colors, font sizes, the language, etc.
 
 Do you know if CGI::Session allows storing some more values in a MySQL
 record than the session ID?
 
 Or if you know that it doesn't allow such a thing, please tell me if there
 are other modules that can do this.
 
 Thank you.
 
 Teddy
 
 --
 To unsubscribe, e-mail: [EMAIL PROTECTED]
 For additional commands, e-mail: [EMAIL PROTECTED]
 http://learn.perl.org/ http://learn.perl.org/first-response
 


-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/ http://learn.perl.org/first-response




Re: atom syndication

2005-01-16 Thread Ing. Branislav Gerzo
Harsh Busa [HB], on Sunday, January 16, 2005 at 01:42 (+0530) thinks
about:

HB  my $doc = $atomic-get('http://www.timaoutloud.org/xml/atom.xml');

in this line you have error, you have to write:
my ($doc) = $atomic-get('http://www.timaoutloud.org/xml/atom.xml');

-- 

 ...m8s, cu l8r, Brano.

[I'd have thrown up on the kid...   -Danny Davids]



-=x=-
Skontrolované antivírovým programom NOD32


-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/ http://learn.perl.org/first-response




Triple Combo Box with Perl?

2005-01-16 Thread Maxipoint Rep Office

Have someone idea or url how create Triple Combo Box with Perl?

something like here:
http://javascriptkit.com/script/script2/triplecombo.shtml

but not redirection at the end, i need only data submision after user select
combination..


-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/ http://learn.perl.org/first-response




Re: atom syndication

2005-01-16 Thread Jenda Krynicky
From: Ing. Branislav Gerzo [EMAIL PROTECTED]
 Harsh Busa [HB], on Sunday, January 16, 2005 at 01:42 (+0530) thinks
 about:
 
 HB  my $doc =
 $atomic-get('http://www.timaoutloud.org/xml/atom.xml');
 
 in this line you have error, you have to write:
 my ($doc) = $atomic-get('http://www.timaoutloud.org/xml/atom.xml');

Don't think so. This may make a difference, but I don't think it 
would in this case.

I tried Harhs's code with a recently installed XML::Atom::Syndication 
0.08 and it seems to work fine. Exactly the same results without and 
with the braces.

Jenda

P.S.: Explanation for those new engough to Perl:
The braces change the context in which the $atomic-get() method is 
called. In the first case it's called in scalar context, in the 
second in list context. The method may test for the context using the 
wantarray() builtin and return different results in each case:

my $x = localtime();
print $x\n;
vs.
my ($x) = localtime();
print $x\n;

The result may be different even without the method testing it 
directly. If the return statement looks like this:

return @array;

then in scalar context you'll get the number of elements in the array 
and in list context you'll get the contents. In which case the 
behaviour could be 1 in scalar context and the object in list 
context:

sub foo {
my @arr = ('obj');
return @arr;
}

my $x = foo();
print $x\n;
my ($x) = foo();
print $x\n;

Doesn't seem to be the case with XML::Atom::Syndication.

Jenda

= [EMAIL PROTECTED] === http://Jenda.Krynicky.cz =
When it comes to wine, women and song, wizards are allowed 
to get drunk and croon as much as they like.
-- Terry Pratchett in Sourcery


-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/ http://learn.perl.org/first-response




Re: atom syndication

2005-01-16 Thread Ing. Branislav Gerzo
Jenda Krynicky [JK], on Sunday, January 16, 2005 at 23:56 (+0100)
contributed this to our collective wisdom:

 in this line you have error, you have to write:
 my ($doc) =
 $atomic-get('http://www.timaoutloud.org/xml/atom.xml');

JK Don't think so. This may make a difference, but I don't think it 
JK would in this case.

I am sorry, I should wrote I guess. Ok, when it doesn't work, why
Dumper($doc) outputs only 1 ? It should be nice complex data
structure of parsed rss file, hm ?

-- 

 ...m8s, cu l8r, Brano.

[If GOD doesn't like how I live, let HIM tell me, NOT you!]



-=x=-
Skontrolované antivírovým programom NOD32


-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/ http://learn.perl.org/first-response




RE: Triple Combo Box with Perl?

2005-01-16 Thread Michael Kraus
You don't. You create it with HTML and JavaScript. You use perl to read
the select boxes values.

It's simply that Perl is used server-side, not client-side. Perl can be
used to generate the HTML (and javascript if needed).

Javascript is a client-side technology. The two languages don't directly
compete with each other, but can be used co-operatively.

Perl packages of interest to you would be: CGI, HTML::Template,
CGI::FormBuilder and/or CGI::Untaint

Regards,
 

Michael S. E. Kraus
B. Info. Tech. (CQU), Dip. Business (Computing)
Software Developer
Wild Technology Pty Ltd
___
ABN 98 091 470 692
Level 4 Tiara, 306/9 Crystal Street, Waterloo NSW 2017, Australia
Telephone 1300-13-9453 |  Facsimile 1300-88-9453
http://www.wildtechnology.net
 
The information contained in this email message and any attachments may
be confidential information and may also be the subject of client legal
- legal professional privilege. If you are not the intended recipient,
any use, interference with, disclosure or copying of this material is
unauthorised and prohibited.   This email and any attachments are also
subject to copyright.  No part of them may be reproduced, adapted or
transmitted without the written permission of the copyright owner.  If
you have received this email in error, please immediately advise the
sender by return email and delete the message from your system. 

 -Original Message-
 From: Maxipoint Rep Office [mailto:[EMAIL PROTECTED] 
 Sent: Monday, 17 January 2005 9:39 AM
 To: beginners@perl.org
 Subject: Spam:Triple Combo Box with Perl?
 
 
 Have someone idea or url how create Triple Combo Box with Perl?
 
 something like here:
 http://javascriptkit.com/script/script2/triplecombo.shtml
 
 but not redirection at the end, i need only data submision 
 after user select combination..
 
 
 --
 To unsubscribe, e-mail: [EMAIL PROTECTED] For 
 additional commands, e-mail: [EMAIL PROTECTED] 
 http://learn.perl.org/ http://learn.perl.org/first-response
 
 
 




Wild Technology Pty Ltd , ABN 98 091 470 692
Sales - Ground Floor, 265/8 Lachlan Street, Waterloo NSW 2017
Admin - Level 4 Tiara, 306/9 Crystal Street, Waterloo NSW 2017
Telephone 1300-13-9453 |  Facsimile 1300-88-9453
http://www.wildtechnology.net
DISCLAIMER  CONFIDENTIALITY NOTICE:  The information contained in this email 
message and any attachments may be confidential information and may also be the 
subject of client legal - legal professional privilege. If you are not the 
intended recipient, any use, interference with, disclosure or copying of this 
material is unauthorised and prohibited.   This email and any attachments are 
also subject to copyright.  No part of them may be reproduced, adapted or 
transmitted without the written permission of the copyright owner.  If you have 
received this email in error, please immediately advise the sender by return 
email and delete the message from your system.



--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/ http://learn.perl.org/first-response




RE: atom syndication

2005-01-16 Thread Charles K. Clarkson
[EMAIL PROTECTED] [EMAIL PROTECTED] wrote:

: Ok, when it doesn't work,
: why Dumper($doc) outputs only 1 ? It should be nice complex
: data structure of parsed rss file, hm ?

Perhaps $doc is an object and a requires a method to return
anything meaningful. According to the docs get() returns a
root (whatever that is), not a document.


$instance-get($url[,$file])

 A method for fetching an Atom feed and parsing it. If an
 optional file name is provided, the method will mirror the
 feed to the file system location that is specified. Like the
 parse methods, returns the root
 XML::Atom::Syndication::Element object for the feed.

HTH,

Charles K. Clarkson
-- 
Mobile Homes Specialist
254 968-8328


-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/ http://learn.perl.org/first-response




RE: Triple Combo Box with Perl?

2005-01-16 Thread Charles K. Clarkson
Maxipoint Rep Office [EMAIL PROTECTED] wrote:

: Have someone idea or url how create Triple Combo Box with Perl?
: 
: something like here:
: http://javascriptkit.com/script/script2/triplecombo.shtml
: 
: but not redirection at the end, i need only data submision
: after user select combination..


It won't look the same in perl. In JavaScript all the
info for every combination is sent with the page. Each
time you select a different value from the first box, the
values of the second box change. This is all done through
JavaScript, using the clients browser.

To replicate this is only perl, the user would select
a value from the first menu and than submit that to the
server, the server would then return the values for the
second set. Each time, the server sends a new page
rewriting everything instead of just the combo box
controls.

The user also has to send the information selection
from each combo with a button if you want to completely
eliminate all JavaScript. If you want the selection sent
as the choice is selected, you need JavaScript. So why
not use the JavaScript triple combo?

To sum up, yes, you can get triple box functionality
with perl, but the user won't experience the same feel as
she does with the JavaScript version. The perl version
would require at least two trips to the server before
data selection.


HTH,

Charles K. Clarkson
-- 
Mobile Homes Specialist
254 968-8328









-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/ http://learn.perl.org/first-response




RE: CGI::Session

2005-01-16 Thread Michael Kraus
G'day...

 I would like to use a session mechanism that allows to store 
 some hashes in a MySQL database, but also allow storing some 
 other visitor preferences like the font style, colors, font 
 sizes, the language, etc.
 
 Do you know if CGI::Session allows storing some more values 
 in a MySQL record than the session ID?

CGI::Session is perfect for this. You don't have to use a database (eg.
MySQL), but can if you like.

You can set as many session variables as you like.

E.g.

my %font = { size = 12, color = red, style = italic, type =
Verdana };
$session-param(font, \%font);

See the CGI::Session documentation on CPAN -
http://search.cpan.org/~sherzodr/CGI-Session-3.95/Session.pm

(It also has a great additional documentation, including tutorial.)

Regards,
 

Michael S. E. Kraus
B. Info. Tech. (CQU), Dip. Business (Computing)
Software Developer
Wild Technology Pty Ltd
___
ABN 98 091 470 692
Level 4 Tiara, 306/9 Crystal Street, Waterloo NSW 2017, Australia
Telephone 1300-13-9453 |  Facsimile 1300-88-9453
http://www.wildtechnology.net
 
The information contained in this email message and any attachments may
be confidential information and may also be the subject of client legal
- legal professional privilege. If you are not the intended recipient,
any use, interference with, disclosure or copying of this material is
unauthorised and prohibited.   This email and any attachments are also
subject to copyright.  No part of them may be reproduced, adapted or
transmitted without the written permission of the copyright owner.  If
you have received this email in error, please immediately advise the
sender by return email and delete the message from your system. 




Wild Technology Pty Ltd , ABN 98 091 470 692
Sales - Ground Floor, 265/8 Lachlan Street, Waterloo NSW 2017
Admin - Level 4 Tiara, 306/9 Crystal Street, Waterloo NSW 2017
Telephone 1300-13-9453 |  Facsimile 1300-88-9453
http://www.wildtechnology.net
DISCLAIMER  CONFIDENTIALITY NOTICE:  The information contained in this email 
message and any attachments may be confidential information and may also be the 
subject of client legal - legal professional privilege. If you are not the 
intended recipient, any use, interference with, disclosure or copying of this 
material is unauthorised and prohibited.   This email and any attachments are 
also subject to copyright.  No part of them may be reproduced, adapted or 
transmitted without the written permission of the copyright owner.  If you have 
received this email in error, please immediately advise the sender by return 
email and delete the message from your system.



--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/ http://learn.perl.org/first-response




Re: Regex help

2005-01-16 Thread Dave Gray
On Sat, 15 Jan 2005 01:25:21 -0800 (PST), Ajey Kulkarni [EMAIL PROTECTED] 
wrote:
 I'm trying to match a floating point in ada.
 They are normal floating points with 2 extra things.(they can or can't
 come)
 
 1. an underscore is permitted between the digits and
 2. An alternate numeric base may be specified surrounding the nonexponent
 part of the number with pound signs, precided by a base in decimal.
 
 Eg: 16#6.a7#e+2, 18.9,

Sounds suspiciously like homework, but that's a fun problem.

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

my @numbers = (
  '16#6.f7#e+2',
  '18.9',
  '2#01013#',
  '16e+2',
);
my @valid   = (0 .. 9, 'a' .. 'z');

for my $num (@numbers) {
  my ($base, $n, $exp);
  if ($num =~ /^(\d+)\#([^\#]*?)\#(?:e\+(\d+))?$/x) {
($base, $n) = ($1, $2);
$exp = defined $3 ? $3 : 1;
  } elsif ($num =~ /^(\d[\d._]*?)(?:e\+(\d+))?$/) {
($base, $n) = (10, $1);
$exp = defined $2 ? $2 : 1;
  }
  next if not $n;
  my $invalid = '[^._'.join('',@valid[0..($base-1)]).']';
  warn invalid base $base number [$n] detected! ($invalid)\n
if $n =~ /$invalid/;
  print got base $base, num $n, exp $exp\n;
}
__END__

That should (more than) get you started!

HTH,
Dave

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/ http://learn.perl.org/first-response




Re: Regex help

2005-01-16 Thread Ajey Kulkarni
Huh..
Thanks a ton. I never expected a program. :-)).
regards
-Ajey
On Sun, 16 Jan 2005, Dave Gray wrote:
On Sat, 15 Jan 2005 01:25:21 -0800 (PST), Ajey Kulkarni [EMAIL PROTECTED] wrote:
I'm trying to match a floating point in ada.
They are normal floating points with 2 extra things.(they can or can't
come)
1. an underscore is permitted between the digits and
2. An alternate numeric base may be specified surrounding the nonexponent
part of the number with pound signs, precided by a base in decimal.
Eg: 16#6.a7#e+2, 18.9,
Sounds suspiciously like homework, but that's a fun problem.
__CODE__
#!/usr/bin/perl
use strict;
use warnings;
my @numbers = (
 '16#6.f7#e+2',
 '18.9',
 '2#01013#',
 '16e+2',
);
my @valid   = (0 .. 9, 'a' .. 'z');
for my $num (@numbers) {
 my ($base, $n, $exp);
 if ($num =~ /^(\d+)\#([^\#]*?)\#(?:e\+(\d+))?$/x) {
   ($base, $n) = ($1, $2);
   $exp = defined $3 ? $3 : 1;
 } elsif ($num =~ /^(\d[\d._]*?)(?:e\+(\d+))?$/) {
   ($base, $n) = (10, $1);
   $exp = defined $2 ? $2 : 1;
 }
 next if not $n;
 my $invalid = '[^._'.join('',@valid[0..($base-1)]).']';
 warn invalid base $base number [$n] detected! ($invalid)\n
   if $n =~ /$invalid/;
 print got base $base, num $n, exp $exp\n;
}
__END__
That should (more than) get you started!
HTH,
Dave
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/ http://learn.perl.org/first-response

--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/ http://learn.perl.org/first-response



Re: Can perl produce a huge-sized file for download testing?

2005-01-16 Thread Robin
On Monday 17 January 2005 19:53, Harold Castro wrote:
 versa. What I'm thinking now is to create a simple
 perl script that will create a file, as huge as it can
 be, or just a continues stream of dummy bytes being
 uploaded to a remote host. Only I don't know where to
 begin. Any idea??
I'd pull a long string of bytes from /dev/urandom (say, several 10s of Kb 
worth) and just send that block over and over. (random so that you get the 
information of the line without any interim compression happening)

Doing this as a Perl CGI probably wouldn't be too tricky.

-- 
Robin [EMAIL PROTECTED] JabberID: [EMAIL PROTECTED]

Hostes alienigeni me abduxerunt. Qui annus est?

PGP Key 0xA99CEB6D = 5957 6D23 8B16 EFAB FEF8  7175 14D3 6485 A99C EB6D


pgpZQibHB0daI.pgp
Description: PGP signature


Re: Regex help

2005-01-16 Thread manfred
That leads me to a question :-)
__CODE__
#!/usr/bin/perl
use strict;
use warnings;
my @numbers = (
 '16#6.f7#e+2',
 '18.9',
 '2#01013#',
 '16e+2',
);
my @valid   = (0 .. 9, 'a' .. 'z');
for my $num (@numbers) {
 my ($base, $n, $exp);
 if ($num =~ /^(\d+)\#([^\#]*?)\#(?:e\+(\d+))?$/x) {
What particular use has the _x_ modifier in this example?
I mean the hashes are escaped?
--manfred
   ($base, $n) = ($1, $2);
   $exp = defined $3 ? $3 : 1;
 } elsif ($num =~ /^(\d[\d._]*?)(?:e\+(\d+))?$/) {
   ($base, $n) = (10, $1);
   $exp = defined $2 ? $2 : 1;
 }
 next if not $n;
 my $invalid = '[^._'.join('',@valid[0..($base-1)]).']';
 warn invalid base $base number [$n] detected! ($invalid)\n
   if $n =~ /$invalid/;
 print got base $base, num $n, exp $exp\n;
}
__END__
That should (more than) get you started!
HTH,
Dave
-- To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/ http://learn.perl.org/first-response



--
http://glassdoc.org
http://glassdoc.de
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/ http://learn.perl.org/first-response