develooper Front page | perl.beginners | Postings from June 2007

Re: Passing arguments to subroutine

Thread Previous | Thread Next
Rob Dixon
June 1, 2007 06:50
Re: Passing arguments to subroutine
Message ID:
Paul Lalli wrote:
> On May 31, 9:35 am, (Eish...@Googlemail.Com) wrote:
>> On May 31, 9:27 am, (Alma) wrote:
>>> # extract the file name
>>> #       my @parts = split('\/',$file_path);
>> Your split statement seems to be wrong. split uses a regex to match so
>> it should be:
>> split /\\/, $file_path;
> There is nothing at all wrong with the OP's split.  Single quotes are
> a perfectly legitamite delimiter for a regular expression.  And why
> did you change the OP's from splitting on a front-slash to splitting
> on a back-slash?

However it was a little confusing to write

  split '\/', $file_path;

when what was meant was

  split '/', $file_path;

The former appears to split on the literal value '\/' but, because the
string is reinterpolated into a regex, the effect is the same as just '/'.
Bizarrely, to actually split on '\/' would require

  split '\\\/', $file_path;


Thread Previous | Thread Next Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at | Group listing | About