Re: Perl programming related question.

2012-08-17 Thread Lázaro Morales
Some time ago, Dave Cross said: Why bother wrestiling with complex regular expressions when someone else has already done the work? Perl has a URI module ("yum install perl-URI") which understands how URIs (and URLs) work. I'd recommend using that. use URI; my $url = URI->new('http://somesite.

Re: Perl programming related question.

2012-08-17 Thread Dave Cross
On 16 August 2012 16:28, Lázaro Morales wrote: > Hello folks, > > This question is a bit off-topic but the Fedora Community is awesome. This > is the question, How can I from this string: > >my $url = "http://somesite.org/somefile.zip";;# Example URL > > obtain only this sub-string: > >

Re: Perl programming related question.

2012-08-16 Thread Mark LaPierre
On 08/16/2012 11:28 AM, Lázaro Morales wrote: Hello folks, This question is a bit off-topic but the Fedora Community is awesome. This is the question, How can I from this string: my $url = "http://somesite.org/somefile.zip";; # Example URL obtain only this sub-string: my $file = "somefile.zip

Re: Perl programming related question.

2012-08-16 Thread Jack Craig
On Thu, Aug 16, 2012 at 9:09 AM, Lázaro Morales wrote: > Some time ago, Chris Adams said: > > Of course, being perl, there's more than one way to do it. >> I would do something like: >> my ($file) = $url =~ m!^http://[^/]+/(.*)!; >> That would strip off the leading protocol/host, leaving the re

Re: Perl programming related question.

2012-08-16 Thread Lázaro Morales
Some time ago, Chris Adams said: Of course, being perl, there's more than one way to do it. I would do something like: my ($file) = $url =~ m!^http://[^/]+/(.*)!; That would strip off the leading protocol/host, leaving the rest. If there was a subdirectory in the URL (e.g. http://host/some/fi

Re: Perl programming related question.

2012-08-16 Thread Lázaro Morales
Some time ago, Boris Epstein said: Lazaro, I don't remember all the details of how you'd do it but I believe you can use the split() function to split the string and then find the last member of the resulting array. Good luck! Boris. Thanks Boris and Craig, Using the split function I get this

Re: Perl programming related question.

2012-08-16 Thread Chris Adams
Once upon a time, Lázaro Morales said: > Hello folks, > > This question is a bit off-topic but the Fedora Community is awesome. This > is the question, How can I from this string: > >my $url = "http://somesite.org/somefile.zip";;# Example URL > > obtain only this sub-string: > > my

Re: Perl programming related question.

2012-08-16 Thread Jack Craig
substr($orig, start, numbytes), see also index(str, "searchstr"); On Thu, Aug 16, 2012 at 8:28 AM, Lázaro Morales wrote: > Hello folks, > > This question is a bit off-topic but the Fedora Community is awesome. This > is the question, How can I from this string: > >my $url = > "http://somesi

Re: Perl programming related question.

2012-08-16 Thread Boris Epstein
Lazaro, I don't remember all the details of how you'd do it but I believe you can use the split() function to split the string and then find the last member of the resulting array. Good luck! Boris. On Thu, Aug 16, 2012 at 11:28 AM, Lázaro Morales wrote: > Hello folks, > > This question is a b