in reply to regular expression with @@/

\@ should work. Are you sure $line contains what you think it does? Perhaps if you gave us a little more code?

#!/usr/bin/perl use strict; use warnings; my $line = 'sometext@@sometext'; if ($line =~ m|\@\@|) { print "success!\n"; }

I'm willing to bet that what is going on is described in Quote and Quote like Operators.

Replies are listed 'Best First'.
Re^2: regular expression with @@/
by jim_neophyte (Sexton) on Dec 07, 2009 at 18:29 UTC
    Thank you all for the help. This works as expected so I will dig deeper in my code.
    use warnings; use strict; my $line = 'cfperfexh.prof@@/main/1'; print "Success! -- $1\n" if $line =~ /\A(.+)\@\@/; exit 0;
      You need -e or -d, not -f
Re^2: regular expression with @@/
by jim_neophyte (Sexton) on Dec 07, 2009 at 18:20 UTC
    here is my revised code: (with parts edited out)
    use warnings; use strict; my $file = shift or die "need filename from command-line"; open FH, '<', $file or die "could not open $file for reading: $!"; while( defined( my $line = <FH> )) { chomp $line; $line =~ m|\@\@/| && -f $line and do { ( $filename ) = $line =~ m|\A(.+)\@\@/|; chomp $line; print "$line -- "; next; }; }
      What file system are you on that / is a valid character in a file name? You presumably expect a regular file (-f) to end in @@/, which is presumably where your tests are failing. Perhaps this is a relative vs. absolute path issue?
        Am trying to write a quick utility script in Clearcase. The "@@/" allows us to grab versions of the file.